调整 ValueDescriptor

This commit is contained in:
2025-09-29 22:23:35 +08:00
parent 4f730cf58f
commit 8392438dc5
2 changed files with 14 additions and 15 deletions

View File

@@ -6,10 +6,16 @@ import (
"gorm.io/datatypes"
)
// SensorDataType 定义了 SensorData 记录中 Data 字段的整体类型
// SensorType 定义了 SensorData 记录中 Data 字段的整体类型
type SensorType string
// DeviceSubTypeToSensorDataTypeMap 定义了设备子类型到其产生的传感器数据类型的静态映射.
// 这个公开的 map 是连接设备定义和数据记录的桥梁, 供其他包直接查询.
const (
SensorTypeSignalMetrics SensorType = "signal_metrics" // 信号强度
SensorTypeBatteryLevel SensorType = "battery_level" // 电池电量
SensorTypeTemperature SensorType = "temperature" // 温度
SensorTypeHumidity SensorType = "humidity" // 湿度
SensorTypeWeight SensorType = "weight" // 重量
)
// SignalMetrics 存储信号强度数据
type SignalMetrics struct {
@@ -53,7 +59,7 @@ type SensorData struct {
RegionalControllerID uint `json:"regional_controller_id"`
// SensorDataType 是传感数据的类型
SensorDataType string `gorm:"not null;index" json:"sensor_data_type"`
SensorDataType SensorType `gorm:"not null;index" json:"sensor_data_type"`
// Data 存储一个或多个传感器读数,格式为 JSON。
Data datatypes.JSON `gorm:"type:jsonb" json:"data"`