|
@@ -0,0 +1,67 @@
|
|
|
+import { Injectable } from '@nestjs/common'
|
|
|
+
|
|
|
+import { IAgentExecutionService } from '@/interface/agent-execution.interface'
|
|
|
+import { ServiceResponse } from '@/response/response.interface'
|
|
|
+import { BusinessCode, HttpStatusCode } from '@/response/status-code.enum'
|
|
|
+
|
|
|
+import { AgentExecutionHttpService } from './agent-execution-http.service'
|
|
|
+
|
|
|
+@Injectable()
|
|
|
+export class AgentExecutionService implements IAgentExecutionService {
|
|
|
+ constructor(private readonly httpService: AgentExecutionHttpService) {}
|
|
|
+
|
|
|
+ async createAgentTask(
|
|
|
+ params: Record<string, any>
|
|
|
+ ): Promise<ServiceResponse<any>> {
|
|
|
+ const { code, data, msg } = await this.httpService.createAgentTask(params)
|
|
|
+ if (code !== HttpStatusCode.OK) {
|
|
|
+ return {
|
|
|
+ code: BusinessCode.BAD_REQUEST,
|
|
|
+ msg: msg || '创建任务失败',
|
|
|
+ data: null
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return {
|
|
|
+ code: BusinessCode.SUCCESS,
|
|
|
+ data,
|
|
|
+ msg: msg || '创建任务成功'
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ async getAgentTaskList(
|
|
|
+ params: Record<string, any>
|
|
|
+ ): Promise<ServiceResponse<any>> {
|
|
|
+ const { code, data, msg } = await this.httpService.getAgentTaskList(params)
|
|
|
+ if (code !== HttpStatusCode.OK) {
|
|
|
+ return {
|
|
|
+ code: BusinessCode.BAD_REQUEST,
|
|
|
+ msg: msg || '获取任务列表失败',
|
|
|
+ data: null
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return {
|
|
|
+ code: BusinessCode.SUCCESS,
|
|
|
+ data,
|
|
|
+ msg: msg || '获取任务列表成功'
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ async getAgentTaskDetail(
|
|
|
+ params: Record<string, any>
|
|
|
+ ): Promise<ServiceResponse<any>> {
|
|
|
+ const { code, data, msg } =
|
|
|
+ await this.httpService.getAgentTaskDetail(params)
|
|
|
+ if (code !== HttpStatusCode.OK) {
|
|
|
+ return {
|
|
|
+ code: BusinessCode.BAD_REQUEST,
|
|
|
+ msg: msg || '获取任务详情失败',
|
|
|
+ data: null
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return {
|
|
|
+ code: BusinessCode.SUCCESS,
|
|
|
+ data,
|
|
|
+ msg: msg || '获取任务详情成功'
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|