From b6ce24b3395efe8f09b6f6e193b0e0bd3ea7c58c Mon Sep 17 00:00:00 2001 From: acebear <> Date: Thu, 4 Sep 2025 16:56:38 +0800 Subject: [PATCH] =?UTF-8?q?API=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/aix.ts | 151 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 144 insertions(+), 7 deletions(-) diff --git a/src/api/aix.ts b/src/api/aix.ts index df26462..36c47dd 100644 --- a/src/api/aix.ts +++ b/src/api/aix.ts @@ -1,7 +1,144 @@ -// 对接后端API - -const AixAPI = { - -} - -export { AixAPI } +```typescript +import axios from 'axios'; +import { AixCfg } from './aix.cfg'; + +export interface Sophont { + id: number; + planetId: number; + tagName: string; + state: string; + dealTotal: number; + dealTimeCostTotal: number; +} + +export interface Project { + id: number; + apiType: string; + owner: string; + repo: string; +} + +export interface Planet { + id: number; + solarId: number; + name: string; + sophontList: Sophont[]; + projectList: Project[]; +} + +export interface Solar { + id: number; + name: string; + serviceId: string; + planetList: Planet[]; +} + +export interface SolarStatusResponse { + code: number; + message: string; + data: Solar[]; +} + +export class AixAPI { + private aixCfg: AixCfg; + + constructor(aixCfg: AixCfg) { + this.aixCfg = aixCfg; + } + + async getSolarStatus(): Promise { + const response = await axios.get('http://127.0.0.1:8080/api/report/solar/status'); + return response.data; + } + + async getTaskList(): Promise { + const response = await axios.get(`${this.aixCfg.apiBase}/task/list`); + return response.data; + } + + async getTaskDetail(id: string): Promise { + const response = await axios.get(`${this.aixCfg.apiBase}/task/detail/${id}`); + return response.data; + } + + async createTask(task: any): Promise { + const response = await axios.post(`${this.aixCfg.apiBase}/task/create`, task); + return response.data; + } + + async updateTask(id: string, task: any): Promise { + const response = await axios.put(`${this.aixCfg.apiBase}/task/update/${id}`, task); + return response.data; + } + + async deleteTask(id: string): Promise { + const response = await axios.delete(`${this.aixCfg.apiBase}/task/delete/${id}`); + return response.data; + } + + async getTaskResult(id: string): Promise { + const response = await axios.get(`${this.aixCfg.apiBase}/task/result/${id}`); + return response.data; + } + + async getTaskLog(id: string): Promise { + const response = await axios.get(`${this.aixCfg.apiBase}/task/log/${id}`); + return response.data; + } + + async getTaskStat(): Promise { + const response = await axios.get(`${this.aixCfg.apiBase}/task/stat`); + return response.data; + } + + async getTaskQueue(): Promise { + const response = await axios.get(`${this.aixCfg.apiBase}/task/queue`); + return response.data; + } + + async getTaskQueueStat(): Promise { + const response = await axios.get(`${this.aixCfg.apiBase}/task/queue/stat`); + return response.data; + } + + async getTaskQueueList(): Promise { + const response = await axios.get(`${this.aixCfg.apiBase}/task/queue/list`); + return response.data; + } + + async getTaskQueueDetail(id: string): Promise { + const response = await axios.get(`${this.aixCfg.apiBase}/task/queue/detail/${id}`); + return response.data; + } + + async getTaskQueueLog(id: string): Promise { + const response = await axios.get(`${this.aixCfg.apiBase}/task/queue/log/${id}`); + return response.data; + } + + async getTaskQueueResult(id: string): Promise { + const response = await axios.get(`${this.aixCfg.apiBase}/task/queue/result/${id}`); + return response.data; + } + + async getTaskQueueStatDetail(id: string): Promise { + const response = await axios.get(`${this.aixCfg.apiBase}/task/queue/stat/detail/${id}`); + return response.data; + } + + async getTaskQueueStatList(): Promise { + const response = await axios.get(`${this.aixCfg.apiBase}/task/queue/stat/list`); + return response.data; + } + + async getTaskQueueStatLog(id: string): Promise { + const response = await axios.get(`${this.aixCfg.apiBase}/task/queue/stat/log/${id}`); + return response.data; + } + + async getTaskQueueStatResult(id: string): Promise { + const response = await axios.get(`${this.aixCfg.apiBase}/task/queue/stat/result/${id}`); + return response.data; + } +} +``` \ No newline at end of file -- Gitee