mirror of
https://gitee.com/pnoker/iot-dc3.git
synced 2026-09-21 05:11:58 +08:00
refactor(api): centralize axios calls into typed http helpers in api/common.ts
This commit is contained in:
+3
-23
@@ -14,28 +14,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import request from '@/config/axios';
|
||||
import { httpGet } from '@/api/common';
|
||||
|
||||
/**
|
||||
* Get driver attributes by driver ID
|
||||
*
|
||||
* @param id Driver ID
|
||||
* @returns MyAxiosPromise
|
||||
*/
|
||||
export const getDriverAttributeByDriverId = (id: string) =>
|
||||
request<R>({
|
||||
url: `api/v3/manager/driver_attribute/driver_id/${id}`,
|
||||
method: 'get',
|
||||
});
|
||||
export const getDriverAttributeByDriverId = (id: string) => httpGet(`api/v3/manager/driver_attribute/driver_id/${id}`);
|
||||
|
||||
/**
|
||||
* Get point attributes by driver ID
|
||||
*
|
||||
* @param id Driver ID
|
||||
* @returns MyAxiosPromise
|
||||
*/
|
||||
export const getPointAttributeByDriverId = (id: string) =>
|
||||
request<R>({
|
||||
url: `api/v3/manager/point_attribute/driver_id/${id}`,
|
||||
method: 'get',
|
||||
});
|
||||
export const getPointAttributeByDriverId = (id: string) => httpGet(`api/v3/manager/point_attribute/driver_id/${id}`);
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright 2016-present the IoT DC3 original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import request from '@/config/axios';
|
||||
import type { AxiosRequestConfig } from 'axios';
|
||||
|
||||
/**
|
||||
* Shared HTTP helpers so every `src/api/*.ts` module stays a one-liner per
|
||||
* endpoint. Keeps URL strings visible inline (grep-friendly) and lets the
|
||||
* response interceptor do the payload unwrapping.
|
||||
*/
|
||||
|
||||
export const httpGet = <T = R>(url: string, config?: AxiosRequestConfig) =>
|
||||
request<T>({ ...config, url, method: 'get' });
|
||||
|
||||
export const httpPost = <T = R, D = unknown>(url: string, data?: D, config?: AxiosRequestConfig) =>
|
||||
request<T>({ ...config, url, method: 'post', data });
|
||||
+14
-147
@@ -14,170 +14,37 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import request from '@/config/axios';
|
||||
import { httpGet, httpPost } from '@/api/common';
|
||||
|
||||
/**
|
||||
* Add a new device
|
||||
*
|
||||
* @param device Device object
|
||||
* @returns MyAxiosPromise
|
||||
*/
|
||||
export const addDevice = (device: any) =>
|
||||
request<R>({
|
||||
url: `api/v3/manager/device/add`,
|
||||
method: 'post',
|
||||
data: device,
|
||||
});
|
||||
export const addDevice = (device: any) => httpPost('api/v3/manager/device/add', device);
|
||||
|
||||
/**
|
||||
* Delete a device
|
||||
*
|
||||
* @param id Device ID
|
||||
* @returns MyAxiosPromise
|
||||
*/
|
||||
export const deleteDevice = (id: string) =>
|
||||
request<R>({
|
||||
url: `api/v3/manager/device/delete/${id}`,
|
||||
method: 'post',
|
||||
});
|
||||
export const deleteDevice = (id: string) => httpPost(`api/v3/manager/device/delete/${id}`);
|
||||
|
||||
/**
|
||||
* Update a device
|
||||
*
|
||||
* @param device Device object
|
||||
* @returns MyAxiosPromise
|
||||
*/
|
||||
export const updateDevice = (device: any) =>
|
||||
request<R>({
|
||||
url: `api/v3/manager/device/update`,
|
||||
method: 'post',
|
||||
data: device,
|
||||
});
|
||||
export const updateDevice = (device: any) => httpPost('api/v3/manager/device/update', device);
|
||||
|
||||
/**
|
||||
* Get device by ID
|
||||
*
|
||||
* @param id Device ID
|
||||
* @returns MyAxiosPromise
|
||||
*/
|
||||
export const getDeviceById = (id: string) =>
|
||||
request<R>({
|
||||
url: `api/v3/manager/device/id/${id}`,
|
||||
method: 'get',
|
||||
});
|
||||
export const getDeviceById = (id: string) => httpGet(`api/v3/manager/device/id/${id}`);
|
||||
|
||||
/**
|
||||
* Get devices by IDs
|
||||
*
|
||||
* @param deviceIds Device ID array
|
||||
* @returns MyAxiosPromise
|
||||
*/
|
||||
export const getDeviceByIds = (deviceIds: any) =>
|
||||
request<R>({
|
||||
url: `api/v3/manager/device/ids`,
|
||||
method: 'post',
|
||||
data: deviceIds,
|
||||
});
|
||||
export const getDeviceByIds = (deviceIds: any) => httpPost('api/v3/manager/device/ids', deviceIds);
|
||||
|
||||
/**
|
||||
* Get devices by driver ID
|
||||
*
|
||||
* @param driverId Driver ID
|
||||
* @returns MyAxiosPromise
|
||||
*/
|
||||
export const getDeviceByDriverId = (driverId: string) =>
|
||||
request<R>({
|
||||
url: `api/v3/manager/device/driver_id/${driverId}`,
|
||||
method: 'get',
|
||||
});
|
||||
export const getDeviceByDriverId = (driverId: string) => httpGet(`api/v3/manager/device/driver_id/${driverId}`);
|
||||
|
||||
/**
|
||||
* Get devices by profile ID
|
||||
*
|
||||
* @param profileId Profile ID
|
||||
* @returns MyAxiosPromise
|
||||
*/
|
||||
export const getDeviceByProfileId = (profileId: string) =>
|
||||
request<R>({
|
||||
url: `api/v3/manager/device/profile_id/${profileId}`,
|
||||
method: 'get',
|
||||
});
|
||||
export const getDeviceByProfileId = (profileId: string) => httpGet(`api/v3/manager/device/profile_id/${profileId}`);
|
||||
|
||||
/**
|
||||
* Get device list with pagination
|
||||
*
|
||||
* @param device Device query parameters
|
||||
* @returns MyAxiosPromise
|
||||
*/
|
||||
export const getDeviceList = (device: any) =>
|
||||
request<R>({
|
||||
url: `api/v3/manager/device/list`,
|
||||
method: 'post',
|
||||
data: device,
|
||||
});
|
||||
export const getDeviceList = (device: any) => httpPost('api/v3/manager/device/list', device);
|
||||
|
||||
/**
|
||||
* Get device status with pagination
|
||||
*
|
||||
* @param device Device query parameters
|
||||
* @returns MyAxiosPromise
|
||||
*/
|
||||
export const getDeviceStatus = (device: any) =>
|
||||
request<R>({
|
||||
url: `api/v3/data/device/status/device`,
|
||||
method: 'post',
|
||||
data: device,
|
||||
});
|
||||
export const getDeviceStatus = (device: any) => httpPost('api/v3/data/device/status/device', device);
|
||||
|
||||
/**
|
||||
* Get device status by driver ID
|
||||
*
|
||||
* @param driverId Driver ID
|
||||
* @returns MyAxiosPromise
|
||||
*/
|
||||
export const getDeviceStatusByDriverId = (driverId: string) =>
|
||||
request<R>({
|
||||
url: `api/v3/data/device/status/device/driver_id/${driverId}`,
|
||||
method: 'get',
|
||||
});
|
||||
httpGet(`api/v3/data/device/status/device/driver_id/${driverId}`);
|
||||
|
||||
/**
|
||||
* Get device status by profile ID
|
||||
*
|
||||
* @param profileId Profile ID
|
||||
* @returns MyAxiosPromise
|
||||
*/
|
||||
export const getDeviceStatusByProfileId = (profileId: string) =>
|
||||
request<R>({
|
||||
url: `api/v3/data/device/status/device/profile_id/${profileId}`,
|
||||
method: 'get',
|
||||
});
|
||||
httpGet(`api/v3/data/device/status/device/profile_id/${profileId}`);
|
||||
|
||||
/**
|
||||
* Get device import template
|
||||
*
|
||||
* @param device Device query parameters
|
||||
* @returns MyAxiosPromise
|
||||
*/
|
||||
export const importDeviceTemplate = (device: any) =>
|
||||
request<R>({
|
||||
url: `api/v3/manager/device/export/import_template`,
|
||||
responseType: 'blob',
|
||||
method: 'post',
|
||||
data: device,
|
||||
});
|
||||
httpPost('api/v3/manager/device/export/import_template', device, { responseType: 'blob' });
|
||||
|
||||
/**
|
||||
* Import devices from file
|
||||
*
|
||||
* @param device Device file data
|
||||
* @returns MyAxiosPromise
|
||||
*/
|
||||
export const importDevice = (device: any) =>
|
||||
request<R>({
|
||||
url: `api/v3/manager/device/import`,
|
||||
method: 'post',
|
||||
httpPost('api/v3/manager/device/import', device, {
|
||||
timeout: 0,
|
||||
headers: { 'Content-Type': 'multipart/form-data' },
|
||||
data: device,
|
||||
});
|
||||
|
||||
+5
-49
@@ -14,56 +14,12 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import request from '@/config/axios';
|
||||
import { httpPost } from '@/api/common';
|
||||
|
||||
/**
|
||||
* Get driver dictionary
|
||||
*
|
||||
* @param dictionary Dictionary query parameters
|
||||
* @returns MyAxiosPromise
|
||||
*/
|
||||
export const getDriverDictionary = (dictionary: any) =>
|
||||
request<R>({
|
||||
url: `api/v3/manager/dictionary/driver`,
|
||||
method: 'post',
|
||||
data: dictionary,
|
||||
});
|
||||
export const getDriverDictionary = (dictionary: any) => httpPost('api/v3/manager/dictionary/driver', dictionary);
|
||||
|
||||
/**
|
||||
* Get device dictionary
|
||||
*
|
||||
* @param dictionary Dictionary query parameters
|
||||
* @returns MyAxiosPromise
|
||||
*/
|
||||
export const getDeviceDictionary = (dictionary: any) =>
|
||||
request<R>({
|
||||
url: `api/v3/manager/dictionary/device`,
|
||||
method: 'post',
|
||||
data: dictionary,
|
||||
});
|
||||
export const getDeviceDictionary = (dictionary: any) => httpPost('api/v3/manager/dictionary/device', dictionary);
|
||||
|
||||
/**
|
||||
* Get profile dictionary
|
||||
*
|
||||
* @param dictionary Dictionary query parameters
|
||||
* @returns MyAxiosPromise
|
||||
*/
|
||||
export const getProfileDictionary = (dictionary: any) =>
|
||||
request<R>({
|
||||
url: `api/v3/manager/dictionary/profile`,
|
||||
method: 'post',
|
||||
data: dictionary,
|
||||
});
|
||||
export const getProfileDictionary = (dictionary: any) => httpPost('api/v3/manager/dictionary/profile', dictionary);
|
||||
|
||||
/**
|
||||
* Get point dictionary
|
||||
*
|
||||
* @param dictionary Dictionary query parameters
|
||||
* @returns MyAxiosPromise
|
||||
*/
|
||||
export const getPointDictionary = (dictionary: any) =>
|
||||
request<R>({
|
||||
url: `api/v3/manager/dictionary/device_point`,
|
||||
method: 'post',
|
||||
data: dictionary,
|
||||
});
|
||||
export const getPointDictionary = (dictionary: any) => httpPost('api/v3/manager/dictionary/device_point', dictionary);
|
||||
|
||||
+5
-48
@@ -14,55 +14,12 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import request from '@/config/axios';
|
||||
import { httpGet, httpPost } from '@/api/common';
|
||||
|
||||
/**
|
||||
* Get driver by ID
|
||||
*
|
||||
* @param id Driver ID
|
||||
* @returns MyAxiosPromise
|
||||
*/
|
||||
export const getDriverById = (id: string) =>
|
||||
request<R>({
|
||||
url: `api/v3/manager/driver/id/${id}`,
|
||||
method: 'get',
|
||||
});
|
||||
export const getDriverById = (id: string) => httpGet(`api/v3/manager/driver/id/${id}`);
|
||||
|
||||
/**
|
||||
* Get drivers by IDs
|
||||
*
|
||||
* @param driverIds Driver ID array
|
||||
* @returns MyAxiosPromise
|
||||
*/
|
||||
export const getDriverByIds = (driverIds: any) =>
|
||||
request<R>({
|
||||
url: `api/v3/manager/driver/ids`,
|
||||
method: 'post',
|
||||
data: driverIds,
|
||||
});
|
||||
export const getDriverByIds = (driverIds: any) => httpPost('api/v3/manager/driver/ids', driverIds);
|
||||
|
||||
/**
|
||||
* Get driver list with pagination
|
||||
*
|
||||
* @param driver Driver query parameters
|
||||
* @returns MyAxiosPromise
|
||||
*/
|
||||
export const getDriverList = (driver: any) =>
|
||||
request<R>({
|
||||
url: `api/v3/manager/driver/list`,
|
||||
method: 'post',
|
||||
data: driver,
|
||||
});
|
||||
export const getDriverList = (driver: any) => httpPost('api/v3/manager/driver/list', driver);
|
||||
|
||||
/**
|
||||
* Get driver status
|
||||
*
|
||||
* @param driver Driver query parameters
|
||||
* @returns MyAxiosPromise
|
||||
*/
|
||||
export const getDriverStatus = (driver: any) =>
|
||||
request<R>({
|
||||
url: `api/v3/data/driver/status/driver`,
|
||||
method: 'post',
|
||||
data: driver,
|
||||
});
|
||||
export const getDriverStatus = (driver: any) => httpPost('api/v3/data/driver/status/driver', driver);
|
||||
|
||||
+9
-90
@@ -14,106 +14,25 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import request from '@/config/axios';
|
||||
import { httpGet, httpPost } from '@/api/common';
|
||||
|
||||
/**
|
||||
* Add driver configuration
|
||||
*
|
||||
* @param driverInfo Driver configuration object
|
||||
* @returns MyAxiosPromise
|
||||
*/
|
||||
export const addDriverInfo = (driverInfo: any) =>
|
||||
request<R>({
|
||||
url: `api/v3/manager/driver_attribute_config/add`,
|
||||
method: 'post',
|
||||
data: driverInfo,
|
||||
});
|
||||
export const addDriverInfo = (driverInfo: any) => httpPost('api/v3/manager/driver_attribute_config/add', driverInfo);
|
||||
|
||||
/**
|
||||
* Update driver configuration
|
||||
*
|
||||
* @param driverInfo Driver configuration object
|
||||
* @returns MyAxiosPromise
|
||||
*/
|
||||
export const updateDriverInfo = (driverInfo: any) =>
|
||||
request<R>({
|
||||
url: `api/v3/manager/driver_attribute_config/update`,
|
||||
method: 'post',
|
||||
data: driverInfo,
|
||||
});
|
||||
httpPost('api/v3/manager/driver_attribute_config/update', driverInfo);
|
||||
|
||||
/**
|
||||
* Get driver configuration by device ID and attribute ID
|
||||
*
|
||||
* @param deviceId Device ID
|
||||
* @param attributeId Attribute ID
|
||||
* @returns MyAxiosPromise
|
||||
*/
|
||||
export const getDriverInfoByDeviceIdAndAttributeId = (deviceId: string, attributeId: string) =>
|
||||
request<R>({
|
||||
url: `api/v3/manager/driver_attribute_config/device_id/${deviceId}/attribute_id/${attributeId}`,
|
||||
method: 'get',
|
||||
});
|
||||
httpGet(`api/v3/manager/driver_attribute_config/device_id/${deviceId}/attribute_id/${attributeId}`);
|
||||
|
||||
/**
|
||||
* Get driver configuration by device ID
|
||||
*
|
||||
* @param deviceId Device ID
|
||||
* @returns MyAxiosPromise
|
||||
*/
|
||||
export const getDriverInfoByDeviceId = (deviceId: string) =>
|
||||
request<R>({
|
||||
url: `api/v3/manager/driver_attribute_config/device_id/${deviceId}`,
|
||||
method: 'get',
|
||||
});
|
||||
httpGet(`api/v3/manager/driver_attribute_config/device_id/${deviceId}`);
|
||||
|
||||
/**
|
||||
* Add point configuration
|
||||
*
|
||||
* @param pointInfo Point configuration object
|
||||
* @returns MyAxiosPromise
|
||||
*/
|
||||
export const addPointInfo = (pointInfo: any) =>
|
||||
request<R>({
|
||||
url: `api/v3/manager/point_attribute_config/add`,
|
||||
method: 'post',
|
||||
data: pointInfo,
|
||||
});
|
||||
export const addPointInfo = (pointInfo: any) => httpPost('api/v3/manager/point_attribute_config/add', pointInfo);
|
||||
|
||||
/**
|
||||
* Update point configuration
|
||||
*
|
||||
* @param pointInfo Point configuration object
|
||||
* @returns MyAxiosPromise
|
||||
*/
|
||||
export const updatePointInfo = (pointInfo: any) =>
|
||||
request<R>({
|
||||
url: `api/v3/manager/point_attribute_config/update`,
|
||||
method: 'post',
|
||||
data: pointInfo,
|
||||
});
|
||||
export const updatePointInfo = (pointInfo: any) => httpPost('api/v3/manager/point_attribute_config/update', pointInfo);
|
||||
|
||||
/**
|
||||
* Get point configuration by device ID and point ID
|
||||
*
|
||||
* @param deviceId Device ID
|
||||
* @param pointId Point ID
|
||||
* @returns MyAxiosPromise
|
||||
*/
|
||||
export const getPointInfoByDeviceIdAndPointId = (deviceId: string, pointId: string) =>
|
||||
request<R>({
|
||||
url: `api/v3/manager/point_attribute_config/device_id/${deviceId}/point_id/${pointId}`,
|
||||
method: 'get',
|
||||
});
|
||||
httpGet(`api/v3/manager/point_attribute_config/device_id/${deviceId}/point_id/${pointId}`);
|
||||
|
||||
/**
|
||||
* Get point configuration by device ID
|
||||
*
|
||||
* @param deviceId Device ID
|
||||
* @returns MyAxiosPromise
|
||||
*/
|
||||
export const getPointInfoByDeviceId = (deviceId: string) =>
|
||||
request<R>({
|
||||
url: `api/v3/manager/point_attribute_config/device_id/${deviceId}`,
|
||||
method: 'get',
|
||||
});
|
||||
httpGet(`api/v3/manager/point_attribute_config/device_id/${deviceId}`);
|
||||
|
||||
+16
-165
@@ -14,186 +14,37 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import request from '@/config/axios';
|
||||
import { httpGet, httpPost } from '@/api/common';
|
||||
|
||||
/**
|
||||
* Add a new point
|
||||
*
|
||||
* @param point Point object
|
||||
* @returns MyAxiosPromise
|
||||
*/
|
||||
export const pointAddApi = (point: any) =>
|
||||
request<R>({
|
||||
url: `api/v3/manager/point/add`,
|
||||
method: 'post',
|
||||
data: point,
|
||||
});
|
||||
export const pointAddApi = (point: any) => httpPost('api/v3/manager/point/add', point);
|
||||
|
||||
/**
|
||||
* Delete a point
|
||||
*
|
||||
* @param id Point ID
|
||||
* @returns MyAxiosPromise
|
||||
*/
|
||||
export const pointDeleteApi = (id: string) =>
|
||||
request<R>({
|
||||
url: `api/v3/manager/point/delete/${id}`,
|
||||
method: 'post',
|
||||
});
|
||||
export const pointDeleteApi = (id: string) => httpPost(`api/v3/manager/point/delete/${id}`);
|
||||
|
||||
/**
|
||||
* Update a point
|
||||
*
|
||||
* @param point Point object
|
||||
* @returns MyAxiosPromise
|
||||
*/
|
||||
export const getPointUpdate = (point: any) =>
|
||||
request<R>({
|
||||
url: `api/v3/manager/point/update`,
|
||||
method: 'post',
|
||||
data: point,
|
||||
});
|
||||
export const getPointUpdate = (point: any) => httpPost('api/v3/manager/point/update', point);
|
||||
|
||||
/**
|
||||
* Get point by ID
|
||||
*
|
||||
* @param id Point ID
|
||||
* @returns MyAxiosPromise
|
||||
*/
|
||||
export const getPointById = (id: string) =>
|
||||
request<R>({
|
||||
url: `api/v3/manager/point/id/${id}`,
|
||||
method: 'get',
|
||||
});
|
||||
export const getPointById = (id: string) => httpGet(`api/v3/manager/point/id/${id}`);
|
||||
|
||||
/**
|
||||
* Get points by IDs
|
||||
*
|
||||
* @param pointIds Point ID array
|
||||
* @returns MyAxiosPromise
|
||||
*/
|
||||
export const getPointByIds = (pointIds: any) =>
|
||||
request<R>({
|
||||
url: `api/v3/manager/point/ids`,
|
||||
method: 'post',
|
||||
data: pointIds,
|
||||
});
|
||||
export const getPointByIds = (pointIds: any) => httpPost('api/v3/manager/point/ids', pointIds);
|
||||
|
||||
/**
|
||||
* Get point list with pagination and fuzzy search
|
||||
*
|
||||
* @param point Point query parameters
|
||||
* @returns MyAxiosPromise
|
||||
*/
|
||||
export const getPointList = (point: any) =>
|
||||
request<R>({
|
||||
url: `api/v3/manager/point/list`,
|
||||
method: 'post',
|
||||
data: point,
|
||||
});
|
||||
export const getPointList = (point: any) => httpPost('api/v3/manager/point/list', point);
|
||||
|
||||
/**
|
||||
* Get point units by point IDs
|
||||
*
|
||||
* @param pointIds Point ID array
|
||||
* @returns MyAxiosPromise
|
||||
*/
|
||||
export const getPointUnit = (pointIds: any) =>
|
||||
request<R>({
|
||||
url: `api/v3/manager/point/unit`,
|
||||
method: 'post',
|
||||
data: pointIds,
|
||||
});
|
||||
export const getPointUnit = (pointIds: any) => httpPost('api/v3/manager/point/unit', pointIds);
|
||||
|
||||
/**
|
||||
* Get points by profile ID
|
||||
*
|
||||
* @param profileId Profile ID
|
||||
* @returns MyAxiosPromise
|
||||
*/
|
||||
export const getPointByProfileId = (profileId: string) =>
|
||||
request<R>({
|
||||
url: `api/v3/manager/point/profile_id/${profileId}`,
|
||||
method: 'get',
|
||||
});
|
||||
export const getPointByProfileId = (profileId: string) => httpGet(`api/v3/manager/point/profile_id/${profileId}`);
|
||||
|
||||
/**
|
||||
* Get points by device ID
|
||||
*
|
||||
* @param deviceId Device ID
|
||||
* @returns MyAxiosPromise
|
||||
*/
|
||||
export const getPointByDeviceId = (deviceId: string) =>
|
||||
request<R>({
|
||||
url: `api/v3/manager/point/device_id/${deviceId}`,
|
||||
method: 'get',
|
||||
});
|
||||
export const getPointByDeviceId = (deviceId: string) => httpGet(`api/v3/manager/point/device_id/${deviceId}`);
|
||||
|
||||
/**
|
||||
* Get latest point values with pagination
|
||||
*
|
||||
* @param pointValue Point value query parameters
|
||||
* @returns MyAxiosPromise
|
||||
*/
|
||||
export const getPointValueLatest = (pointValue: any) =>
|
||||
request<R>({
|
||||
url: `api/v3/data/point_value/latest`,
|
||||
method: 'post',
|
||||
data: pointValue,
|
||||
});
|
||||
export const getPointValueLatest = (pointValue: any) => httpPost('api/v3/data/point_value/latest', pointValue);
|
||||
|
||||
/**
|
||||
* Get point values with pagination
|
||||
*
|
||||
* @param pointValue Point value query parameters
|
||||
* @returns MyAxiosPromise
|
||||
*/
|
||||
export const getPointValueList = (pointValue: any) =>
|
||||
request<R>({
|
||||
url: `api/v3/data/point_value/list`,
|
||||
method: 'post',
|
||||
data: pointValue,
|
||||
});
|
||||
export const getPointValueList = (pointValue: any) => httpPost('api/v3/data/point_value/list', pointValue);
|
||||
|
||||
/**
|
||||
* Get point value history
|
||||
*
|
||||
* @param deviceId Device ID
|
||||
* @param pointId Point ID
|
||||
* @param count Number of records to retrieve
|
||||
* @returns MyAxiosPromise
|
||||
*/
|
||||
export const getPointValueHistory = (deviceId: number, pointId: number, count: number = 100) =>
|
||||
request<R>({
|
||||
url: `api/v3/data/point_value/history/device_id/${deviceId}/point_id/${pointId}`,
|
||||
method: 'get',
|
||||
params: {
|
||||
count,
|
||||
},
|
||||
httpGet(`api/v3/data/point_value/history/device_id/${deviceId}/point_id/${pointId}`, {
|
||||
params: { count },
|
||||
});
|
||||
|
||||
/**
|
||||
* Read point value
|
||||
*
|
||||
* @param pointValueReadVO Point value read object
|
||||
* @returns MyAxiosPromise
|
||||
*/
|
||||
export const readPointValue = (pointValueReadVO: any) =>
|
||||
request<R>({
|
||||
url: `api/v3/data/point_value_command/read`,
|
||||
method: 'post',
|
||||
data: pointValueReadVO,
|
||||
});
|
||||
httpPost('api/v3/data/point_value_command/read', pointValueReadVO);
|
||||
|
||||
/**
|
||||
* Write point value
|
||||
*
|
||||
* @param pointValueWriteVO Point value write object
|
||||
* @returns MyAxiosPromise
|
||||
*/
|
||||
export const writePointValue = (pointValueWriteVO: any) =>
|
||||
request<R>({
|
||||
url: `api/v3/data/point_value_command/write`,
|
||||
method: 'post',
|
||||
data: pointValueWriteVO,
|
||||
});
|
||||
httpPost('api/v3/data/point_value_command/write', pointValueWriteVO);
|
||||
|
||||
+8
-82
@@ -14,92 +14,18 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import request from '@/config/axios';
|
||||
import { httpGet, httpPost } from '@/api/common';
|
||||
|
||||
/**
|
||||
* Add a new profile
|
||||
*
|
||||
* @param profile Profile object
|
||||
* @returns MyAxiosPromise
|
||||
*/
|
||||
export const addProfile = (profile: any) =>
|
||||
request<R>({
|
||||
url: `api/v3/manager/profile/add`,
|
||||
method: 'post',
|
||||
data: profile,
|
||||
});
|
||||
export const addProfile = (profile: any) => httpPost('api/v3/manager/profile/add', profile);
|
||||
|
||||
/**
|
||||
* Delete a profile
|
||||
*
|
||||
* @param id Profile ID
|
||||
* @returns MyAxiosPromise
|
||||
*/
|
||||
export const deleteProfile = (id: string) =>
|
||||
request<R>({
|
||||
url: `api/v3/manager/profile/delete/${id}`,
|
||||
method: 'post',
|
||||
});
|
||||
export const deleteProfile = (id: string) => httpPost(`api/v3/manager/profile/delete/${id}`);
|
||||
|
||||
/**
|
||||
* Update a profile
|
||||
*
|
||||
* @param profile Profile object
|
||||
* @returns MyAxiosPromise
|
||||
*/
|
||||
export const updateProfile = (profile: any) =>
|
||||
request<R>({
|
||||
url: `api/v3/manager/profile/update`,
|
||||
method: 'post',
|
||||
data: profile,
|
||||
});
|
||||
export const updateProfile = (profile: any) => httpPost('api/v3/manager/profile/update', profile);
|
||||
|
||||
/**
|
||||
* Get profile by ID
|
||||
*
|
||||
* @param id Profile ID
|
||||
* @returns MyAxiosPromise
|
||||
*/
|
||||
export const getProfileById = (id: string) =>
|
||||
request<R>({
|
||||
url: `api/v3/manager/profile/id/${id}`,
|
||||
method: 'get',
|
||||
});
|
||||
export const getProfileById = (id: string) => httpGet(`api/v3/manager/profile/id/${id}`);
|
||||
|
||||
/**
|
||||
* Get profiles by IDs
|
||||
*
|
||||
* @param profileIds Profile ID array
|
||||
* @returns MyAxiosPromise
|
||||
*/
|
||||
export const getProfileByIds = (profileIds: any) =>
|
||||
request<R>({
|
||||
url: `api/v3/manager/profile/ids`,
|
||||
method: 'post',
|
||||
data: profileIds,
|
||||
});
|
||||
export const getProfileByIds = (profileIds: any) => httpPost('api/v3/manager/profile/ids', profileIds);
|
||||
|
||||
/**
|
||||
* Get profile by device ID
|
||||
*
|
||||
* @param deviceId Device ID
|
||||
* @returns MyAxiosPromise
|
||||
*/
|
||||
export const getProfileByDeviceId = (deviceId: string) =>
|
||||
request<R>({
|
||||
url: `api/v3/manager/profile/device_id/${deviceId}`,
|
||||
method: 'get',
|
||||
});
|
||||
export const getProfileByDeviceId = (deviceId: string) => httpGet(`api/v3/manager/profile/device_id/${deviceId}`);
|
||||
|
||||
/**
|
||||
* Get profile list with pagination
|
||||
*
|
||||
* @param profile Profile query parameters
|
||||
* @returns MyAxiosPromise
|
||||
*/
|
||||
export const getProfileList = (profile: any) =>
|
||||
request<R>({
|
||||
url: `api/v3/manager/profile/list`,
|
||||
method: 'post',
|
||||
data: profile,
|
||||
});
|
||||
export const getProfileList = (profile: any) => httpPost('api/v3/manager/profile/list', profile);
|
||||
|
||||
+2
-13
@@ -14,17 +14,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import request from '@/config/axios';
|
||||
import { httpPost } from '@/api/common';
|
||||
|
||||
/**
|
||||
* Get flows list
|
||||
*
|
||||
* @param flowsQuery Flows query parameters
|
||||
* @returns MyAxiosPromise
|
||||
*/
|
||||
export const getFlowsList = (flowsQuery: any) =>
|
||||
request<R>({
|
||||
url: 'api/v3/manager/ruleengine/flowsList',
|
||||
method: 'post',
|
||||
data: flowsQuery,
|
||||
});
|
||||
export const getFlowsList = (flowsQuery: any) => httpPost('api/v3/manager/ruleengine/flowsList', flowsQuery);
|
||||
|
||||
+5
-49
@@ -14,57 +14,13 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import request from '@/config/axios';
|
||||
import { httpPost } from '@/api/common';
|
||||
import type { Login } from '@/config/entity';
|
||||
|
||||
/**
|
||||
* Generate salt for password encryption
|
||||
*
|
||||
* @param login Login object
|
||||
* @returns MyAxiosPromise
|
||||
*/
|
||||
export const generateSalt = (login: Login) =>
|
||||
request<R>({
|
||||
url: `api/v3/auth/token/salt`,
|
||||
method: 'post',
|
||||
data: login,
|
||||
});
|
||||
export const generateSalt = (login: Login) => httpPost('api/v3/auth/token/salt', login);
|
||||
|
||||
/**
|
||||
* Generate authentication token (login)
|
||||
*
|
||||
* @param login Login object
|
||||
* @returns MyAxiosPromise
|
||||
*/
|
||||
export const generateToken = (login: Login) =>
|
||||
request<R>({
|
||||
url: `api/v3/auth/token/generate`,
|
||||
method: 'post',
|
||||
data: login,
|
||||
});
|
||||
export const generateToken = (login: Login) => httpPost('api/v3/auth/token/generate', login);
|
||||
|
||||
/**
|
||||
* Cancel authentication token (logout)
|
||||
*
|
||||
* @param login Login object
|
||||
* @returns MyAxiosPromise
|
||||
*/
|
||||
export const cancelToken = (login: Login) =>
|
||||
request<R>({
|
||||
url: `api/v3/auth/token/cancel`,
|
||||
method: 'post',
|
||||
data: login,
|
||||
});
|
||||
export const cancelToken = (login: Login) => httpPost('api/v3/auth/token/cancel', login);
|
||||
|
||||
/**
|
||||
* Check if token is valid
|
||||
*
|
||||
* @param login Login object
|
||||
* @returns MyAxiosPromise
|
||||
*/
|
||||
export const checkTokenValid = (login: Login) =>
|
||||
request<R>({
|
||||
url: `api/v3/auth/token/check`,
|
||||
method: 'post',
|
||||
data: login,
|
||||
});
|
||||
export const checkTokenValid = (login: Login) => httpPost('api/v3/auth/token/check', login);
|
||||
|
||||
@@ -134,7 +134,9 @@ request.interceptors.response.use(
|
||||
} else {
|
||||
failMessage(ERROR_MESSAGES.REQUEST_ERROR, response.data.code, response.data);
|
||||
}
|
||||
return Promise.reject();
|
||||
// Reject with the server payload so callers can inspect code/message if needed.
|
||||
// Existing no-op `.catch(() => {})` sites remain valid because they ignore the argument.
|
||||
return Promise.reject(response.data ?? { status, message: 'Request failed' });
|
||||
},
|
||||
(error: AxiosError) => {
|
||||
return Promise.reject(error);
|
||||
|
||||
Reference in New Issue
Block a user