فهرست منبع

Merge branch 'feature/agent-management' of Web/web-server into master

huangzhichao 23 ساعت پیش
والد
کامیت
4e6d4bfa78

+ 19 - 18
src/dto/agent-module.ts

@@ -1,37 +1,38 @@
-import { IsString, IsNotEmpty, IsNumber } from 'class-validator'
+import { IsString, IsNotEmpty, IsNumber, IsOptional } from 'class-validator'
 
+export class GetModuleListDto {
+  @IsNumber()
+  @IsNotEmpty({ message: 'page不能为空' })
+  page: number
+
+  @IsNumber()
+  @IsNotEmpty({ message: 'pageSize不能为空' })
+  pageSize: number
+}
 export class GetModuleConfigurationDto {
-  @IsString()
-  @IsNotEmpty({ message: 'module_id不能为空' })
+  @IsNumber()
+  @IsNotEmpty({ message: 'moduleId不能为空' })
   moduleId: number
 }
 
 export class SaveModuleConfigurationDto {
   @IsNumber()
-  @IsNotEmpty({ message: 'id不能为空' })
-  id: number
+  @IsOptional()
+  moduleId: number
 
   @IsString()
   @IsNotEmpty({ message: 'name不能为空' })
   name: string
 
   @IsString()
-  @IsNotEmpty({ message: 'display_name不能为空' })
+  @IsOptional()
   displayName: string
 
   @IsNumber()
-  @IsNotEmpty({ message: 'default_agent_type不能为空' })
-  defaultAgentType: number
+  @IsOptional()
+  type: number
 
   @IsNumber()
-  @IsNotEmpty({ message: 'default_agent_id不能为空' })
-  defaultAgentId: number
-
-  @IsString()
-  @IsNotEmpty({ message: 'create_time不能为空' })
-  createTime: string
-
-  @IsString()
-  @IsNotEmpty({ message: 'updated_time不能为空' })
-  updatedTime: string
+  @IsOptional()
+  agentId: number
 }

+ 4 - 1
src/interface/agent-module.interface.ts

@@ -1,7 +1,10 @@
 import { ServiceResponse } from '../response/response.interface'
 
 export interface IAgentModuleService {
-  getModuleList(): Promise<ServiceResponse<ModuleConfigurationType[]>>
+  getModuleList(
+    page: number,
+    pageSize: number
+  ): Promise<ServiceResponse<ModuleConfigurationType[]>>
   getModuleConfiguration(
     module_id: number
   ): Promise<ServiceResponse<ModuleConfigurationType>>

+ 6 - 5
src/module/agent-module/agent-module.controller.ts

@@ -2,6 +2,7 @@ import { Controller, Get, Query, Post, Body } from '@nestjs/common'
 import { ApiOperation, ApiTags } from '@nestjs/swagger'
 
 import {
+  GetModuleListDto,
   GetModuleConfigurationDto,
   SaveModuleConfigurationDto
 } from '@/dto/agent-module'
@@ -15,8 +16,8 @@ export class AgentModuleController {
 
   @Get('get-module-list')
   @ApiOperation({ summary: '获取模块列表' })
-  async getModuleList() {
-    return this.agentModuleService.getModuleList()
+  async getModuleList(@Query() query: GetModuleListDto) {
+    return this.agentModuleService.getModuleList(query.page, query.pageSize)
   }
 
   @Get('get-module-configuration')
@@ -29,11 +30,11 @@ export class AgentModuleController {
   @ApiOperation({ summary: '保存模块配置' })
   async saveModuleConfiguration(@Body() body: SaveModuleConfigurationDto) {
     return this.agentModuleService.saveModuleConfiguration(
-      body.id,
+      body.moduleId,
       body.name,
       body.displayName,
-      body.defaultAgentType,
-      body.defaultAgentId
+      body.type,
+      body.agentId
     )
   }
 

+ 8 - 2
src/module/agent-module/service/agent-module-http.service.ts

@@ -25,8 +25,14 @@ export class AgentModuleHttpService {
     return this.httpClientService.post<T>(url, params)
   }
 
-  async getModuleList(): Promise<ServiceResponse<ModuleConfigurationType[]>> {
-    return this.makeRequest<ModuleConfigurationType[]>('getModuleList')
+  async getModuleList(
+    page: number,
+    page_size: number
+  ): Promise<ServiceResponse<ModuleConfigurationType[]>> {
+    return this.makeRequest<ModuleConfigurationType[]>('getModuleList', {
+      page,
+      page_size
+    })
   }
 
   async getModuleConfiguration(

+ 8 - 2
src/module/agent-module/service/agent-module.service.ts

@@ -10,8 +10,14 @@ import { AgentModuleHttpService } from './agent-module-http.service'
 export class AgentModuleService implements IAgentModuleService {
   constructor(private readonly httpService: AgentModuleHttpService) {}
 
-  async getModuleList(): Promise<ServiceResponse<ModuleConfigurationType[]>> {
-    const { code, data, msg } = await this.httpService.getModuleList()
+  async getModuleList(
+    page: number,
+    pageSize: number
+  ): Promise<ServiceResponse<ModuleConfigurationType[]>> {
+    const { code, data, msg } = await this.httpService.getModuleList(
+      page,
+      pageSize
+    )
     if (code !== HttpStatusCode.OK) {
       return {
         code: BusinessCode.BAD_REQUEST,