playerfetchcsinfologic.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. playerId := ctxdata.GetPlayerIdFromCtx(l.ctx)
  24. gameId := ctxdata.GetGameIdFromCtx(l.ctx)
  25. l.Logger.Infof("player id: %s", playerId)
  26. cmdResp, err := l.svcCtx.CmdRpc.PlayerFetchCsInfo(l.ctx, &cmd.PlayerFetchCsInfoReq{
  27. PlayerId: playerId,
  28. GameId: gameId,
  29. CsId: req.CsId,
  30. })
  31. if err != nil {
  32. l.Logger.Info(err.Error())
  33. return nil, err
  34. }
  35. return &types.PlayerFetchCsInfoResp{
  36. CsId: cmdResp.CsId,
  37. CsNickname: cmdResp.CsNickname,
  38. CsAvatarUrl: cmdResp.CsAvatarUrl,
  39. CsSignature: cmdResp.CsSignature,
  40. OnlineStatus: cmdResp.OnlineStatus,
  41. }, nil
  42. }