package controllers import ( "eta/eta_mobile/models" "eta/eta_mobile/models/company" "eta/eta_mobile/models/system" "eta/eta_mobile/utils" ) type SysRoleController struct { BaseAuthController } // ButtonList // @Title 角色-按钮权限列表 // @Description 角色-按钮权限列表 // @Param RoleId query int true "角色Id" // @Success 200 {object} system.SysRoleListResp // @router /role/menu/buttons [get] func (this *SysRoleController) ButtonList() { br := new(models.BaseResponse).Init() defer func() { if br.ErrMsg == "" { br.IsSendEmail = false } this.Data["json"] = br this.ServeJSON() }() sysUser := this.SysUser if sysUser == nil { br.Msg = "请登录" br.ErrMsg = "请登录,SysUser Is Empty" br.Ret = 408 return } roleId := sysUser.RoleId list, e := system.GetMenuButtonsByRoleId(roleId) if e != nil { br.Msg = "获取失败" br.ErrMsg = "获取角色按钮权限失败, Err: " + e.Error() return } buttonList := make([]*system.SysMenuButtonResp, 0) for _, v := range list { tmp := new(system.SysMenuButtonResp) tmp.MenuId = v.MenuId tmp.ParentId = v.ParentId tmp.MenuType = v.MenuType tmp.Name = v.Name tmp.ButtonCode = v.ButtonCode buttonList = append(buttonList, tmp) } br.Data = buttonList br.Ret = 200 br.Success = true br.Msg = "获取成功" } // SystemConfig // @Title 系统配置列表 // @Description 系统配置列表 // @Success 200 {object} []system.BusinessConf // @router /config [get] func (this *SysRoleController) SystemConfig() { br := new(models.BaseResponse).Init() defer func() { if br.ErrMsg == "" { br.IsSendEmail = false } this.Data["json"] = br this.ServeJSON() }() sysUser := this.SysUser if sysUser == nil { br.Msg = "请登录" br.ErrMsg = "请登录,SysUser Is Empty" br.Ret = 408 return } list := make([]system.BusinessConf, 0) // 获取基础配置, 若未配置则直接返回 conf, e := models.GetBusinessConf() if e != nil { br.Msg = "获取失败" br.ErrMsg = "获取基础配置失败, Err: " + e.Error() return } list = append(list, system.BusinessConf{ ConfKey: "ReportViewUrl", ConfVal: conf["ReportViewUrl"], }, system.BusinessConf{ ConfKey: "ChartViewUrl", ConfVal: conf["ChartViewUrl"], }) osc := system.BusinessConf{ ConfKey: "ObjectStorageClient", ConfVal: utils.ObjectStorageClient, } if osc.ConfVal == "" { osc.ConfVal = "oss" } list = append(list, osc) // 获取审批流设置 confKey := "approval_flow" confTmp, e := company.GetConfigDetailByCode(confKey) if e != nil { br.Msg = "获取审批流配置失败" br.ErrMsg = "获取审批流配置失败, Err: " + e.Error() return } list = append(list, system.BusinessConf{ ConfKey: "ApprovalFlow", ConfVal: confTmp.ConfigValue, }) br.Data = list br.Ret = 200 br.Success = true br.Msg = "获取成功" }