f0048f9e12
AddGamesResp 加 Games 字段,创建后查询回填。Game.Id 加 optional 避免请求解析时要求传 id。getPlayerLogic 初始化 resp 避免 copier 写入 nil 指针。补跑 ent go generate 确保 userfollows schema 与 生成代码一致。
39 lines
632 B
Plaintext
39 lines
632 B
Plaintext
syntax = "v1"
|
|
|
|
import "common.api"
|
|
|
|
type (
|
|
Game {
|
|
Id int64 `json:"id,optional"`
|
|
Name string `json:"name"`
|
|
Icon string `json:"icon"`
|
|
Category string `json:"category"`
|
|
}
|
|
GameListResp {
|
|
Items []Game `json:"items"`
|
|
Meta PageMeta `json:"meta"`
|
|
}
|
|
GetGameReq {
|
|
Id int64 `path:"id"`
|
|
}
|
|
)
|
|
|
|
@server (
|
|
prefix: api/v1/games
|
|
group: game
|
|
)
|
|
service game-api {
|
|
@doc "获取游戏列表"
|
|
@handler ListGames
|
|
get / (PageReq) returns (GameListResp)
|
|
|
|
@doc "获取游戏详情"
|
|
@handler GetGame
|
|
get /:id (GetGameReq) returns (Game)
|
|
|
|
@doc "创建游戏"
|
|
@handler CreateGame
|
|
post / (Game) returns (Game)
|
|
}
|
|
|