Sun.go 762 B

123456789101112131415161718192021222324252627
  1. package dao
  2. import "server/global"
  3. type Sun struct {
  4. DeviceId string `json:"deviceId" gorm:"column:device_id;comment:设备ID"`
  5. BatteryVoltage float64 `json:"batteryVoltage" gorm:"column:battery_voltage;comment:电池电压"`
  6. BatteryCurrent int `json:"batteryCurrent" gorm:"column:battery_current;comment:电池电流"`
  7. BatteryPlateVoltage float64 `json:"batteryPlateVoltage" gorm:"column:battery_plate_voltage;comment:电池板电压"`
  8. }
  9. func (Sun) TableName() string {
  10. return "sun"
  11. }
  12. func QueryAllSuns() (suns []Sun, err error) {
  13. err = global.GVA_DB.Find(&suns).Error
  14. return
  15. }
  16. func (s Sun) CreateSun() error {
  17. return global.GVA_DB.Create(&s).Error
  18. }
  19. func (s Sun) SaveSun() error {
  20. return global.GVA_DB.Save(&s).Error
  21. }