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

+ 1 - 1
pkg/models/device_command.go

@@ -18,7 +18,7 @@ type DeviceCommand struct {
 	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:command_id" json:"data"`                         // 数据
+	Data         DeviceCommandDatas `gorm:"foreignkey:CommandId,RecordID" json:"data"`                 // 数据
 	CommandType  int                `gorm:"column:command_type" json:"command_type"`                   // 指令类型
 }
 

+ 1 - 1
pkg/models/device_status.go

@@ -21,7 +21,7 @@ type DeviceStatus struct {
 	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:status_id" json:"data"`                          // 状态数据
+	Data           DeviceStatusDatas `gorm:"foreignkey:StatusID,RecordID" json:"data"`                  // 状态数据
 }
 
 // TableName 表名