From a1d7e81859f554f3a53680cc35f0f49bf1f77098 Mon Sep 17 00:00:00 2001
From: wwf <1971391498@qq.com>
Date: 星期四, 14 五月 2026 14:37:02 +0800
Subject: [PATCH] 导入项目
---
src/api/iot/device/device/index.ts | 165 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 165 insertions(+), 0 deletions(-)
diff --git a/src/api/iot/device/device/index.ts b/src/api/iot/device/device/index.ts
new file mode 100644
index 0000000..2311a9a
--- /dev/null
+++ b/src/api/iot/device/device/index.ts
@@ -0,0 +1,165 @@
+import request from '@/config/axios'
+
+// IoT 璁惧 VO
+export interface DeviceVO {
+ id: number // 璁惧 ID锛屼富閿紝鑷
+ deviceName: string // 璁惧鍚嶇О
+ productId: number // 浜у搧缂栧彿
+ productKey: string // 浜у搧鏍囪瘑
+ deviceType: number // 璁惧绫诲瀷
+ nickname: string // 璁惧澶囨敞鍚嶇О
+ gatewayId: number // 缃戝叧璁惧 ID
+ state: number // 璁惧鐘舵��
+ onlineTime: Date // 鏈�鍚庝笂绾挎椂闂�
+ offlineTime: Date // 鏈�鍚庣绾挎椂闂�
+ activeTime: Date // 璁惧婵�娲绘椂闂�
+ createTime: Date // 鍒涘缓鏃堕棿
+ ip: string // 璁惧鐨� IP 鍦板潃
+ firmwareVersion: string // 璁惧鐨勫浐浠剁増鏈�
+ deviceSecret: string // 璁惧瀵嗛挜锛岀敤浜庤澶囪璇侊紝闇�瀹夊叏瀛樺偍
+ mqttClientId: string // MQTT 瀹㈡埛绔� ID
+ mqttUsername: string // MQTT 鐢ㄦ埛鍚�
+ mqttPassword: string // MQTT 瀵嗙爜
+ authType: string // 璁よ瘉绫诲瀷
+ locationType: number // 瀹氫綅绫诲瀷
+ latitude?: number // 璁惧浣嶇疆鐨勭含搴�
+ longitude?: number // 璁惧浣嶇疆鐨勭粡搴�
+ areaId: number // 鍦板尯缂栫爜
+ address: string // 璁惧璇︾粏鍦板潃
+ serialNumber: string // 璁惧搴忓垪鍙�
+ config: string // 璁惧閰嶇疆
+ groupIds?: number[] // 娣诲姞鍒嗙粍 ID
+}
+
+// IoT 璁惧灞炴�ц缁� VO
+export interface IotDevicePropertyDetailRespVO {
+ identifier: string // 灞炴�ф爣璇嗙
+ value: string // 鏈�鏂板��
+ updateTime: Date // 鏇存柊鏃堕棿
+ name: string // 灞炴�у悕绉�
+ dataType: string // 鏁版嵁绫诲瀷
+ dataSpecs: any // 鏁版嵁瀹氫箟
+ dataSpecsList: any[] // 鏁版嵁瀹氫箟鍒楄〃
+}
+
+// IoT 璁惧灞炴�� VO
+export interface IotDevicePropertyRespVO {
+ identifier: string // 灞炴�ф爣璇嗙
+ value: string // 鏈�鏂板��
+ updateTime: Date // 鏇存柊鏃堕棿
+}
+
+// TODO @鑺嬭壙锛氳皟鏁村埌 constants
+// IoT 璁惧鐘舵�佹灇涓�
+export enum DeviceStateEnum {
+ INACTIVE = 0, // 鏈縺娲�
+ ONLINE = 1, // 鍦ㄧ嚎
+ OFFLINE = 2 // 绂荤嚎
+}
+
+// 璁惧璁よ瘉鍙傛暟 VO
+export interface IotDeviceAuthInfoVO {
+ clientId: string // 瀹㈡埛绔� ID
+ username: string // 鐢ㄦ埛鍚�
+ password: string // 瀵嗙爜
+}
+
+// IoT 璁惧鍙戦�佹秷鎭� Request VO
+export interface IotDeviceMessageSendReqVO {
+ deviceId: number // 璁惧缂栧彿
+ method: string // 璇锋眰鏂规硶
+ params?: any // 璇锋眰鍙傛暟
+}
+
+// 璁惧 API
+export const DeviceApi = {
+ // 鏌ヨ璁惧鍒嗛〉
+ getDevicePage: async (params: any) => {
+ return await request.get({ url: `/iot/device/page`, params })
+ },
+
+ // 鏌ヨ璁惧璇︽儏
+ getDevice: async (id: number) => {
+ return await request.get({ url: `/iot/device/get?id=` + id })
+ },
+
+ // 鏂板璁惧
+ createDevice: async (data: DeviceVO) => {
+ return await request.post({ url: `/iot/device/create`, data })
+ },
+
+ // 淇敼璁惧
+ updateDevice: async (data: DeviceVO) => {
+ return await request.put({ url: `/iot/device/update`, data })
+ },
+
+ // 淇敼璁惧鍒嗙粍
+ updateDeviceGroup: async (data: { ids: number[]; groupIds: number[] }) => {
+ return await request.put({ url: `/iot/device/update-group`, data })
+ },
+
+ // 鍒犻櫎鍗曚釜璁惧
+ deleteDevice: async (id: number) => {
+ return await request.delete({ url: `/iot/device/delete?id=` + id })
+ },
+
+ // 鍒犻櫎澶氫釜璁惧
+ deleteDeviceList: async (ids: number[]) => {
+ return await request.delete({ url: `/iot/device/delete-list`, params: { ids: ids.join(',') } })
+ },
+
+ // 瀵煎嚭璁惧
+ exportDeviceExcel: async (params: any) => {
+ return await request.download({ url: `/iot/device/export-excel`, params })
+ },
+
+ // 鑾峰彇璁惧鏁伴噺
+ getDeviceCount: async (productId: number) => {
+ return await request.get({ url: `/iot/device/count?productId=` + productId })
+ },
+
+ // 鑾峰彇璁惧鐨勭簿绠�淇℃伅鍒楄〃
+ getSimpleDeviceList: async (deviceType?: number, productId?: number) => {
+ return await request.get({ url: `/iot/device/simple-list?`, params: { deviceType, productId } })
+ },
+
+ // 鏍规嵁浜у搧缂栧彿锛岃幏鍙栬澶囩殑绮剧畝淇℃伅鍒楄〃
+ getDeviceListByProductId: async (productId: number) => {
+ return await request.get({ url: `/iot/device/simple-list?`, params: { productId } })
+ },
+
+ // 鑾峰彇瀵煎叆妯℃澘
+ importDeviceTemplate: async () => {
+ return await request.download({ url: `/iot/device/get-import-template` })
+ },
+
+ // 鑾峰彇璁惧灞炴�ф渶鏂版暟鎹�
+ getLatestDeviceProperties: async (params: any) => {
+ return await request.get({ url: `/iot/device/property/get-latest`, params })
+ },
+
+ // 鑾峰彇璁惧灞炴�у巻鍙叉暟鎹�
+ getHistoryDevicePropertyList: async (params: any) => {
+ return await request.get({ url: `/iot/device/property/history-list`, params })
+ },
+
+ // 鑾峰彇璁惧璁よ瘉淇℃伅
+ getDeviceAuthInfo: async (id: number) => {
+ return await request.get({ url: `/iot/device/get-auth-info`, params: { id } })
+ },
+
+ // 鏌ヨ璁惧娑堟伅鍒嗛〉
+ getDeviceMessagePage: async (params: any) => {
+ return await request.get({ url: `/iot/device/message/page`, params })
+ },
+
+ // 鏌ヨ璁惧娑堟伅閰嶅鍒嗛〉
+ getDeviceMessagePairPage: async (params: any) => {
+ return await request.get({ url: `/iot/device/message/pair-page`, params })
+ },
+
+ // 鍙戦�佽澶囨秷鎭�
+ sendDeviceMessage: async (params: IotDeviceMessageSendReqVO) => {
+ return await request.post({ url: `/iot/device/message/send`, data: params })
+ }
+}
--
Gitblit v1.8.0