rpc.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package service
  2. import (
  3. "context"
  4. accmdl "go-common/app/service/main/account/api"
  5. feedmdl "go-common/app/service/main/reply-feed/api"
  6. "go-common/library/log"
  7. )
  8. // nextID return next reply id.
  9. func (s *Service) nextID(c context.Context) (int64, error) {
  10. rpID, err := s.seqSrv.ID32(c, s.seqArg)
  11. if err != nil {
  12. log.Error("s.seqSrv.ID(%v) error(%v)", s.seqArg, err)
  13. return 0, err
  14. }
  15. return int64(rpID), err
  16. }
  17. func (s *Service) userInfo(c context.Context, mid int64) (*accmdl.Profile, error) {
  18. arg := &accmdl.MidReq{
  19. Mid: mid,
  20. }
  21. res, err := s.acc.Profile3(c, arg)
  22. if err != nil {
  23. log.Error("s.acc.UserInfo(%d) error(%v)", mid, err)
  24. return nil, err
  25. }
  26. return res.Profile, nil
  27. }
  28. func (s *Service) replyFeed(c context.Context, mid int64, pn, ps int) (res *feedmdl.ReplyRes, err error) {
  29. req := &feedmdl.ReplyReq{Mid: mid, Pn: int32(pn), Ps: int32(ps)}
  30. if res, err = s.feedClient.Reply(c, req); err != nil {
  31. log.Error("s.feedClient.Reply(%v) error(%v)", req, err)
  32. return nil, err
  33. }
  34. return
  35. }
  36. func (s *Service) replyHotFeed(c context.Context, mid, oid int64, tp, pn, ps int) (res *feedmdl.HotReplyRes, err error) {
  37. req := &feedmdl.HotReplyReq{Mid: mid, Oid: oid, Tp: int32(tp), Pn: int32(pn), Ps: int32(ps)}
  38. if res, err = s.feedClient.HotReply(c, req); err != nil {
  39. log.Error("s.feedClient.HotReply(%v) error(%v)", req, err)
  40. return nil, err
  41. }
  42. return
  43. }