package dao // GarbageData 垃圾桶数据 type GarbageData struct { ID int `gorm:"primary_key" json:"id"` //编号 DeviceId string `gorm:"type:varchar(20)" json:"deviceId"` //设备名称 StartTime string `gorm:"type:varchar(15)" json:"startTime"` //工作时段开始时间 EndTime string `gorm:"type:varchar(15)" json:"endTime"` //工作时段结束时间 PostTime string `gorm:"type:varchar(30)" json:"postTime"` //上传时间 BatteryVoltage float32 `gorm:"type:float(5, 1)" json:"batteryVoltage"` //电池电压 BatteryPercentage float32 `gorm:"type:float(5, 1)" json:"batteryPercentage"` //电池电量 SensorCount int `gorm:"type:int" json:"sensorCount"` //传感器通道数量 SensorOne float32 `gorm:"type:float(5, 1)" json:"sensorOne"` //通道一原始数值 SensorTwo float32 `gorm:"type:float(5, 1)" json:"sensorTwo"` //通道二原始数值 SensorOnePercentage float32 `gorm:"type:float(5, 1)" json:"sensorOnePercentage"` //通道一垃圾量百分比 SensorTwoPercentage float32 `gorm:"type:float(5, 1)" json:"sensorTwoPercentage"` //通道二垃圾量百分比 WorkTime string `gorm:"type:varchar(50)" json:"workTime"` //工作时间段 } func (GarbageData) TableName() string { return "data_garbage" } func (c *GarbageData) Save() error { return Db.Debug().Model(&c).Create(&c).Error } func (c *GarbageData) BatchSave(data []GarbageData) error { return Db.Debug().Model(&c).Create(&data).Error } func (c *GarbageData) Get() error { return Db.Debug().Model(&c).Where("device_id = ?", c.DeviceId).Find(&c).Error }