playerfetchhistorymsglogic.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package logic
  2. import (
  3. "context"
  4. "ylink/comm/ctxdata"
  5. "ylink/core/cmd/rpc/pb"
  6. "ylink/bff/cmdbff/api/internal/svc"
  7. "ylink/bff/cmdbff/api/internal/types"
  8. "github.com/zeromicro/go-zero/core/logx"
  9. )
  10. type PlayerFetchHistoryMsgLogic struct {
  11. logx.Logger
  12. ctx context.Context
  13. svcCtx *svc.ServiceContext
  14. }
  15. func NewPlayerFetchHistoryMsgLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PlayerFetchHistoryMsgLogic {
  16. return &PlayerFetchHistoryMsgLogic{
  17. Logger: logx.WithContext(ctx),
  18. ctx: ctx,
  19. svcCtx: svcCtx,
  20. }
  21. }
  22. func (l *PlayerFetchHistoryMsgLogic) PlayerFetchHistoryMsg(req *types.PlayerFetchHistoryMsgReq) (resp *types.PlayerFetchHistoryMsgResp, err error) {
  23. gameId := ctxdata.GetGameIdFromCtx(l.ctx)
  24. playerId := ctxdata.GetPlayerIdFromCtx(l.ctx)
  25. cmdResp, err := l.svcCtx.CmdRpc.PlayerFetchHistoryMsg(l.ctx, &pb.PlayerFetchHistoryMsgReq{
  26. GameId: gameId,
  27. PlayerId: playerId,
  28. Page: req.Page,
  29. Limit: req.Limit,
  30. })
  31. if err != nil {
  32. return nil, err
  33. }
  34. return &types.PlayerFetchHistoryMsgResp{
  35. TotalPage: cmdResp.TotalPage,
  36. CurrentPage: cmdResp.CurrentPage,
  37. List: cmdResp.List.AsSlice(),
  38. }, nil
  39. }