定义api
This commit is contained in:
		
							
								
								
									
										71
									
								
								src/api/plan.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										71
									
								
								src/api/plan.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,71 @@ | ||||
| import http from '../utils/http.js'; | ||||
|  | ||||
| /** | ||||
|  * 计划管理API | ||||
|  */ | ||||
| export class PlanApi { | ||||
|   /** | ||||
|    * 获取计划列表 | ||||
|    * @returns {Promise} 计划列表 | ||||
|    */ | ||||
|   static list() { | ||||
|     return http.get('/plans'); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * 创建新计划 | ||||
|    * @param {Object} planData 计划数据 | ||||
|    * @returns {Promise} 创建结果 | ||||
|    */ | ||||
|   static create(planData) { | ||||
|     return http.post('/plans', planData); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * 获取计划详情 | ||||
|    * @param {string|number} id 计划ID | ||||
|    * @returns {Promise} 计划详情 | ||||
|    */ | ||||
|   static get(id) { | ||||
|     return http.get(`/plans/${id}`); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * 更新计划信息 | ||||
|    * @param {string|number} id 计划ID | ||||
|    * @param {Object} planData 计划数据 | ||||
|    * @returns {Promise} 更新结果 | ||||
|    */ | ||||
|   static update(id, planData) { | ||||
|     return http.put(`/plans/${id}`, planData); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * 删除计划 | ||||
|    * @param {string|number} id 计划ID | ||||
|    * @returns {Promise} 删除结果 | ||||
|    */ | ||||
|   static delete(id) { | ||||
|     return http.delete(`/plans/${id}`); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * 启动计划 | ||||
|    * @param {string|number} id 计划ID | ||||
|    * @returns {Promise} 启动结果 | ||||
|    */ | ||||
|   static start(id) { | ||||
|     return http.post(`/plans/${id}/start`); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * 停止计划 | ||||
|    * @param {string|number} id 计划ID | ||||
|    * @returns {Promise} 停止结果 | ||||
|    */ | ||||
|   static stop(id) { | ||||
|     return http.post(`/plans/${id}/stop`); | ||||
|   } | ||||
| } | ||||
|  | ||||
| export default PlanApi; | ||||
		Reference in New Issue
	
	Block a user