| 123456789101112131415161718192021222324252627 |
- package dao
- import "server/global"
- type Sun struct {
- DeviceId string `json:"deviceId" gorm:"column:device_id;comment:设备ID"`
- BatteryVoltage float64 `json:"batteryVoltage" gorm:"column:battery_voltage;comment:电池电压"`
- BatteryCurrent int `json:"batteryCurrent" gorm:"column:battery_current;comment:电池电流"`
- BatteryPlateVoltage float64 `json:"batteryPlateVoltage" gorm:"column:battery_plate_voltage;comment:电池板电压"`
- }
- func (Sun) TableName() string {
- return "sun"
- }
- func QueryAllSuns() (suns []Sun, err error) {
- err = global.GVA_DB.Find(&suns).Error
- return
- }
- func (s Sun) CreateSun() error {
- return global.GVA_DB.Create(&s).Error
- }
- func (s Sun) SaveSun() error {
- return global.GVA_DB.Save(&s).Error
- }
|