定义api

This commit is contained in:
2025-09-19 14:34:51 +08:00
parent fbf3f77229
commit 1e894b7700
5 changed files with 172 additions and 6 deletions

53
src/api/device.js Normal file
View File

@@ -0,0 +1,53 @@
import http from '../utils/http.js';
/**
* 设备管理API
*/
export class DeviceApi {
/**
* 获取设备列表
* @returns {Promise} 设备列表
*/
static list() {
return http.get('/devices');
}
/**
* 创建新设备
* @param {Object} deviceData 设备数据
* @returns {Promise} 创建结果
*/
static create(deviceData) {
return http.post('/devices', deviceData);
}
/**
* 获取设备详情
* @param {string|number} id 设备ID
* @returns {Promise} 设备详情
*/
static get(id) {
return http.get(`/devices/${id}`);
}
/**
* 更新设备信息
* @param {string|number} id 设备ID
* @param {Object} deviceData 设备数据
* @returns {Promise} 更新结果
*/
static update(id, deviceData) {
return http.put(`/devices/${id}`, deviceData);
}
/**
* 删除设备
* @param {string|number} id 设备ID
* @returns {Promise} 删除结果
*/
static delete(id) {
return http.delete(`/devices/${id}`);
}
}
export default DeviceApi;