block.go 865 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package gorpc
  2. import (
  3. rpcmodel "go-common/app/service/main/member/model/block"
  4. "go-common/library/net/rpc/context"
  5. )
  6. // BlockInfo is
  7. func (r *RPC) BlockInfo(c context.Context, arg *rpcmodel.RPCArgInfo, res *rpcmodel.RPCResInfo) (err error) {
  8. var (
  9. blockInfos []*rpcmodel.BlockInfo
  10. )
  11. if blockInfos, err = r.block.Infos(c, []int64{arg.MID}); err != nil {
  12. return
  13. }
  14. if len(blockInfos) < 1 {
  15. res.Parse(r.block.DefaultUser(arg.MID))
  16. }
  17. res.Parse(blockInfos[0])
  18. return
  19. }
  20. // BlockBatchInfo is
  21. func (r *RPC) BlockBatchInfo(c context.Context, arg *rpcmodel.RPCArgBatchInfo, res *[]*rpcmodel.RPCResInfo) (err error) {
  22. var (
  23. blockInfos []*rpcmodel.BlockInfo
  24. )
  25. if blockInfos, err = r.block.Infos(c, arg.MIDs); err != nil {
  26. return
  27. }
  28. for _, info := range blockInfos {
  29. r := &rpcmodel.RPCResInfo{}
  30. r.Parse(info)
  31. *res = append(*res, r)
  32. }
  33. return
  34. }