feat: 初始化配置中心项目
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
package model
|
||||
|
||||
import "time"
|
||||
|
||||
type AppConfig struct {
|
||||
Id int `xorm:"int autoincr pk" json:"id"`
|
||||
GroupId *int `xorm:"int" json:"groupId"`
|
||||
AppId *int `xorm:"int" json:"appId"`
|
||||
AppCode string `xorm:"varchar(32)" json:"appCode"`
|
||||
Env string `xorm:"varchar(16)" json:"env"`
|
||||
Version string `xorm:"varchar(32)" json:"version"`
|
||||
Name string `xorm:"varchar(32)" json:"name"`
|
||||
Type int `xorm:"smallint(1)" json:"type"` // 1:file, 2:kv, 3:json
|
||||
Contents string `xorm:"text" json:"contents"`
|
||||
Enabled bool `xorm:"tinyint(1) default 1" json:"enabled"`
|
||||
CreatedAt *time.Time `xorm:"datetime" json:"createdAt"`
|
||||
CreatedBy string `xorm:"varchar(32)" json:"createdBy"`
|
||||
UpdatedAt *time.Time `xorm:"datetime" json:"updatedAt"`
|
||||
UpdatedBy string `xorm:"varchar(32)" json:"updatedBy"`
|
||||
Global bool `xorm:"-" json:"global"`
|
||||
AppNames string `xorm:"-" json:"appNames,omitempty"`
|
||||
}
|
||||
|
||||
type AppConfigHistory struct {
|
||||
Id int `xorm:"int autoincr pk" json:"id"`
|
||||
OriginId int `xorm:"int" json:"originId"`
|
||||
AppId *int `xorm:"int" json:"appId"`
|
||||
AppName string `xorm:"varchar(32)" json:"appName"`
|
||||
AppNames string `xorm:"varchar(64)" json:"appNames"`
|
||||
Env string `xorm:"varchar(16)" json:"env"`
|
||||
Version string `xorm:"varchar(32)" json:"version"`
|
||||
Name string `xorm:"varchar(32)" json:"name"`
|
||||
Type int `xorm:"smallint(1)" json:"type"`
|
||||
Contents string `xorm:"text" json:"contents"`
|
||||
ActiveContents string `xorm:"-" json:"activeContents,omitempty"`
|
||||
CreatedAt *time.Time `xorm:"datetime" json:"createdAt"`
|
||||
CreatedBy string `xorm:"varchar(32)" json:"createdBy"`
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package model
|
||||
|
||||
import "time"
|
||||
|
||||
type Application struct {
|
||||
Id int `xorm:"int autoincr pk" json:"id"`
|
||||
GroupId *int `xorm:"int" json:"groupId"`
|
||||
ParentId *int `xorm:"int" json:"parentId"`
|
||||
Name string `xorm:"varchar(32)" json:"name"`
|
||||
Code string `xorm:"varchar(32)" json:"code"`
|
||||
ServiceId string `xorm:"varchar(64)" json:"serviceId"`
|
||||
IsModule bool `xorm:"tinyint(1) default 1" json:"isModule"`
|
||||
OwnerId *int `xorm:"int" json:"ownerId"`
|
||||
OwnerName string `xorm:"varchar(16)" json:"ownerName"`
|
||||
Remarks string `xorm:"text" json:"remarks"`
|
||||
Enabled bool `xorm:"tinyint(1) default 1" json:"enabled"`
|
||||
CreatedAt *time.Time `xorm:"datetime" json:"createdAt"`
|
||||
CreatedBy string `xorm:"varchar(32)" json:"createdBy"`
|
||||
UpdatedAt *time.Time `xorm:"datetime" json:"updatedAt"`
|
||||
UpdatedBy string `xorm:"varchar(32)" json:"updatedBy"`
|
||||
ParentName string `xorm:"-" json:"parentName,omitempty"`
|
||||
FullName string `xorm:"-" json:"fullName,omitempty"`
|
||||
GroupName string `xorm:"-" json:"groupName,omitempty"`
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package model
|
||||
|
||||
import "time"
|
||||
|
||||
type BusinessGroup struct {
|
||||
Id int `xorm:"int autoincr pk" json:"id"`
|
||||
Name string `xorm:"varchar(32) notnull" json:"name"`
|
||||
Master string `xorm:"varchar(16)" json:"master"`
|
||||
MasterUid *int `xorm:"int" json:"masterUid"`
|
||||
Remarks string `xorm:"text" json:"remarks"`
|
||||
Enabled bool `xorm:"tinyint(1) default 1" json:"enabled"`
|
||||
CreatedAt *time.Time `xorm:"datetime" json:"createdAt"`
|
||||
CreatedBy string `xorm:"varchar(32)" json:"createdBy"`
|
||||
UpdatedAt *time.Time `xorm:"datetime" json:"updatedAt"`
|
||||
UpdatedBy string `xorm:"varchar(32)" json:"updatedBy"`
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package model
|
||||
|
||||
type Profile struct {
|
||||
Id int `xorm:"int autoincr pk" json:"id"`
|
||||
Name string `xorm:"varchar(32)" json:"name"`
|
||||
Alias string `xorm:"varchar(32)" json:"alias"`
|
||||
IsDefault bool `xorm:"tinyint(1) default 0" json:"isDefault"`
|
||||
Enabled bool `xorm:"tinyint(1) default 1" json:"enabled"`
|
||||
}
|
||||
|
||||
type AppExtrAttr struct {
|
||||
AppId int `xorm:"int pk" json:"appId"`
|
||||
Env string `xorm:"varchar(16) pk" json:"env"`
|
||||
AttrName string `xorm:"varchar(32) pk" json:"attrName"`
|
||||
AttrValue string `xorm:"varchar(100)" json:"attrValue"`
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package model
|
||||
|
||||
type WrapperResponse struct {
|
||||
Code int `json:"code"`
|
||||
Msg string `json:"msg,omitempty"`
|
||||
Data interface{} `json:"data,omitempty"`
|
||||
}
|
||||
|
||||
type PageResult struct {
|
||||
PageNo int `json:"pageNo"`
|
||||
PageSize int `json:"pageSize"`
|
||||
Total int64 `json:"total"`
|
||||
Data interface{} `json:"data"`
|
||||
}
|
||||
|
||||
type SelectOption struct {
|
||||
Value string `json:"value"`
|
||||
Label string `json:"label"`
|
||||
}
|
||||
|
||||
type Menu struct {
|
||||
Title string `json:"title"`
|
||||
Icon string `json:"icon"`
|
||||
Active bool `json:"active"`
|
||||
Children []SubMenu `json:"children"`
|
||||
}
|
||||
|
||||
type SubMenu struct {
|
||||
Title string `json:"title"`
|
||||
Icon string `json:"icon"`
|
||||
Url string `json:"url"`
|
||||
}
|
||||
|
||||
func NewMenu(title, icon string, active bool) Menu {
|
||||
return Menu{Title: title, Icon: icon, Active: active, Children: make([]SubMenu, 0)}
|
||||
}
|
||||
|
||||
func (m *Menu) AddSubMenu(title, icon, url string) {
|
||||
m.Children = append(m.Children, SubMenu{Title: title, Icon: icon, Url: url})
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package model
|
||||
|
||||
import "time"
|
||||
|
||||
type User struct {
|
||||
Id int `xorm:"int autoincr pk" json:"id"`
|
||||
GroupId *int `xorm:"int" json:"groupId"`
|
||||
Name string `xorm:"varchar(16)" json:"name"`
|
||||
Password string `xorm:"varchar(64)" json:"-"`
|
||||
Mobile string `xorm:"char(11)" json:"mobile"`
|
||||
Email string `xorm:"varchar(32)" json:"email"`
|
||||
Type string `xorm:"varchar(16) default 'user'" json:"type"` // user, groupAdmin, superAdmin
|
||||
Enabled bool `xorm:"tinyint(1) default 1" json:"enabled"`
|
||||
CreatedAt *time.Time `xorm:"datetime" json:"createdAt"`
|
||||
UpdatedAt *time.Time `xorm:"datetime" json:"updatedAt"`
|
||||
GroupName string `xorm:"-" json:"groupName,omitempty"`
|
||||
GroupMaster bool `xorm:"-" json:"groupMaster,omitempty"`
|
||||
}
|
||||
|
||||
type UserPermission struct {
|
||||
Id int `xorm:"int autoincr pk" json:"id"`
|
||||
UserId int `xorm:"int" json:"userId"`
|
||||
Env string `xorm:"varchar(16)" json:"env"`
|
||||
AppId int `xorm:"int" json:"appId"`
|
||||
Operate string `xorm:"varchar(8) default 'RW'" json:"operate"` // RO, RW
|
||||
}
|
||||
|
||||
type LoginUserInfo struct {
|
||||
Id string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Type string `json:"type"`
|
||||
GroupId *int `json:"groupId"`
|
||||
GrantAppIds []int `json:"grantAppIds"`
|
||||
GrantPermissons []string `json:"grantPermissons"`
|
||||
GroupMaster bool `json:"groupMaster"`
|
||||
}
|
||||
|
||||
func (u *LoginUserInfo) IsSuperAdmin() bool {
|
||||
return u.Type == "superAdmin"
|
||||
}
|
||||
|
||||
func (u *LoginUserInfo) IsGroupAdmin() bool {
|
||||
return u.Type == "groupAdmin"
|
||||
}
|
||||
Reference in New Issue
Block a user