sys_role.go 2.8 KB

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