playerfetchcsinfologic.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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 PlayerFetchCsInfoLogic struct {
  11. logx.Logger
  12. ctx context.Context
  13. svcCtx *svc.ServiceContext
  14. }
  15. func NewPlayerFetchCsInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PlayerFetchCsInfoLogic {
  16. return &PlayerFetchCsInfoLogic{
  17. Logger: logx.WithContext(ctx),
  18. ctx: ctx,
  19. svcCtx: svcCtx,
  20. }
  21. }
  22. func (l *PlayerFetchCsInfoLogic) PlayerFetchCsInfo(req *types.PlayerFetchCsInfoReq) (resp *types.PlayerFetchCsInfoResp, err error) {
  23. gameId := ctxdata.GetGameIdFromCtx(l.ctx)
  24. playerId := ctxdata.GetPlayerIdFromCtx(l.ctx)
  25. cmdResp, err := l.svcCtx.CmdRpc.PlayerFetchCsInfo(l.ctx, &cmd.PlayerFetchCsInfoReq{
  26. GameId: gameId,
  27. PlayerId: playerId,
  28. CsId: req.CsId,
  29. })
  30. if err != nil {
  31. return nil, err
  32. }
  33. return &types.PlayerFetchCsInfoResp{
  34. CsId: cmdResp.CsId,
  35. CsNickname: cmdResp.CsNickname,
  36. CsAvatarUrl: cmdResp.CsAvatarUrl,
  37. CsSignature: cmdResp.CsSignature,
  38. OnlineStatus: cmdResp.OnlineStatus,
  39. }, nil
  40. }