فهرست منبع

feat: 完成迭代

huangzhichao 1 ماه پیش
والد
کامیت
f326cda98e

+ 12 - 0
src/dto/agent-server.ts

@@ -74,3 +74,15 @@ export class RunPromptDto {
   @IsNotEmpty({ message: 'currentTimestamp不能为空' })
   currentTimestamp: number
 }
+
+export class ListUsersDto {
+  @IsString()
+  @ValidateIf((o) => !o.unionId)
+  @IsNotEmpty({ message: 'userName不能为空' })
+  userName: string
+
+  @IsString()
+  @ValidateIf((o) => !o.userName)
+  @IsNotEmpty({ message: 'unionId不能为空' })
+  unionId: string
+}

+ 8 - 1
src/module/agent-server/agent-server.controller.ts

@@ -6,7 +6,8 @@ import {
   GetBasePromptDto,
   GetUserProfileDto,
   GetStaffProfileDto,
-  RunPromptDto
+  RunPromptDto,
+  ListUsersDto
 } from '@/dto/agent-server'
 
 import { AgentServerService } from './service/agent-server.service'
@@ -69,4 +70,10 @@ export class AgentServerController {
   async runPrompt(@Body() body: RunPromptDto) {
     return this.agentServerService.runPrompt(body)
   }
+
+  @Get('user/list')
+  @ApiOperation({ summary: '获取用户列表' })
+  async listUsers(@Query() query: ListUsersDto) {
+    return this.agentServerService.listUsers(query.userName, query.unionId)
+  }
 }

+ 22 - 0
src/module/agent-server/service/agent-server.service.ts

@@ -196,4 +196,26 @@ export class AgentServerService implements IAgentServerService {
       data: data
     }
   }
+
+  async listUsers(
+    userName: string,
+    unionId: string
+  ): Promise<ServiceResponse<UserProfile[]>> {
+    const { code, data, msg } = await this.httpService.listUsers(
+      userName,
+      unionId
+    )
+    if (code !== HttpStatusCode.OK) {
+      return {
+        code: BusinessCode.BAD_REQUEST,
+        msg: msg || '获取用户列表失败',
+        data: null
+      }
+    }
+    return {
+      code: BusinessCode.SUCCESS,
+      msg: '获取用户列表成功',
+      data: data
+    }
+  }
 }