tag.go 3.3 KB

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