rpc.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package weeklyhonor
  2. import (
  3. "context"
  4. "go-common/app/service/main/archive/model/archive"
  5. upgrpc "go-common/app/service/main/up/api/v1"
  6. "go-common/library/ecode"
  7. "go-common/library/log"
  8. )
  9. const fromWeeklyHonor = 1
  10. // UpCount get archives count.
  11. func (d *Dao) UpCount(c context.Context, mid int64) (count int, err error) {
  12. var arg = &archive.ArgUpCount2{Mid: mid}
  13. if count, err = d.arc.UpCount2(c, arg); err != nil {
  14. log.Error("rpc UpCount2 (%v) error(%v)", mid, err)
  15. err = ecode.CreativeArcServiceErr
  16. }
  17. return
  18. }
  19. // UpActivesList list up-actives
  20. func (d *Dao) UpActivesList(c context.Context, lastID int64, ps int) (upActives []*upgrpc.UpActivity, newid int64, err error) {
  21. upListReq := upgrpc.UpListByLastIDReq{
  22. LastID: lastID,
  23. Ps: ps,
  24. }
  25. reply, err := d.upClient.UpInfoActivitys(c, &upListReq)
  26. if err != nil {
  27. log.Error("failed to list up&active info,err(%v)", err)
  28. return
  29. }
  30. newid = reply.GetLastID()
  31. upActives = reply.GetUpActivitys()
  32. return
  33. }
  34. // GetUpSwitch get up switch state
  35. func (d *Dao) GetUpSwitch(c context.Context, mid int64) (state uint8, err error) {
  36. req := upgrpc.UpSwitchReq{
  37. Mid: mid,
  38. From: fromWeeklyHonor,
  39. }
  40. reply, err := d.upClient.UpSwitch(c, &req)
  41. if err != nil {
  42. log.Error("d.upClient.UpSwitch req(%+v),err(%v)", req, err)
  43. return
  44. }
  45. state = reply.GetState()
  46. return
  47. }