定义api
This commit is contained in:
53
src/api/device.js
Normal file
53
src/api/device.js
Normal 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;
|
||||
Reference in New Issue
Block a user