【代码评审】IoT:产品、设备、物模型的代码

This commit is contained in:
YunaiV
2024-10-01 19:29:24 +08:00
parent 4b2800f723
commit 6d641177b8
15 changed files with 114 additions and 149 deletions

View File

@ -1,16 +1,16 @@
import request from '@/config/axios'
// 设备 VO
// IoT 设备 VO
export interface DeviceVO {
id: number // 设备 ID主键自增
deviceKey: string // 设备唯一标识符,全局唯一,用于识别设备
deviceName: string // 设备名称,在产品内唯一,用于标识设备
productId: number // 产品 ID关联 iot_product 表的 id
productKey: string // 产品 Key关联 iot_product 表的 product_key
deviceType: number // 设备类型0 - 直连设备1 - 网关子设备2 - 网关设备
nickname: string // 设备备注名称,供用户自定义备注
gatewayId: number // 网关设备 ID,子设备需要关联的网关设备 ID
status: number // 设备状态0 - 未激活1 - 在线2 - 离线3 - 已禁用
deviceKey: string // 设备唯一标识符
deviceName: string // 设备名称
productId: number // 产品编号
productKey: string // 产品标识
deviceType: number // 设备类型
nickname: string // 设备备注名称
gatewayId: number // 网关设备 ID
status: number // 设备状态
statusLastUpdateTime: Date // 设备状态最后更新时间
lastOnlineTime: Date // 最后上线时间
lastOfflineTime: Date // 最后离线时间
@ -22,17 +22,17 @@ export interface DeviceVO {
mqttClientId: string // MQTT 客户端 ID
mqttUsername: string // MQTT 用户名
mqttPassword: string // MQTT 密码
authType: string // 认证类型(如一机一密、动态注册)
latitude: number // 设备位置的纬度,范围 -90.000000 ~ 90.000000
longitude: number // 设备位置的经度,范围 -180.000000 ~ 180.000000
areaId: number // 地区编码,符合国家地区编码标准,关联地区表
authType: string // 认证类型
latitude: number // 设备位置的纬度
longitude: number // 设备位置的经度
areaId: number // 地区编码
address: string // 设备详细地址
serialNumber: string // 设备序列号
}
export interface DeviceUpdateStatusVO {
id: number // 设备 ID主键自增
status: number // 设备状态0 - 未激活1 - 在线2 - 离线3 - 已禁用
status: number // 设备状态
}
// 设备 API

View File

@ -1,50 +1,51 @@
import request from '@/config/axios'
// iot 产品 VO
// IoT 产品 VO
export interface ProductVO {
id: number // 产品编号
name: string // 产品名称
id: number // 产品ID
productKey: string // 产品标识
protocolId: number // 协议编号(脚本解析 id
protocolId: number // 协议编号
categoryId: number // 产品所属品类标识符
description: string // 产品描述
validateType: number // 数据校验级别, 0: 强校验, 1: 弱校验, 2: 免校验
status: number // 产品状态, 0: DEVELOPMENT_STATUS, 1: RELEASE_STATUS
deviceType: number // 设备类型, 0: 直连设备, 1: 网关子设备, 2: 网关设备
netType: number // 联网方式, 0: Wi-Fi, 1: Cellular, 2: Ethernet, 3: 其他
protocolType: number // 接入网关协议, 0: modbus, 1: opc-ua, 2: customize, 3: ble, 4: zigbee
dataFormat: number // 数据格式, 0: 透传模式, 1: Alink JSON
validateType: number // 数据校验级别
status: number // 产品状态
deviceType: number // 设备类型
netType: number // 联网方式
protocolType: number // 接入网关协议
dataFormat: number // 数据格式
deviceCount: number // 设备数量
createTime: Date // 创建时间
}
// iot 产品 API
// IoT 产品 API
export const ProductApi = {
// 查询iot 产品分页
// 查询产品分页
getProductPage: async (params: any) => {
return await request.get({ url: `/iot/product/page`, params })
},
// 查询iot 产品详情
// 查询产品详情
getProduct: async (id: number) => {
return await request.get({ url: `/iot/product/get?id=` + id })
},
// 新增iot 产品
// 新增产品
createProduct: async (data: ProductVO) => {
return await request.post({ url: `/iot/product/create`, data })
},
// 修改iot 产品
// 修改产品
updateProduct: async (data: ProductVO) => {
return await request.put({ url: `/iot/product/update`, data })
},
// 删除iot 产品
// 删除产品
deleteProduct: async (id: number) => {
return await request.delete({ url: `/iot/product/delete?id=` + id })
},
// 导出iot 产品 Excel
// 导出产品 Excel
exportProduct: async (params) => {
return await request.download({ url: `/iot/product/export-excel`, params })
},
@ -54,7 +55,7 @@ export const ProductApi = {
return await request.put({ url: `/iot/product/update-status?id=` + id + `&status=` + status })
},
// 查询产品(精简)列表
// 查询产品(精简列表
getSimpleProductList() {
return request.get({ url: '/iot/product/list-all-simple' })
}

View File

@ -6,21 +6,21 @@ export interface ThinkModelFunctionVO {
identifier: string // 功能标识
name: string // 功能名称
description: string // 功能描述
productId: number // 产品ID关联 IotProductDO 的 id
productKey: string // 产品Key关联 IotProductDO 的 productKey
type: number // 功能类型1 - 属性2 - 服务3 - 事件)
property: string // 属性(存储 ThingModelProperty 的 JSON 数据)
event: string // 事件(存储 ThingModelEvent 的 JSON 数据)
service: string // 服务(存储服务的 JSON 数据)
productId: number // 产品编号
productKey: string // 产品标识
type: number // 功能类型
property: string // 属性
event: string // 事件
service: string // 服务
}
// IoT 产品物模型 API
export const ThinkModelFunctionApi = {
// 查询IoT 产品物模型分页
// 查询产品物模型分页
getThinkModelFunctionPage: async (params: any) => {
return await request.get({ url: `/iot/think-model-function/page`, params })
},
// 获得IoT 产品物模型
// 获得产品物模型
getThinkModelFunctionListByProductId: async (params: any) => {
return await request.get({
url: `/iot/think-model-function/list-by-product-id`,
@ -28,27 +28,27 @@ export const ThinkModelFunctionApi = {
})
},
// 查询IoT 产品物模型详情
// 查询产品物模型详情
getThinkModelFunction: async (id: number) => {
return await request.get({ url: `/iot/think-model-function/get?id=` + id })
},
// 新增IoT 产品物模型
// 新增产品物模型
createThinkModelFunction: async (data: ThinkModelFunctionVO) => {
return await request.post({ url: `/iot/think-model-function/create`, data })
},
// 修改IoT 产品物模型
// 修改产品物模型
updateThinkModelFunction: async (data: ThinkModelFunctionVO) => {
return await request.put({ url: `/iot/think-model-function/update`, data })
},
// 删除IoT 产品物模型
// 删除产品物模型
deleteThinkModelFunction: async (id: number) => {
return await request.delete({ url: `/iot/think-model-function/delete?id=` + id })
},
// 导出IoT 产品物模型 Excel
// 导出产品物模型 Excel
exportThinkModelFunction: async (params) => {
return await request.download({ url: `/iot/think-model-function/export-excel`, params })
}