banner.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package http
  2. import (
  3. "strconv"
  4. "go-common/library/ecode"
  5. "go-common/library/log"
  6. bm "go-common/library/net/http/blademaster"
  7. )
  8. // banner get banner
  9. func banner(c *bm.Context) {
  10. params := c.Request.Form
  11. aid, _ := strconv.ParseInt(params.Get("aid"), 10, 64)
  12. platStr := params.Get("plat")
  13. plat, err := strconv.Atoi(platStr)
  14. if err != nil {
  15. c.JSON(nil, ecode.RequestErr)
  16. return
  17. }
  18. mobiApp := params.Get("mobi_app")
  19. resIds := params.Get("resource_ids")
  20. buildStr := params.Get("build")
  21. channel := params.Get("channel")
  22. network := params.Get("network")
  23. isAd, _ := strconv.ParseBool(params.Get("is_ad"))
  24. // check params
  25. build, err := strconv.Atoi(buildStr)
  26. if err != nil {
  27. log.Error("build(%s) error(%v)", buildStr, err)
  28. c.JSON(nil, ecode.RequestErr)
  29. return
  30. }
  31. var mid int64
  32. if midInter, ok := c.Get("mid"); ok {
  33. mid = midInter.(int64)
  34. }
  35. buvid := params.Get("buvid")
  36. ip := params.Get("ip")
  37. device := params.Get("device")
  38. openEvent := params.Get("open_event")
  39. version := params.Get("version")
  40. adExtra := params.Get("ad_extra")
  41. banner := resSvc.Banners(c, int8(plat), build, aid, mid, resIds, channel, ip, buvid, network, mobiApp, device, openEvent, adExtra, version, isAd)
  42. if banner != nil {
  43. c.JSON(banner.Banner, nil)
  44. }
  45. }