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 (
|
import (
|
||||||
"github.com/jinzhu/gorm"
|
"github.com/jinzhu/gorm"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type File struct {
|
type File struct {
|
||||||
gorm.Model
|
gorm.Model
|
||||||
Name string
|
Name string
|
||||||
Path string
|
Path string `gorm:"not null"`
|
||||||
Type string
|
Type string
|
||||||
Size uint
|
Size uint
|
||||||
Dimmensions string
|
Dimmensions string // TODO: Mixed Type
|
||||||
FileUser User
|
FileUser User `gorm:"not null"`
|
||||||
|
Date Time `gorm:"default:Time.Now"`
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,10 +8,10 @@ import (
|
||||||
|
|
||||||
type Project struct {
|
type Project struct {
|
||||||
gorm.Model
|
gorm.Model
|
||||||
Name string
|
Name string `gorm:"not null"`
|
||||||
UserProject User // XXX: association?
|
ProjectUser User `gorm:"not null"`
|
||||||
Visualizations []Visualization // TODO: association & foreign key
|
Visualizations []Visualization
|
||||||
SimulationProject Simulation // XXX: association?n
|
ProjectSimulation Simulation `gorm:"not null"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: execute before project.delete()
|
// TODO: execute before project.delete()
|
||||||
|
|
|
@ -8,10 +8,10 @@ import (
|
||||||
|
|
||||||
type Simulation struct {
|
type Simulation struct {
|
||||||
gorm.Model
|
gorm.Model
|
||||||
Name string
|
Name string `gorm:"not null"`
|
||||||
Running bool `gorm:"default:false"`
|
Running bool `gorm:"default:false"`
|
||||||
Models []SimulationModel // TODO: association & foreign key
|
Models []SimulationModel
|
||||||
Projects []Project // TODO: association & foreign key
|
Projects []Project
|
||||||
User []Users // TODO: association & foreign key
|
SimulationUser User `gorm:"not null"`
|
||||||
StartParameters []string // TODO: Mixed Type
|
StartParameters []string // TODO: Mixed Type
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,6 @@ type SimulationModel struct {
|
||||||
OutputMapping []string // TODO: Mixed Type
|
OutputMapping []string // TODO: Mixed Type
|
||||||
InputMapping []string // TODO: Mixed Type
|
InputMapping []string // TODO: Mixed Type
|
||||||
StartParameters []string // TODO: Mixed Type
|
StartParameters []string // TODO: Mixed Type
|
||||||
ModelSimulation Simulation // TODO: association & foreign key
|
ModelSimulation Simulation `gorm:"not null"`
|
||||||
ModelSimulator Simulator // TODO: association & foreign key
|
ModelSimulator Simulator `gorm:"not null"`
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,15 +2,17 @@ package simulator
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/jinzhu/gorm"
|
"github.com/jinzhu/gorm"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Simulator struct {
|
type Simulator struct {
|
||||||
gorm.Model
|
gorm.Model
|
||||||
UUID string
|
UUID string `gorm:"unique;not null"`
|
||||||
Host string `gorm:"default:"`
|
Host string `gorm:"default:"`
|
||||||
Model string `gorm:"default:"`
|
Model string `gorm:"default:"`
|
||||||
Uptime int `gorm:"default:0"`
|
Uptime int `gorm:"default:0"`
|
||||||
State string `gorm:"default:"`
|
State string `gorm:"default:"`
|
||||||
Properties []string
|
StateUpdateAt Time `gorm:"default:Time.Now"`
|
||||||
RawProperties []string
|
Properties []string // TODO: mixed type
|
||||||
|
RawProperties []string // TODO: mixed type
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,13 +10,13 @@ import (
|
||||||
|
|
||||||
type User struct {
|
type User struct {
|
||||||
gorm.Model
|
gorm.Model
|
||||||
Username string `gorm:"unique"`
|
Username string `gorm:"unique;not null"`
|
||||||
Password string
|
Password string `gorm:"not null"`
|
||||||
Mail string `gorm:"default:"`
|
Mail string `gorm:"default:"`
|
||||||
Role string `gorm:"default:user"`
|
Role string `gorm:"default:user"`
|
||||||
Projects []Project // TODO: association & foreign key
|
Projects []Project
|
||||||
Simulations []Simulaion // TODO: association & foreign key
|
Simulations []Simulaion
|
||||||
Files []File // TODO: association & foreign key
|
Files []File
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: callback for verifying password
|
// TODO: callback for verifying password
|
||||||
|
|
|
@ -6,9 +6,9 @@ import (
|
||||||
|
|
||||||
type Visualization struct {
|
type Visualization struct {
|
||||||
gorm.Model
|
gorm.Model
|
||||||
Name string
|
Name string `gorm:"not null"`
|
||||||
VisualizationProject Project
|
VisualizationProject Project `gorm:"not null"`
|
||||||
Widgets string
|
Widgets []string // XXX: array of what type?
|
||||||
Grid int `gorm:"default:15"`
|
Grid int `gorm:"default:15"`
|
||||||
VisualizationUser User
|
VisualizationUser User `gorm:"not null"`
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue