diff --git a/src/api/aix.ts b/src/api/aix.ts index df264626e9ca05d555bd97d9812a0e2c902df2f1..36c47dd902e2855d447890e3a8a56b778380e53f 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