From 6775f5d1231caed221cebe28f3e138656c6fa206 Mon Sep 17 00:00:00 2001 From: whyour Date: Sun, 12 Jan 2025 17:02:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20QLAPI=20=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E9=80=9A=E7=9F=A5=E5=93=8D=E5=BA=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- back/protos/api.proto | 3 +-- back/protos/api.ts | 58 +++++-------------------------------------- back/schedule/api.ts | 7 +++--- 3 files changed, 10 insertions(+), 58 deletions(-) diff --git a/back/protos/api.proto b/back/protos/api.proto index 017b0f10..f399a3d1 100644 --- a/back/protos/api.proto +++ b/back/protos/api.proto @@ -57,7 +57,6 @@ message SystemNotifyRequest { string title = 1; string content = 2; } -message SystemNotifyResponse {} service Api { rpc GetEnvs(GetEnvsRequest) returns (EnvsResponse) {} @@ -69,5 +68,5 @@ service Api { rpc EnableEnvs(EnableEnvsRequest) returns (Response) {} rpc UpdateEnvNames(UpdateEnvNamesRequest) returns (Response) {} rpc GetEnvById(GetEnvByIdRequest) returns (EnvResponse) {} - rpc SystemNotify(SystemNotifyRequest) returns (SystemNotifyResponse) {} + rpc SystemNotify(SystemNotifyRequest) returns (Response) {} } \ No newline at end of file diff --git a/back/protos/api.ts b/back/protos/api.ts index 596788ca..10780ec3 100644 --- a/back/protos/api.ts +++ b/back/protos/api.ts @@ -91,9 +91,6 @@ export interface SystemNotifyRequest { content: string; } -export interface SystemNotifyResponse { -} - function createBaseEnvItem(): EnvItem { return { id: undefined, @@ -1171,49 +1168,6 @@ export const SystemNotifyRequest = { }, }; -function createBaseSystemNotifyResponse(): SystemNotifyResponse { - return {}; -} - -export const SystemNotifyResponse = { - encode(_: SystemNotifyResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - return writer; - }, - - decode(input: _m0.Reader | Uint8Array, length?: number): SystemNotifyResponse { - const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseSystemNotifyResponse(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skipType(tag & 7); - } - return message; - }, - - fromJSON(_: any): SystemNotifyResponse { - return {}; - }, - - toJSON(_: SystemNotifyResponse): unknown { - const obj: any = {}; - return obj; - }, - - create, I>>(base?: I): SystemNotifyResponse { - return SystemNotifyResponse.fromPartial(base ?? ({} as any)); - }, - fromPartial, I>>(_: I): SystemNotifyResponse { - const message = createBaseSystemNotifyResponse(); - return message; - }, -}; - export type ApiService = typeof ApiService; export const ApiService = { getEnvs: { @@ -1303,8 +1257,8 @@ export const ApiService = { responseStream: false, requestSerialize: (value: SystemNotifyRequest) => Buffer.from(SystemNotifyRequest.encode(value).finish()), requestDeserialize: (value: Buffer) => SystemNotifyRequest.decode(value), - responseSerialize: (value: SystemNotifyResponse) => Buffer.from(SystemNotifyResponse.encode(value).finish()), - responseDeserialize: (value: Buffer) => SystemNotifyResponse.decode(value), + responseSerialize: (value: Response) => Buffer.from(Response.encode(value).finish()), + responseDeserialize: (value: Buffer) => Response.decode(value), }, } as const; @@ -1318,7 +1272,7 @@ export interface ApiServer extends UntypedServiceImplementation { enableEnvs: handleUnaryCall; updateEnvNames: handleUnaryCall; getEnvById: handleUnaryCall; - systemNotify: handleUnaryCall; + systemNotify: handleUnaryCall; } export interface ApiClient extends Client { @@ -1459,18 +1413,18 @@ export interface ApiClient extends Client { ): ClientUnaryCall; systemNotify( request: SystemNotifyRequest, - callback: (error: ServiceError | null, response: SystemNotifyResponse) => void, + callback: (error: ServiceError | null, response: Response) => void, ): ClientUnaryCall; systemNotify( request: SystemNotifyRequest, metadata: Metadata, - callback: (error: ServiceError | null, response: SystemNotifyResponse) => void, + callback: (error: ServiceError | null, response: Response) => void, ): ClientUnaryCall; systemNotify( request: SystemNotifyRequest, metadata: Metadata, options: Partial, - callback: (error: ServiceError | null, response: SystemNotifyResponse) => void, + callback: (error: ServiceError | null, response: Response) => void, ): ClientUnaryCall; } diff --git a/back/schedule/api.ts b/back/schedule/api.ts index e650cfad..080c07c5 100644 --- a/back/schedule/api.ts +++ b/back/schedule/api.ts @@ -15,7 +15,6 @@ import { MoveEnvRequest, Response, SystemNotifyRequest, - SystemNotifyResponse, UpdateEnvNamesRequest, UpdateEnvRequest, } from '../protos/api'; @@ -161,13 +160,13 @@ export const getEnvById = async ( }; export const systemNotify = async ( - call: ServerUnaryCall, - callback: sendUnaryData, + call: ServerUnaryCall, + callback: sendUnaryData, ) => { try { const systemService = Container.get(SystemService); const data = await systemService.notify(call.request); - callback(null, { code: 200, data }); + callback(null, data); } catch (e: any) { callback(e); }