dao.go 710 B

1234567891011121314151617181920212223242526272829303132333435
  1. package relation
  2. import (
  3. "context"
  4. "go-common/app/interface/main/app-feed/conf"
  5. relation "go-common/app/service/main/relation/model"
  6. relrpc "go-common/app/service/main/relation/rpc/client"
  7. "github.com/pkg/errors"
  8. )
  9. // Dao is rpc dao.
  10. type Dao struct {
  11. // relation rpc
  12. relRPC *relrpc.Service
  13. }
  14. // New new a relation dao.
  15. func New(c *conf.Config) (d *Dao) {
  16. d = &Dao{
  17. // relation rpc
  18. relRPC: relrpc.New(c.RelationRPC),
  19. }
  20. return
  21. }
  22. // Stats fids stats
  23. func (d *Dao) Stats(ctx context.Context, mids []int64) (res map[int64]*relation.Stat, err error) {
  24. arg := &relation.ArgMids{Mids: mids}
  25. if res, err = d.relRPC.Stats(ctx, arg); err != nil {
  26. err = errors.Wrapf(err, "%v", arg)
  27. }
  28. return
  29. }