/
projectModel.go
51 lines (44 loc) · 1.1 KB
/
projectModel.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package gormdal
import (
"github.com/gregod-com/grgd/interfaces"
"gorm.io/gorm"
)
func projectModelToIProject(in *ProjectModel, out interfaces.IProject) error {
out.SetID(in.ID)
out.SetName(in.Name)
out.SetPath(in.Path)
out.SetSettingsYamlPath(in.SettingsYamlPath)
out.SetInitialized(in.Initialized)
return nil
}
func iprojectToProjectModel(in interfaces.IProject, out *ProjectModel) error {
out.ID = in.GetID()
out.Name = in.GetName()
out.Initialized = in.IsInitialized()
out.Path = in.GetPath()
out.SettingsYamlPath = in.GetSettingsYamlPath()
return nil
}
// ProjectModel ...
type ProjectModel struct {
gorm.Model
Name string `gorm:"not null;default:null"`
Path string
SettingsYamlPath string
Initialized bool
Description string
Profiles []*ProfileModel `gorm:"constraint:OnUpdate:CASCADE,OnDelete:SET NULL;;many2many:profiles_projects;"`
}
// ProjectTag ...
type ProjectTag struct {
gorm.Model
Name string
}
// GetID ...
func (p *ProjectModel) GetID() uint {
return p.ID
}
// GetName ...
func (p *ProjectModel) GetName() string {
return p.Name
}