Files
pig-farm-controller-fe/src/api/device.js

102 lines
2.2 KiB
JavaScript
Raw Normal View History

2025-09-19 14:34:51 +08:00
import http from '../utils/http.js';
/**
* 区域主控管理API
*/
export class AreaControllerApi {
/**
* 获取区域主控列表
* @returns {Promise} 区域主控列表
*/
static list() {
return http.get('/api/v1/area-controllers');
}
/**
* 创建新区域主控
* @param {Object} areaControllerData 区域主控数据
* @returns {Promise} 创建结果
*/
static create(areaControllerData) {
return http.post('/api/v1/area-controllers', areaControllerData);
}
/**
* 获取区域主控详情
* @param {string|number} id 区域主控ID
* @returns {Promise} 区域主控详情
*/
static get(id) {
return http.get(`/api/v1/area-controllers/${id}`);
}
/**
* 更新区域主控信息
* @param {string|number} id 区域主控ID
* @param {Object} areaControllerData 区域主控数据
* @returns {Promise} 更新结果
*/
static update(id, areaControllerData) {
return http.put(`/api/v1/area-controllers/${id}`, areaControllerData);
}
/**
* 删除区域主控
* @param {string|number} id 区域主控ID
* @returns {Promise} 删除结果
*/
static delete(id) {
return http.delete(`/api/v1/area-controllers/${id}`);
}
}
/**
* 普通设备管理API
2025-09-19 14:34:51 +08:00
*/
export class DeviceApi {
/**
* 获取设备列表
* @returns {Promise} 设备列表
*/
static list() {
2025-09-19 15:59:44 +08:00
return http.get('/api/v1/devices');
2025-09-19 14:34:51 +08:00
}
/**
* 创建新设备
* @param {Object} deviceData 设备数据
* @returns {Promise} 创建结果
*/
static create(deviceData) {
2025-09-19 15:59:44 +08:00
return http.post('/api/v1/devices', deviceData);
2025-09-19 14:34:51 +08:00
}
/**
* 获取设备详情
* @param {string|number} id 设备ID
* @returns {Promise} 设备详情
*/
static get(id) {
2025-09-19 15:59:44 +08:00
return http.get(`/api/v1/devices/${id}`);
2025-09-19 14:34:51 +08:00
}
/**
* 更新设备信息
* @param {string|number} id 设备ID
* @param {Object} deviceData 设备数据
* @returns {Promise} 更新结果
*/
static update(id, deviceData) {
2025-09-19 15:59:44 +08:00
return http.put(`/api/v1/devices/${id}`, deviceData);
2025-09-19 14:34:51 +08:00
}
/**
* 删除设备
* @param {string|number} id 设备ID
* @returns {Promise} 删除结果
*/
static delete(id) {
2025-09-19 15:59:44 +08:00
return http.delete(`/api/v1/devices/${id}`);
2025-09-19 14:34:51 +08:00
}
}