更新后端api

This commit is contained in:
2025-10-19 21:38:04 +08:00
parent 76d01af86c
commit a457b9713c
13 changed files with 5803 additions and 649 deletions

View File

@@ -1,71 +1,64 @@
import http from '../utils/http.js';
import http from '../utils/http';
/**
* 计划管理API
* 获取所有计划的列表
* @returns {Promise<*>}
*/
export class PlanApi {
/**
* 获取计划列表
* @returns {Promise} 计划列表
*/
static list() {
return http.get('/api/v1/plans');
}
export const getPlans = () => {
return http.get('/api/v1/plans');
};
/**
* 创建计划
* @param {Object} planData 计划数据
* @returns {Promise} 创建结果
*/
static create(planData) {
return http.post('/api/v1/plans', planData);
}
/**
* 创建一个新的计划
* @param {object} planData - 计划信息,对应 dto.CreatePlanRequest
* @returns {Promise<*>}
*/
export const createPlan = (planData) => {
return http.post('/api/v1/plans', planData);
};
/**
* 获取计划详情
* @param {string|number} id 计划ID
* @returns {Promise} 计划详情
*/
static get(id) {
return http.get(`/api/v1/plans/${id}`);
}
/**
* 根据计划ID获取单个计划的详细信息
* @param {number} id - 计划ID
* @returns {Promise<*>}
*/
export const getPlanById = (id) => {
return http.get(`/api/v1/plans/${id}`);
};
/**
* 更新计划信息
* @param {string|number} id 计划ID
* @param {Object} planData 计划数据
* @returns {Promise} 更新结果
*/
static update(id, planData) {
return http.put(`/api/v1/plans/${id}`, planData);
}
/**
* 根据计划ID更新计划的详细信息
* @param {number} id - 计划ID
* @param {object} planData - 更新后的计划信息,对应 dto.UpdatePlanRequest
* @returns {Promise<*>}
*/
export const updatePlan = (id, planData) => {
return http.put(`/api/v1/plans/${id}`, planData);
};
/**
* 删除计划
* @param {string|number} id 计划ID
* @returns {Promise} 删除结果
*/
static delete(id) {
return http.delete(`/api/v1/plans/${id}`);
}
/**
* 根据计划ID删除计划软删除
* @param {number} id - 计划ID
* @returns {Promise<*>}
*/
export const deletePlan = (id) => {
return http.delete(`/api/v1/plans/${id}`);
};
/**
* 启动计划
* @param {string|number} id 计划ID
* @returns {Promise} 启动结果
*/
static start(id) {
return http.post(`/api/v1/plans/${id}/start`);
}
/**
* 根据计划ID启动一个计划的执行
* @param {number} id - 计划ID
* @returns {Promise<*>}
*/
export const startPlan = (id) => {
return http.post(`/api/v1/plans/${id}/start`);
};
/**
* 停止计划
* @param {string|number} id 计划ID
* @returns {Promise} 停止结果
*/
static stop(id) {
return http.post(`/api/v1/plans/${id}/stop`);
}
}
export default PlanApi;
/**
* 根据计划ID停止一个正在执行的计划
* @param {number} id - 计划ID
* @returns {Promise<*>}
*/
export const stopPlan = (id) => {
return http.post(`/api/v1/plans/${id}/stop`);
};