company_permission.go 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. package controllers
  2. import (
  3. "hongze/hz_eta_api/models"
  4. "hongze/hz_eta_api/models/company"
  5. "hongze/hz_eta_api/services"
  6. "hongze/hz_eta_api/utils"
  7. )
  8. // CompanyPermissionController 客户权限管理
  9. type CompanyPermissionController struct {
  10. BaseAuthController
  11. }
  12. // List
  13. // @Title 获取权限设置基础信息
  14. // @Description 获取权限设置基础信息接口
  15. // @Param CompanyType query string true "客户类型:传空字符串或者不传为全部,'ficc','权益'"
  16. // @Param NoUpgrade query bool false "是否不展示升级权限,默认为 false"
  17. // @Success 200 {object} company.PermissionSetResp
  18. // @router /permission/list [get]
  19. func (this *CompanyPermissionController) List() {
  20. br := new(models.BaseResponse).Init()
  21. defer func() {
  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. // Tips:目前这个接口权益在添加客户、申请转正、领取客户、续约申请均有用到
  33. companyType := this.GetString("CompanyType")
  34. var productId int
  35. resp := new(company.PermissionSetResp)
  36. roleTypeCode := sysUser.RoleTypeCode
  37. productId = services.GetProductId(roleTypeCode)
  38. // FICC
  39. if productId == utils.COMPANY_PRODUCT_FICC_ID || companyType == utils.COMPANY_PRODUCT_FICC_NAME {
  40. for _, v := range utils.PermissionFiccClassifyArr {
  41. checkList := make([]int, 0)
  42. p := new(company.PermissionSetList)
  43. p.ClassifyName = v
  44. items, err := company.GetPermissionSetItems(utils.COMPANY_PRODUCT_FICC_ID, v)
  45. if err != nil {
  46. br.Msg = "获取失败"
  47. br.ErrMsg = "获取权限信息失败,Err:" + err.Error()
  48. return
  49. }
  50. p.Items = items
  51. if v == "宏观经济" {
  52. checkList = append(checkList, 1)
  53. }
  54. p.CheckList = checkList
  55. resp.List = append(resp.List, p)
  56. }
  57. br.Ret = 200
  58. br.Success = true
  59. br.Msg = "获取成功"
  60. br.Data = resp
  61. return
  62. }
  63. br.Ret = 200
  64. br.Success = true
  65. br.Msg = "获取成功"
  66. br.Data = resp
  67. }
  68. // PermissionVariety
  69. // @Title 品种
  70. // @Description 品种接口
  71. // @Param CompanyType query string true "客户类型:传空字符串或者不传为全部,'ficc','权益'"
  72. // @Success 200 {object} company.PermissionVarietyResp
  73. // @router /permission/variety [get]
  74. func (this *CompanyPermissionController) PermissionVariety() {
  75. br := new(models.BaseResponse).Init()
  76. defer func() {
  77. this.Data["json"] = br
  78. this.ServeJSON()
  79. }()
  80. sysUser := this.SysUser
  81. if sysUser == nil {
  82. br.Msg = "请登录"
  83. br.ErrMsg = "请登录,SysUser Is Empty"
  84. br.Ret = 408
  85. return
  86. }
  87. companyType := this.GetString("CompanyType")
  88. var productId int
  89. resp := new(company.PermissionVarietyResp)
  90. roleTypeCode := sysUser.RoleTypeCode
  91. if roleTypeCode == utils.ROLE_TYPE_CODE_RAI_SELLER || roleTypeCode == utils.ROLE_TYPE_CODE_RAI_ADMIN {
  92. productId = 2
  93. } else if roleTypeCode == utils.ROLE_TYPE_CODE_FICC_SELLER || roleTypeCode == utils.ROLE_TYPE_CODE_FICC_ADMIN {
  94. productId = 1
  95. } else {
  96. productId = 0
  97. }
  98. if productId == 1 {
  99. for k, v := range utils.PermissionFiccClassifyArr {
  100. p := new(company.PermissionVarietyList)
  101. p.ClassifyName = v
  102. p.ChartPermissionId = k + 100
  103. items, err := company.GetPermissionVarietyItems(productId, v)
  104. if err != nil {
  105. br.Msg = "获取失败"
  106. br.ErrMsg = "获取权限信息失败,Err:" + err.Error()
  107. return
  108. }
  109. p.Items = items
  110. resp.List = append(resp.List, p)
  111. }
  112. } else if productId == 2 {
  113. v := "权益"
  114. p := new(company.PermissionVarietyList)
  115. p.ClassifyName = v
  116. p.ChartPermissionId = 105
  117. items, err := company.GetPermissionVarietyItems(productId, v)
  118. if err != nil {
  119. br.Msg = "获取失败"
  120. br.ErrMsg = "获取权限信息失败,Err:" + err.Error()
  121. return
  122. }
  123. p.Items = items
  124. resp.List = append(resp.List, p)
  125. } else {
  126. if companyType == utils.COMPANY_PRODUCT_FICC_NAME {
  127. for k, v := range utils.PermissionFiccClassifyArr {
  128. p := new(company.PermissionVarietyList)
  129. p.ClassifyName = v
  130. p.ChartPermissionId = k + 100
  131. items, err := company.GetPermissionVarietyItems(1, v)
  132. if err != nil {
  133. br.Msg = "获取失败"
  134. br.ErrMsg = "获取权限信息失败,Err:" + err.Error()
  135. return
  136. }
  137. p.Items = items
  138. resp.List = append(resp.List, p)
  139. }
  140. } else if companyType == utils.COMPANY_PRODUCT_RAI_NAME {
  141. v := "权益"
  142. p := new(company.PermissionVarietyList)
  143. p.ClassifyName = v
  144. p.ChartPermissionId = 105
  145. items, err := company.GetPermissionVarietyItems(2, v)
  146. if err != nil {
  147. br.Msg = "获取失败"
  148. br.ErrMsg = "获取权限信息失败,Err:" + err.Error()
  149. return
  150. }
  151. p.Items = items
  152. resp.List = append(resp.List, p)
  153. }
  154. }
  155. br.Ret = 200
  156. br.Success = true
  157. br.Msg = "获取成功"
  158. br.Data = resp
  159. }