pgc.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package pgc
  2. import (
  3. "context"
  4. "go-common/app/admin/main/feed/conf"
  5. pgcdao "go-common/app/admin/main/feed/dao/pgc"
  6. epgrpc "go-common/app/service/openplatform/pgc-season/api/grpc/episode/v1"
  7. seasongrpc "go-common/app/service/openplatform/pgc-season/api/grpc/season/v1"
  8. "go-common/library/log"
  9. )
  10. // Service is egg service
  11. type Service struct {
  12. pgc *pgcdao.Dao
  13. }
  14. // New new a egg service
  15. func New(c *conf.Config) (s *Service) {
  16. var (
  17. b *pgcdao.Dao
  18. err error
  19. )
  20. if b, err = pgcdao.New(c); err != nil {
  21. log.Error("pgcdao.New error(%v)", err)
  22. return
  23. }
  24. s = &Service{
  25. pgc: b,
  26. }
  27. return
  28. }
  29. //GetSeason get season from pgc
  30. func (s *Service) GetSeason(c context.Context, seasonIDs []int32) (seasonCards map[int32]*seasongrpc.CardInfoProto, err error) {
  31. if seasonCards, err = s.pgc.CardsInfoReply(c, seasonIDs); err != nil {
  32. log.Error("%+v", err)
  33. }
  34. return
  35. }
  36. //GetEp get ep from pgc
  37. func (s *Service) GetEp(c context.Context, epIds []int32) (res map[int32]*epgrpc.EpisodeCardsProto, err error) {
  38. if res, err = s.pgc.CardsEpInfoReply(c, epIds); err != nil {
  39. log.Error("%+v", err)
  40. }
  41. return
  42. }