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