fix: 服务创建接口未返回数据
AddPlayerServicesResp 加 PlayerServices 字段,创建后查询回填。 PlayerService.Id 加 optional 避免请求解析时要求传 id。
This commit is contained in:
@@ -52,7 +52,7 @@ func (l *CreateServiceLogic) CreateService(req *types.CreateServiceReq) (resp *t
|
||||
return nil, errors.New("player not initialized")
|
||||
}
|
||||
|
||||
_, err = l.svcCtx.PlayerRpc.AddPlayerServices(l.ctx, &playerservice.AddPlayerServicesReq{
|
||||
serviceResp, err := l.svcCtx.PlayerRpc.AddPlayerServices(l.ctx, &playerservice.AddPlayerServicesReq{
|
||||
PlayerId: player.Id,
|
||||
GameId: req.GameId,
|
||||
Title: req.Title,
|
||||
@@ -66,5 +66,21 @@ func (l *CreateServiceLogic) CreateService(req *types.CreateServiceReq) (resp *t
|
||||
logx.Errorf("failed to create player service: %v", err)
|
||||
return nil, errors.New("failed to create player service")
|
||||
}
|
||||
return
|
||||
|
||||
service := serviceResp.GetPlayerServices()
|
||||
if service == nil {
|
||||
return nil, errors.New("failed to create player service")
|
||||
}
|
||||
|
||||
return &types.PlayerService{
|
||||
Id: service.Id,
|
||||
PlayerId: service.PlayerId,
|
||||
GameId: service.GameId,
|
||||
Title: service.Title,
|
||||
Description: service.Description,
|
||||
Price: service.Price,
|
||||
Unit: service.Unit,
|
||||
RankRange: service.RankRange,
|
||||
Availability: service.Availability,
|
||||
}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user