playersendmsglogic.go 851 B

1234567891011121314151617181920212223242526272829303132333435363738
  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 PlayerSendMsgLogic struct {
  11. logx.Logger
  12. ctx context.Context
  13. svcCtx *svc.ServiceContext
  14. }
  15. func NewPlayerSendMsgLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PlayerSendMsgLogic {
  16. return &PlayerSendMsgLogic{
  17. Logger: logx.WithContext(ctx),
  18. ctx: ctx,
  19. svcCtx: svcCtx,
  20. }
  21. }
  22. func (l *PlayerSendMsgLogic) PlayerSendMsg(req *types.PlayerSendMsgReq) error {
  23. gameId := ctxdata.GetGameIdFromCtx(l.ctx)
  24. playerId := ctxdata.GetPlayerIdFromCtx(l.ctx)
  25. _, err := l.svcCtx.CmdRpc.PlayerSendMsg(l.ctx, &pb.PlayerSendMsgReq{
  26. GameId: gameId,
  27. PlayerId: playerId,
  28. Content: req.Content,
  29. Pic: req.Pic,
  30. })
  31. return err
  32. }