mirror of
https://git.rwth-aachen.de/acs/public/villas/web-backend-go/
synced 2025-03-30 00:00:12 +01:00
Improvement of models:
- Added 'not null' tags - Followed associations according to Mongoose schemas from the current backend
This commit is contained in:
parent
428227f9cf
commit
a50626fd2f
7 changed files with 38 additions and 34 deletions
|
@ -2,14 +2,16 @@ package file
|
|||
|
||||
import (
|
||||
"github.com/jinzhu/gorm"
|
||||
"time"
|
||||
)
|
||||
|
||||
type File struct {
|
||||
gorm.Model
|
||||
Name string
|
||||
Path string
|
||||
Path string `gorm:"not null"`
|
||||
Type string
|
||||
Size uint
|
||||
Dimmensions string
|
||||
FileUser User
|
||||
Dimmensions string // TODO: Mixed Type
|
||||
FileUser User `gorm:"not null"`
|
||||
Date Time `gorm:"default:Time.Now"`
|
||||
}
|
||||
|
|
|
@ -8,10 +8,10 @@ import (
|
|||
|
||||
type Project struct {
|
||||
gorm.Model
|
||||
Name string
|
||||
UserProject User // XXX: association?
|
||||
Visualizations []Visualization // TODO: association & foreign key
|
||||
SimulationProject Simulation // XXX: association?n
|
||||
Name string `gorm:"not null"`
|
||||
ProjectUser User `gorm:"not null"`
|
||||
Visualizations []Visualization
|
||||
ProjectSimulation Simulation `gorm:"not null"`
|
||||
}
|
||||
|
||||
// TODO: execute before project.delete()
|
||||
|
|
|
@ -8,10 +8,10 @@ import (
|
|||
|
||||
type Simulation struct {
|
||||
gorm.Model
|
||||
Name string
|
||||
Running bool `gorm:"default:false"`
|
||||
Models []SimulationModel // TODO: association & foreign key
|
||||
Projects []Project // TODO: association & foreign key
|
||||
User []Users // TODO: association & foreign key
|
||||
StartParameters []string // TODO: Mixed Type
|
||||
Name string `gorm:"not null"`
|
||||
Running bool `gorm:"default:false"`
|
||||
Models []SimulationModel
|
||||
Projects []Project
|
||||
SimulationUser User `gorm:"not null"`
|
||||
StartParameters []string // TODO: Mixed Type
|
||||
}
|
||||
|
|
|
@ -13,6 +13,6 @@ type SimulationModel struct {
|
|||
OutputMapping []string // TODO: Mixed Type
|
||||
InputMapping []string // TODO: Mixed Type
|
||||
StartParameters []string // TODO: Mixed Type
|
||||
ModelSimulation Simulation // TODO: association & foreign key
|
||||
ModelSimulator Simulator // TODO: association & foreign key
|
||||
ModelSimulation Simulation `gorm:"not null"`
|
||||
ModelSimulator Simulator `gorm:"not null"`
|
||||
}
|
||||
|
|
|
@ -2,15 +2,17 @@ package simulator
|
|||
|
||||
import (
|
||||
"github.com/jinzhu/gorm"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Simulator struct {
|
||||
gorm.Model
|
||||
UUID string
|
||||
Host string `gorm:"default:"`
|
||||
Model string `gorm:"default:"`
|
||||
Uptime int `gorm:"default:0"`
|
||||
State string `gorm:"default:"`
|
||||
Properties []string
|
||||
RawProperties []string
|
||||
UUID string `gorm:"unique;not null"`
|
||||
Host string `gorm:"default:"`
|
||||
Model string `gorm:"default:"`
|
||||
Uptime int `gorm:"default:0"`
|
||||
State string `gorm:"default:"`
|
||||
StateUpdateAt Time `gorm:"default:Time.Now"`
|
||||
Properties []string // TODO: mixed type
|
||||
RawProperties []string // TODO: mixed type
|
||||
}
|
||||
|
|
|
@ -10,13 +10,13 @@ import (
|
|||
|
||||
type User struct {
|
||||
gorm.Model
|
||||
Username string `gorm:"unique"`
|
||||
Password string
|
||||
Mail string `gorm:"default:"`
|
||||
Role string `gorm:"default:user"`
|
||||
Projects []Project // TODO: association & foreign key
|
||||
Simulations []Simulaion // TODO: association & foreign key
|
||||
Files []File // TODO: association & foreign key
|
||||
Username string `gorm:"unique;not null"`
|
||||
Password string `gorm:"not null"`
|
||||
Mail string `gorm:"default:"`
|
||||
Role string `gorm:"default:user"`
|
||||
Projects []Project
|
||||
Simulations []Simulaion
|
||||
Files []File
|
||||
}
|
||||
|
||||
// TODO: callback for verifying password
|
||||
|
|
|
@ -6,9 +6,9 @@ import (
|
|||
|
||||
type Visualization struct {
|
||||
gorm.Model
|
||||
Name string
|
||||
VisualizationProject Project
|
||||
Widgets string
|
||||
Grid int `gorm:"default:15"`
|
||||
VisualizationUser User
|
||||
Name string `gorm:"not null"`
|
||||
VisualizationProject Project `gorm:"not null"`
|
||||
Widgets []string // XXX: array of what type?
|
||||
Grid int `gorm:"default:15"`
|
||||
VisualizationUser User `gorm:"not null"`
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue