dao.go 994 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package resource
  2. import (
  3. "context"
  4. "go-common/app/interface/main/app-view/conf"
  5. "go-common/app/service/main/resource/model"
  6. rscrpc "go-common/app/service/main/resource/rpc/client"
  7. "go-common/library/ecode"
  8. "github.com/pkg/errors"
  9. )
  10. // Dao is archive dao.
  11. type Dao struct {
  12. // rpc
  13. rscRPC *rscrpc.Service
  14. }
  15. // New new a archive dao.
  16. func New(c *conf.Config) (d *Dao) {
  17. d = &Dao{
  18. // rpc
  19. rscRPC: rscrpc.New(c.ResourceRPC),
  20. }
  21. return
  22. }
  23. func (d *Dao) Paster(c context.Context, plat, adType int8, aid, typeID, buvid string) (res *model.Paster, err error) {
  24. arg := &model.ArgPaster{Platform: plat, AdType: adType, Aid: aid, TypeId: typeID, Buvid: buvid}
  25. if res, err = d.rscRPC.PasterAPP(c, arg); err != nil {
  26. err = errors.Wrapf(err, "%v", arg)
  27. }
  28. return
  29. }
  30. func (d *Dao) PlayerIcon(c context.Context) (res *model.PlayerIcon, err error) {
  31. if res, err = d.rscRPC.PlayerIcon(c); err != nil {
  32. if ecode.Cause(err) == ecode.NothingFound {
  33. res, err = nil, nil
  34. }
  35. }
  36. return
  37. }