article.go 787 B

123456789101112131415161718192021222324252627282930313233343536
  1. package article
  2. import (
  3. "context"
  4. "go-common/app/interface/main/app-channel/conf"
  5. article "go-common/app/interface/openplatform/article/model"
  6. artrpc "go-common/app/interface/openplatform/article/rpc/client"
  7. "go-common/library/net/metadata"
  8. "github.com/pkg/errors"
  9. )
  10. // Dao is archive dao.
  11. type Dao struct {
  12. // rpc
  13. artRPC *artrpc.Service
  14. }
  15. // New new a archive dao.
  16. func New(c *conf.Config) (d *Dao) {
  17. d = &Dao{
  18. // rpc
  19. artRPC: artrpc.New(c.ArticleRPC),
  20. }
  21. return
  22. }
  23. func (d *Dao) Articles(c context.Context, aids []int64) (ms map[int64]*article.Meta, err error) {
  24. ip := metadata.String(c, metadata.RemoteIP)
  25. arg := &article.ArgAids{Aids: aids, RealIP: ip}
  26. if ms, err = d.artRPC.ArticleMetas(c, arg); err != nil {
  27. err = errors.Wrapf(err, "%v", aids)
  28. }
  29. return
  30. }