ads.go 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. package http
  2. import (
  3. "strconv"
  4. "go-common/library/ecode"
  5. bm "go-common/library/net/http/blademaster"
  6. "go-common/app/service/main/resource/model"
  7. )
  8. // pasterAPP get paster for APP
  9. func pasterAPP(c *bm.Context) {
  10. var (
  11. params = c.Request.Form
  12. aid, typeID, buvid string
  13. platform, adType int
  14. err error
  15. )
  16. aid = params.Get("aid")
  17. typeID = params.Get("type_id")
  18. if aid == "" && typeID == "" {
  19. c.JSON(nil, ecode.RequestErr)
  20. return
  21. }
  22. if buvid = params.Get("buvid"); buvid == "" {
  23. c.JSON(nil, ecode.RequestErr)
  24. return
  25. }
  26. if platform, err = strconv.Atoi(params.Get("platform")); err != nil {
  27. c.JSON(nil, ecode.RequestErr)
  28. return
  29. }
  30. if adType, err = strconv.Atoi(params.Get("type")); err != nil {
  31. c.JSON(nil, ecode.RequestErr)
  32. return
  33. }
  34. c.JSON(resSvc.PasterAPP(c, int8(platform), int8(adType), aid, typeID, buvid))
  35. }
  36. // pasterPGC get paster for PGC
  37. func pasterPGC(c *bm.Context) {
  38. var (
  39. params = c.Request.Form
  40. sid, platform, device string
  41. adType int
  42. plat int8
  43. err error
  44. )
  45. sid = params.Get("season_id")
  46. if _, err = strconv.ParseInt(sid, 10, 64); err != nil {
  47. c.JSON(nil, ecode.RequestErr)
  48. return
  49. }
  50. if adType, err = strconv.Atoi(params.Get("type")); err != nil {
  51. c.JSON(nil, ecode.RequestErr)
  52. return
  53. }
  54. if platform = params.Get("platform"); platform == "" {
  55. c.JSON(nil, ecode.RequestErr)
  56. return
  57. }
  58. device = params.Get("device")
  59. if platform == "web" {
  60. plat = model.PlatWEB
  61. } else {
  62. plat = model.Plat(platform, device)
  63. }
  64. c.JSON(resSvc.PasterPGC(c, plat, int8(adType), sid))
  65. }