1
Some checks failed
Build / build (push) Has been cancelled
CodeQL / Analyze (go) (push) Has been cancelled
build / Build (push) Has been cancelled
GitHub Actions Mirror / mirror_to_gitee (push) Has been cancelled
GitHub Actions Mirror / mirror_to_gitlab (push) Has been cancelled
Issue Close Require / issue-close-require (push) Has been cancelled
Issue Check Inactive / issue-check-inactive (push) Has been cancelled
Some checks failed
Build / build (push) Has been cancelled
CodeQL / Analyze (go) (push) Has been cancelled
build / Build (push) Has been cancelled
GitHub Actions Mirror / mirror_to_gitee (push) Has been cancelled
GitHub Actions Mirror / mirror_to_gitlab (push) Has been cancelled
Issue Close Require / issue-close-require (push) Has been cancelled
Issue Check Inactive / issue-check-inactive (push) Has been cancelled
This commit is contained in:
22
cmd/migrate/migration/models/by.go
Normal file
22
cmd/migrate/migration/models/by.go
Normal file
@ -0,0 +1,22 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type ControlBy struct {
|
||||
CreateBy int `json:"createBy" gorm:"index;comment:创建者"`
|
||||
UpdateBy int `json:"updateBy" gorm:"index;comment:更新者"`
|
||||
}
|
||||
|
||||
type Model struct {
|
||||
Id int `json:"id" gorm:"primaryKey;autoIncrement;comment:主键编码"`
|
||||
}
|
||||
|
||||
type ModelTime struct {
|
||||
CreatedAt time.Time `json:"createdAt" gorm:"comment:创建时间"`
|
||||
UpdatedAt time.Time `json:"updatedAt" gorm:"comment:最后更新时间"`
|
||||
DeletedAt gorm.DeletedAt `json:"-" gorm:"index;comment:删除时间"`
|
||||
}
|
||||
17
cmd/migrate/migration/models/casbin_rule.go
Normal file
17
cmd/migrate/migration/models/casbin_rule.go
Normal file
@ -0,0 +1,17 @@
|
||||
package models
|
||||
|
||||
// CasbinRule sys_casbin_rule
|
||||
type CasbinRule struct {
|
||||
ID uint `gorm:"primaryKey;autoIncrement"`
|
||||
Ptype string `gorm:"size:512;uniqueIndex:unique_index"`
|
||||
V0 string `gorm:"size:512;uniqueIndex:unique_index"`
|
||||
V1 string `gorm:"size:512;uniqueIndex:unique_index"`
|
||||
V2 string `gorm:"size:512;uniqueIndex:unique_index"`
|
||||
V3 string `gorm:"size:512;uniqueIndex:unique_index"`
|
||||
V4 string `gorm:"size:512;uniqueIndex:unique_index"`
|
||||
V5 string `gorm:"size:512;uniqueIndex:unique_index"`
|
||||
}
|
||||
|
||||
func (CasbinRule) TableName() string {
|
||||
return "sys_casbin_rule"
|
||||
}
|
||||
72
cmd/migrate/migration/models/initdb.go
Normal file
72
cmd/migrate/migration/models/initdb.go
Normal file
@ -0,0 +1,72 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"go-admin/common/global"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"strings"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
func InitDb(db *gorm.DB) (err error) {
|
||||
filePath := "config/db.sql"
|
||||
if global.Driver == "postgres" {
|
||||
filePath := "config/db.sql"
|
||||
if err = ExecSql(db, filePath); err != nil {
|
||||
return err
|
||||
}
|
||||
filePath = "config/pg.sql"
|
||||
err = ExecSql(db, filePath)
|
||||
} else if global.Driver == "mysql" {
|
||||
filePath = "config/db-begin-mysql.sql"
|
||||
if err = ExecSql(db, filePath); err != nil {
|
||||
return err
|
||||
}
|
||||
filePath = "config/db.sql"
|
||||
if err = ExecSql(db, filePath); err != nil {
|
||||
return err
|
||||
}
|
||||
filePath = "config/db-end-mysql.sql"
|
||||
err = ExecSql(db, filePath)
|
||||
} else {
|
||||
err = ExecSql(db, filePath)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func ExecSql(db *gorm.DB, filePath string) error {
|
||||
sql, err := Ioutil(filePath)
|
||||
if err != nil {
|
||||
fmt.Println("数据库基础数据初始化脚本读取失败!原因:", err.Error())
|
||||
return err
|
||||
}
|
||||
sqlList := strings.Split(sql, ";")
|
||||
for i := 0; i < len(sqlList)-1; i++ {
|
||||
if strings.Contains(sqlList[i], "--") {
|
||||
fmt.Println(sqlList[i])
|
||||
continue
|
||||
}
|
||||
sql := strings.Replace(sqlList[i]+";", "\n", "", -1)
|
||||
sql = strings.TrimSpace(sql)
|
||||
if err = db.Exec(sql).Error; err != nil {
|
||||
log.Printf("error sql: %s", sql)
|
||||
if !strings.Contains(err.Error(), "Query was empty") {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func Ioutil(filePath string) (string, error) {
|
||||
if contents, err := ioutil.ReadFile(filePath); err == nil {
|
||||
//因为contents是[]byte类型,直接转换成string类型后会多一行空格,需要使用strings.Replace替换换行符
|
||||
result := strings.Replace(string(contents), "\n", "", 1)
|
||||
fmt.Println("Use ioutil.ReadFile to read a file:", result)
|
||||
return result, nil
|
||||
} else {
|
||||
return "", err
|
||||
}
|
||||
}
|
||||
11
cmd/migrate/migration/models/model.go
Normal file
11
cmd/migrate/migration/models/model.go
Normal file
@ -0,0 +1,11 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type BaseModel struct {
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
DeletedAt *time.Time `json:"deletedAt"`
|
||||
}
|
||||
10
cmd/migrate/migration/models/role_dept.go
Normal file
10
cmd/migrate/migration/models/role_dept.go
Normal file
@ -0,0 +1,10 @@
|
||||
package models
|
||||
|
||||
type SysRoleDept struct {
|
||||
RoleId int `gorm:"size:11;primaryKey"`
|
||||
DeptId int `gorm:"size:11;primaryKey"`
|
||||
}
|
||||
|
||||
func (SysRoleDept) TableName() string {
|
||||
return "sys_role_dept"
|
||||
}
|
||||
16
cmd/migrate/migration/models/sys_api.go
Normal file
16
cmd/migrate/migration/models/sys_api.go
Normal file
@ -0,0 +1,16 @@
|
||||
package models
|
||||
|
||||
type SysApi struct {
|
||||
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:地址"`
|
||||
Type string `json:"type" gorm:"size:16;comment:接口类型"`
|
||||
Action string `json:"action" gorm:"size:16;comment:请求类型"`
|
||||
ModelTime
|
||||
ControlBy
|
||||
}
|
||||
|
||||
func (SysApi) TableName() string {
|
||||
return "sys_api"
|
||||
}
|
||||
44
cmd/migrate/migration/models/sys_columns.go
Normal file
44
cmd/migrate/migration/models/sys_columns.go
Normal file
@ -0,0 +1,44 @@
|
||||
package models
|
||||
|
||||
type SysColumns struct {
|
||||
ColumnId int `gorm:"primaryKey;autoIncrement" json:"columnId"`
|
||||
TableId int `gorm:"" json:"tableId"`
|
||||
ColumnName string `gorm:"size:128;" json:"columnName"`
|
||||
ColumnComment string `gorm:"column:column_comment;size:128;" json:"columnComment"`
|
||||
ColumnType string `gorm:"column:column_type;size:128;" json:"columnType"`
|
||||
GoType string `gorm:"column:go_type;size:128;" json:"goType"`
|
||||
GoField string `gorm:"column:go_field;size:128;" json:"goField"`
|
||||
JsonField string `gorm:"column:json_field;size:128;" json:"jsonField"`
|
||||
IsPk string `gorm:"column:is_pk;size:4;" json:"isPk"`
|
||||
IsIncrement string `gorm:"column:is_increment;size:4;" json:"isIncrement"`
|
||||
IsRequired string `gorm:"column:is_required;size:4;" json:"isRequired"`
|
||||
IsInsert string `gorm:"column:is_insert;size:4;" json:"isInsert"`
|
||||
IsEdit string `gorm:"column:is_edit;size:4;" json:"isEdit"`
|
||||
IsList string `gorm:"column:is_list;size:4;" json:"isList"`
|
||||
IsQuery string `gorm:"column:is_query;size:4;" json:"isQuery"`
|
||||
QueryType string `gorm:"column:query_type;size:128;" json:"queryType"`
|
||||
HtmlType string `gorm:"column:html_type;size:128;" json:"htmlType"`
|
||||
DictType string `gorm:"column:dict_type;size:128;" json:"dictType"`
|
||||
Sort int `gorm:"column:sort;" json:"sort"`
|
||||
List string `gorm:"column:list;size:1;" json:"list"`
|
||||
Pk bool `gorm:"column:pk;size:1;" json:"pk"`
|
||||
Required bool `gorm:"column:required;size:1;" json:"required"`
|
||||
SuperColumn bool `gorm:"column:super_column;size:1;" json:"superColumn"`
|
||||
UsableColumn bool `gorm:"column:usable_column;size:1;" json:"usableColumn"`
|
||||
Increment bool `gorm:"column:increment;size:1;" json:"increment"`
|
||||
Insert bool `gorm:"column:insert;size:1;" json:"insert"`
|
||||
Edit bool `gorm:"column:edit;size:1;" json:"edit"`
|
||||
Query bool `gorm:"column:query;size:1;" json:"query"`
|
||||
Remark string `gorm:"column:remark;size:255;" json:"remark"`
|
||||
FkTableName string `gorm:"" json:"fkTableName"`
|
||||
FkTableNameClass string `gorm:"" json:"fkTableNameClass"`
|
||||
FkTableNamePackage string `gorm:"" json:"fkTableNamePackage"`
|
||||
FkLabelId string `gorm:"" json:"fkLabelId"`
|
||||
FkLabelName string `gorm:"size:255;" json:"fkLabelName"`
|
||||
ModelTime
|
||||
ControlBy
|
||||
}
|
||||
|
||||
func (SysColumns) TableName() string {
|
||||
return "sys_columns"
|
||||
}
|
||||
17
cmd/migrate/migration/models/sys_config.go
Normal file
17
cmd/migrate/migration/models/sys_config.go
Normal file
@ -0,0 +1,17 @@
|
||||
package models
|
||||
|
||||
type SysConfig struct {
|
||||
Model
|
||||
ConfigName string `json:"configName" gorm:"type:varchar(128);comment:ConfigName"`
|
||||
ConfigKey string `json:"configKey" gorm:"type:varchar(128);comment:ConfigKey"`
|
||||
ConfigValue string `json:"configValue" gorm:"type:varchar(255);comment:ConfigValue"`
|
||||
ConfigType string `json:"configType" gorm:"type:varchar(64);comment:ConfigType"`
|
||||
IsFrontend int `json:"isFrontend" gorm:"type:varchar(64);comment:是否前台"`
|
||||
Remark string `json:"remark" gorm:"type:varchar(128);comment:Remark"`
|
||||
ControlBy
|
||||
ModelTime
|
||||
}
|
||||
|
||||
func (SysConfig) TableName() string {
|
||||
return "sys_config"
|
||||
}
|
||||
19
cmd/migrate/migration/models/sys_dept.go
Normal file
19
cmd/migrate/migration/models/sys_dept.go
Normal file
@ -0,0 +1,19 @@
|
||||
package models
|
||||
|
||||
type SysDept struct {
|
||||
DeptId int `json:"deptId" gorm:"primaryKey;autoIncrement;"` //部门编码
|
||||
ParentId int `json:"parentId" gorm:""` //上级部门
|
||||
DeptPath string `json:"deptPath" gorm:"size:255;"` //
|
||||
DeptName string `json:"deptName" gorm:"size:128;"` //部门名称
|
||||
Sort int `json:"sort" gorm:"size:4;"` //排序
|
||||
Leader string `json:"leader" gorm:"size:128;"` //负责人
|
||||
Phone string `json:"phone" gorm:"size:11;"` //手机
|
||||
Email string `json:"email" gorm:"size:64;"` //邮箱
|
||||
Status int `json:"status" gorm:"size:4;"` //状态
|
||||
ControlBy
|
||||
ModelTime
|
||||
}
|
||||
|
||||
func (SysDept) TableName() string {
|
||||
return "sys_dept"
|
||||
}
|
||||
21
cmd/migrate/migration/models/sys_dict_data.go
Normal file
21
cmd/migrate/migration/models/sys_dict_data.go
Normal file
@ -0,0 +1,21 @@
|
||||
package models
|
||||
|
||||
type DictData struct {
|
||||
DictCode int `gorm:"primaryKey;autoIncrement;" json:"dictCode" example:"1"` //字典编码
|
||||
DictSort int `gorm:"" json:"dictSort"` //显示顺序
|
||||
DictLabel string `gorm:"size:128;" json:"dictLabel"` //数据标签
|
||||
DictValue string `gorm:"size:255;" json:"dictValue"` //数据键值
|
||||
DictType string `gorm:"size:64;" json:"dictType"` //字典类型
|
||||
CssClass string `gorm:"size:128;" json:"cssClass"` //
|
||||
ListClass string `gorm:"size:128;" json:"listClass"` //
|
||||
IsDefault string `gorm:"size:8;" json:"isDefault"` //
|
||||
Status int `gorm:"size:4;" json:"status"` //状态
|
||||
Default string `gorm:"size:8;" json:"default"` //
|
||||
Remark string `gorm:"size:255;" json:"remark"` //备注
|
||||
ControlBy
|
||||
ModelTime
|
||||
}
|
||||
|
||||
func (DictData) TableName() string {
|
||||
return "sys_dict_data"
|
||||
}
|
||||
15
cmd/migrate/migration/models/sys_dict_type.go
Normal file
15
cmd/migrate/migration/models/sys_dict_type.go
Normal file
@ -0,0 +1,15 @@
|
||||
package models
|
||||
|
||||
type DictType struct {
|
||||
DictId int `gorm:"primaryKey;autoIncrement;" json:"dictId"`
|
||||
DictName string `gorm:"size:128;" json:"dictName"` //字典名称
|
||||
DictType string `gorm:"size:128;" json:"dictType"` //字典类型
|
||||
Status int `gorm:"size:4;" json:"status"` //状态
|
||||
Remark string `gorm:"size:255;" json:"remark"` //备注
|
||||
ControlBy
|
||||
ModelTime
|
||||
}
|
||||
|
||||
func (DictType) TableName() string {
|
||||
return "sys_dict_type"
|
||||
}
|
||||
21
cmd/migrate/migration/models/sys_job.go
Normal file
21
cmd/migrate/migration/models/sys_job.go
Normal file
@ -0,0 +1,21 @@
|
||||
package models
|
||||
|
||||
type SysJob struct {
|
||||
JobId int `json:"jobId" gorm:"primaryKey;autoIncrement"` // 编码
|
||||
JobName string `json:"jobName" gorm:"size:255;"` // 名称
|
||||
JobGroup string `json:"jobGroup" gorm:"size:255;"` // 任务分组
|
||||
JobType int `json:"jobType" gorm:"size:1;"` // 任务类型
|
||||
CronExpression string `json:"cronExpression" gorm:"size:255;"` // cron表达式
|
||||
InvokeTarget string `json:"invokeTarget" gorm:"size:255;"` // 调用目标
|
||||
Args string `json:"args" gorm:"size:255;"` // 目标参数
|
||||
MisfirePolicy int `json:"misfirePolicy" gorm:"size:255;"` // 执行策略
|
||||
Concurrent int `json:"concurrent" gorm:"size:1;"` // 是否并发
|
||||
Status int `json:"status" gorm:"size:1;"` // 状态
|
||||
EntryId int `json:"entry_id" gorm:"size:11;"` // job启动时返回的id
|
||||
ModelTime
|
||||
ControlBy
|
||||
}
|
||||
|
||||
func (SysJob) TableName() string {
|
||||
return "sys_job"
|
||||
}
|
||||
26
cmd/migrate/migration/models/sys_login_log.go
Normal file
26
cmd/migrate/migration/models/sys_login_log.go
Normal file
@ -0,0 +1,26 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type SysLoginLog struct {
|
||||
Model
|
||||
Username string `json:"username" gorm:"type:varchar(128);comment:用户名"`
|
||||
Status string `json:"status" gorm:"type:varchar(4);comment:状态"`
|
||||
Ipaddr string `json:"ipaddr" gorm:"type:varchar(255);comment:ip地址"`
|
||||
LoginLocation string `json:"loginLocation" gorm:"type:varchar(255);comment:归属地"`
|
||||
Browser string `json:"browser" gorm:"type:varchar(255);comment:浏览器"`
|
||||
Os string `json:"os" gorm:"type:varchar(255);comment:系统"`
|
||||
Platform string `json:"platform" gorm:"type:varchar(255);comment:固件"`
|
||||
LoginTime time.Time `json:"loginTime" gorm:"type:timestamp;comment:登录时间"`
|
||||
Remark string `json:"remark" gorm:"type:varchar(255);comment:备注"`
|
||||
Msg string `json:"msg" gorm:"type:varchar(255);comment:信息"`
|
||||
CreatedAt time.Time `json:"createdAt" gorm:"comment:创建时间"`
|
||||
UpdatedAt time.Time `json:"updatedAt" gorm:"comment:最后更新时间"`
|
||||
ControlBy
|
||||
}
|
||||
|
||||
func (SysLoginLog) TableName() string {
|
||||
return "sys_login_log"
|
||||
}
|
||||
27
cmd/migrate/migration/models/sys_menu.go
Normal file
27
cmd/migrate/migration/models/sys_menu.go
Normal file
@ -0,0 +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 `json:"sysApi" gorm:"many2many:sys_menu_api_rule"`
|
||||
ControlBy
|
||||
ModelTime
|
||||
}
|
||||
|
||||
func (SysMenu) TableName() string {
|
||||
return "sys_menu"
|
||||
}
|
||||
34
cmd/migrate/migration/models/sys_opera_log.go
Normal file
34
cmd/migrate/migration/models/sys_opera_log.go
Normal file
@ -0,0 +1,34 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type SysOperaLog struct {
|
||||
Model
|
||||
Title string `json:"title" gorm:"type:varchar(255);comment:操作模块"`
|
||||
BusinessType string `json:"businessType" gorm:"type:varchar(128);comment:操作类型"`
|
||||
BusinessTypes string `json:"businessTypes" gorm:"type:varchar(128);comment:BusinessTypes"`
|
||||
Method string `json:"method" gorm:"type:varchar(128);comment:函数"`
|
||||
RequestMethod string `json:"requestMethod" gorm:"type:varchar(128);comment:请求方式: GET POST PUT DELETE"`
|
||||
OperatorType string `json:"operatorType" gorm:"type:varchar(128);comment:操作类型"`
|
||||
OperName string `json:"operName" gorm:"type:varchar(128);comment:操作者"`
|
||||
DeptName string `json:"deptName" gorm:"type:varchar(128);comment:部门名称"`
|
||||
OperUrl string `json:"operUrl" gorm:"type:varchar(255);comment:访问地址"`
|
||||
OperIp string `json:"operIp" gorm:"type:varchar(128);comment:客户端ip"`
|
||||
OperLocation string `json:"operLocation" gorm:"type:varchar(128);comment:访问位置"`
|
||||
OperParam string `json:"operParam" gorm:"type:text;comment:请求参数"`
|
||||
Status string `json:"status" gorm:"type:varchar(4);comment:操作状态 1:正常 2:关闭"`
|
||||
OperTime time.Time `json:"operTime" gorm:"type:timestamp;comment:操作时间"`
|
||||
JsonResult string `json:"jsonResult" gorm:"type:varchar(255);comment:返回数据"`
|
||||
Remark string `json:"remark" gorm:"type:varchar(255);comment:备注"`
|
||||
LatencyTime string `json:"latencyTime" gorm:"type:varchar(128);comment:耗时"`
|
||||
UserAgent string `json:"userAgent" gorm:"type:varchar(255);comment:ua"`
|
||||
CreatedAt time.Time `json:"createdAt" gorm:"comment:创建时间"`
|
||||
UpdatedAt time.Time `json:"updatedAt" gorm:"comment:最后更新时间"`
|
||||
ControlBy
|
||||
}
|
||||
|
||||
func (SysOperaLog) TableName() string {
|
||||
return "sys_opera_log"
|
||||
}
|
||||
16
cmd/migrate/migration/models/sys_post.go
Normal file
16
cmd/migrate/migration/models/sys_post.go
Normal file
@ -0,0 +1,16 @@
|
||||
package models
|
||||
|
||||
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:"size:4;" json:"sort"` //岗位排序
|
||||
Status int `gorm:"size:4;" json:"status"` //状态
|
||||
Remark string `gorm:"size:255;" json:"remark"` //描述
|
||||
ControlBy
|
||||
ModelTime
|
||||
}
|
||||
|
||||
func (SysPost) TableName() string {
|
||||
return "sys_post"
|
||||
}
|
||||
20
cmd/migrate/migration/models/sys_role.go
Normal file
20
cmd/migrate/migration/models/sys_role.go
Normal 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;"`
|
||||
ControlBy
|
||||
ModelTime
|
||||
}
|
||||
|
||||
func (SysRole) TableName() string {
|
||||
return "sys_role"
|
||||
}
|
||||
37
cmd/migrate/migration/models/sys_tables.go
Normal file
37
cmd/migrate/migration/models/sys_tables.go
Normal file
@ -0,0 +1,37 @@
|
||||
package models
|
||||
|
||||
type SysTables struct {
|
||||
TableId int `gorm:"primaryKey;autoIncrement" json:"tableId"` //表编码
|
||||
TBName string `gorm:"column:table_name;size:255;" json:"tableName"` //表名称
|
||||
TableComment string `gorm:"size:255;" json:"tableComment"` //表备注
|
||||
ClassName string `gorm:"size:255;" json:"className"` //类名
|
||||
TplCategory string `gorm:"size:255;" json:"tplCategory"` //
|
||||
PackageName string `gorm:"size:255;" json:"packageName"` //包名
|
||||
ModuleName string `gorm:"size:255;" json:"moduleName"` //go文件名
|
||||
ModuleFrontName string `gorm:"size:255;comment:前端文件名;" json:"moduleFrontName"` //前端文件名
|
||||
BusinessName string `gorm:"size:255;" json:"businessName"` //
|
||||
FunctionName string `gorm:"size:255;" json:"functionName"` //功能名称
|
||||
FunctionAuthor string `gorm:"size:255;" json:"functionAuthor"` //功能作者
|
||||
PkColumn string `gorm:"size:255;" json:"pkColumn"`
|
||||
PkGoField string `gorm:"size:255;" json:"pkGoField"`
|
||||
PkJsonField string `gorm:"size:255;" json:"pkJsonField"`
|
||||
Options string `gorm:"size:255;" json:"options"`
|
||||
TreeCode string `gorm:"size:255;" json:"treeCode"`
|
||||
TreeParentCode string `gorm:"size:255;" json:"treeParentCode"`
|
||||
TreeName string `gorm:"size:255;" json:"treeName"`
|
||||
Tree bool `gorm:"size:1;default:0;" json:"tree"`
|
||||
Crud bool `gorm:"size:1;default:1;" json:"crud"`
|
||||
Remark string `gorm:"size:255;" json:"remark"`
|
||||
IsDataScope int `gorm:"size:1;" json:"isDataScope"`
|
||||
IsActions int `gorm:"size:1;" json:"isActions"`
|
||||
IsAuth int `gorm:"size:1;" json:"isAuth"`
|
||||
IsLogicalDelete string `gorm:"size:1;" json:"isLogicalDelete"`
|
||||
LogicalDelete bool `gorm:"size:1;" json:"logicalDelete"`
|
||||
LogicalDeleteColumn string `gorm:"size:128;" json:"logicalDeleteColumn"`
|
||||
ModelTime
|
||||
ControlBy
|
||||
}
|
||||
|
||||
func (SysTables) TableName() string {
|
||||
return "sys_tables"
|
||||
}
|
||||
48
cmd/migrate/migration/models/sys_user.go
Normal file
48
cmd/migrate/migration/models/sys_user.go
Normal file
@ -0,0 +1,48 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type SysUser struct {
|
||||
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:密码"`
|
||||
NickName string `json:"nickName" gorm:"type:varchar(128);comment:昵称"`
|
||||
Phone string `json:"phone" gorm:"type:varchar(11);comment:手机号"`
|
||||
RoleId int `json:"roleId" gorm:"type:bigint;comment:角色ID"`
|
||||
Salt string `json:"-" gorm:"type:varchar(255);comment:加盐"`
|
||||
Avatar string `json:"avatar" gorm:"type:varchar(255);comment:头像"`
|
||||
Sex string `json:"sex" gorm:"type:varchar(255);comment:性别"`
|
||||
Email string `json:"email" gorm:"type:varchar(128);comment:邮箱"`
|
||||
DeptId int `json:"deptId" gorm:"type:bigint;comment:部门"`
|
||||
PostId int `json:"postId" gorm:"type:bigint;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 {
|
||||
return "sys_user"
|
||||
}
|
||||
|
||||
// Encrypt 加密
|
||||
func (e *SysUser) Encrypt() (err error) {
|
||||
if e.Password == "" {
|
||||
return
|
||||
}
|
||||
|
||||
var hash []byte
|
||||
if hash, err = bcrypt.GenerateFromPassword([]byte(e.Password), bcrypt.DefaultCost); err != nil {
|
||||
return
|
||||
} else {
|
||||
e.Password = string(hash)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func (e *SysUser) BeforeCreate(_ *gorm.DB) error {
|
||||
return e.Encrypt()
|
||||
}
|
||||
12
cmd/migrate/migration/models/tb_demo.go
Normal file
12
cmd/migrate/migration/models/tb_demo.go
Normal file
@ -0,0 +1,12 @@
|
||||
package models
|
||||
|
||||
type TbDemo struct {
|
||||
Model
|
||||
Name string `json:"name" gorm:"type:varchar(128);comment:名称"`
|
||||
ModelTime
|
||||
ControlBy
|
||||
}
|
||||
|
||||
func (TbDemo) TableName() string {
|
||||
return "tb_demo"
|
||||
}
|
||||
Reference in New Issue
Block a user