dao.go 762 B

123456789101112131415161718192021222324252627282930313233
  1. package dm
  2. import (
  3. "context"
  4. "go-common/app/interface/main/app-intl/conf"
  5. dm "go-common/app/interface/main/dm2/model"
  6. dmrpc "go-common/app/interface/main/dm2/rpc/client"
  7. "go-common/library/net/metadata"
  8. "github.com/pkg/errors"
  9. )
  10. // Dao struct
  11. type Dao struct {
  12. dmRPC *dmrpc.Service
  13. }
  14. // New a dao
  15. func New(c *conf.Config) (d *Dao) {
  16. return &Dao{
  17. dmRPC: dmrpc.New(c.DMRPC),
  18. }
  19. }
  20. // SubjectInfos is.
  21. func (d *Dao) SubjectInfos(c context.Context, typ int32, plat int8, oids ...int64) (res map[int64]*dm.SubjectInfo, err error) {
  22. ip := metadata.String(c, metadata.RemoteIP)
  23. arg := &dm.ArgOids{Type: typ, Plat: plat, Oids: oids, RealIP: ip}
  24. if res, err = d.dmRPC.SubjectInfos(c, arg); err != nil {
  25. err = errors.Wrapf(err, "%v", arg)
  26. }
  27. return
  28. }