Files
d8d-vite-starter/src/client/admin/api/zichan.ts
D8D Developer b9a3c991d0 update
2025-06-27 01:56:30 +00:00

61 lines
1.5 KiB
TypeScript

import axios from "axios";
import { DeviceCategory, DeviceStatus, ZichanInfo } from "@/share/monitorTypes";
// 资产管理API
export const ZichanAPI = {
// 获取资产列表
getZichanList: async (params?: {
page?: number,
limit?: number,
asset_name?: string,
device_category?: DeviceCategory,
device_status?: DeviceStatus
}) => {
try {
const response = await axios.get(`/zichan`, { params });
return response.data;
} catch (error) {
throw error;
}
},
// 获取单个资产
getZichan: async (id: number) => {
try {
const response = await axios.get(`/zichan/${id}`);
return response.data;
} catch (error) {
throw error;
}
},
// 创建资产
createZichan: async (data: Partial<ZichanInfo>) => {
try {
const response = await axios.post(`/zichan`, data);
return response.data;
} catch (error) {
throw error;
}
},
// 更新资产
updateZichan: async (id: number, data: Partial<ZichanInfo>) => {
try {
const response = await axios.put(`/zichan/${id}`, data);
return response.data;
} catch (error) {
throw error;
}
},
// 删除资产
deleteZichan: async (id: number) => {
try {
const response = await axios.delete(`/zichan/${id}`);
return response.data;
} catch (error) {
throw error;
}
}
};