tag.go 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. package controllers
  2. import (
  3. "encoding/json"
  4. "hongze/hongze_cygx/models"
  5. "hongze/hongze_cygx/services"
  6. )
  7. type TagController struct {
  8. BaseAuthController
  9. }
  10. // @Title 获取标签列表-自定义顺序
  11. // @Description 获取标签列表-自定义顺序接口
  12. // @Success 200 {object} cygx.ChartPermissionResp
  13. // @router /list/custom [get]
  14. func (this *TagController) TagCustomizeList() {
  15. br := new(models.BaseResponse).Init()
  16. defer func() {
  17. this.Data["json"] = br
  18. this.ServeJSON()
  19. }()
  20. sysUser := this.User
  21. if sysUser == nil {
  22. br.Msg = "请登录"
  23. br.ErrMsg = "请登录,SysUser Is Empty"
  24. br.Ret = 408
  25. return
  26. }
  27. var condition string
  28. //hasPermission, err := services.GetUserHasPermissionSimple(sysUser)
  29. //if err != nil {
  30. // br.Msg = "获取信息失败"
  31. // br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  32. // return
  33. //}
  34. //if hasPermission > 1 {
  35. // list := make([]*models.CygxTagList, 0)
  36. // br.Ret = 200
  37. // br.Success = true
  38. // br.Msg = "获取成功"
  39. // br.Data = list
  40. // return
  41. //}
  42. list, err := models.GetCygxTagList(condition)
  43. for _, v := range list {
  44. if v.ArticleTypes != "" {
  45. v.CheckList = append(v.CheckList, "A")
  46. }
  47. if v.ActivityTypes != "" {
  48. v.CheckList = append(v.CheckList, "B")
  49. }
  50. if v.Industries != "" {
  51. v.CheckList = append(v.CheckList, "C")
  52. }
  53. if v.SubjectNames != "" {
  54. v.CheckList = append(v.CheckList, "D")
  55. }
  56. //固定标签默认都属于,前端互斥使用
  57. if v.TagType > 0 {
  58. v.CheckList = []string{"A", "B", "C", "D"}
  59. }
  60. }
  61. if err != nil {
  62. br.Msg = "获取标签失败"
  63. br.ErrMsg = "获取标签信息失败,Err:" + err.Error()
  64. return
  65. }
  66. condition = ` AND permission_name IN ('医药1','消费','科技','智造','策略','固收','周期') `
  67. listPermission, err := models.GetChartPermissionReportAll(condition)
  68. if err != nil {
  69. br.Msg = "获取信息失败"
  70. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  71. return
  72. }
  73. //item := new(models.ChartPermission)
  74. //item.ChartPermissionId = utils.GU_SHOU_ID
  75. //item.PermissionName = utils.GU_SHOU_NAME
  76. //listPermission = append(listPermission, item)
  77. resp := new(models.CygxTagListResp)
  78. resp.List = list
  79. resp.ListPermission = listPermission
  80. br.Ret = 200
  81. br.Success = true
  82. br.Msg = "获取成功"
  83. br.Data = resp
  84. }
  85. // @Title 记录点击信息
  86. // @Description 记录点击信息
  87. // @Param request body cygx.CygxTagIdReq true "type json string"
  88. // @Success 200 Ret=200 发布成功
  89. // @router /add/history [post]
  90. func (this *TagController) History() {
  91. br := new(models.BaseResponse).Init()
  92. defer func() {
  93. this.Data["json"] = br
  94. this.ServeJSON()
  95. }()
  96. user := this.User
  97. if user == nil {
  98. br.Msg = "请登录"
  99. br.ErrMsg = "请登录,用户信息为空"
  100. br.Ret = 408
  101. return
  102. }
  103. var req models.CygxTagIdReq
  104. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  105. if err != nil {
  106. br.Msg = "参数解析异常!"
  107. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  108. return
  109. }
  110. tagId := req.TagId
  111. if tagId == 0 {
  112. br.Msg = "参数错误"
  113. br.ErrMsg = "参数错误,id不可为空"
  114. return
  115. }
  116. go services.AddCygxTagHistory(user, tagId)
  117. br.Ret = 200
  118. br.Success = true
  119. br.Msg = "记录成功"
  120. }