| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- import axios from "axios";
- import { DeviceCategory, DeviceStatus, ZichanInfo } from "../../share/monitorTypes.ts";
- // 资产管理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;
- }
- }
- };
|