push.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. notice "go-common/app/service/bbq/notice-service/api/v1"
  6. bm "go-common/library/net/http/blademaster"
  7. "github.com/pkg/errors"
  8. )
  9. func pushRegister(c *bm.Context) {
  10. args := &v1.PushRegisterRequest{}
  11. if err := c.Bind(args); err != nil {
  12. errors.Wrap(err, "参数验证失败")
  13. return
  14. }
  15. var mid int64
  16. if tmp, ok := c.Get("mid"); ok {
  17. mid = tmp.(int64)
  18. }
  19. buvid := c.Request.Header.Get("Buvid")
  20. req := &notice.UserPushDev{
  21. Mid: mid,
  22. RegisterId: args.RegID,
  23. Buvid: buvid,
  24. Platform: 1,
  25. Sdk: 1,
  26. }
  27. if args.Platform == "ios" {
  28. req.Platform = 2
  29. }
  30. c.JSON(srv.PushRegister(c, req))
  31. // 埋点
  32. uiLog(c, model.ActionPushRegister, args)
  33. }
  34. func pushLogout(c *bm.Context) {
  35. args := &notice.UserPushDev{}
  36. var mid int64
  37. if tmp, ok := c.Get("mid"); ok {
  38. mid = tmp.(int64)
  39. }
  40. args.Mid = mid
  41. buvid := c.Request.Header.Get("Buvid")
  42. args.Buvid = buvid
  43. c.JSON(srv.PushLogout(c, args))
  44. }
  45. func pushCallback(c *bm.Context) {
  46. args := &v1.PushCallbackRequest{}
  47. if err := c.Bind(args); err != nil {
  48. errors.Wrap(err, "参数验证失败")
  49. return
  50. }
  51. var mid int64
  52. if tmp, ok := c.Get("mid"); ok {
  53. mid = tmp.(int64)
  54. }
  55. buvid := c.Request.Header.Get("Buvid")
  56. c.JSON(srv.PushCallback(c, args, mid, buvid))
  57. // 埋点
  58. uiLog(c, model.ActionPushCallback, args)
  59. }