更新后端api
This commit is contained in:
@@ -1,101 +1,56 @@
|
||||
import http from '../utils/http.js';
|
||||
import http from '../utils/http';
|
||||
|
||||
/**
|
||||
* 区域主控管理API
|
||||
* 获取系统中所有设备的列表
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
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}`);
|
||||
}
|
||||
}
|
||||
export const getDevices = () => {
|
||||
return http.get('/api/v1/devices');
|
||||
};
|
||||
|
||||
/**
|
||||
* 普通设备管理API
|
||||
* 根据提供的信息创建一个新设备
|
||||
* @param {object} deviceData - 设备信息,对应 dto.CreateDeviceRequest
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export class DeviceApi {
|
||||
/**
|
||||
* 获取设备列表
|
||||
* @returns {Promise} 设备列表
|
||||
*/
|
||||
static list() {
|
||||
return http.get('/api/v1/devices');
|
||||
}
|
||||
export const createDevice = (deviceData) => {
|
||||
return http.post('/api/v1/devices', deviceData);
|
||||
};
|
||||
|
||||
/**
|
||||
* 创建新设备
|
||||
* @param {Object} deviceData 设备数据
|
||||
* @returns {Promise} 创建结果
|
||||
*/
|
||||
static create(deviceData) {
|
||||
return http.post('/api/v1/devices', deviceData);
|
||||
}
|
||||
/**
|
||||
* 根据设备ID获取单个设备的详细信息
|
||||
* @param {string} id - 设备ID
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export const getDeviceById = (id) => {
|
||||
return http.get(`/api/v1/devices/${id}`);
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取设备详情
|
||||
* @param {string|number} id 设备ID
|
||||
* @returns {Promise} 设备详情
|
||||
*/
|
||||
static get(id) {
|
||||
return http.get(`/api/v1/devices/${id}`);
|
||||
}
|
||||
/**
|
||||
* 根据设备ID更新一个已存在的设备信息
|
||||
* @param {string} id - 设备ID
|
||||
* @param {object} deviceData - 要更新的设备信息,对应 dto.UpdateDeviceRequest
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export const updateDevice = (id, deviceData) => {
|
||||
return http.put(`/api/v1/devices/${id}`, deviceData);
|
||||
};
|
||||
|
||||
/**
|
||||
* 更新设备信息
|
||||
* @param {string|number} id 设备ID
|
||||
* @param {Object} deviceData 设备数据
|
||||
* @returns {Promise} 更新结果
|
||||
*/
|
||||
static update(id, deviceData) {
|
||||
return http.put(`/api/v1/devices/${id}`, deviceData);
|
||||
}
|
||||
/**
|
||||
* 根据设备ID删除一个设备(软删除)
|
||||
* @param {string} id - 设备ID
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export const deleteDevice = (id) => {
|
||||
return http.delete(`/api/v1/devices/${id}`);
|
||||
};
|
||||
|
||||
/**
|
||||
* 删除设备
|
||||
* @param {string|number} id 设备ID
|
||||
* @returns {Promise} 删除结果
|
||||
*/
|
||||
static delete(id) {
|
||||
return http.delete(`/api/v1/devices/${id}`);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 根据设备ID和指定的动作(开启或关闭)来手动控制设备
|
||||
* @param {string} id - 设备ID
|
||||
* @param {object} manualControlData - 手动控制指令,对应 dto.ManualControlDeviceRequest
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export const manualControlDevice = (id, manualControlData) => {
|
||||
return http.post(`/api/v1/devices/manual-control/${id}`, manualControlData);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user