rpc.go 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. package archive
  2. import (
  3. "context"
  4. "strconv"
  5. "go-common/app/interface/openplatform/article/model"
  6. "go-common/app/service/main/archive/api"
  7. "go-common/app/service/main/archive/model/archive"
  8. "go-common/library/ecode"
  9. "go-common/library/log"
  10. )
  11. // UpCount get archives count.
  12. func (d *Dao) UpCount(c context.Context, mid int64) (count int, err error) {
  13. var arg = &archive.ArgUpCount2{Mid: mid}
  14. if count, err = d.arc.UpCount2(c, arg); err != nil {
  15. log.Error("rpc UpCount2 (%v) error(%v)", mid, err)
  16. err = ecode.CreativeArcServiceErr
  17. }
  18. return
  19. }
  20. // Archives get archive list.
  21. func (d *Dao) Archives(c context.Context, aids []int64) (a map[int64]*api.Arc, err error) {
  22. var arg = &archive.ArgAids2{Aids: aids, RealIP: ""}
  23. if a, err = d.arc.Archives3(c, arg); err != nil {
  24. log.Error("d.arc.Archive3 aids(%v+)|error(%v)", aids, err)
  25. err = ecode.CreativeArcServiceErr
  26. }
  27. return
  28. }
  29. // Archive get archive info.
  30. func (d *Dao) Archive(c context.Context, aid int64) (a *api.Arc, err error) {
  31. var arg = &archive.ArgAid2{Aid: aid, RealIP: ""}
  32. if a, err = d.arc.Archive3(c, arg); err != nil {
  33. log.Error("d.arc.Archive3 aid(%d)|error(%v)", aid, err)
  34. err = ecode.CreativeArcServiceErr
  35. }
  36. return
  37. }
  38. // Stats get archives stat.
  39. func (d *Dao) Stats(c context.Context, aids []int64) (a map[int64]*api.Stat, err error) {
  40. var arg = &archive.ArgAids2{Aids: aids, RealIP: ""}
  41. if a, err = d.arc.Stats3(c, arg); err != nil {
  42. log.Error("rpc Stats (%v) error(%v)", aids, err)
  43. err = ecode.CreativeArcServiceErr
  44. }
  45. return
  46. }
  47. // ArticleMetas batch get articles by aids.
  48. func (d *Dao) ArticleMetas(c context.Context, aids []int64) (res map[int64]*model.Meta, err error) {
  49. arg := &model.ArgAids{Aids: aids, RealIP: ""}
  50. if res, err = d.art.ArticleMetas(c, arg); err != nil {
  51. log.Error("d.art.ArticleMetas aids(%+v)|error(%v)", arg, err)
  52. if _, er := strconv.ParseInt(err.Error(), 10, 64); er != nil {
  53. err = ecode.CreativeArticleRPCErr
  54. }
  55. }
  56. return
  57. }