bangumi.go 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. package http
  2. import (
  3. epgrpc "go-common/app/service/openplatform/pgc-season/api/grpc/episode/v1"
  4. seasongrpc "go-common/app/service/openplatform/pgc-season/api/grpc/season/v1"
  5. "go-common/library/ecode"
  6. bm "go-common/library/net/http/blademaster"
  7. )
  8. //getPgcSeason GetSeason get season from pgc with grpc
  9. func getPgcSeason(c *bm.Context) {
  10. var (
  11. err error
  12. seasonCards map[int32]*seasongrpc.CardInfoProto
  13. )
  14. res := map[string]interface{}{}
  15. param := &struct {
  16. ID int32 `form:"id" validate:"required"`
  17. }{}
  18. if err = c.Bind(param); err != nil {
  19. return
  20. }
  21. v := []int32{param.ID}
  22. if seasonCards, err = pgcSvr.GetSeason(c, v); err != nil {
  23. res["message"] = "获取失败:" + err.Error()
  24. c.JSONMap(res, ecode.RequestErr)
  25. return
  26. }
  27. c.JSON(seasonCards, nil)
  28. }
  29. //getPgcSeasons GetSeasons get season from pgc with grpc
  30. func getPgcSeasons(c *bm.Context) {
  31. var (
  32. err error
  33. seasonCards map[int32]*seasongrpc.CardInfoProto
  34. )
  35. res := map[string]interface{}{}
  36. param := &struct {
  37. IDs []int32 `form:"ids,split" validate:"required,dive,gt=0"`
  38. }{}
  39. if err = c.Bind(param); err != nil {
  40. return
  41. }
  42. if seasonCards, err = pgcSvr.GetSeason(c, param.IDs); err != nil {
  43. res["message"] = "获取失败:" + err.Error()
  44. c.JSONMap(res, ecode.RequestErr)
  45. return
  46. }
  47. c.JSON(seasonCards, nil)
  48. }
  49. //getPgcEp GetSeasons get ep from pgc with grpc
  50. func getPgcEp(c *bm.Context) {
  51. var (
  52. err error
  53. epCards map[int32]*epgrpc.EpisodeCardsProto
  54. )
  55. res := map[string]interface{}{}
  56. param := &struct {
  57. IDs []int32 `form:"ids,split" validate:"required,dive,gt=0"`
  58. }{}
  59. if err = c.Bind(param); err != nil {
  60. return
  61. }
  62. if epCards, err = pgcSvr.GetEp(c, param.IDs); err != nil {
  63. res["message"] = "获取失败:" + err.Error()
  64. c.JSONMap(res, ecode.RequestErr)
  65. return
  66. }
  67. c.JSON(epCards, nil)
  68. }