-
Notifications
You must be signed in to change notification settings - Fork 0
/
user-group.go
58 lines (47 loc) · 1.06 KB
/
user-group.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
52
53
54
55
56
57
58
package model
import (
"time"
. "github.com/Madongming/resource-tree/global"
)
// DB recorder.
type DBUser struct {
ID int `gorm:"primary_key"`
CreatedAt time.Time
UpdatedAt time.Time
Name string `gorm:"type:varchar(128)"`
CnName string `gorm:"type:varchar(378)"`
}
// DB recorder.
type DBGroup struct {
ID int `gorm:"primary_key"`
CreatedAt time.Time
UpdatedAt time.Time
Name string `gorm:"type:varchar(128)"`
CnName string `gorm:"type:varchar(378)"`
}
// DB recorder.
type DBUserGroup struct {
ID int `gorm:"primary_key"`
CreatedAt time.Time
UpdatedAt time.Time
UserID int `gorm:"index"`
GroupID int `gorm:"index"`
}
func (u *DBUser) Create() error {
return DB().Create(u).Error
}
func (g *DBGroup) Create() error {
return DB().Create(g).Error
}
func (ug *DBUserGroup) Create() error {
return DB().Create(ug).Error
}
func (u *DBUser) Update() error {
return DB().Save(u).Error
}
func (g *DBGroup) Update() error {
return DB().Save(g).Error
}
func (ug *DBUserGroup) Update() error {
return DB().Save(ug).Error
}