block.go 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package grpc
  2. import (
  3. "context"
  4. "go-common/app/service/main/member/api"
  5. )
  6. // BlockInfo 查询封禁信息
  7. func (s *MemberServer) BlockInfo(ctx context.Context, req *api.MemberMidReq) (*api.BlockInfoReply, error) {
  8. res, err := s.blockSvr.Infos(ctx, []int64{req.Mid})
  9. if err != nil {
  10. return nil, err
  11. }
  12. if len(res) == 0 {
  13. return api.FromBlockInfo(s.blockSvr.DefaultUser(req.Mid)), nil
  14. }
  15. blockInfoReply := api.FromBlockInfo(res[0])
  16. return blockInfoReply, nil
  17. }
  18. // BlockBatchInfo 批量查询封禁信息
  19. func (s *MemberServer) BlockBatchInfo(ctx context.Context, req *api.MemberMidsReq) (*api.BlockBatchInfoReply, error) {
  20. res, err := s.blockSvr.Infos(ctx, req.Mids)
  21. if err != nil {
  22. return nil, err
  23. }
  24. blockInfos := make([]*api.BlockInfoReply, 0, len(res))
  25. for i := range res {
  26. blockInfos = append(blockInfos, api.FromBlockInfo(res[i]))
  27. }
  28. blockInfosReply := &api.BlockBatchInfoReply{
  29. BlockInfos: blockInfos,
  30. }
  31. return blockInfosReply, nil
  32. }
  33. // BlockBatchDetail 批量查询封禁信息
  34. func (s *MemberServer) BlockBatchDetail(ctx context.Context, req *api.MemberMidsReq) (reply *api.BlockBatchDetailReply, err error) {
  35. res, err := s.blockSvr.UserDetails(ctx, req.Mids)
  36. if err != nil {
  37. return nil, err
  38. }
  39. userDetails := make(map[int64]*api.BlockDetailReply, len(res))
  40. for mid := range res {
  41. userDetails[mid] = api.FromBlockUserDetail(res[mid])
  42. }
  43. blockUserDetailsReply := &api.BlockBatchDetailReply{
  44. BlockDetails: userDetails,
  45. }
  46. return blockUserDetailsReply, nil
  47. }