fix: 店铺邀请改为查找打手身份
This commit is contained in:
@@ -8,12 +8,15 @@ import (
|
||||
"errors"
|
||||
"time"
|
||||
|
||||
"juwan-backend/app/player/rpc/playerservice"
|
||||
"juwan-backend/app/shop/api/internal/svc"
|
||||
"juwan-backend/app/shop/api/internal/types"
|
||||
"juwan-backend/app/shop/rpc/pb"
|
||||
"juwan-backend/common/utils/contextj"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
type RejectInvitationLogic struct {
|
||||
@@ -36,6 +39,18 @@ func (l *RejectInvitationLogic) RejectInvitation(req *types.AcceptInvitationReq)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
playerResp, err := l.svcCtx.PlayerRpc.GetPlayerByUserId(l.ctx, &playerservice.SearchPlayersReq{UserId: &userID})
|
||||
if err != nil {
|
||||
st, _ := status.FromError(err)
|
||||
if st.Code() == codes.NotFound {
|
||||
return nil, contextj.ERRILLEGALUSER
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
player := playerResp.GetPlayers()
|
||||
if player == nil {
|
||||
return nil, contextj.ERRILLEGALUSER
|
||||
}
|
||||
|
||||
invitation, err := l.svcCtx.ShopRpc.GetShopInvitationsById(l.ctx, &pb.GetShopInvitationsByIdReq{Id: req.Id})
|
||||
if err != nil {
|
||||
@@ -44,7 +59,7 @@ func (l *RejectInvitationLogic) RejectInvitation(req *types.AcceptInvitationReq)
|
||||
if invitation.ShopInvitations == nil {
|
||||
return nil, errors.New("invitation not found")
|
||||
}
|
||||
if invitation.ShopInvitations.PlayerId != userID {
|
||||
if invitation.ShopInvitations.PlayerId != player.Id {
|
||||
return nil, contextj.ERRILLEGALUSER
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user