chart_permission.go 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. package controllers
  2. import (
  3. "hongze/hongze_clpt/models"
  4. "hongze/hongze_clpt/utils"
  5. "strconv"
  6. )
  7. // 品种
  8. type ChartPermissionController struct {
  9. BaseCommonController
  10. }
  11. type ChartPermissionAuthController struct {
  12. BaseAuthController
  13. }
  14. type MobileChartPermissionAuthController struct {
  15. BaseAuthMobileController
  16. }
  17. // @Title 获取所有品种
  18. // @Description 获取所有品种接口
  19. // @Success 200 {object} models.ChartPermissionListResp
  20. // @router /list [get]
  21. func (this *ChartPermissionController) Detail() {
  22. br := new(models.BaseResponse).Init()
  23. defer func() {
  24. this.Data["json"] = br
  25. this.ServeJSON()
  26. }()
  27. var condition string
  28. var chartPermissionId string
  29. chartPermissionId = strconv.Itoa(utils.YI_YAO_ID) + "," + strconv.Itoa(utils.XIAO_FEI_ID) + "," + strconv.Itoa(utils.KE_JI_ID) + "," + strconv.Itoa(utils.ZHI_ZAO_ID) + "," + strconv.Itoa(utils.CHART_PERMISSION_ID_YANXUAN)
  30. condition += ` AND chart_permission_id IN ( ` + chartPermissionId + `)`
  31. list, err := models.GetChartPermissionReportAll(condition)
  32. if err != nil {
  33. br.Msg = "获取信息失败"
  34. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  35. return
  36. }
  37. resp := new(models.ChartPermissionListResp)
  38. for _, v := range list {
  39. if v.PermissionName == utils.CHART_PERMISSION_NAME_MF_YANXUAN {
  40. v.PermissionName = utils.MAI_FANG_YAN_XUAN_NAME
  41. }
  42. }
  43. resp.List = list
  44. br.Ret = 200
  45. br.Success = true
  46. br.Msg = "获取成功"
  47. br.Data = resp
  48. }
  49. // @Title 获取报告所有品种
  50. // @Description 获取报告所有品种接口
  51. // @Success 200 {object} models.ChartPermissionListResp
  52. // @router /listByReport [get]
  53. func (this *ChartPermissionController) ListByReport() {
  54. br := new(models.BaseResponse).Init()
  55. defer func() {
  56. this.Data["json"] = br
  57. this.ServeJSON()
  58. }()
  59. var condition string
  60. //var chartPermissionId string
  61. //chartPermissionId = strconv.Itoa(utils.YI_YAO_ID) + "," + strconv.Itoa(utils.XIAO_FEI_ID) + "," + strconv.Itoa(utils.KE_JI_ID) + "," + strconv.Itoa(utils.ZHI_ZAO_ID) + "," + strconv.Itoa(utils.CE_LUE_ID) + "," + strconv.Itoa(utils.GU_SHOU_ID_CHART)
  62. //condition += ` AND chart_permission_id IN ( ` + chartPermissionId + `)`
  63. condition += ` AND permission_name IN ('医药','消费','科技','智造','策略','固收','周期') `
  64. list, err := models.GetChartPermissionReportAll(condition)
  65. if err != nil {
  66. br.Msg = "获取信息失败"
  67. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  68. return
  69. }
  70. //item := new(models.ChartPermissionResp)
  71. //item.PermissionName = utils.GU_SHOU_NAME
  72. //item.ChartPermissionId = utils.GU_SHOU_ID
  73. //list = append(list, item)
  74. resp := new(models.ChartPermissionListResp)
  75. resp.List = list
  76. br.Ret = 200
  77. br.Success = true
  78. br.Msg = "获取成功"
  79. br.Data = resp
  80. }
  81. // @Title 获取活动所有品种
  82. // @Description 获取活动所有品种接口
  83. // @Success 200 {object} models.ChartPermissionListResp
  84. // @router /listByActivity [get]
  85. func (this *MobileChartPermissionAuthController) ListByActivity() {
  86. br := new(models.BaseResponse).Init()
  87. defer func() {
  88. this.Data["json"] = br
  89. this.ServeJSON()
  90. }()
  91. user := this.User
  92. if user == nil {
  93. br.Msg = "请重新登录"
  94. br.Ret = 408
  95. return
  96. }
  97. var condition string
  98. //var chartPermissionId string
  99. //chartPermissionId = strconv.Itoa(utils.YI_YAO_ID) + "," + strconv.Itoa(utils.XIAO_FEI_ID) + "," + strconv.Itoa(utils.KE_JI_ID) + "," + strconv.Itoa(utils.ZHI_ZAO_ID) + "," + strconv.Itoa(utils.CE_LUE_ID) + "," + strconv.Itoa(utils.CHART_PERMISSION_ID_YANXUAN) + "," + strconv.Itoa(utils.GU_SHOU_ID_CHART)
  100. //condition += ` AND chart_permission_id IN ( ` + chartPermissionId + `)`
  101. condition += ` AND permission_name IN ('医药','消费','科技','智造','策略','固收','研选订阅','周期') `
  102. list, err := models.GetChartPermissionReportAll(condition)
  103. if err != nil {
  104. br.Msg = "获取信息失败"
  105. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  106. return
  107. }
  108. for _, v := range list {
  109. if v.PermissionName == utils.CHART_PERMISSION_NAME_MF_YANXUAN {
  110. v.PermissionName = utils.MAI_FANG_YAN_XUAN_NAME
  111. }
  112. }
  113. resp := new(models.ChartPermissionListResp)
  114. if user.CompanyId > 1 {
  115. chartList, err := models.GetUserCompanyPermissionSand(user.CompanyId)
  116. if err != nil && err.Error() != utils.ErrNoRow() {
  117. br.Msg = "获取信息失败"
  118. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  119. return
  120. }
  121. for _, v := range chartList {
  122. resp.CheckList = append(resp.CheckList, v.ChartPermissionId)
  123. }
  124. }
  125. resp.List = list
  126. br.Ret = 200
  127. br.Success = true
  128. br.Msg = "获取成功"
  129. br.Data = resp
  130. }
  131. // @Title 获取报告医药、消费、科技、智造、策略权限列表(没有买方研选)
  132. // @Description 获取报告医药、消费、科技、智造、策略权限列表(没有买方研选)
  133. // @Success 200 {object} models.ChartPermissionResp
  134. // @router /noyx [get]
  135. func (this *MobileChartPermissionAuthController) Noyx() {
  136. br := new(models.BaseResponse).Init()
  137. defer func() {
  138. this.Data["json"] = br
  139. this.ServeJSON()
  140. }()
  141. user := this.User
  142. if user == nil {
  143. br.Msg = "请重新登录"
  144. br.Ret = 408
  145. return
  146. }
  147. var condition string
  148. condition += ` AND permission_name IN ('医药','消费','科技','智造','策略','固收','周期') `
  149. list, err := models.GetChartPermissionReportAll(condition)
  150. if err != nil {
  151. br.Msg = "获取信息失败"
  152. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  153. return
  154. }
  155. resp := new(models.ChartPermissionListResp)
  156. resp.List = list
  157. br.Ret = 200
  158. br.Success = true
  159. br.Msg = "获取成功"
  160. br.Data = resp
  161. }