fix: 游戏创建与打手详情接口未返回数据

AddGamesResp 加 Games 字段,创建后查询回填。Game.Id 加 optional
避免请求解析时要求传 id。getPlayerLogic 初始化 resp 避免 copier
写入 nil 指针。补跑 ent go generate 确保 userfollows schema 与
生成代码一致。
This commit is contained in:
zetaloop
2026-04-05 17:43:57 +08:00
parent 168cec6d57
commit f0048f9e12
11 changed files with 130 additions and 102 deletions
+16 -15
View File
@@ -3,11 +3,13 @@ package logic
import (
"context"
"errors"
"juwan-backend/app/game/rpc/internal/models/games"
"juwan-backend/app/snowflake/rpc/snowflake"
"juwan-backend/app/game/rpc/internal/svc"
"juwan-backend/app/game/rpc/pb"
"github.com/jinzhu/copier"
"github.com/zeromicro/go-zero/core/logx"
)
@@ -44,21 +46,20 @@ func (l *AddGamesLogic) AddGames(in *pb.AddGamesReq) (*pb.AddGamesResp, error) {
return nil, errors.New("add game failed")
}
return &pb.AddGamesResp{}, nil
}
game, err := l.svcCtx.GameModelRO.Games.Query().Where(games.IDEQ(idResp.Id)).First(l.ctx)
if err != nil {
logx.Errorf("AddGamesLogic.getGamesById err:%v", err)
return nil, errors.New("get game failed")
}
/*
pbGame := pb.Games{}
err = copier.Copy(&pbGame, &game)
if err != nil {
logx.Errorf("AddGamesLogic.copier err:%v", err)
return nil, errors.New("get game failed")
}
pbGame.CreatedAt = game.CreatedAt.Unix()
pbGame.UpdatedAt = game.UpdatedAt.Unix()
type AddGamesReq struct {
state protoimpl.MessageState `protogen:"open.v1"`
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` //name
Icon string `protobuf:"bytes,2,opt,name=icon,proto3" json:"icon,omitempty"` //icon
Category string `protobuf:"bytes,3,opt,name=category,proto3" json:"category,omitempty"` //category
SortOrder int64 `protobuf:"varint,4,opt,name=sortOrder,proto3" json:"sortOrder,omitempty"` //sortOrder
IsActive bool `protobuf:"varint,5,opt,name=isActive,proto3" json:"isActive,omitempty"` //isActive
CreatedAt int64 `protobuf:"varint,6,opt,name=createdAt,proto3" json:"createdAt,omitempty"` //createdAt
UpdatedAt int64 `protobuf:"varint,7,opt,name=updatedAt,proto3" json:"updatedAt,omitempty"` //updatedAt
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
return &pb.AddGamesResp{Games: &pbGame}, nil
}
*/