-
Notifications
You must be signed in to change notification settings - Fork 96
/
config_resource.go
54 lines (44 loc) · 1.83 KB
/
config_resource.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
// 配置资源相关
package db
import (
"time"
"gorm.io/gorm"
)
type (
ConfigResource struct {
ID uint `gorm:"column:id;primary_key;auto_increment"`
UID uint `gorm:"column:uid;"` // 创建人
IsGlobal bool `gorm:"column:is_global;"` // 是否是全局资源
Name string `gorm:"column:name;type:varchar(50);"`
Env string `gorm:"column:env;type:varchar(30);"`
ZoneCode string `gorm:"column:zone_code;type:varchar(50);"`
Description string `gorm:"column:description;"`
Visible bool `gorm:"column:visible;"`
Tags []ConfigResourceTag `gorm:"foreignKey:config_resource_id"`
Zone Zone `gorm:"foreignKey:zone_code;association_foreignkey:zone_code;association_autoupdate:false"`
User User `gorm:"foreignKey:username;association_foreignkey:uid;association_autoupdate:false"`
Values []ConfigResourceValue `gorm:"foreignKey:config_resource_id;association_autoupdate:false"`
}
ConfigResourceValue struct {
ID uint `gorm:"column:id;primary_key;auto_increment"`
ConfigResourceID uint `gorm:"column:config_resource_id;"`
Value string `gorm:"column:value;type:text;"`
CreatedAt time.Time `gorm:"column:created_at;"`
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;"`
}
//ConfigResourceTag 资源标签
ConfigResourceTag struct {
ID uint `gorm:"column:id;primary_key;auto_increment"`
ConfigResourceID uint `gorm:"column:config_resource_id;"`
Value string `gorm:"column:value;type:varchar(30)"`
}
)
func (ConfigResource) TableName() string {
return "config_resource"
}
func (ConfigResourceValue) TableName() string {
return "config_resource_value"
}
func (ConfigResourceTag) TableName() string {
return "config_resource_tag"
}