add batch game info request

This commit is contained in:
2025-12-18 20:04:50 +01:00
parent f6d40b8f2e
commit d916014872
5 changed files with 206 additions and 40 deletions
+132
View File
@@ -116,6 +116,14 @@ export interface RemoveOpinionRequest {
gameTitle: string;
}
export interface GetGameInfoRequest {
games: string[];
}
export interface GameInfoResponse {
games: Game[];
}
function createBasePerson(): Person {
return { name: "", opinion: [] };
}
@@ -1213,6 +1221,122 @@ export const RemoveOpinionRequest: MessageFns<RemoveOpinionRequest> = {
},
};
function createBaseGetGameInfoRequest(): GetGameInfoRequest {
return { games: [] };
}
export const GetGameInfoRequest: MessageFns<GetGameInfoRequest> = {
encode(message: GetGameInfoRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
for (const v of message.games) {
writer.uint32(10).string(v!);
}
return writer;
},
decode(input: BinaryReader | Uint8Array, length?: number): GetGameInfoRequest {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
const end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseGetGameInfoRequest();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1: {
if (tag !== 10) {
break;
}
message.games.push(reader.string());
continue;
}
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skip(tag & 7);
}
return message;
},
fromJSON(object: any): GetGameInfoRequest {
return { games: globalThis.Array.isArray(object?.games) ? object.games.map((e: any) => globalThis.String(e)) : [] };
},
toJSON(message: GetGameInfoRequest): unknown {
const obj: any = {};
if (message.games?.length) {
obj.games = message.games;
}
return obj;
},
create<I extends Exact<DeepPartial<GetGameInfoRequest>, I>>(base?: I): GetGameInfoRequest {
return GetGameInfoRequest.fromPartial(base ?? ({} as any));
},
fromPartial<I extends Exact<DeepPartial<GetGameInfoRequest>, I>>(object: I): GetGameInfoRequest {
const message = createBaseGetGameInfoRequest();
message.games = object.games?.map((e) => e) || [];
return message;
},
};
function createBaseGameInfoResponse(): GameInfoResponse {
return { games: [] };
}
export const GameInfoResponse: MessageFns<GameInfoResponse> = {
encode(message: GameInfoResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
for (const v of message.games) {
Game.encode(v!, writer.uint32(10).fork()).join();
}
return writer;
},
decode(input: BinaryReader | Uint8Array, length?: number): GameInfoResponse {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
const end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseGameInfoResponse();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1: {
if (tag !== 10) {
break;
}
message.games.push(Game.decode(reader, reader.uint32()));
continue;
}
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skip(tag & 7);
}
return message;
},
fromJSON(object: any): GameInfoResponse {
return { games: globalThis.Array.isArray(object?.games) ? object.games.map((e: any) => Game.fromJSON(e)) : [] };
},
toJSON(message: GameInfoResponse): unknown {
const obj: any = {};
if (message.games?.length) {
obj.games = message.games.map((e) => Game.toJSON(e));
}
return obj;
},
create<I extends Exact<DeepPartial<GameInfoResponse>, I>>(base?: I): GameInfoResponse {
return GameInfoResponse.fromPartial(base ?? ({} as any));
},
fromPartial<I extends Exact<DeepPartial<GameInfoResponse>, I>>(object: I): GameInfoResponse {
const message = createBaseGameInfoResponse();
message.games = object.games?.map((e) => Game.fromPartial(e)) || [];
return message;
},
};
/** Authentication service */
export interface AuthService {
Login(request: LoginRequest): Promise<LoginResponse>;
@@ -1255,6 +1379,7 @@ export interface MainService {
GetGames(request: GetGamesRequest): Promise<GameList>;
AddGame(request: Game): Promise<Game>;
AddOpinion(request: AddOpinionRequest): Promise<Person>;
GetGameInfo(request: GetGameInfoRequest): Promise<GameInfoResponse>;
}
export const MainServiceServiceName = "items.MainService";
@@ -1268,6 +1393,7 @@ export class MainServiceClientImpl implements MainService {
this.GetGames = this.GetGames.bind(this);
this.AddGame = this.AddGame.bind(this);
this.AddOpinion = this.AddOpinion.bind(this);
this.GetGameInfo = this.GetGameInfo.bind(this);
}
GetGame(request: GameRequest): Promise<Game> {
const data = GameRequest.encode(request).finish();
@@ -1292,6 +1418,12 @@ export class MainServiceClientImpl implements MainService {
const promise = this.rpc.request(this.service, "AddOpinion", data);
return promise.then((data) => Person.decode(new BinaryReader(data)));
}
GetGameInfo(request: GetGameInfoRequest): Promise<GameInfoResponse> {
const data = GetGameInfoRequest.encode(request).finish();
const promise = this.rpc.request(this.service, "GetGameInfo", data);
return promise.then((data) => GameInfoResponse.decode(new BinaryReader(data)));
}
}
interface Rpc {