feat: 增加后台模块
This commit is contained in:
46
yudao-ui-admin-vue3/src/api/iot/alert/config/index.ts
Normal file
46
yudao-ui-admin-vue3/src/api/iot/alert/config/index.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
import request from '@/config/axios'
|
||||
|
||||
/** IoT 告警配置信息 */
|
||||
export interface AlertConfig {
|
||||
id: number // 配置编号
|
||||
name?: string // 配置名称
|
||||
description: string // 配置描述
|
||||
level?: number // 告警级别
|
||||
status?: number // 配置状态
|
||||
sceneRuleIds: string // 关联的场景联动规则编号数组
|
||||
receiveUserIds: string // 接收的用户编号数组
|
||||
receiveTypes: string // 接收的类型数组
|
||||
}
|
||||
|
||||
// IoT 告警配置 API
|
||||
export const AlertConfigApi = {
|
||||
// 查询告警配置分页
|
||||
getAlertConfigPage: async (params: any) => {
|
||||
return await request.get({ url: `/iot/alert-config/page`, params })
|
||||
},
|
||||
|
||||
// 查询告警配置详情
|
||||
getAlertConfig: async (id: number) => {
|
||||
return await request.get({ url: `/iot/alert-config/get?id=` + id })
|
||||
},
|
||||
|
||||
// 新增告警配置
|
||||
createAlertConfig: async (data: AlertConfig) => {
|
||||
return await request.post({ url: `/iot/alert-config/create`, data })
|
||||
},
|
||||
|
||||
// 修改告警配置
|
||||
updateAlertConfig: async (data: AlertConfig) => {
|
||||
return await request.put({ url: `/iot/alert-config/update`, data })
|
||||
},
|
||||
|
||||
// 删除告警配置
|
||||
deleteAlertConfig: async (id: number) => {
|
||||
return await request.delete({ url: `/iot/alert-config/delete?id=` + id })
|
||||
},
|
||||
|
||||
// 获取告警配置简单列表
|
||||
getSimpleAlertConfigList: async () => {
|
||||
return await request.get({ url: `/iot/alert-config/simple-list` })
|
||||
}
|
||||
}
|
||||
35
yudao-ui-admin-vue3/src/api/iot/alert/record/index.ts
Normal file
35
yudao-ui-admin-vue3/src/api/iot/alert/record/index.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import request from '@/config/axios'
|
||||
|
||||
/** IoT 告警记录信息 */
|
||||
export interface AlertRecord {
|
||||
id: number // 记录编号
|
||||
configId: number // 告警配置编号
|
||||
configName: string // 告警名称
|
||||
configLevel: number // 告警级别
|
||||
productId: number // 产品编号
|
||||
deviceId: number // 设备编号
|
||||
deviceMessage: any // 触发的设备消息
|
||||
processStatus?: boolean // 是否处理
|
||||
processRemark: string // 处理结果(备注)
|
||||
}
|
||||
|
||||
// IoT 告警记录 API
|
||||
export const AlertRecordApi = {
|
||||
// 查询告警记录分页
|
||||
getAlertRecordPage: async (params: any) => {
|
||||
return await request.get({ url: `/iot/alert-record/page`, params })
|
||||
},
|
||||
|
||||
// 查询告警记录详情
|
||||
getAlertRecord: async (id: number) => {
|
||||
return await request.get({ url: `/iot/alert-record/get?id=` + id })
|
||||
},
|
||||
|
||||
// 处理告警记录
|
||||
processAlertRecord: async (id: number, processRemark: string) => {
|
||||
return await request.put({
|
||||
url: `/iot/alert-record/process`,
|
||||
data: { id, processRemark }
|
||||
})
|
||||
}
|
||||
}
|
||||
184
yudao-ui-admin-vue3/src/api/iot/device/device/index.ts
Normal file
184
yudao-ui-admin-vue3/src/api/iot/device/device/index.ts
Normal file
@@ -0,0 +1,184 @@
|
||||
import request from '@/config/axios'
|
||||
|
||||
// IoT 设备 VO
|
||||
export interface DeviceVO {
|
||||
id: number // 设备 ID,主键,自增
|
||||
deviceName: string // 设备名称
|
||||
productId: number // 产品编号
|
||||
productName?: string // 产品名称(只有部分接口返回,例如 getDeviceLocationList)
|
||||
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 密码
|
||||
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 // 更新时间
|
||||
}
|
||||
|
||||
// 设备认证参数 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 } })
|
||||
},
|
||||
|
||||
// 获取设备位置列表(用于地图展示)
|
||||
getDeviceLocationList: async () => {
|
||||
return await request.get<DeviceVO[]>({ url: `/iot/device/location-list` })
|
||||
},
|
||||
|
||||
// 根据产品编号,获取设备的精简信息列表
|
||||
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 })
|
||||
},
|
||||
|
||||
// 绑定子设备到网关
|
||||
bindDeviceGateway: async (data: { subIds: number[]; gatewayId: number }) => {
|
||||
return await request.put({ url: `/iot/device/bind-gateway`, data })
|
||||
},
|
||||
|
||||
// 解绑子设备与网关
|
||||
unbindDeviceGateway: async (data: { subIds: number[]; gatewayId: number }) => {
|
||||
return await request.put({ url: `/iot/device/unbind-gateway`, data })
|
||||
},
|
||||
|
||||
// 获取网关的子设备列表
|
||||
getSubDeviceList: async (gatewayId: number) => {
|
||||
return await request.get<DeviceVO[]>({
|
||||
url: `/iot/device/sub-device-list`,
|
||||
params: { gatewayId }
|
||||
})
|
||||
},
|
||||
|
||||
// 获取未绑定网关的子设备分页
|
||||
getUnboundSubDevicePage: async (params: any) => {
|
||||
return await request.get({ url: `/iot/device/unbound-sub-device-page`, params })
|
||||
}
|
||||
}
|
||||
43
yudao-ui-admin-vue3/src/api/iot/device/group/index.ts
Normal file
43
yudao-ui-admin-vue3/src/api/iot/device/group/index.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
import request from '@/config/axios'
|
||||
|
||||
// IoT 设备分组 VO
|
||||
export interface DeviceGroupVO {
|
||||
id: number // 分组 ID
|
||||
name: string // 分组名字
|
||||
status: number // 分组状态
|
||||
description: string // 分组描述
|
||||
deviceCount?: number // 设备数量
|
||||
}
|
||||
|
||||
// IoT 设备分组 API
|
||||
export const DeviceGroupApi = {
|
||||
// 查询设备分组分页
|
||||
getDeviceGroupPage: async (params: any) => {
|
||||
return await request.get({ url: `/iot/device-group/page`, params })
|
||||
},
|
||||
|
||||
// 查询设备分组详情
|
||||
getDeviceGroup: async (id: number) => {
|
||||
return await request.get({ url: `/iot/device-group/get?id=` + id })
|
||||
},
|
||||
|
||||
// 新增设备分组
|
||||
createDeviceGroup: async (data: DeviceGroupVO) => {
|
||||
return await request.post({ url: `/iot/device-group/create`, data })
|
||||
},
|
||||
|
||||
// 修改设备分组
|
||||
updateDeviceGroup: async (data: DeviceGroupVO) => {
|
||||
return await request.put({ url: `/iot/device-group/update`, data })
|
||||
},
|
||||
|
||||
// 删除设备分组
|
||||
deleteDeviceGroup: async (id: number) => {
|
||||
return await request.delete({ url: `/iot/device-group/delete?id=` + id })
|
||||
},
|
||||
|
||||
// 获取设备分组的精简信息列表
|
||||
getSimpleDeviceGroupList: async () => {
|
||||
return await request.get({ url: `/iot/device-group/simple-list` })
|
||||
}
|
||||
}
|
||||
44
yudao-ui-admin-vue3/src/api/iot/ota/firmware/index.ts
Normal file
44
yudao-ui-admin-vue3/src/api/iot/ota/firmware/index.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
import request from '@/config/axios'
|
||||
|
||||
/** IoT OTA 固件信息 */
|
||||
export interface IoTOtaFirmware {
|
||||
id?: number // 固件编号
|
||||
name?: string // 固件名称
|
||||
description?: string // 固件描述
|
||||
version?: string // 版本号
|
||||
productId?: number // 产品编号
|
||||
productName?: string // 产品名称
|
||||
fileUrl?: string // 固件文件 URL
|
||||
fileSize?: number // 固件文件大小
|
||||
fileDigestAlgorithm?: string // 固件文件签名算法
|
||||
fileDigestValue?: string // 固件文件签名结果
|
||||
createTime?: Date // 创建时间
|
||||
}
|
||||
|
||||
// IoT OTA 固件 API
|
||||
export const IoTOtaFirmwareApi = {
|
||||
// 查询 OTA 固件分页
|
||||
getOtaFirmwarePage: async (params: any) => {
|
||||
return await request.get({ url: `/iot/ota/firmware/page`, params })
|
||||
},
|
||||
|
||||
// 查询 OTA 固件详情
|
||||
getOtaFirmware: async (id: number) => {
|
||||
return await request.get({ url: `/iot/ota/firmware/get?id=` + id })
|
||||
},
|
||||
|
||||
// 新增 OTA 固件
|
||||
createOtaFirmware: async (data: IoTOtaFirmware) => {
|
||||
return await request.post({ url: `/iot/ota/firmware/create`, data })
|
||||
},
|
||||
|
||||
// 修改 OTA 固件
|
||||
updateOtaFirmware: async (data: IoTOtaFirmware) => {
|
||||
return await request.put({ url: `/iot/ota/firmware/update`, data })
|
||||
},
|
||||
|
||||
// 删除 OTA 固件
|
||||
deleteOtaFirmware: async (id: number) => {
|
||||
return await request.delete({ url: `/iot/ota/firmware/delete?id=` + id })
|
||||
}
|
||||
}
|
||||
38
yudao-ui-admin-vue3/src/api/iot/ota/task/index.ts
Normal file
38
yudao-ui-admin-vue3/src/api/iot/ota/task/index.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import request from '@/config/axios'
|
||||
|
||||
/** IoT OTA 任务信息 */
|
||||
export interface OtaTask {
|
||||
id?: number // 任务编号
|
||||
name: string // 任务名称
|
||||
description?: string // 任务描述
|
||||
firmwareId?: number // 固件编号
|
||||
status: number // 任务状态
|
||||
deviceScope?: number // 升级范围
|
||||
deviceIds?: number[] // 指定设备ID列表(当升级范围为指定设备时使用)
|
||||
deviceTotalCount?: number // 设备总共数量
|
||||
deviceSuccessCount?: number // 设备成功数量
|
||||
createTime?: Date // 创建时间
|
||||
}
|
||||
|
||||
// IoT OTA 任务 API
|
||||
export const IoTOtaTaskApi = {
|
||||
// 查询 OTA 升级任务分页
|
||||
getOtaTaskPage: async (params: any) => {
|
||||
return await request.get({ url: `/iot/ota/task/page`, params })
|
||||
},
|
||||
|
||||
// 查询 OTA 升级任务详情
|
||||
getOtaTask: async (id: number) => {
|
||||
return await request.get({ url: `/iot/ota/task/get?id=` + id })
|
||||
},
|
||||
|
||||
// 创建 OTA 升级任务
|
||||
createOtaTask: async (data: OtaTask) => {
|
||||
return await request.post({ url: `/iot/ota/task/create`, data })
|
||||
},
|
||||
|
||||
// 取消 OTA 升级任务
|
||||
cancelOtaTask: async (id: number) => {
|
||||
return await request.post({ url: `/iot/ota/task/cancel?id=` + id })
|
||||
}
|
||||
}
|
||||
38
yudao-ui-admin-vue3/src/api/iot/ota/task/record/index.ts
Normal file
38
yudao-ui-admin-vue3/src/api/iot/ota/task/record/index.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import request from '@/config/axios'
|
||||
|
||||
/** IoT OTA 任务记录信息 */
|
||||
export interface OtaTaskRecord {
|
||||
id?: number // 升级记录编号
|
||||
firmwareId?: number // 固件编号
|
||||
firmwareVersion?: string // 固件版本
|
||||
taskId?: number // 任务编号
|
||||
deviceId?: string // 设备编号
|
||||
deviceName?: string // 设备名称
|
||||
currentVersion?: string // 当前版本
|
||||
fromFirmwareId?: number // 来源的固件编号
|
||||
fromFirmwareVersion?: string // 来源的固件版本
|
||||
status?: number // 升级状态
|
||||
progress?: number // 升级进度,百分比
|
||||
description?: string // 升级进度描述
|
||||
updateTime?: Date // 更新时间
|
||||
}
|
||||
|
||||
// IoT OTA 任务记录 API
|
||||
export const IoTOtaTaskRecordApi = {
|
||||
getOtaTaskRecordStatusStatistics: async (firmwareId?: number, taskId?: number) => {
|
||||
const params: any = {}
|
||||
if (firmwareId) params.firmwareId = firmwareId
|
||||
if (taskId) params.taskId = taskId
|
||||
return await request.get({ url: `/iot/ota/task/record/get-status-statistics`, params })
|
||||
},
|
||||
|
||||
// 查询 OTA 任务记录分页
|
||||
getOtaTaskRecordPage: async (params: any) => {
|
||||
return await request.get({ url: `/iot/ota/task/record/page`, params })
|
||||
},
|
||||
|
||||
// 取消 OTA 任务记录
|
||||
cancelOtaTaskRecord: async (id: number) => {
|
||||
return await request.put({ url: `/iot/ota/task/record/cancel?id=` + id })
|
||||
}
|
||||
}
|
||||
43
yudao-ui-admin-vue3/src/api/iot/product/category/index.ts
Normal file
43
yudao-ui-admin-vue3/src/api/iot/product/category/index.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
import request from '@/config/axios'
|
||||
|
||||
// IoT 产品分类 VO
|
||||
export interface ProductCategoryVO {
|
||||
id: number // 分类 ID
|
||||
name: string // 分类名字
|
||||
sort: number // 分类排序
|
||||
status: number // 分类状态
|
||||
description: string // 分类描述
|
||||
}
|
||||
|
||||
// IoT 产品分类 API
|
||||
export const ProductCategoryApi = {
|
||||
// 查询产品分类分页
|
||||
getProductCategoryPage: async (params: any) => {
|
||||
return await request.get({ url: `/iot/product-category/page`, params })
|
||||
},
|
||||
|
||||
// 查询产品分类详情
|
||||
getProductCategory: async (id: number) => {
|
||||
return await request.get({ url: `/iot/product-category/get?id=` + id })
|
||||
},
|
||||
|
||||
// 新增产品分类
|
||||
createProductCategory: async (data: ProductCategoryVO) => {
|
||||
return await request.post({ url: `/iot/product-category/create`, data })
|
||||
},
|
||||
|
||||
// 修改产品分类
|
||||
updateProductCategory: async (data: ProductCategoryVO) => {
|
||||
return await request.put({ url: `/iot/product-category/update`, data })
|
||||
},
|
||||
|
||||
// 删除产品分类
|
||||
deleteProductCategory: async (id: number) => {
|
||||
return await request.delete({ url: `/iot/product-category/delete?id=` + id })
|
||||
},
|
||||
|
||||
/** 获取产品分类精简列表 */
|
||||
getSimpleProductCategoryList: () => {
|
||||
return request.get({ url: '/iot/product-category/simple-list' })
|
||||
}
|
||||
}
|
||||
81
yudao-ui-admin-vue3/src/api/iot/product/product/index.ts
Normal file
81
yudao-ui-admin-vue3/src/api/iot/product/product/index.ts
Normal file
@@ -0,0 +1,81 @@
|
||||
import request from '@/config/axios'
|
||||
|
||||
// IoT 产品 VO
|
||||
export interface ProductVO {
|
||||
id: number // 产品编号
|
||||
name: string // 产品名称
|
||||
productKey: string // 产品标识
|
||||
productSecret?: string // 产品密钥
|
||||
registerEnabled?: boolean // 动态注册
|
||||
protocolId: number // 协议编号
|
||||
categoryId: number // 产品所属品类标识符
|
||||
categoryName?: string // 产品所属品类名称
|
||||
icon: string // 产品图标
|
||||
picUrl: string // 产品图片
|
||||
description: string // 产品描述
|
||||
status: number // 产品状态
|
||||
deviceType: number // 设备类型
|
||||
netType: number // 联网方式
|
||||
codecType: string // 数据格式(编解码器类型)
|
||||
deviceCount: number // 设备数量
|
||||
createTime: Date // 创建时间
|
||||
}
|
||||
|
||||
// IOT 产品设备类型枚举类 0: 直连设备, 1: 网关子设备, 2: 网关设备
|
||||
export enum DeviceTypeEnum {
|
||||
DEVICE = 0, // 直连设备
|
||||
GATEWAY_SUB = 1, // 网关子设备
|
||||
GATEWAY = 2 // 网关设备
|
||||
}
|
||||
// IOT 数据格式(编解码器类型)枚举类
|
||||
export enum CodecTypeEnum {
|
||||
ALINK = 'Alink' // 阿里云 Alink 协议
|
||||
}
|
||||
|
||||
// IoT 产品 API
|
||||
export const ProductApi = {
|
||||
// 查询产品分页
|
||||
getProductPage: async (params: any) => {
|
||||
return await request.get({ url: `/iot/product/page`, params })
|
||||
},
|
||||
|
||||
// 查询产品详情
|
||||
getProduct: async (id: number) => {
|
||||
return await request.get({ url: `/iot/product/get?id=` + id })
|
||||
},
|
||||
|
||||
// 新增产品
|
||||
createProduct: async (data: ProductVO) => {
|
||||
return await request.post({ url: `/iot/product/create`, data })
|
||||
},
|
||||
|
||||
// 修改产品
|
||||
updateProduct: async (data: ProductVO) => {
|
||||
return await request.put({ url: `/iot/product/update`, data })
|
||||
},
|
||||
|
||||
// 删除产品
|
||||
deleteProduct: async (id: number) => {
|
||||
return await request.delete({ url: `/iot/product/delete?id=` + id })
|
||||
},
|
||||
|
||||
// 导出产品 Excel
|
||||
exportProduct: async (params) => {
|
||||
return await request.download({ url: `/iot/product/export-excel`, params })
|
||||
},
|
||||
|
||||
// 更新产品状态
|
||||
updateProductStatus: async (id: number, status: number) => {
|
||||
return await request.put({ url: `/iot/product/update-status?id=` + id + `&status=` + status })
|
||||
},
|
||||
|
||||
// 查询产品(精简)列表
|
||||
getSimpleProductList(deviceType?: number) {
|
||||
return request.get({ url: '/iot/product/simple-list', params: { deviceType } })
|
||||
},
|
||||
|
||||
// 根据 ProductKey 获取产品信息
|
||||
getProductByKey: async (productKey: string) => {
|
||||
return await request.get({ url: `/iot/product/get-by-key`, params: { productKey } })
|
||||
}
|
||||
}
|
||||
39
yudao-ui-admin-vue3/src/api/iot/rule/data/rule/index.ts
Normal file
39
yudao-ui-admin-vue3/src/api/iot/rule/data/rule/index.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import request from '@/config/axios'
|
||||
|
||||
/** IoT 数据流转规则信息 */
|
||||
export interface DataRule {
|
||||
id: number // 场景编号
|
||||
name?: string // 场景名称
|
||||
description: string // 场景描述
|
||||
status?: number // 场景状态
|
||||
sourceConfigs?: any[] // 数据源配置数组
|
||||
sinkIds?: number[] // 数据目的编号数组
|
||||
}
|
||||
|
||||
// IoT 数据流转规则 API
|
||||
export const DataRuleApi = {
|
||||
// 查询数据流转规则分页
|
||||
getDataRulePage: async (params: any) => {
|
||||
return await request.get({ url: `/iot/data-rule/page`, params })
|
||||
},
|
||||
|
||||
// 查询数据流转规则详情
|
||||
getDataRule: async (id: number) => {
|
||||
return await request.get({ url: `/iot/data-rule/get?id=` + id })
|
||||
},
|
||||
|
||||
// 新增数据流转规则
|
||||
createDataRule: async (data: DataRule) => {
|
||||
return await request.post({ url: `/iot/data-rule/create`, data })
|
||||
},
|
||||
|
||||
// 修改数据流转规则
|
||||
updateDataRule: async (data: DataRule) => {
|
||||
return await request.put({ url: `/iot/data-rule/update`, data })
|
||||
},
|
||||
|
||||
// 删除数据流转规则
|
||||
deleteDataRule: async (id: number) => {
|
||||
return await request.delete({ url: `/iot/data-rule/delete?id=` + id })
|
||||
}
|
||||
}
|
||||
160
yudao-ui-admin-vue3/src/api/iot/rule/data/sink/index.ts
Normal file
160
yudao-ui-admin-vue3/src/api/iot/rule/data/sink/index.ts
Normal file
@@ -0,0 +1,160 @@
|
||||
import request from '@/config/axios'
|
||||
|
||||
// IoT 数据流转目的 VO
|
||||
export interface DataSinkVO {
|
||||
id?: number // 桥梁编号
|
||||
name?: string // 桥梁名称
|
||||
description?: string // 桥梁描述
|
||||
status?: number // 桥梁状态
|
||||
direction?: number // 桥梁方向
|
||||
type?: number // 桥梁类型
|
||||
config?:
|
||||
| HttpConfig
|
||||
| TcpConfig
|
||||
| WebSocketConfig
|
||||
| MqttConfig
|
||||
| RocketMQConfig
|
||||
| KafkaMQConfig
|
||||
| RabbitMQConfig
|
||||
| RedisStreamMQConfig // 桥梁配置
|
||||
}
|
||||
|
||||
interface Config {
|
||||
type: string
|
||||
}
|
||||
|
||||
/** HTTP 配置 */
|
||||
export interface HttpConfig extends Config {
|
||||
url: string
|
||||
method: string
|
||||
headers: Record<string, string>
|
||||
query: Record<string, string>
|
||||
body: string
|
||||
}
|
||||
|
||||
/** TCP 配置 */
|
||||
export interface TcpConfig extends Config {
|
||||
host: string
|
||||
port: number
|
||||
connectTimeoutMs: number
|
||||
readTimeoutMs: number
|
||||
ssl: boolean
|
||||
sslCertPath: string
|
||||
dataFormat: string
|
||||
heartbeatIntervalMs: number
|
||||
reconnectIntervalMs: number
|
||||
maxReconnectAttempts: number
|
||||
}
|
||||
|
||||
/** WebSocket 配置 */
|
||||
export interface WebSocketConfig extends Config {
|
||||
serverUrl: string
|
||||
connectTimeoutMs: number
|
||||
sendTimeoutMs: number
|
||||
heartbeatIntervalMs: number
|
||||
heartbeatMessage: string
|
||||
subprotocols: string
|
||||
customHeaders: string
|
||||
verifySslCert: boolean
|
||||
dataFormat: string
|
||||
reconnectIntervalMs: number
|
||||
maxReconnectAttempts: number
|
||||
enableCompression: boolean
|
||||
sendRetryCount: number
|
||||
sendRetryIntervalMs: number
|
||||
}
|
||||
|
||||
/** MQTT 配置 */
|
||||
export interface MqttConfig extends Config {
|
||||
url: string
|
||||
username: string
|
||||
password: string
|
||||
clientId: string
|
||||
topic: string
|
||||
}
|
||||
|
||||
/** RocketMQ 配置 */
|
||||
export interface RocketMQConfig extends Config {
|
||||
nameServer: string
|
||||
accessKey: string
|
||||
secretKey: string
|
||||
group: string
|
||||
topic: string
|
||||
tags: string
|
||||
}
|
||||
|
||||
/** Kafka 配置 */
|
||||
export interface KafkaMQConfig extends Config {
|
||||
bootstrapServers: string
|
||||
username: string
|
||||
password: string
|
||||
ssl: boolean
|
||||
topic: string
|
||||
}
|
||||
|
||||
/** RabbitMQ 配置 */
|
||||
export interface RabbitMQConfig extends Config {
|
||||
host: string
|
||||
port: number
|
||||
virtualHost: string
|
||||
username: string
|
||||
password: string
|
||||
exchange: string
|
||||
routingKey: string
|
||||
queue: string
|
||||
}
|
||||
|
||||
/** Redis Stream MQ 配置 */
|
||||
export interface RedisStreamMQConfig extends Config {
|
||||
host: string
|
||||
port: number
|
||||
password: string
|
||||
database: number
|
||||
topic: string
|
||||
}
|
||||
|
||||
/** 数据流转目的类型 */
|
||||
export const IotDataSinkTypeEnum = {
|
||||
HTTP: 1,
|
||||
TCP: 2,
|
||||
WEBSOCKET: 3,
|
||||
MQTT: 10,
|
||||
DATABASE: 20,
|
||||
REDIS_STREAM: 21,
|
||||
ROCKETMQ: 30,
|
||||
RABBITMQ: 31,
|
||||
KAFKA: 32
|
||||
} as const
|
||||
|
||||
// 数据流转目的 API
|
||||
export const DataSinkApi = {
|
||||
// 查询数据流转目的分页
|
||||
getDataSinkPage: async (params: any) => {
|
||||
return await request.get({ url: `/iot/data-sink/page`, params })
|
||||
},
|
||||
|
||||
// 查询数据流转目的详情
|
||||
getDataSink: async (id: number) => {
|
||||
return await request.get({ url: `/iot/data-sink/get?id=` + id })
|
||||
},
|
||||
|
||||
// 新增数据流转目的
|
||||
createDataSink: async (data: DataSinkVO) => {
|
||||
return await request.post({ url: `/iot/data-sink/create`, data })
|
||||
},
|
||||
|
||||
// 修改数据流转目的
|
||||
updateDataSink: async (data: DataSinkVO) => {
|
||||
return await request.put({ url: `/iot/data-sink/update`, data })
|
||||
},
|
||||
|
||||
// 删除数据流转目的
|
||||
deleteDataSink: async (id: number) => {
|
||||
return await request.delete({ url: `/iot/data-sink/delete?id=` + id })
|
||||
},
|
||||
|
||||
// 查询数据流转目的(精简)列表
|
||||
getDataSinkSimpleList() {
|
||||
return request.get({ url: '/iot/data-sink/simple-list' })
|
||||
}
|
||||
}
|
||||
87
yudao-ui-admin-vue3/src/api/iot/rule/scene/index.ts
Normal file
87
yudao-ui-admin-vue3/src/api/iot/rule/scene/index.ts
Normal file
@@ -0,0 +1,87 @@
|
||||
import request from '@/config/axios'
|
||||
|
||||
// 场景联动
|
||||
export interface IotSceneRule {
|
||||
id?: number // 场景编号
|
||||
name: string // 场景名称
|
||||
description?: string // 场景描述
|
||||
status: number // 场景状态:0-开启,1-关闭
|
||||
triggers: Trigger[] // 触发器数组
|
||||
actions: Action[] // 执行器数组
|
||||
}
|
||||
|
||||
// 触发器结构
|
||||
export interface Trigger {
|
||||
type: number // 触发类型
|
||||
productId?: number // 产品编号
|
||||
deviceId?: number // 设备编号
|
||||
identifier?: string // 物模型标识符
|
||||
operator?: string // 操作符
|
||||
value?: string // 参数值
|
||||
cronExpression?: string // CRON 表达式
|
||||
conditionGroups?: TriggerCondition[][] // 条件组(二维数组)
|
||||
}
|
||||
|
||||
// 触发条件结构
|
||||
export interface TriggerCondition {
|
||||
type: number // 条件类型:1-设备状态,2-设备属性,3-当前时间
|
||||
productId?: number // 产品编号
|
||||
deviceId?: number // 设备编号
|
||||
identifier?: string // 标识符
|
||||
operator: string // 操作符
|
||||
param: string // 参数
|
||||
}
|
||||
|
||||
// 执行器结构
|
||||
export interface Action {
|
||||
type: number // 执行类型
|
||||
productId?: number // 产品编号
|
||||
deviceId?: number // 设备编号
|
||||
identifier?: string // 物模型标识符(服务调用时使用)
|
||||
params?: string // 请求参数
|
||||
alertConfigId?: number // 告警配置编号
|
||||
}
|
||||
|
||||
// IoT 场景联动 API
|
||||
export const RuleSceneApi = {
|
||||
// 查询场景联动分页
|
||||
getRuleScenePage: async (params: any) => {
|
||||
return await request.get({ url: `/iot/scene-rule/page`, params })
|
||||
},
|
||||
|
||||
// 查询场景联动详情
|
||||
getRuleScene: async (id: number) => {
|
||||
return await request.get({ url: `/iot/scene-rule/get?id=` + id })
|
||||
},
|
||||
|
||||
// 新增场景联动
|
||||
createRuleScene: async (data: IotSceneRule) => {
|
||||
return await request.post({ url: `/iot/scene-rule/create`, data })
|
||||
},
|
||||
|
||||
// 修改场景联动
|
||||
updateRuleScene: async (data: IotSceneRule) => {
|
||||
return await request.put({ url: `/iot/scene-rule/update`, data })
|
||||
},
|
||||
|
||||
// 修改场景联动
|
||||
updateRuleSceneStatus: async (id: number, status: number) => {
|
||||
return await request.put({
|
||||
url: `/iot/scene-rule/update-status`,
|
||||
data: {
|
||||
id,
|
||||
status
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
// 删除场景联动
|
||||
deleteRuleScene: async (id: number) => {
|
||||
return await request.delete({ url: `/iot/scene-rule/delete?id=` + id })
|
||||
},
|
||||
|
||||
// 获取场景联动简单列表
|
||||
getSimpleRuleSceneList: async () => {
|
||||
return await request.get({ url: `/iot/scene-rule/simple-list` })
|
||||
}
|
||||
}
|
||||
59
yudao-ui-admin-vue3/src/api/iot/statistics/index.ts
Normal file
59
yudao-ui-admin-vue3/src/api/iot/statistics/index.ts
Normal file
@@ -0,0 +1,59 @@
|
||||
import request from '@/config/axios'
|
||||
|
||||
/** IoT 统计数据类型 */
|
||||
export interface IotStatisticsSummaryRespVO {
|
||||
productCategoryCount: number
|
||||
productCount: number
|
||||
deviceCount: number
|
||||
deviceMessageCount: number
|
||||
productCategoryTodayCount: number
|
||||
productTodayCount: number
|
||||
deviceTodayCount: number
|
||||
deviceMessageTodayCount: number
|
||||
deviceOnlineCount: number
|
||||
deviceOfflineCount: number
|
||||
deviceInactiveCount: number
|
||||
productCategoryDeviceCounts: Record<string, number>
|
||||
}
|
||||
|
||||
/** 新的消息统计数据项 */
|
||||
export interface IotStatisticsDeviceMessageSummaryByDateRespVO {
|
||||
time: string
|
||||
upstreamCount: number
|
||||
downstreamCount: number
|
||||
}
|
||||
|
||||
/** 新的消息统计接口参数 */
|
||||
export interface IotStatisticsDeviceMessageReqVO {
|
||||
interval: number
|
||||
times?: string[]
|
||||
}
|
||||
|
||||
/** 设备位置数据 VO */
|
||||
export interface DeviceLocationRespVO {
|
||||
id: number
|
||||
deviceName: string
|
||||
nickname?: string
|
||||
productName?: string
|
||||
state: number
|
||||
longitude: number
|
||||
latitude: number
|
||||
}
|
||||
|
||||
// IoT 数据统计 API
|
||||
export const StatisticsApi = {
|
||||
// 查询全局的数据统计
|
||||
getStatisticsSummary: async () => {
|
||||
return await request.get<IotStatisticsSummaryRespVO>({
|
||||
url: `/iot/statistics/get-summary`
|
||||
})
|
||||
},
|
||||
|
||||
// 获取设备消息的数据统计
|
||||
getDeviceMessageSummaryByDate: async (params: IotStatisticsDeviceMessageReqVO) => {
|
||||
return await request.get<IotStatisticsDeviceMessageSummaryByDateRespVO[]>({
|
||||
url: `/iot/statistics/get-device-message-summary-by-date`,
|
||||
params
|
||||
})
|
||||
}
|
||||
}
|
||||
301
yudao-ui-admin-vue3/src/api/iot/thingmodel/index.ts
Normal file
301
yudao-ui-admin-vue3/src/api/iot/thingmodel/index.ts
Normal file
@@ -0,0 +1,301 @@
|
||||
import request from '@/config/axios'
|
||||
import { isEmpty } from '@/utils/is'
|
||||
|
||||
/**
|
||||
* IoT 产品物模型
|
||||
*/
|
||||
export interface ThingModelData {
|
||||
id?: number // 物模型功能编号
|
||||
identifier?: string // 功能标识
|
||||
name?: string // 功能名称
|
||||
description?: string // 功能描述
|
||||
productId?: number // 产品编号
|
||||
productKey?: string // 产品标识
|
||||
dataType: string // 数据类型,与 dataSpecs 的 dataType 保持一致
|
||||
type: number // 功能类型
|
||||
property: ThingModelProperty // 属性
|
||||
event?: ThingModelEvent // 事件
|
||||
service?: ThingModelService // 服务
|
||||
}
|
||||
|
||||
/**
|
||||
* ThingModelProperty 类型
|
||||
*/
|
||||
export interface ThingModelProperty {
|
||||
[key: string]: any
|
||||
}
|
||||
|
||||
/**
|
||||
* ThingModelEvent 类型
|
||||
*/
|
||||
export interface ThingModelEvent {
|
||||
[key: string]: any
|
||||
}
|
||||
|
||||
/**
|
||||
* ThingModelService 类型
|
||||
*/
|
||||
export interface ThingModelService {
|
||||
[key: string]: any
|
||||
}
|
||||
|
||||
/** dataSpecs 数值型数据结构 */
|
||||
export interface DataSpecsNumberData {
|
||||
dataType: 'int' | 'float' | 'double' // 数据类型,取值为 INT、FLOAT 或 DOUBLE
|
||||
max: string // 最大值,必须与 dataType 设置一致,且为 STRING 类型
|
||||
min: string // 最小值,必须与 dataType 设置一致,且为 STRING 类型
|
||||
step: string // 步长,必须与 dataType 设置一致,且为 STRING 类型
|
||||
precise?: string // 精度,当 dataType 为 FLOAT 或 DOUBLE 时可选
|
||||
defaultValue?: string // 默认值,可选
|
||||
unit: string // 单位的符号
|
||||
unitName: string // 单位的名称
|
||||
}
|
||||
|
||||
/** dataSpecs 枚举型数据结构 */
|
||||
export interface DataSpecsEnumOrBoolData {
|
||||
dataType: 'enum' | 'bool'
|
||||
defaultValue?: string // 默认值,可选
|
||||
name: string // 枚举项的名称
|
||||
value: number | undefined // 枚举值
|
||||
}
|
||||
|
||||
/** 物模型TSL响应数据结构 */
|
||||
export interface IotThingModelTSLResp {
|
||||
productId: number
|
||||
productKey: string
|
||||
properties: ThingModelProperty[]
|
||||
events: ThingModelEvent[]
|
||||
services: ThingModelService[]
|
||||
}
|
||||
|
||||
/** 物模型属性 */
|
||||
export interface ThingModelProperty {
|
||||
identifier: string
|
||||
name: string
|
||||
accessMode: string
|
||||
required?: boolean
|
||||
dataType: string
|
||||
description?: string
|
||||
dataSpecs?: ThingModelProperty
|
||||
dataSpecsList?: ThingModelProperty[]
|
||||
}
|
||||
|
||||
/** 物模型事件 */
|
||||
export interface ThingModelEvent {
|
||||
identifier: string
|
||||
name: string
|
||||
required?: boolean
|
||||
type: string
|
||||
description?: string
|
||||
outputParams?: ThingModelParam[]
|
||||
method?: string
|
||||
}
|
||||
|
||||
/** 物模型服务 */
|
||||
export interface ThingModelService {
|
||||
identifier: string
|
||||
name: string
|
||||
required?: boolean
|
||||
callType: string
|
||||
description?: string
|
||||
inputParams?: ThingModelParam[]
|
||||
outputParams?: ThingModelParam[]
|
||||
method?: string
|
||||
}
|
||||
|
||||
/** 物模型参数 */
|
||||
export interface ThingModelParam {
|
||||
identifier: string
|
||||
name: string
|
||||
direction: string
|
||||
paraOrder?: number
|
||||
dataType: string
|
||||
dataSpecs?: ThingModelProperty
|
||||
dataSpecsList?: ThingModelProperty[]
|
||||
}
|
||||
|
||||
/** 数值型数据规范 */
|
||||
export interface ThingModelNumericDataSpec {
|
||||
dataType: 'int' | 'float' | 'double'
|
||||
max: string
|
||||
min: string
|
||||
step: string
|
||||
precise?: string
|
||||
defaultValue?: string
|
||||
unit?: string
|
||||
unitName?: string
|
||||
}
|
||||
|
||||
/** 布尔/枚举型数据规范 */
|
||||
export interface ThingModelBoolOrEnumDataSpecs {
|
||||
dataType: 'bool' | 'enum'
|
||||
name: string
|
||||
value: number
|
||||
}
|
||||
|
||||
/** 文本/时间型数据规范 */
|
||||
export interface ThingModelDateOrTextDataSpecs {
|
||||
dataType: 'text' | 'date'
|
||||
length?: number
|
||||
defaultValue?: string
|
||||
}
|
||||
|
||||
/** 数组型数据规范 */
|
||||
export interface ThingModelArrayDataSpecs {
|
||||
dataType: 'array'
|
||||
size: number
|
||||
childDataType: string
|
||||
dataSpecsList?: ThingModelProperty[]
|
||||
}
|
||||
|
||||
/** 结构体型数据规范 */
|
||||
export interface ThingModelStructDataSpecs {
|
||||
dataType: 'struct'
|
||||
identifier: string
|
||||
name: string
|
||||
accessMode: string
|
||||
required?: boolean
|
||||
childDataType: string
|
||||
dataSpecs?: ThingModelProperty
|
||||
dataSpecsList?: ThingModelProperty[]
|
||||
}
|
||||
|
||||
// IoT 产品物模型 API
|
||||
export const ThingModelApi = {
|
||||
// 查询产品物模型分页
|
||||
getThingModelPage: async (params: any) => {
|
||||
return await request.get({ url: `/iot/thing-model/page`, params })
|
||||
},
|
||||
|
||||
// 获得产品物模型列表
|
||||
getThingModelList: async (params: any) => {
|
||||
return await request.get({ url: `/iot/thing-model/list`, params })
|
||||
},
|
||||
|
||||
// 获得产品物模型 TSL
|
||||
getThingModelTSLByProductId: async (productId: number) => {
|
||||
return await request.get({
|
||||
url: `/iot/thing-model/get-tsl?productId=${productId}`
|
||||
})
|
||||
},
|
||||
|
||||
// 查询产品物模型详情
|
||||
getThingModel: async (id: number) => {
|
||||
return await request.get({ url: `/iot/thing-model/get?id=` + id })
|
||||
},
|
||||
|
||||
// 新增产品物模型
|
||||
createThingModel: async (data: ThingModelData) => {
|
||||
return await request.post({ url: `/iot/thing-model/create`, data })
|
||||
},
|
||||
|
||||
// 修改产品物模型
|
||||
updateThingModel: async (data: ThingModelData) => {
|
||||
return await request.put({ url: `/iot/thing-model/update`, data })
|
||||
},
|
||||
|
||||
// 删除产品物模型
|
||||
deleteThingModel: async (id: number) => {
|
||||
return await request.delete({ url: `/iot/thing-model/delete?id=` + id })
|
||||
}
|
||||
}
|
||||
|
||||
/** 公共校验规则 */
|
||||
export const ThingModelFormRules = {
|
||||
name: [
|
||||
{ required: true, message: '功能名称不能为空', trigger: 'blur' },
|
||||
{
|
||||
pattern: /^[\u4e00-\u9fa5a-zA-Z0-9][\u4e00-\u9fa5a-zA-Z0-9\-_/\.]{0,29}$/,
|
||||
message:
|
||||
'支持中文、大小写字母、日文、数字、短划线、下划线、斜杠和小数点,必须以中文、英文或数字开头,不超过 30 个字符',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
type: [{ required: true, message: '功能类型不能为空', trigger: 'blur' }],
|
||||
identifier: [
|
||||
{ required: true, message: '标识符不能为空', trigger: 'blur' },
|
||||
{
|
||||
pattern: /^[a-zA-Z0-9_]{1,50}$/,
|
||||
message: '支持大小写字母、数字和下划线,不超过 50 个字符',
|
||||
trigger: 'blur'
|
||||
},
|
||||
{
|
||||
validator: (_: any, value: string, callback: any) => {
|
||||
const reservedKeywords = ['set', 'get', 'post', 'property', 'event', 'time', 'value']
|
||||
if (reservedKeywords.includes(value)) {
|
||||
callback(
|
||||
new Error(
|
||||
'set, get, post, property, event, time, value 是系统保留字段,不能用于标识符定义'
|
||||
)
|
||||
)
|
||||
} else if (/^\d+$/.test(value)) {
|
||||
callback(new Error('标识符不能是纯数字'))
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
},
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
'property.dataSpecs.childDataType': [{ required: true, message: '元素类型不能为空' }],
|
||||
'property.dataSpecs.size': [
|
||||
{ required: true, message: '元素个数不能为空' },
|
||||
{
|
||||
validator: (_: any, value: any, callback: any) => {
|
||||
if (isEmpty(value)) {
|
||||
callback(new Error('元素个数不能为空'))
|
||||
return
|
||||
}
|
||||
if (isNaN(Number(value))) {
|
||||
callback(new Error('元素个数必须是数字'))
|
||||
return
|
||||
}
|
||||
callback()
|
||||
},
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
'property.dataSpecs.length': [
|
||||
{ required: true, message: '请输入文本字节长度', trigger: 'blur' },
|
||||
{
|
||||
validator: (_: any, value: any, callback: any) => {
|
||||
if (isEmpty(value)) {
|
||||
callback(new Error('文本长度不能为空'))
|
||||
return
|
||||
}
|
||||
if (isNaN(Number(value))) {
|
||||
callback(new Error('文本长度必须是数字'))
|
||||
return
|
||||
}
|
||||
callback()
|
||||
},
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
'property.accessMode': [{ required: true, message: '请选择读写类型', trigger: 'change' }]
|
||||
}
|
||||
|
||||
/** 校验布尔值名称 */
|
||||
export const validateBoolName = (_: any, value: string, callback: any) => {
|
||||
if (isEmpty(value)) {
|
||||
callback(new Error('布尔值名称不能为空'))
|
||||
return
|
||||
}
|
||||
// 检查开头字符
|
||||
if (!/^[\u4e00-\u9fa5a-zA-Z0-9]/.test(value)) {
|
||||
callback(new Error('布尔值名称必须以中文、英文字母或数字开头'))
|
||||
return
|
||||
}
|
||||
// 检查整体格式
|
||||
if (!/^[\u4e00-\u9fa5a-zA-Z0-9][a-zA-Z0-9\u4e00-\u9fa5_-]*$/.test(value)) {
|
||||
callback(new Error('布尔值名称只能包含中文、英文字母、数字、下划线和短划线'))
|
||||
return
|
||||
}
|
||||
// 检查长度(一个中文算一个字符)
|
||||
if (value.length > 20) {
|
||||
callback(new Error('布尔值名称长度不能超过 20 个字符'))
|
||||
return
|
||||
}
|
||||
|
||||
callback()
|
||||
}
|
||||
Reference in New Issue
Block a user