refactor🎨: 数据初始化

This commit is contained in:
wenjianzhang committed 2021-06-09 18:30:47 +08:00
1 parent 6a31ac916a
commit 54e116818b
15 files changed
+4175 -266

No files matched your search

+1 -23
View File
@@ -30,28 +30,6 @@ type SysMenu struct {
models.ModelTime
}
//type SysMenus struct {
// MenuId int `json:"menuId" gorm:"column:menu_id;primaryKey;autoIncrement;"`
// MenuName string `json:"menuName" gorm:"column:menu_name"`
// Title string `json:"title" gorm:"column:title"`
// Icon string `json:"icon" gorm:"column:icon"`
// Path string `json:"path" gorm:"column:path"`
// MenuType string `json:"menuType" gorm:"column:menu_type"`
// Action string `json:"action" gorm:"column:action"`
// Permission string `json:"permission" gorm:"column:permission"`
// ParentId int `json:"parentId" gorm:"column:parent_id"`
// NoCache bool `json:"noCache" gorm:"column:no_cache"`
// Breadcrumb string `json:"breadcrumb" gorm:"column:breadcrumb"`
// Component string `json:"component" gorm:"column:component"`
// Sort int `json:"sort" gorm:"column:sort"`
// Visible string `json:"visible" gorm:"column:visible"`
// Children []SysMenu `json:"children" gorm:"-"`
// models.ControlBy
// models.ModelTime
// DataScope string `json:"dataScope" gorm:"-"`
// Params string `json:"params" gorm:"-"`
//}
func (SysMenu) TableName() string {
return "sys_menu"
}
@@ -63,4 +41,4 @@ func (e *SysMenu) Generate() models.ActiveRecord {
func (e *SysMenu) GetId() interface{} {
return e.MenuId
}
}
+2 -2
View File
@@ -6,7 +6,7 @@ type SysPost struct {
PostId int `gorm:"primaryKey;autoIncrement" json:"postId"` //岗位编号
PostName string `gorm:"size:128;" json:"postName"` //岗位名称
PostCode string `gorm:"size:128;" json:"postCode"` //岗位代码
Sort int `gorm:"" json:"sort"` //岗位排序
Sort int `gorm:"size:4;" json:"sort"` //岗位排序
Status int `gorm:"size:4;" json:"status"` //状态
Remark string `gorm:"size:255;" json:"remark"` //描述
models.ControlBy
@@ -27,4 +27,4 @@ func (e *SysPost) Generate() models.ActiveRecord {
func (e *SysPost) GetId() interface{} {
return e.PostId
}
}
-19
View File
@@ -1,19 +0,0 @@
package models
type SysRole struct {
RoleId int `json:"roleId" gorm:"primaryKey;autoIncrement"` // 角色编码
RoleName string `json:"roleName" gorm:"size:128;"` // 角色名称
Status string `json:"status" gorm:"size:4;"` //
RoleKey string `json:"roleKey" gorm:"size:128;"` //角色代码
RoleSort int `json:"roleSort" gorm:""` //角色排序
Flag string `json:"flag" gorm:"size:128;"` //
Remark string `json:"remark" gorm:"size:255;"` //备注
Admin bool `json:"admin" gorm:"size:4;"`
DataScope string `json:"dataScope" gorm:"size:128;"`
ModelTime
ControlBy
}
func (SysRole) TableName() string {
return "sys_role"
}
-12
View File
@@ -1,12 +0,0 @@
package models
type RoleMenu struct {
RoleId int `gorm:""`
MenuId int `gorm:""`
RoleName string `gorm:"size:128)"`
ControlBy
}
func (RoleMenu) TableName() string {
return "sys_role_menu"
}
+9 -23
View File
@@ -1,30 +1,16 @@
package models
import "go-admin/common/models"
type SysApi struct {
Id int `json:"id" gorm:"primaryKey;autoIncrement;comment:主键编码"`
Handle string `json:"handle" gorm:"type:varchar(128);comment:handle"`
Title string `json:"title" gorm:"type:varchar(128);comment:标题"`
Permission string `json:"permission" gorm:"size:255;"`
Path string `json:"path" gorm:"type:varchar(128);comment:地址"`
Paths string `json:"paths" gorm:"type:varchar(128);comment:Paths"`
Action string `json:"action" gorm:"type:varchar(16);comment:类型"`
ParentId int `json:"parentId" gorm:"comment:按钮id"`
Sort int `json:"sort" gorm:"type:tinyint(4);comment:排序"`
models.ModelTime
models.ControlBy
Id int `json:"id" gorm:"primaryKey;autoIncrement;comment:主键编码"`
Handle string `json:"handle" gorm:"size:128;comment:handle"`
Title string `json:"title" gorm:"size:128;comment:标题"`
Path string `json:"path" gorm:"size:128;comment:地址"`
Action string `json:"action" gorm:"size:16;comment:请求类型"`
Type string `json:"type" gorm:"size:16;comment:接口类型"`
ModelTime
ControlBy
}
func (SysApi) TableName() string {
return "sys_api"
}
func (e *SysApi) Generate() models.ActiveRecord {
o := *e
return &o
}
func (e *SysApi) GetId() interface{} {
return e.Id
}
}
+18 -20
View File
@@ -1,29 +1,27 @@
package models
type SysMenu struct {
MenuId int `json:"menuId" gorm:"primaryKey;autoIncrement"`
MenuName string `json:"menuName" gorm:"size:128;"`
Title string `json:"title" gorm:"size:128;"`
Icon string `json:"icon" gorm:"size:128;"`
Path string `json:"path" gorm:"size:128;"`
Paths string `json:"paths" gorm:"size:128;"`
MenuType string `json:"menuType" gorm:"size:1;"`
Action string `json:"action" gorm:"size:16;"`
Permission string `json:"permission" gorm:"size:255;"`
ParentId int `json:"parentId" gorm:"size:11;"`
NoCache bool `json:"noCache" gorm:"size:8;"`
Breadcrumb string `json:"breadcrumb" gorm:"size:255;"`
Component string `json:"component" gorm:"size:255;"`
Sort int `json:"sort" gorm:"size:4;"`
Visible string `json:"visible" gorm:"size:1;"`
IsFrame string `json:"isFrame" gorm:"size:1;DEFAULT:0;"`
SysApi []SysApi `gorm:"many2many:sys_menu_api_rule"`
DataScope string `json:"dataScope" gorm:"-"`
Params string `json:"params" gorm:"-"`
MenuId int `json:"menuId" gorm:"primaryKey;autoIncrement"`
MenuName string `json:"menuName" gorm:"size:128;"`
Title string `json:"title" gorm:"size:128;"`
Icon string `json:"icon" gorm:"size:128;"`
Path string `json:"path" gorm:"size:128;"`
Paths string `json:"paths" gorm:"size:128;"`
MenuType string `json:"menuType" gorm:"size:1;"`
Action string `json:"action" gorm:"size:16;"`
Permission string `json:"permission" gorm:"size:255;"`
ParentId int `json:"parentId" gorm:"size:11;"`
NoCache bool `json:"noCache" gorm:"size:8;"`
Breadcrumb string `json:"breadcrumb" gorm:"size:255;"`
Component string `json:"component" gorm:"size:255;"`
Sort int `json:"sort" gorm:"size:4;"`
Visible string `json:"visible" gorm:"size:1;"`
IsFrame string `json:"isFrame" gorm:"size:1;DEFAULT:0;"`
SysApi []SysApi `json:"sysApi" gorm:"many2many:sys_menu_api_rule"`
ControlBy
ModelTime
}
func (SysMenu) TableName() string {
return "sys_menu"
}
}
@@ -1,16 +1,16 @@
package models
type Post struct {
type SysPost struct {
PostId int `gorm:"primaryKey;autoIncrement" json:"postId"` //岗位编号
PostName string `gorm:"size:128;" json:"postName"` //岗位名称
PostCode string `gorm:"size:128;" json:"postCode"` //岗位代码
Sort int `gorm:"" json:"sort"` //岗位排序
Status string `gorm:"size:4;" json:"status"` //状态
Sort int `gorm:"size:4;" json:"sort"` //岗位排序
Status int `gorm:"size:4;" json:"status"` //状态
Remark string `gorm:"size:255;" json:"remark"` //描述
ModelTime
ControlBy
ModelTime
}
func (Post) TableName() string {
func (SysPost) TableName() string {
return "sys_post"
}
}
+20
View File
@@ -0,0 +1,20 @@
package models
type SysRole struct {
RoleId int `json:"roleId" gorm:"primaryKey;autoIncrement"` // 角色编码
RoleName string `json:"roleName" gorm:"size:128;"` // 角色名称
Status string `json:"status" gorm:"size:4;"` //
RoleKey string `json:"roleKey" gorm:"size:128;"` //角色代码
RoleSort int `json:"roleSort" gorm:""` //角色排序
Flag string `json:"flag" gorm:"size:128;"` //
Remark string `json:"remark" gorm:"size:255;"` //备注
Admin bool `json:"admin" gorm:"size:4;"`
DataScope string `json:"dataScope" gorm:"size:128;"`
SysMenu []SysMenu `json:"sysMenu" gorm:"many2many:sys_role_menu;foreignKey:RoleId;joinForeignKey:role_id;references:MenuId;joinReferences:menu_id;"`
ModelTime
ControlBy
}
func (SysRole) TableName() string {
return "sys_role"
}
+3 -3
View File
@@ -6,8 +6,6 @@ import (
)
type SysUser struct {
ControlBy
ModelTime
UserId int `gorm:"primaryKey;autoIncrement;comment:编码" json:"userId"`
Username string `json:"username" gorm:"type:varchar(64);comment:用户名"`
Password string `json:"-" gorm:"type:varchar(128);comment:密码"`
@@ -22,6 +20,8 @@ type SysUser struct {
PostId int `json:"postId" gorm:"type:bigint(20);comment:岗位"`
Remark string `json:"remark" gorm:"type:varchar(255);comment:备注"`
Status string `json:"status" gorm:"type:varchar(4);comment:状态"`
ControlBy
ModelTime
}
func (SysUser) TableName() string {
@@ -45,4 +45,4 @@ func (e *SysUser) Encrypt() (err error) {
func (e *SysUser) BeforeCreate(_ *gorm.DB) error {
return e.Encrypt()
}
}
@@ -25,11 +25,10 @@ func _1599190683659Tables(db *gorm.DB, version string) error {
new(models.SysMenu),
new(models.SysLoginLog),
new(models.SysOperaLog),
new(models.RoleMenu),
new(models.SysRoleDept),
new(models.SysUser),
new(models.SysRole),
new(models.Post),
new(models.SysPost),
new(models.DictData),
new(models.DictType),
new(models.SysJob),
@@ -47,4 +46,4 @@ func _1599190683659Tables(db *gorm.DB, version string) error {
return db.Create(&common.Migration{
Version: version,
}).Error
}
}
+4114 -155
View File
File diff suppressed because it is too large. Load diff