tag.go 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. //var condition string
  67. condition = ` AND permission_name IN ('医药','消费','科技','智造','策略','固收','周期') `
  68. listPermission, err := models.GetChartPermissionReportAll(condition)
  69. if err != nil {
  70. br.Msg = "获取信息失败"
  71. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  72. return
  73. }
  74. //item := new(models.ChartPermission)
  75. //item.ChartPermissionId = utils.GU_SHOU_ID
  76. //item.PermissionName = utils.GU_SHOU_NAME
  77. //listPermission = append(listPermission, item)
  78. resp := new(models.CygxTagListResp)
  79. resp.List = list
  80. resp.ListPermission = listPermission
  81. br.Ret = 200
  82. br.Success = true
  83. br.Msg = "获取成功"
  84. br.Data = resp
  85. }
  86. // @Title 记录点击信息
  87. // @Description 记录点击信息
  88. // @Param request body cygx.CygxTagIdReq true "type json string"
  89. // @Success 200 Ret=200 发布成功
  90. // @router /add/history [post]
  91. func (this *TagController) History() {
  92. br := new(models.BaseResponse).Init()
  93. defer func() {
  94. this.Data["json"] = br
  95. this.ServeJSON()
  96. }()
  97. user := this.User
  98. if user == nil {
  99. br.Msg = "请登录"
  100. br.ErrMsg = "请登录,用户信息为空"
  101. br.Ret = 408
  102. return
  103. }
  104. var req models.CygxTagIdReq
  105. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  106. if err != nil {
  107. br.Msg = "参数解析异常!"
  108. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  109. return
  110. }
  111. tagId := req.TagId
  112. if tagId == 0 {
  113. br.Msg = "参数错误"
  114. br.ErrMsg = "参数错误,id不可为空"
  115. return
  116. }
  117. go services.AddCygxTagHistory(user, tagId)
  118. br.Ret = 200
  119. br.Success = true
  120. br.Msg = "记录成功"
  121. }