pgc.go 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. package http
  2. import (
  3. "time"
  4. "go-common/library/ecode"
  5. bm "go-common/library/net/http/blademaster"
  6. )
  7. func pgcfull(c *bm.Context) {
  8. var (
  9. err error
  10. items interface{}
  11. )
  12. v := new(struct {
  13. Pn int64 `form:"pn" validate:"min=1"`
  14. Ps int64 `form:"ps" validate:"min=1,max=50"`
  15. Tp int `form:"season_type" validate:"min=1,max=5"`
  16. Source string `form:"bsource" validate:"required"`
  17. })
  18. if err = c.Bind(v); err != nil {
  19. return
  20. }
  21. if !accessCard(_pgcFull, v.Source) {
  22. c.JSON(nil, ecode.AccessDenied)
  23. return
  24. }
  25. if items, err = srvWeb.PgcFull(c, v.Tp, v.Pn, v.Ps, v.Source); err != nil {
  26. c.JSON(nil, err)
  27. return
  28. }
  29. if items == nil {
  30. items = struct{}{}
  31. }
  32. data := make(map[string]interface{}, 5)
  33. data["app_name"] = _appName
  34. data["package_name"] = _packageName
  35. data["update_time"] = time.Now().Format("2006-01-02 15:04:05")
  36. data["source"] = v.Source
  37. data["shortvideos"] = items
  38. c.JSONMap(data, nil)
  39. }
  40. func pgcincre(c *bm.Context) {
  41. var (
  42. err error
  43. items interface{}
  44. )
  45. v := new(struct {
  46. Pn int64 `form:"pn" validate:"min=1"`
  47. Ps int64 `form:"ps" validate:"min=1,max=50"`
  48. Tp int `form:"season_type" validate:"min=1,max=5"`
  49. StartTime int64 `form:"start_ts" validate:"required"`
  50. EndTime int64 `form:"end_ts" validate:"required"`
  51. Source string `form:"bsource" validate:"required"`
  52. })
  53. if err = c.Bind(v); err != nil {
  54. return
  55. }
  56. if !accessCard(_pgcIncre, v.Source) {
  57. c.JSON(nil, ecode.AccessDenied)
  58. return
  59. }
  60. if items, err = srvWeb.PgcIncre(c, v.Tp, v.Pn, v.Ps, v.StartTime, v.EndTime, v.Source); err != nil {
  61. c.JSON(nil, err)
  62. return
  63. }
  64. if items == nil {
  65. items = struct{}{}
  66. }
  67. data := make(map[string]interface{}, 5)
  68. data["app_name"] = _appName
  69. data["package_name"] = _packageName
  70. data["update_time"] = time.Now().Format("2006-01-02 15:04:05")
  71. data["source"] = v.Source
  72. data["shortvideos"] = items
  73. c.JSONMap(data, nil)
  74. }