liuxiulin 2 hafta önce
ebeveyn
işleme
105dd7cbff
2 değiştirilmiş dosya ile 16 ekleme ve 16 silme
  1. 7 7
      pkg/models/device_command.go
  2. 9 9
      pkg/models/device_status.go

+ 7 - 7
pkg/models/device_command.go

@@ -13,13 +13,13 @@ type DeviceCommandDatas []DeviceCommandData
 type DeviceCommand struct {
 	gorm.Model
 	RecordID     string             `gorm:"primary_key;column:record_id;size:32;index" json:"record_id"`
-	DeviceType   string             `gorm:"column:device_type;size:200" json:"device_type"`            // 设备类型
-	DeviceTypeId string             `gorm:"column:device_type_id;size:32;index" json:"device_type_id"` // 设备类型id
-	Name         string             `gorm:"column:name;size:200" json:"name"`                          // 名称
-	Command      string             `gorm:"column:command;size:200" json:"command"`                    // 指令
-	DataType     string             `gorm:"column:data_type;size:100" json:"data_type"`                // 数据类型
-	Data         DeviceCommandDatas `gorm:"foreignkey:CommandId,RecordID" json:"data"`                 // 数据
-	CommandType  int                `gorm:"column:command_type" json:"command_type"`                   // 指令类型
+	DeviceType   string             `gorm:"column:device_type;size:200" json:"device_type"`                  // 设备类型
+	DeviceTypeId string             `gorm:"column:device_type_id;size:32;index" json:"device_type_id"`       // 设备类型id
+	Name         string             `gorm:"column:name;size:200" json:"name"`                                // 名称
+	Command      string             `gorm:"column:command;size:200" json:"command"`                          // 指令
+	DataType     string             `gorm:"column:data_type;size:100" json:"data_type"`                      // 数据类型
+	Data         DeviceCommandDatas `gorm:"foreignkey:CommandId;associationforeignkey:RecordID" json:"data"` // 数据
+	CommandType  int                `gorm:"column:command_type" json:"command_type"`                         // 指令类型
 }
 
 // TableName 表名

+ 9 - 9
pkg/models/device_status.go

@@ -13,15 +13,15 @@ type DeviceStatusDatas []DeviceStatusData
 type DeviceStatus struct {
 	gorm.Model
 	RecordID       string            `gorm:"primary_key;column:record_id;size:32;index" json:"record_id"`
-	DeviceTypeId   string            `gorm:"column:device_type_id;size:32;index" json:"device_type_id"` // 设备类型id
-	DeviceTypeCode string            `gorm:"column:device_type_code;size:100" json:"device_type_code"`  // 设备类型code
-	Desc           string            `gorm:"column:desc;size:500" json:"desc"`                          // 描述
-	Name           string            `gorm:"column:name;size:200" json:"name"`                          // 状态字段名称
-	Label          string            `gorm:"column:label;size:200" json:"label"`                        // 状态字段标签
-	Type           string            `gorm:"column:type;size:100" json:"type"`                          // 状态字段类型
-	Unit           string            `gorm:"column:unit;size:50" json:"unit"`                           // 单位
-	FieldType      int               `gorm:"column:field_type" json:"field_type"`                       // 数据类型
-	Data           DeviceStatusDatas `gorm:"foreignkey:StatusID,RecordID" json:"data"`                  // 状态数据
+	DeviceTypeId   string            `gorm:"column:device_type_id;size:32;index" json:"device_type_id"`      // 设备类型id
+	DeviceTypeCode string            `gorm:"column:device_type_code;size:100" json:"device_type_code"`       // 设备类型code
+	Desc           string            `gorm:"column:desc;size:500" json:"desc"`                               // 描述
+	Name           string            `gorm:"column:name;size:200" json:"name"`                               // 状态字段名称
+	Label          string            `gorm:"column:label;size:200" json:"label"`                             // 状态字段标签
+	Type           string            `gorm:"column:type;size:100" json:"type"`                               // 状态字段类型
+	Unit           string            `gorm:"column:unit;size:50" json:"unit"`                                // 单位
+	FieldType      int               `gorm:"column:field_type" json:"field_type"`                            // 数据类型
+	Data           DeviceStatusDatas `gorm:"foreignkey:StatusID;associationforeignkey:RecordID" json:"data"` // 状态数据
 }
 
 // TableName 表名