From e5ebf85e28f6efdcc8bc9c13a610137e0faaa7d9 Mon Sep 17 00:00:00 2001 From: hqer927 <41457198+hqer927@users.noreply.github.com> Date: Thu, 16 Jan 2025 18:59:34 +0800 Subject: [PATCH] fix: update ai server api result format & extend room list api about isAI key (#868) * feat: add timber_type and config product AI server * fix: update ai server api result format --- src/v1/controller/agora/ai/ping.ts | 6 +++++- src/v1/controller/agora/ai/start.ts | 7 ++++++- src/v1/controller/agora/ai/stop.ts | 6 +++++- src/v1/controller/room/list/index.ts | 3 +++ 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/v1/controller/agora/ai/ping.ts b/src/v1/controller/agora/ai/ping.ts index 39c9c355..e9538b26 100644 --- a/src/v1/controller/agora/ai/ping.ts +++ b/src/v1/controller/agora/ai/ping.ts @@ -3,6 +3,7 @@ import { ax } from "../../../utils/Axios"; import { AbstractController } from "../../../../abstract/controller"; import { Controller } from "../../../../decorator/Controller"; import { AI_SERVER_URL_CN, AI_SERVER_URL_EN } from "./const"; +import { Status } from "constants/Project"; @Controller({ method: "post", @@ -41,7 +42,10 @@ export class AgoraAIPing extends AbstractController { } } ) - return res; + return { + status: Status.Success, + data: res, + } } diff --git a/src/v1/controller/agora/ai/start.ts b/src/v1/controller/agora/ai/start.ts index 96385f7b..0cadee34 100644 --- a/src/v1/controller/agora/ai/start.ts +++ b/src/v1/controller/agora/ai/start.ts @@ -3,6 +3,7 @@ import { ax } from "../../../utils/Axios"; import { AbstractController } from "../../../../abstract/controller"; import { Controller } from "../../../../decorator/Controller"; import { AI_SERVER_URL_CN, AI_SERVER_URL_EN } from "./const"; +import { Status } from "constants/Project"; @Controller({ method: "post", @@ -52,7 +53,11 @@ export class AgoraAIStart extends AbstractController { } } ) - return res; + + return { + status: Status.Success, + data: res, + } } public errorHandler(error: Error): ResponseError { diff --git a/src/v1/controller/agora/ai/stop.ts b/src/v1/controller/agora/ai/stop.ts index da7eb90a..16c0b029 100644 --- a/src/v1/controller/agora/ai/stop.ts +++ b/src/v1/controller/agora/ai/stop.ts @@ -3,6 +3,7 @@ import { ax } from "../../../utils/Axios"; import { AbstractController } from "../../../../abstract/controller"; import { Controller } from "../../../../decorator/Controller"; import { AI_SERVER_URL_CN, AI_SERVER_URL_EN } from "./const"; +import { Status } from "constants/Project"; @Controller({ method: "post", @@ -41,7 +42,10 @@ export class AgoraAIStop extends AbstractController { } } ) - return res; + return { + status: Status.Success, + data: res, + } } public errorHandler(error: Error): ResponseError { diff --git a/src/v1/controller/room/list/index.ts b/src/v1/controller/room/list/index.ts index d3eecb26..2d5ed1d1 100644 --- a/src/v1/controller/room/list/index.ts +++ b/src/v1/controller/room/list/index.ts @@ -68,6 +68,7 @@ export class List extends AbstractController { hasRecord: !!room.hasRecord, inviteCode: inviteCodes[index] || room.periodicUUID || room.roomUUID, isPmi: false, + isAI: room.isAI }; }); @@ -102,6 +103,7 @@ export class List extends AbstractController { .addSelect("r.owner_uuid", "ownerUUID") .addSelect("r.room_status", "roomStatus") .addSelect("r.region", "region") + .addSelect("r.is_ai", "isAI") .addSelect("u.user_name", "ownerName") .addSelect("u.avatar_url", "ownerAvatarURL") .andWhere("ru.user_uuid = :userUUID", { @@ -182,4 +184,5 @@ export type ResponseType = Array<{ region: Region; inviteCode: string; isPmi: boolean; + isAI: boolean; }>;