search.go 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. package http
  2. import (
  3. "go-common/app/interface/bbq/app-bbq/api/http/v1"
  4. "go-common/app/interface/bbq/app-bbq/model"
  5. bm "go-common/library/net/http/blademaster"
  6. "github.com/pkg/errors"
  7. )
  8. const (
  9. qn1080 = 80
  10. )
  11. //hotWord .
  12. func hotWord(c *bm.Context) {
  13. arg := new(v1.HotWordRequest)
  14. if err := c.Bind(arg); err != nil {
  15. errors.Wrap(err, "参数验证失败")
  16. return
  17. }
  18. c.JSON(srv.HotWord(c, arg))
  19. }
  20. func videoSearch(c *bm.Context) {
  21. arg := new(v1.BaseSearchReq)
  22. if err := c.Bind(arg); err != nil {
  23. errors.Wrap(err, "参数验证失败")
  24. return
  25. }
  26. if arg.Qn == 0 {
  27. arg.Qn = qn1080
  28. }
  29. if arg.PageSize == 0 || arg.PageSize > 20 {
  30. arg.PageSize = 20
  31. }
  32. res, err := srv.VideoSearch(c, arg)
  33. c.JSON(res, err)
  34. // 埋点
  35. if err != nil {
  36. return
  37. }
  38. svidList := make([]int64, len(res.List))
  39. for i, v := range res.List {
  40. svidList[i] = v.SVID
  41. }
  42. ext := struct {
  43. Request *v1.BaseSearchReq
  44. Svid []int64
  45. }{
  46. Request: arg,
  47. Svid: svidList,
  48. }
  49. uiLog(c, model.ActionVideoSearch, ext)
  50. }
  51. func userSearch(c *bm.Context) {
  52. arg := new(v1.BaseSearchReq)
  53. if err := c.Bind(arg); err != nil {
  54. errors.Wrap(err, "参数验证失败")
  55. return
  56. }
  57. mid, _ := c.Get("mid")
  58. if mid == nil {
  59. mid = int64(0)
  60. }
  61. if arg.Qn == 0 {
  62. arg.Qn = qn1080
  63. }
  64. if arg.PageSize == 0 || arg.PageSize > 20 {
  65. arg.PageSize = 20
  66. }
  67. res, err := srv.UserSearch(c, mid.(int64), arg)
  68. c.JSON(res, err)
  69. // 埋点
  70. if err != nil {
  71. return
  72. }
  73. midList := make([]int64, len(res.List))
  74. for i, v := range res.List {
  75. midList[i] = v.Mid
  76. }
  77. ext := struct {
  78. Request *v1.BaseSearchReq
  79. MID []int64
  80. }{
  81. Request: arg,
  82. MID: midList,
  83. }
  84. uiLog(c, model.ActionUserSearch, ext)
  85. }
  86. func sug(c *bm.Context) {
  87. arg := new(v1.SugReq)
  88. if err := c.Bind(arg); err != nil {
  89. errors.Wrap(err, "参数验证失败")
  90. return
  91. }
  92. if arg.PageSize == 0 || arg.PageSize > 20 {
  93. arg.PageSize = 20
  94. }
  95. c.JSON(srv.BBQSug(c, arg))
  96. }