feat:update sql init
This commit is contained in:
1 parent
ca8d1e7e33
commit
000cd1d07d
10 files changed
+370
-347
No files matched your search
@@ -17,9 +17,10 @@ type SysConfig struct {
|
||||
Remark string `json:"remark" gorm:"size:128;"` //备注
|
||||
CreateBy string `json:"createBy" gorm:"size:128;"`
|
||||
UpdateBy string `json:"updateBy" gorm:"size:128;"`
|
||||
BaseModel
|
||||
|
||||
DataScope string `json:"dataScope" gorm:"-"`
|
||||
Params string `json:"params" gorm:"-"`
|
||||
BaseModel
|
||||
}
|
||||
|
||||
func (SysConfig) TableName() string {
|
||||
|
||||
@@ -20,10 +20,11 @@ type SysDept struct {
|
||||
Status string `json:"status" gorm:"size:4;"` //状态
|
||||
CreateBy string `json:"createBy" gorm:"size:64;"`
|
||||
UpdateBy string `json:"updateBy" gorm:"size:64;"`
|
||||
BaseModel
|
||||
|
||||
DataScope string `json:"dataScope" gorm:"-"`
|
||||
Params string `json:"params" gorm:"-"`
|
||||
Children []SysDept `json:"children" gorm:"-"`
|
||||
BaseModel
|
||||
}
|
||||
|
||||
func (SysDept) TableName() string {
|
||||
|
||||
@@ -21,9 +21,10 @@ type DictData struct {
|
||||
CreateBy string `gorm:"size:64;" json:"createBy"` //
|
||||
UpdateBy string `gorm:"size:64;" json:"updateBy"` //
|
||||
Remark string `gorm:"size:255;" json:"remark"` //备注
|
||||
BaseModel
|
||||
|
||||
Params string `gorm:"-" json:"params"`
|
||||
DataScope string `gorm:"-" json:"dataScope"`
|
||||
BaseModel
|
||||
}
|
||||
|
||||
func (DictData) TableName() string {
|
||||
|
||||
@@ -14,12 +14,13 @@ type DictType struct {
|
||||
DictName string `gorm:"size:128;" json:"dictName"` //字典名称
|
||||
DictType string `gorm:"size:128;" json:"dictType"` //字典类型
|
||||
Status string `gorm:"size:4;" json:"status"` //状态
|
||||
DataScope string `gorm:"-" json:"dataScope"` //
|
||||
Params string `gorm:"-" json:"params"` //
|
||||
CreateBy string `gorm:"size:11;" json:"createBy"` //创建者
|
||||
UpdateBy string `gorm:"size:11;" json:"updateBy"` //更新者
|
||||
Remark string `gorm:"size:255;" json:"remark"` //备注
|
||||
BaseModel
|
||||
|
||||
DataScope string `gorm:"-" json:"dataScope"` //
|
||||
Params string `gorm:"-" json:"params"` //
|
||||
}
|
||||
|
||||
func (DictType) TableName() string {
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
package gorm
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
|
||||
"go-admin/app/admin/models"
|
||||
"go-admin/app/admin/models/tools"
|
||||
)
|
||||
|
||||
func AutoMigrate(db *gorm.DB) (err error) {
|
||||
err = db.Migrator().AutoMigrate(new(models.CasbinRule),
|
||||
new(models.SysDept),
|
||||
new(models.SysConfig),
|
||||
new(tools.SysTables),
|
||||
new(tools.SysColumns),
|
||||
new(models.Menu),
|
||||
new(models.LoginLog),
|
||||
new(models.SysOperLog),
|
||||
new(models.RoleMenu),
|
||||
new(models.SysRoleDept),
|
||||
new(models.SysUser),
|
||||
new(models.SysRole),
|
||||
new(models.Post),
|
||||
new(models.DictData),
|
||||
new(models.DictType),
|
||||
new(models.SysJob),
|
||||
new(models.SysConfig),
|
||||
new(models.SysSetting),
|
||||
new(models.SysFileDir),
|
||||
new(models.SysCategory),
|
||||
new(models.SysContent))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
models.DataInit()
|
||||
return err
|
||||
}
|
||||
|
||||
func CustomMigrate(db *gorm.DB, table interface{}) error {
|
||||
return db.AutoMigrate(&table)
|
||||
}
|
||||
@@ -14,9 +14,10 @@ type Post struct {
|
||||
Remark string `gorm:"size:255;" json:"remark"` //描述
|
||||
CreateBy string `gorm:"size:128;" json:"createBy"`
|
||||
UpdateBy string `gorm:"size:128;" json:"updateBy"`
|
||||
BaseModel
|
||||
|
||||
DataScope string `gorm:"-" json:"dataScope"`
|
||||
Params string `gorm:"-" json:"params"`
|
||||
BaseModel
|
||||
}
|
||||
|
||||
func (Post) TableName() string {
|
||||
|
||||
@@ -20,10 +20,11 @@ type SysRole struct {
|
||||
Remark string `json:"remark" gorm:"size:255;"` //备注
|
||||
Admin bool `json:"admin" gorm:"size:4;"`
|
||||
DataScope string `json:"dataScope" gorm:"size:128;"`
|
||||
BaseModel
|
||||
|
||||
Params string `json:"params" gorm:"-"`
|
||||
MenuIds []int `json:"menuIds" gorm:"-"`
|
||||
DeptIds []int `json:"deptIds" gorm:"-"`
|
||||
BaseModel
|
||||
}
|
||||
|
||||
func (SysRole) TableName() string {
|
||||
|
||||
@@ -56,16 +56,16 @@ type SysUserB struct {
|
||||
UpdateBy string `gorm:"size:128" json:"updateBy"` //
|
||||
Remark string `gorm:"size:255" json:"remark"` //备注
|
||||
Status string `gorm:"size:4;" json:"status"`
|
||||
BaseModel
|
||||
|
||||
DataScope string `gorm:"-" json:"dataScope"`
|
||||
Params string `gorm:"-" json:"params"`
|
||||
|
||||
BaseModel
|
||||
}
|
||||
|
||||
type SysUser struct {
|
||||
SysUserId
|
||||
SysUserB
|
||||
LoginM
|
||||
SysUserB
|
||||
}
|
||||
|
||||
func (SysUser) TableName() string {
|
||||
|
||||
Reference in new issue
Block a user