Files
pig-farm-controller-fe/src/api/plan.js
2025-10-20 14:52:25 +08:00

75 lines
1.5 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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,
};