refactor personlist
This commit is contained in:
+99
-9
@@ -48,7 +48,7 @@ export interface Person {
|
||||
}
|
||||
|
||||
export interface Opinion {
|
||||
game: Game | undefined;
|
||||
title: string;
|
||||
wouldPlay: boolean;
|
||||
}
|
||||
|
||||
@@ -97,6 +97,10 @@ export interface AuthStatusResponse {
|
||||
message: string;
|
||||
}
|
||||
|
||||
export interface GameRequest {
|
||||
title: string;
|
||||
}
|
||||
|
||||
function createBasePerson(): Person {
|
||||
return { name: "", opinion: [] };
|
||||
}
|
||||
@@ -174,13 +178,13 @@ export const Person: MessageFns<Person> = {
|
||||
};
|
||||
|
||||
function createBaseOpinion(): Opinion {
|
||||
return { game: undefined, wouldPlay: false };
|
||||
return { title: "", wouldPlay: false };
|
||||
}
|
||||
|
||||
export const Opinion: MessageFns<Opinion> = {
|
||||
encode(message: Opinion, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
|
||||
if (message.game !== undefined) {
|
||||
Game.encode(message.game, writer.uint32(10).fork()).join();
|
||||
if (message.title !== "") {
|
||||
writer.uint32(10).string(message.title);
|
||||
}
|
||||
if (message.wouldPlay !== false) {
|
||||
writer.uint32(16).bool(message.wouldPlay);
|
||||
@@ -200,7 +204,7 @@ export const Opinion: MessageFns<Opinion> = {
|
||||
break;
|
||||
}
|
||||
|
||||
message.game = Game.decode(reader, reader.uint32());
|
||||
message.title = reader.string();
|
||||
continue;
|
||||
}
|
||||
case 2: {
|
||||
@@ -222,15 +226,15 @@ export const Opinion: MessageFns<Opinion> = {
|
||||
|
||||
fromJSON(object: any): Opinion {
|
||||
return {
|
||||
game: isSet(object.game) ? Game.fromJSON(object.game) : undefined,
|
||||
title: isSet(object.title) ? globalThis.String(object.title) : "",
|
||||
wouldPlay: isSet(object.wouldPlay) ? globalThis.Boolean(object.wouldPlay) : false,
|
||||
};
|
||||
},
|
||||
|
||||
toJSON(message: Opinion): unknown {
|
||||
const obj: any = {};
|
||||
if (message.game !== undefined) {
|
||||
obj.game = Game.toJSON(message.game);
|
||||
if (message.title !== "") {
|
||||
obj.title = message.title;
|
||||
}
|
||||
if (message.wouldPlay !== false) {
|
||||
obj.wouldPlay = message.wouldPlay;
|
||||
@@ -243,7 +247,7 @@ export const Opinion: MessageFns<Opinion> = {
|
||||
},
|
||||
fromPartial<I extends Exact<DeepPartial<Opinion>, I>>(object: I): Opinion {
|
||||
const message = createBaseOpinion();
|
||||
message.game = (object.game !== undefined && object.game !== null) ? Game.fromPartial(object.game) : undefined;
|
||||
message.title = object.title ?? "";
|
||||
message.wouldPlay = object.wouldPlay ?? false;
|
||||
return message;
|
||||
},
|
||||
@@ -917,6 +921,64 @@ export const AuthStatusResponse: MessageFns<AuthStatusResponse> = {
|
||||
},
|
||||
};
|
||||
|
||||
function createBaseGameRequest(): GameRequest {
|
||||
return { title: "" };
|
||||
}
|
||||
|
||||
export const GameRequest: MessageFns<GameRequest> = {
|
||||
encode(message: GameRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
|
||||
if (message.title !== "") {
|
||||
writer.uint32(10).string(message.title);
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: BinaryReader | Uint8Array, length?: number): GameRequest {
|
||||
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
||||
const end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = createBaseGameRequest();
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1: {
|
||||
if (tag !== 10) {
|
||||
break;
|
||||
}
|
||||
|
||||
message.title = reader.string();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if ((tag & 7) === 4 || tag === 0) {
|
||||
break;
|
||||
}
|
||||
reader.skip(tag & 7);
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): GameRequest {
|
||||
return { title: isSet(object.title) ? globalThis.String(object.title) : "" };
|
||||
},
|
||||
|
||||
toJSON(message: GameRequest): unknown {
|
||||
const obj: any = {};
|
||||
if (message.title !== "") {
|
||||
obj.title = message.title;
|
||||
}
|
||||
return obj;
|
||||
},
|
||||
|
||||
create<I extends Exact<DeepPartial<GameRequest>, I>>(base?: I): GameRequest {
|
||||
return GameRequest.fromPartial(base ?? ({} as any));
|
||||
},
|
||||
fromPartial<I extends Exact<DeepPartial<GameRequest>, I>>(object: I): GameRequest {
|
||||
const message = createBaseGameRequest();
|
||||
message.title = object.title ?? "";
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
/** Authentication service */
|
||||
export interface AuthService {
|
||||
Login(request: LoginRequest): Promise<LoginResponse>;
|
||||
@@ -954,6 +1016,34 @@ export class AuthServiceClientImpl implements AuthService {
|
||||
}
|
||||
}
|
||||
|
||||
export interface MainService {
|
||||
GetGame(request: GameRequest): Promise<Game>;
|
||||
AddOpinion(request: GameRequest): Promise<Person>;
|
||||
}
|
||||
|
||||
export const MainServiceServiceName = "items.MainService";
|
||||
export class MainServiceClientImpl implements MainService {
|
||||
private readonly rpc: Rpc;
|
||||
private readonly service: string;
|
||||
constructor(rpc: Rpc, opts?: { service?: string }) {
|
||||
this.service = opts?.service || MainServiceServiceName;
|
||||
this.rpc = rpc;
|
||||
this.GetGame = this.GetGame.bind(this);
|
||||
this.AddOpinion = this.AddOpinion.bind(this);
|
||||
}
|
||||
GetGame(request: GameRequest): Promise<Game> {
|
||||
const data = GameRequest.encode(request).finish();
|
||||
const promise = this.rpc.request(this.service, "GetGame", data);
|
||||
return promise.then((data) => Game.decode(new BinaryReader(data)));
|
||||
}
|
||||
|
||||
AddOpinion(request: GameRequest): Promise<Person> {
|
||||
const data = GameRequest.encode(request).finish();
|
||||
const promise = this.rpc.request(this.service, "AddOpinion", data);
|
||||
return promise.then((data) => Person.decode(new BinaryReader(data)));
|
||||
}
|
||||
}
|
||||
|
||||
interface Rpc {
|
||||
request(service: string, method: string, data: Uint8Array): Promise<Uint8Array>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user