bullet_chat.go 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. package yb
  2. import (
  3. "encoding/json"
  4. "github.com/rdlucklib/rdluck_tools/paging"
  5. "hongze/hz_crm_api/controllers"
  6. "hongze/hz_crm_api/models"
  7. "hongze/hz_crm_api/models/yb/request"
  8. "hongze/hz_crm_api/models/yb/response"
  9. "hongze/hz_crm_api/services/yb"
  10. "hongze/hz_crm_api/utils"
  11. )
  12. // 研报弹幕
  13. type BulletChatController struct {
  14. controllers.BaseAuthController
  15. }
  16. // List
  17. // @Title 弹幕列表
  18. // @Description 弹幕列表
  19. // @Param Source query int false "来源:1-视频社区; 2-线上路演"
  20. // @Param Keywords query string false "关键词:弹幕内容/视频标题"
  21. // @Success 200 {object} response.CommunityQuestionListResp
  22. // @router /bullet_chat/list [get]
  23. func (this *BulletChatController) List() {
  24. br := new(models.BaseResponse).Init()
  25. br.IsSendEmail = false
  26. defer func() {
  27. this.Data["json"] = br
  28. this.ServeJSON()
  29. }()
  30. sysUser := this.SysUser
  31. if sysUser == nil {
  32. br.Msg = "请登录"
  33. br.ErrMsg = "请登录,SysUser Is Empty"
  34. br.Ret = 408
  35. return
  36. }
  37. source, _ := this.GetInt("Source", 0)
  38. keywords := this.GetString("Keywords", "")
  39. condition := ""
  40. pars := make([]interface{}, 0)
  41. if source > 0 {
  42. condition += ` AND source = ?`
  43. pars = append(pars, source)
  44. }
  45. if keywords != "" {
  46. k := "%" + keywords + "%"
  47. condition += ` AND (title LIKE ? OR content LIKE ?)`
  48. pars = append(pars, k, k)
  49. }
  50. var startSize int
  51. pageSize, _ := this.GetInt("PageSize")
  52. currentIndex, _ := this.GetInt("CurrentIndex")
  53. if pageSize <= 0 {
  54. pageSize = utils.PageSize20
  55. }
  56. if currentIndex <= 0 {
  57. currentIndex = 1
  58. }
  59. startSize = paging.StartIndex(currentIndex, pageSize)
  60. total, list, err := yb.GetBulletChatList(condition, pars, startSize, pageSize)
  61. if err != nil {
  62. br.Msg = "获取失败"
  63. br.ErrMsg = "获取弹幕列表失败, ErrMsg:" + err.Error()
  64. return
  65. }
  66. page := paging.GetPaging(currentIndex, pageSize, total)
  67. resp := &response.BulletChatListResp{
  68. Paging: page,
  69. List: list,
  70. }
  71. br.Ret = 200
  72. br.Success = true
  73. br.Msg = "获取成功"
  74. br.Data = resp
  75. }
  76. // Delete
  77. // @Title 删除弹幕
  78. // @Description 删除弹幕
  79. // @Param request body request.CommunityVideoOptionReq true "type json string"
  80. // @Success 200 string "操作成功"
  81. // @router /bullet_chat/delete [post]
  82. func (this *BulletChatController) Delete() {
  83. br := new(models.BaseResponse).Init()
  84. br.IsSendEmail = false
  85. defer func() {
  86. this.Data["json"] = br
  87. this.ServeJSON()
  88. }()
  89. sysUser := this.SysUser
  90. if sysUser == nil {
  91. br.Msg = "请登录"
  92. br.ErrMsg = "请登录,SysUser Is Empty"
  93. br.Ret = 408
  94. return
  95. }
  96. var req request.BulletChatDelReq
  97. if err := json.Unmarshal(this.Ctx.Input.RequestBody, &req); err != nil {
  98. br.Msg = "参数解析异常!"
  99. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  100. return
  101. }
  102. if req.Id <= 0 {
  103. br.Msg = "参数有误"
  104. return
  105. }
  106. if e := yb.SoftDeleteBulletChat(sysUser.AdminId, req.Id); e != nil {
  107. br.Msg = "删除失败"
  108. br.ErrMsg = "删除弹幕失败, Err: " + e.Error()
  109. return
  110. }
  111. br.Ret = 200
  112. br.Success = true
  113. br.Msg = "操作成功"
  114. }