company_permission.go 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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 {
  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. br.Ret = 200
  66. br.Success = true
  67. br.Msg = "获取成功"
  68. br.Data = resp
  69. return
  70. }
  71. br.Ret = 200
  72. br.Success = true
  73. br.Msg = "获取成功"
  74. br.Data = resp
  75. }
  76. // PermissionVariety
  77. // @Title 品种
  78. // @Description 品种接口
  79. // @Param CompanyType query string true "客户类型:传空字符串或者不传为全部,'ficc','权益'"
  80. // @Success 200 {object} company.PermissionVarietyResp
  81. // @router /permission/variety [get]
  82. func (this *CompanyPermissionController) PermissionVariety() {
  83. br := new(models.BaseResponse).Init()
  84. defer func() {
  85. this.Data["json"] = br
  86. this.ServeJSON()
  87. }()
  88. sysUser := this.SysUser
  89. if sysUser == nil {
  90. br.Msg = "请登录"
  91. br.ErrMsg = "请登录,SysUser Is Empty"
  92. br.Ret = 408
  93. return
  94. }
  95. if utils.BusinessCode != utils.BusinessCodeRelease && utils.BusinessCode != utils.BusinessCodeSandbox {
  96. br.Ret = 200
  97. br.Success = true
  98. br.Msg = "获取成功"
  99. return
  100. }
  101. companyType := this.GetString("CompanyType")
  102. var productId int
  103. resp := new(company.PermissionVarietyResp)
  104. roleTypeCode := sysUser.RoleTypeCode
  105. if roleTypeCode == utils.ROLE_TYPE_CODE_RAI_SELLER || roleTypeCode == utils.ROLE_TYPE_CODE_RAI_ADMIN {
  106. productId = 2
  107. } else if roleTypeCode == utils.ROLE_TYPE_CODE_FICC_SELLER || roleTypeCode == utils.ROLE_TYPE_CODE_FICC_ADMIN {
  108. productId = 1
  109. } else {
  110. productId = 0
  111. }
  112. if productId == 1 {
  113. for k, v := range utils.PermissionFiccClassifyArr {
  114. p := new(company.PermissionVarietyList)
  115. p.ClassifyName = v
  116. p.ChartPermissionId = k + 100
  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. }
  126. } else if productId == 2 {
  127. v := "权益"
  128. p := new(company.PermissionVarietyList)
  129. p.ClassifyName = v
  130. p.ChartPermissionId = 105
  131. items, err := company.GetPermissionVarietyItems(productId, 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. } else {
  140. if companyType == utils.COMPANY_PRODUCT_FICC_NAME {
  141. for k, v := range utils.PermissionFiccClassifyArr {
  142. p := new(company.PermissionVarietyList)
  143. p.ClassifyName = v
  144. p.ChartPermissionId = k + 100
  145. items, err := company.GetPermissionVarietyItems(1, 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. } else if companyType == utils.COMPANY_PRODUCT_RAI_NAME {
  155. v := "权益"
  156. p := new(company.PermissionVarietyList)
  157. p.ClassifyName = v
  158. p.ChartPermissionId = 105
  159. items, err := company.GetPermissionVarietyItems(2, v)
  160. if err != nil {
  161. br.Msg = "获取失败"
  162. br.ErrMsg = "获取权限信息失败,Err:" + err.Error()
  163. return
  164. }
  165. p.Items = items
  166. resp.List = append(resp.List, p)
  167. }
  168. }
  169. br.Ret = 200
  170. br.Success = true
  171. br.Msg = "获取成功"
  172. br.Data = resp
  173. }