feed.go 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. // @params FeedListReq
  9. // @router get /bbq/app-bbq/feed/list/
  10. // @response FeedListResponse
  11. func feedList(c *bm.Context) {
  12. arg := &v1.FeedListRequest{}
  13. if err := c.Bind(arg); err != nil {
  14. errors.Wrap(err, "参数验证失败")
  15. return
  16. }
  17. mid, _ := c.Get("mid")
  18. arg.MID = mid.(int64)
  19. dev, _ := c.Get("device")
  20. arg.Device = dev.(*bm.Device)
  21. b, _ := c.Get("BBQBase")
  22. arg.BUVID = b.(*v1.Base).BUVID
  23. resp, err := srv.FeedList(c, arg)
  24. c.JSON(resp, err)
  25. // 埋点
  26. if err != nil {
  27. return
  28. }
  29. var svidList []int64
  30. for _, v := range resp.List {
  31. svidList = append(svidList, v.SVID)
  32. }
  33. ext := &struct {
  34. Svids []int64
  35. }{
  36. Svids: svidList,
  37. }
  38. uiLog(c, model.ActionFeedList, ext)
  39. }
  40. // @params mid
  41. // @router get /bbq/app-bbq/feed/update_num
  42. // @response FeedUpdateNumResponse
  43. func feedUpdateNum(c *bm.Context) {
  44. mid, _ := c.Get("mid")
  45. c.JSON(srv.FeedUpdateNum(c, mid.(int64)))
  46. }
  47. // @params SpaceSvListRequest
  48. // @router get /bbq/app-bbq/space/sv/list/
  49. // @response SpaceSvListResponse
  50. func spaceSvList(c *bm.Context) {
  51. arg := &v1.SpaceSvListRequest{}
  52. if err := c.Bind(arg); err != nil {
  53. errors.Wrap(err, "参数验证失败")
  54. return
  55. }
  56. mid, exists := c.Get("mid")
  57. if exists {
  58. arg.MID = mid.(int64)
  59. }
  60. dev, _ := c.Get("device")
  61. arg.Device = dev.(*bm.Device)
  62. arg.Size = model.SpaceListLen
  63. c.JSON(srv.SpaceSvList(c, arg))
  64. }
  65. // @params SpaceSvListRequest
  66. // @router get /bbq/app-bbq/detail/sv/list/
  67. // @response SpaceSvListResponse
  68. func detailSvList(c *bm.Context) {
  69. arg := &v1.SpaceSvListRequest{}
  70. if err := c.Bind(arg); err != nil {
  71. errors.Wrap(err, "参数验证失败")
  72. return
  73. }
  74. mid, exists := c.Get("mid")
  75. if exists {
  76. arg.MID = mid.(int64)
  77. }
  78. dev, _ := c.Get("device")
  79. arg.Device = dev.(*bm.Device)
  80. // 暂时设置size=3
  81. arg.Size = 3
  82. arg.CursorNext = ""
  83. arg.CursorPrev = ""
  84. c.JSON(srv.SpaceSvList(c, arg))
  85. }