|
@@ -0,0 +1,119 @@
|
|
|
|
+import { Injectable } from '@nestjs/common'
|
|
|
|
+
|
|
|
|
+import { IAgentTestService } from '@/interface/agent-test.interface'
|
|
|
|
+import { ServiceResponse } from '@/response/response.interface'
|
|
|
|
+import { BusinessCode, HttpStatusCode } from '@/response/status-code.enum'
|
|
|
|
+
|
|
|
|
+import { AgentTestHttpService } from './agent-test-http.service'
|
|
|
|
+
|
|
|
|
+@Injectable()
|
|
|
|
+export class AgentTestService implements IAgentTestService {
|
|
|
|
+ constructor(private readonly httpService: AgentTestHttpService) {}
|
|
|
|
+
|
|
|
|
+ async createTestTask(
|
|
|
|
+ params: Record<string, any>
|
|
|
|
+ ): Promise<ServiceResponse<TestTaskType>> {
|
|
|
|
+ const { code, data, msg } = await this.httpService.createTestTask(params)
|
|
|
|
+ if (code !== HttpStatusCode.OK) {
|
|
|
|
+ return {
|
|
|
|
+ code: BusinessCode.BAD_REQUEST,
|
|
|
|
+ msg: msg || '创建测试任务失败',
|
|
|
|
+ data: null
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return {
|
|
|
|
+ code: BusinessCode.SUCCESS,
|
|
|
|
+ data,
|
|
|
|
+ msg: msg || '创建测试任务成功'
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ async getEvaluteType(): Promise<ServiceResponse<EvaluteType>> {
|
|
|
|
+ const { code, data, msg } = await this.httpService.getEvaluteType()
|
|
|
|
+ if (code !== HttpStatusCode.OK) {
|
|
|
|
+ return {
|
|
|
|
+ code: BusinessCode.BAD_REQUEST,
|
|
|
|
+ msg: msg || '获取评估类型失败',
|
|
|
|
+ data: null
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return {
|
|
|
|
+ code: BusinessCode.SUCCESS,
|
|
|
|
+ data,
|
|
|
|
+ msg: msg || '获取评估类型成功'
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ async getTestTaskList(
|
|
|
|
+ params: Record<string, any>
|
|
|
|
+ ): Promise<ServiceResponse<TestTaskListType>> {
|
|
|
|
+ const { code, data, msg } = await this.httpService.getTestTaskList(params)
|
|
|
|
+ if (code !== HttpStatusCode.OK) {
|
|
|
|
+ return {
|
|
|
|
+ code: BusinessCode.BAD_REQUEST,
|
|
|
|
+ msg: msg || '获取测试任务列表失败',
|
|
|
|
+ data: null
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return {
|
|
|
|
+ code: BusinessCode.SUCCESS,
|
|
|
|
+ data,
|
|
|
|
+ msg: msg || '获取测试任务列表成功'
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ async getTestTaskConversations(
|
|
|
|
+ params: Record<string, any>
|
|
|
|
+ ): Promise<ServiceResponse<TaskConversationsType>> {
|
|
|
|
+ const { code, data, msg } =
|
|
|
|
+ await this.httpService.getTestTaskConversations(params)
|
|
|
|
+ if (code !== HttpStatusCode.OK) {
|
|
|
|
+ return {
|
|
|
|
+ code: BusinessCode.BAD_REQUEST,
|
|
|
|
+ msg: msg || '获取测试任务会话列表失败',
|
|
|
|
+ data: null
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return {
|
|
|
|
+ code: BusinessCode.SUCCESS,
|
|
|
|
+ data,
|
|
|
|
+ msg: msg || '获取测试任务会话列表成功'
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ async stopTestTask(
|
|
|
|
+ params: Record<string, any>
|
|
|
|
+ ): Promise<ServiceResponse<any>> {
|
|
|
|
+ const { code, data, msg } = await this.httpService.stopTestTask(params)
|
|
|
|
+ if (code !== HttpStatusCode.OK) {
|
|
|
|
+ return {
|
|
|
|
+ code: BusinessCode.BAD_REQUEST,
|
|
|
|
+ msg: msg || '停止测试任务失败',
|
|
|
|
+ data: null
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return {
|
|
|
|
+ code: BusinessCode.SUCCESS,
|
|
|
|
+ data,
|
|
|
|
+ msg: msg || '停止测试任务成功'
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ async resumeTestTask(
|
|
|
|
+ params: Record<string, any>
|
|
|
|
+ ): Promise<ServiceResponse<any>> {
|
|
|
|
+ const { code, data, msg } = await this.httpService.resumeTestTask(params)
|
|
|
|
+ if (code !== HttpStatusCode.OK) {
|
|
|
|
+ return {
|
|
|
|
+ code: BusinessCode.BAD_REQUEST,
|
|
|
|
+ msg: msg || '恢复测试任务失败',
|
|
|
|
+ data: null
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return {
|
|
|
|
+ code: BusinessCode.SUCCESS,
|
|
|
|
+ data,
|
|
|
|
+ msg: msg || '恢复测试任务成功'
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|