interest.go 1010 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package http
  2. import (
  3. "strconv"
  4. "time"
  5. "go-common/library/ecode"
  6. bm "go-common/library/net/http/blademaster"
  7. )
  8. const (
  9. _headerBuvid = "Buvid"
  10. _headerDeviceID = "Device-ID"
  11. )
  12. // interest get interest list
  13. func interest(c *bm.Context) {
  14. var (
  15. header = c.Request.Header
  16. params = c.Request.Form
  17. )
  18. mobiApp := params.Get("mobi_app")
  19. buvid := header.Get(_headerBuvid)
  20. c.JSON(guideSvc.Interest(mobiApp, buvid, time.Now()), nil)
  21. }
  22. // interest2 get interest list
  23. func interest2(c *bm.Context) {
  24. var (
  25. header = c.Request.Header
  26. params = c.Request.Form
  27. )
  28. mobiApp := params.Get("mobi_app")
  29. device := params.Get("device")
  30. buildStr := params.Get("build")
  31. buvid := header.Get(_headerBuvid)
  32. if buvid == "" || len(buvid) <= 5 {
  33. c.JSON(nil, ecode.RequestErr)
  34. return
  35. }
  36. build, err := strconv.Atoi(buildStr)
  37. if err != nil {
  38. c.JSON(nil, ecode.RequestErr)
  39. return
  40. }
  41. dvcid := header.Get(_headerDeviceID)
  42. c.JSON(guideSvc.Interest2(mobiApp, device, dvcid, buvid, build, time.Now()), nil)
  43. }