package models import ( "time" "gorm.io/gorm" ) type Temperature struct { gorm.Model `json:"-"` ID uint `json:"-" gorm:"primary_key"` Time time.Time `json:"time" gorm:"autoCreateTime"` Temperature float64 `json:"temperature"` RoomID int `json:"room_id"` Room Room `json:"-" gorm:"foreignKey:ID;references:RoomID"` } type Humidity struct { gorm.Model `json:"-"` ID uint `json:"-" gorm:"primary_key"` Time time.Time `json:"time" gorm:"autoCreateTime"` Humidity float64 `json:"humidity"` RoomID int `json:"room_id"` Room Room `json:"-" gorm:"foreignKey:ID;references:RoomID"` } type Room struct { gorm.Model `json:"-"` ID int `json:"-" gorm:"primary_key;autoIncrement"` Name string `json:"name" gorm:"unique"` Temperatures []Temperature `json:"temperature" gorm:"foreignKey:ID"` Humidity []Humidity `json:"humidity" gorm:"foreignKey:ID"` } type AddRoom struct { Name string `json:"Name"` } type AddTemperature struct { RoomName string `json:"room_name"` Temperature float64 `json:"temperature"` } type AddHumidity struct { RoomName string `json:"room_name"` Humidity float64 `json:"humidity"` } type Error struct { Status string `json:"status"` Error string `json:"error"` }