dao.go 702 B

123456789101112131415161718192021222324252627282930313233343536
  1. package account
  2. import (
  3. "context"
  4. "fmt"
  5. "go-common/app/interface/main/app-player/conf"
  6. accrpc "go-common/app/service/main/account/api"
  7. "github.com/pkg/errors"
  8. )
  9. // Dao is account dao.
  10. type Dao struct {
  11. // rpc
  12. accRPC accrpc.AccountClient
  13. }
  14. // New account dao.
  15. func New(c *conf.Config) (d *Dao) {
  16. d = &Dao{}
  17. var err error
  18. d.accRPC, err = accrpc.NewClient(c.AccountClient)
  19. if err != nil {
  20. panic(fmt.Sprintf("account NewClient error(%v)", err))
  21. }
  22. return
  23. }
  24. // Card get card
  25. func (d *Dao) Card(c context.Context, mid int64) (card *accrpc.CardReply, err error) {
  26. if card, err = d.accRPC.Card3(c, &accrpc.MidReq{Mid: mid}); err != nil {
  27. err = errors.Wrapf(err, "%v", mid)
  28. }
  29. return
  30. }