share.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package http
  2. import (
  3. http "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. func shareURL(c *bm.Context) {
  9. var device *bm.Device
  10. if dev, _ := c.Get("device"); dev != nil {
  11. device = dev.(*bm.Device)
  12. }
  13. mid := int64(0)
  14. if v, _ := c.Get("mid"); v != nil {
  15. mid = v.(int64)
  16. }
  17. arg := &http.ShareRequest{}
  18. if err := c.Bind(arg); err != nil {
  19. errors.Wrap(err, "参数验证失败")
  20. return
  21. }
  22. c.JSON(srv.GetShareURL(c, mid, device, arg))
  23. }
  24. func shareCallback(c *bm.Context) {
  25. dev, _ := c.Get("device")
  26. mid, _ := c.Get("mid")
  27. if mid == nil {
  28. mid = int64(0)
  29. }
  30. arg := &http.ShareCallbackRequest{}
  31. if err := c.Bind(arg); err != nil {
  32. errors.Wrap(err, "参数验证失败")
  33. return
  34. }
  35. resp, err := srv.ShareCallback(c, mid.(int64), dev.(*bm.Device), arg)
  36. c.JSON(resp, err)
  37. // 埋点
  38. if err != nil {
  39. return
  40. }
  41. ext := struct {
  42. Svid int64
  43. Channel int32
  44. }{
  45. Svid: arg.Svid,
  46. Channel: arg.Channel,
  47. }
  48. uiLog(c, model.ActionShare, ext)
  49. }