fix: 游戏创建与打手详情接口未返回数据
AddGamesResp 加 Games 字段,创建后查询回填。Game.Id 加 optional 避免请求解析时要求传 id。getPlayerLogic 初始化 resp 避免 copier 写入 nil 指针。补跑 ent go generate 确保 userfollows schema 与 生成代码一致。
This commit is contained in:
@@ -30,8 +30,7 @@ func NewCreateGameLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Create
|
||||
}
|
||||
|
||||
func (l *CreateGameLogic) CreateGame(req *types.Game) (resp *types.Game, err error) {
|
||||
// todo: add your logic here and delete this line
|
||||
_, err = l.svcCtx.GameRpc.AddGames(l.ctx, &pb.AddGamesReq{
|
||||
game, err := l.svcCtx.GameRpc.AddGames(l.ctx, &pb.AddGamesReq{
|
||||
Name: req.Name,
|
||||
Icon: req.Icon,
|
||||
Category: req.Category,
|
||||
@@ -42,5 +41,10 @@ func (l *CreateGameLogic) CreateGame(req *types.Game) (resp *types.Game, err err
|
||||
return nil, errors.New("add game err")
|
||||
}
|
||||
|
||||
return &types.Game{}, nil
|
||||
return &types.Game{
|
||||
Id: game.Games.Id,
|
||||
Name: game.Games.Name,
|
||||
Icon: game.Games.Icon,
|
||||
Category: game.Games.Category,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Code generated by goctl. DO NOT EDIT.
|
||||
// goctl 1.9.2
|
||||
// goctl 1.10.1
|
||||
|
||||
package types
|
||||
|
||||
@@ -7,7 +7,7 @@ type EmptyResp struct {
|
||||
}
|
||||
|
||||
type Game struct {
|
||||
Id int64 `json:"id"`
|
||||
Id int64 `json:"id,optional"`
|
||||
Name string `json:"name"`
|
||||
Icon string `json:"icon"`
|
||||
Category string `json:"category"`
|
||||
|
||||
Reference in New Issue
Block a user