package controllers import ( "eta/eta_mini_api/models" "eta/eta_mini_api/services" ) type ChartPermissionController struct { BaseAuthController } // List // @Title 系统品种列表 // @Description 系统品种列表 // @Param UserId query int true "角色ID" // @Success 200 {object} models.LoginResp // @router /list [get] func (this *ChartPermissionController) List() { br := new(models.BaseResponse).Init() defer func() { this.Data["json"] = br this.ServeJSON() }() id, _ := this.GetInt("chartPermissonId", 0) var resp *models.ChartPermissionResp[[]models.ChartPermission] var err error if id == 0 { resp, err = services.GetChartPermissionList() } else if id > 0 { resp, err = services.GetChartPermissionSecondList(id) } if err != nil { br.Msg = "权限列表获取失败" br.ErrMsg = "权限列表获取失败,系统错误,Err:" + err.Error() return } if resp.Ret != 200 { br.Msg = resp.Msg br.ErrMsg = resp.ErrMsg return } chartPermissionList := make([]models.ChartPermissionView, 0) for _, item := range resp.Data { chartPermissionList = append(chartPermissionList, models.ChartPermissionView{ ChartPermissionId: item.ChartPermissionId, ChartPermissionName: item.ChartPermissionName, PermissionName: item.PermissionName, Remark: item.Remark, ImageUrl: item.ImageUrl, }) } br.Ret = 200 br.Data = chartPermissionList br.Msg = "列表获取成功" br.Success = true }