sys_role.go 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. package controllers
  2. import (
  3. "eta/eta_mobile/models"
  4. "eta/eta_mobile/models/company"
  5. "eta/eta_mobile/models/system"
  6. "eta/eta_mobile/utils"
  7. )
  8. type SysRoleController struct {
  9. BaseAuthController
  10. }
  11. // ButtonList
  12. // @Title 角色-按钮权限列表
  13. // @Description 角色-按钮权限列表
  14. // @Param RoleId query int true "角色Id"
  15. // @Success 200 {object} system.SysRoleListResp
  16. // @router /role/menu/buttons [get]
  17. func (this *SysRoleController) ButtonList() {
  18. br := new(models.BaseResponse).Init()
  19. defer func() {
  20. if br.ErrMsg == "" {
  21. br.IsSendEmail = false
  22. }
  23. this.Data["json"] = br
  24. this.ServeJSON()
  25. }()
  26. sysUser := this.SysUser
  27. if sysUser == nil {
  28. br.Msg = "请登录"
  29. br.ErrMsg = "请登录,SysUser Is Empty"
  30. br.Ret = 408
  31. return
  32. }
  33. roleId := sysUser.RoleId
  34. list, e := system.GetMenuButtonsByRoleId(roleId)
  35. if e != nil {
  36. br.Msg = "获取失败"
  37. br.ErrMsg = "获取角色按钮权限失败, Err: " + e.Error()
  38. return
  39. }
  40. buttonList := make([]*system.SysMenuButtonResp, 0)
  41. for _, v := range list {
  42. tmp := new(system.SysMenuButtonResp)
  43. tmp.MenuId = v.MenuId
  44. tmp.ParentId = v.ParentId
  45. tmp.MenuType = v.MenuType
  46. tmp.Name = v.Name
  47. tmp.ButtonCode = v.ButtonCode
  48. buttonList = append(buttonList, tmp)
  49. }
  50. br.Data = buttonList
  51. br.Ret = 200
  52. br.Success = true
  53. br.Msg = "获取成功"
  54. }
  55. // SystemConfig
  56. // @Title 系统配置列表
  57. // @Description 系统配置列表
  58. // @Success 200 {object} []system.BusinessConf
  59. // @router /config [get]
  60. func (this *SysRoleController) SystemConfig() {
  61. br := new(models.BaseResponse).Init()
  62. defer func() {
  63. if br.ErrMsg == "" {
  64. br.IsSendEmail = false
  65. }
  66. this.Data["json"] = br
  67. this.ServeJSON()
  68. }()
  69. sysUser := this.SysUser
  70. if sysUser == nil {
  71. br.Msg = "请登录"
  72. br.ErrMsg = "请登录,SysUser Is Empty"
  73. br.Ret = 408
  74. return
  75. }
  76. list := make([]system.BusinessConf, 0)
  77. // 获取基础配置, 若未配置则直接返回
  78. conf, e := models.GetBusinessConf()
  79. if e != nil {
  80. br.Msg = "获取失败"
  81. br.ErrMsg = "获取基础配置失败, Err: " + e.Error()
  82. return
  83. }
  84. list = append(list, system.BusinessConf{
  85. ConfKey: "ReportViewUrl",
  86. ConfVal: conf["ReportViewUrl"],
  87. }, system.BusinessConf{
  88. ConfKey: "ChartViewUrl",
  89. ConfVal: conf["ChartViewUrl"],
  90. })
  91. osc := system.BusinessConf{
  92. ConfKey: "ObjectStorageClient",
  93. ConfVal: utils.ObjectStorageClient,
  94. }
  95. if osc.ConfVal == "" {
  96. osc.ConfVal = "oss"
  97. }
  98. list = append(list, osc)
  99. // 获取审批流设置
  100. confKey := "approval_flow"
  101. confTmp, e := company.GetConfigDetailByCode(confKey)
  102. if e != nil {
  103. br.Msg = "获取审批流配置失败"
  104. br.ErrMsg = "获取审批流配置失败, Err: " + e.Error()
  105. return
  106. }
  107. list = append(list, system.BusinessConf{
  108. ConfKey: "ApprovalFlow",
  109. ConfVal: confTmp.ConfigValue,
  110. })
  111. br.Data = list
  112. br.Ret = 200
  113. br.Success = true
  114. br.Msg = "获取成功"
  115. }