device_relay.go 537 B

123456789101112131415161718
  1. package dao
  2. import "server/global"
  3. type DeviceRelay struct {
  4. ID int `json:"id"`
  5. RelayID int `json:"relayId" gorm:"comment:回路id"`
  6. DeviceId int `json:"deviceId" gorm:"comment:设备id"`
  7. State bool `json:"state" gorm:"comment:设备状态"`
  8. }
  9. func (DeviceRelay) TableName() string {
  10. return "device_relay"
  11. }
  12. func UpdateRelayState(deviceId, relayId int, state bool) error {
  13. return global.GVA_DB.Model(&DeviceRelay{}).Debug().Where("device_id = ? AND relay_id = ?", deviceId, relayId).Update("state", state).Error
  14. }