rpc.go 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. package archive
  2. import (
  3. "context"
  4. "go-common/app/service/main/archive/api"
  5. "go-common/app/service/main/archive/model/archive"
  6. "go-common/library/ecode"
  7. "go-common/library/log"
  8. )
  9. // Archive get archive.
  10. func (d *Dao) Archive(c context.Context, aid int64, ip string) (a *api.Arc, err error) {
  11. var arg = &archive.ArgAid2{Aid: aid, RealIP: ip}
  12. if a, err = d.arc.Archive3(c, arg); err != nil {
  13. log.Error("rpc archive (%d) error(%v)", aid, err)
  14. err = ecode.CreativeArcServiceErr
  15. }
  16. return
  17. }
  18. // Archives get archive list.
  19. func (d *Dao) Archives(c context.Context, aids []int64, ip string) (a map[int64]*api.Arc, err error) {
  20. var arg = &archive.ArgAids2{Aids: aids, RealIP: ip}
  21. if a, err = d.arc.Archives3(c, arg); err != nil {
  22. log.Error("rpc archive (%v) error(%v)", aids, err)
  23. err = ecode.CreativeArcServiceErr
  24. }
  25. return
  26. }
  27. // Stats get archives stat.
  28. func (d *Dao) Stats(c context.Context, aids []int64, ip string) (a map[int64]*api.Stat, err error) {
  29. var arg = &archive.ArgAids2{Aids: aids, RealIP: ip}
  30. if a, err = d.arc.Stats3(c, arg); err != nil {
  31. log.Error("rpc Stats (%v) error(%v)", aids, err)
  32. err = ecode.CreativeArcServiceErr
  33. }
  34. return
  35. }
  36. // UpCount get archives count.
  37. func (d *Dao) UpCount(c context.Context, mid int64) (count int, err error) {
  38. var arg = &archive.ArgUpCount2{Mid: mid}
  39. if count, err = d.arc.UpCount2(c, arg); err != nil {
  40. log.Error("rpc UpCount2 (%v) error(%v)", mid, err)
  41. err = ecode.CreativeArcServiceErr
  42. }
  43. return
  44. }
  45. // Video get video.
  46. func (d *Dao) Video(c context.Context, aid, cid int64, ip string) (v *api.Page, err error) {
  47. var arg = &archive.ArgVideo2{Aid: aid, Cid: cid, RealIP: ip}
  48. if v, err = d.arc.Video3(c, arg); err != nil {
  49. if ecode.Cause(err) == ecode.NothingFound {
  50. err = nil
  51. return
  52. }
  53. log.Error("rpc video3 (%d) error(%v)", aid, err)
  54. err = ecode.CreativeArcServiceErr
  55. }
  56. return
  57. }