company_permission.go 5.4 KB

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