csfetchhistorymsglogic.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package logic
  2. import (
  3. "context"
  4. "ylink/comm/ctxdata"
  5. "ylink/core/cmd/rpc/cmd"
  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 CsFetchHistoryMsgLogic struct {
  11. logx.Logger
  12. ctx context.Context
  13. svcCtx *svc.ServiceContext
  14. }
  15. func NewCsFetchHistoryMsgLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CsFetchHistoryMsgLogic {
  16. return &CsFetchHistoryMsgLogic{
  17. Logger: logx.WithContext(ctx),
  18. ctx: ctx,
  19. svcCtx: svcCtx,
  20. }
  21. }
  22. func (l *CsFetchHistoryMsgLogic) CsFetchHistoryMsg(req *types.CsFetchHistoryMsgReq) (resp *types.CsFetchHistoryMsgResp, err error) {
  23. csId := ctxdata.GetCsIdFromCtx(l.ctx)
  24. cmdResp, err := l.svcCtx.CmdRpc.CsFetchHistoryMsg(l.ctx, &cmd.CsFetchHistoryMsgReq{
  25. CsId: csId,
  26. PlayerId: req.PlayerId,
  27. GameId: req.GameId,
  28. Page: req.Page,
  29. Limit: req.Limit,
  30. })
  31. if err != nil {
  32. return nil, err
  33. }
  34. return &types.CsFetchHistoryMsgResp{
  35. TotalPage: cmdResp.TotalPage,
  36. CurrentPage: cmdResp.CurrentPage,
  37. List: cmdResp.List.AsSlice(),
  38. }, nil
  39. }