fix 🐛 优化迁移功能

This commit is contained in:
linwenxiang
2021-04-26 14:47:31 +08:00
parent 845558cc65
commit bf7934c20a
21 changed files with 256 additions and 466 deletions
+1 -2
View File
@@ -8,7 +8,6 @@ import (
_ "github.com/go-admin-team/go-admin-core/sdk/pkg/response" _ "github.com/go-admin-team/go-admin-core/sdk/pkg/response"
"github.com/google/uuid" "github.com/google/uuid"
"go-admin/app/admin/models"
"go-admin/app/admin/models/system" "go-admin/app/admin/models/system"
"go-admin/app/admin/service" "go-admin/app/admin/service"
"go-admin/app/admin/service/dto" "go-admin/app/admin/service/dto"
@@ -424,7 +423,7 @@ func (e *SysUser) GetInfo(c *gin.Context) {
var buttons = make([]string, 1) var buttons = make([]string, 1)
buttons[0] = "*:*:*" buttons[0] = "*:*:*"
RoleMenu := models.RoleMenu{} RoleMenu := system.RoleMenu{}
RoleMenu.RoleId = user.GetRoleId(c) RoleMenu.RoleId = user.GetRoleId(c)
var mp = make(map[string]interface{}) var mp = make(map[string]interface{})
-67
View File
@@ -1,67 +0,0 @@
package system
import (
"go-admin/app/admin/models"
)
// @Summary RoleMenu列表数据
// @Description 获取JSON
// @Tags 角色菜单
// @Param RoleId query string false "RoleId"
// @Success 200 {string} string "{"code": 200, "data": [...]}"
// @Success 200 {string} string "{"code": -1, "message": "抱歉未找到相关信息"}"
// @Router /api/v1/rolemenu [get]
// @Security Bearer
//func GetRoleMenu(c *gin.Context) {
// var Rm models.RoleMenu
// err := c.ShouldBind(&Rm)
// result, err := Rm.Get()
// var res response.Response
// if err != nil {
// res.Msg = "抱歉未找到相关信息"
// c.JSON(http.StatusOK, res.ReturnError(200))
// return
// }
// res.Data = result
// c.JSON(http.StatusOK, res.ReturnOK())
//}
type RoleMenuPost struct {
RoleId string
RoleMenu []models.RoleMenu
}
//func InsertRoleMenu(c *gin.Context) {
//
// var res response.Response
// res.Msg = "添加成功"
// c.JSON(http.StatusOK, res.ReturnOK())
// return
//
//}
// @Summary 删除用户菜单数据
// @Description 删除数据
// @Tags 角色菜单
// @Param id path string true "id"
// @Param menu_id query string false "menu_id"
// @Success 200 {string} string "{"code": 200, "message": "删除成功"}"
// @Success 200 {string} string "{"code": -1, "message": "删除失败"}"
// @Router /api/v1/rolemenu/{id} [delete]
//func DeleteRoleMenu(c *gin.Context) {
// var t models.RoleMenu
// id := c.Param("id")
// menuId := c.Request.FormValue("menu_id")
// fmt.Println(menuId)
// _, err := t.Delete(id, menuId)
// if err != nil {
// var res response.Response
// res.Msg = "删除失败"
// c.JSON(http.StatusOK, res.ReturnError(200))
// return
// }
// var res response.Response
// res.Msg = "删除成功"
// c.JSON(http.StatusOK, res.ReturnOK())
// return
//}
+2 -3
View File
@@ -6,7 +6,6 @@ import (
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth/user" "github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth/user"
"go-admin/app/admin/models"
"go-admin/app/admin/models/system" "go-admin/app/admin/models/system"
"go-admin/app/admin/service" "go-admin/app/admin/service"
"go-admin/app/admin/service/dto" "go-admin/app/admin/service/dto"
@@ -274,9 +273,9 @@ func (e *SysMenu) GetMenuIDS(c *gin.Context) {
log.Error(err) log.Error(err)
return return
} }
var data models.RoleMenu var data system.RoleMenu
data.RoleName = c.GetString("role") data.RoleName = c.GetString("role")
data.UpdateBy = user.GetUserIdStr(c) data.UpdateBy = user.GetUserId(c)
result, err := data.GetIDS(db) result, err := data.GetIDS(db)
if err != nil { if err != nil {
log.Errorf("GetIDS error, %s", err.Error()) log.Errorf("GetIDS error, %s", err.Error())
+2 -1
View File
@@ -3,6 +3,7 @@ package models
import ( import (
"errors" "errors"
"github.com/go-admin-team/go-admin-core/sdk/pkg" "github.com/go-admin-team/go-admin-core/sdk/pkg"
"go-admin/common/models"
"gorm.io/gorm" "gorm.io/gorm"
@@ -33,7 +34,7 @@ type Menu struct {
RoleId int `gorm:"-"` RoleId int `gorm:"-"`
Children []Menu `json:"children" gorm:"-"` Children []Menu `json:"children" gorm:"-"`
IsSelect bool `json:"is_select" gorm:"-"` IsSelect bool `json:"is_select" gorm:"-"`
BaseModel models.ModelTime
} }
func (Menu) TableName() string { func (Menu) TableName() string {
+4 -3
View File
@@ -1,5 +1,7 @@
package models package models
import "go-admin/common/models"
type SysRole struct { type SysRole struct {
RoleId int `json:"roleId" gorm:"primaryKey;autoIncrement"` // 角色编码 RoleId int `json:"roleId" gorm:"primaryKey;autoIncrement"` // 角色编码
RoleName string `json:"roleName" gorm:"size:128;"` // 角色名称 RoleName string `json:"roleName" gorm:"size:128;"` // 角色名称
@@ -7,12 +9,11 @@ type SysRole struct {
RoleKey string `json:"roleKey" gorm:"size:128;"` //角色代码 RoleKey string `json:"roleKey" gorm:"size:128;"` //角色代码
RoleSort int `json:"roleSort" gorm:""` //角色排序 RoleSort int `json:"roleSort" gorm:""` //角色排序
Flag string `json:"flag" gorm:"size:128;"` // Flag string `json:"flag" gorm:"size:128;"` //
CreateBy string `json:"createBy" gorm:"size:128;"` //
UpdateBy string `json:"updateBy" gorm:"size:128;"` //
Remark string `json:"remark" gorm:"size:255;"` //备注 Remark string `json:"remark" gorm:"size:255;"` //备注
Admin bool `json:"admin" gorm:"size:4;"` Admin bool `json:"admin" gorm:"size:4;"`
DataScope string `json:"dataScope" gorm:"size:128;"` DataScope string `json:"dataScope" gorm:"size:128;"`
BaseModel models.ModelTime
models.ControlBy
Params string `json:"params" gorm:"-"` Params string `json:"params" gorm:"-"`
MenuIds []int `json:"menuIds" gorm:"-"` MenuIds []int `json:"menuIds" gorm:"-"`
-231
View File
@@ -1,231 +0,0 @@
package models
import (
"gorm.io/gorm"
)
type RoleMenu struct {
RoleId int `gorm:""`
MenuId int `gorm:""`
RoleName string `gorm:"size:128)"`
CreateBy string `gorm:"size:128)"`
UpdateBy string `gorm:"size:128)"`
}
func (RoleMenu) TableName() string {
return "sys_role_menu"
}
type MenuPath struct {
Path string `json:"path"`
}
//func (rm *RoleMenu) Get(tx *gorm.DB) ([]RoleMenu, error) {
// var r []RoleMenu
// table := tx.Table("sys_role_menu")
// if rm.RoleId != 0 {
// table = table.Where("role_id = ?", rm.RoleId)
//
// }
// if err := table.Find(&r).Error; err != nil {
// return nil, err
// }
// return r, nil
//}
func (rm *RoleMenu) GetPermis(tx *gorm.DB) ([]string, error) {
var r []Menu
table := tx.Select("sys_menu.permission").Table("sys_menu").Joins("left join sys_role_menu on sys_menu.menu_id = sys_role_menu.menu_id")
table = table.Where("role_id = ?", rm.RoleId)
table = table.Where("sys_menu.menu_type in('F','C')")
if err := table.Find(&r).Error; err != nil {
return nil, err
}
var list []string
for i := 0; i < len(r); i++ {
list = append(list, r[i].Permission)
}
return list, nil
}
func (rm *RoleMenu) GetIDS(tx *gorm.DB) ([]MenuPath, error) {
var r []MenuPath
table := tx.Select("sys_menu.path").Table("sys_role_menu")
table = table.Joins("left join sys_role on sys_role.role_id=sys_role_menu.role_id")
table = table.Joins("left join sys_menu on sys_menu.id=sys_role_menu.menu_id")
table = table.Where("sys_role.role_name = ? and sys_menu.type=1", rm.RoleName)
if err := table.Find(&r).Error; err != nil {
return nil, err
}
return r, nil
}
//func (rm *RoleMenu) DeleteRoleMenu(roleId int) (bool, error) {
// tx := orm.Eloquent.Begin()
// defer func() {
// if r := recover(); r != nil {
// tx.Rollback()
// }
// }()
//
// if err := tx.Error; err != nil {
// return false, err
// }
//
// if err := tx.Table("sys_role_dept").Where("role_id = ?", roleId).Delete(&rm).Error; err != nil {
// tx.Rollback()
// return false, err
// }
// if err := tx.Table("sys_role_menu").Where("role_id = ?", roleId).Delete(&rm).Error; err != nil {
// tx.Rollback()
// return false, err
// }
// var role SysRole
// if err := tx.Table("sys_role").Where("role_id = ?", roleId).First(&role).Error; err != nil {
// tx.Rollback()
// return false, err
// }
// sql3 := "delete from sys_casbin_rule where v0= '" + role.RoleKey + "';"
// if err := tx.Exec(sql3).Error; err != nil {
// tx.Rollback()
// return false, err
// }
// if err := tx.Commit().Error; err != nil {
// return false, err
// }
//
// return true, nil
//
//}
// 该方法即将弃用
//func (rm *RoleMenu) BatchDeleteRoleMenu(roleIds []int) (bool, error) {
// tx := orm.Eloquent.Begin()
// defer func() {
// if r := recover(); r != nil {
// tx.Rollback()
// }
// }()
//
// if err := tx.Error; err != nil {
// return false, err
// }
//
// if err := tx.Table("sys_role_menu").Where("role_id in (?)", roleIds).Delete(&rm).Error; err != nil {
// tx.Rollback()
// return false, err
// }
// var role []SysRole
// if err := tx.Table("sys_role").Where("role_id in (?)", roleIds).Find(&role).Error; err != nil {
// tx.Rollback()
// return false, err
// }
// sql := ""
// for i := 0; i < len(role); i++ {
// sql += "delete from sys_casbin_rule where v0= '" + role[i].RoleName + "';"
// }
// if err := tx.Exec(sql).Error; err != nil {
// tx.Rollback()
// return false, err
// }
// if err := tx.Commit().Error; err != nil {
// return false, err
// }
// return true, nil
//
//}
//func (rm *RoleMenu) Insert(roleId int, menuId []int) (bool, error) {
// var (
// role SysRole
// menu []Menu
// casbinRuleQueue []system.CasbinRule // casbinRule 待插入队列
// )
//
// // 开始事务
// tx := orm.Eloquent.Begin()
// defer func() {
// if r := recover(); r != nil {
// tx.Rollback()
// }
// }()
//
// if err := tx.Error; err != nil {
// return false, err
// }
//
// // 在事务中做一些数据库操作(从这一点使用'tx',而不是'db'
// if err := tx.Table("sys_role").Where("role_id = ?", roleId).First(&role).Error; err != nil {
// tx.Rollback()
// return false, err
// }
// if err := tx.Table("sys_menu").Where("menu_id in (?)", menuId).Find(&menu).Error; err != nil {
// tx.Rollback()
// return false, err
// }
// //ORM不支持批量插入所以需要拼接 sql 串
// sysRoleMenuSql := "INSERT INTO `sys_role_menu` (`role_id`,`menu_id`,`role_name`) VALUES "
// casbinRuleSql := "INSERT INTO `sys_casbin_rule` (`p_type`,`v0`,`v1`,`v2`) VALUES "
//
// for i, m := range menu {
// // 拼装'role_menu'表批量插入SQL语句
// sysRoleMenuSql += fmt.Sprintf("(%d,%d,'%s')", role.RoleId, m.MenuId, role.RoleKey)
// if i == len(menu)-1 {
// sysRoleMenuSql += ";" //最后一条数据 以分号结尾
// } else {
// sysRoleMenuSql += ","
// }
// if m.MenuType == "A" {
// // 加入队列
// casbinRuleQueue = append(casbinRuleQueue,
// system.CasbinRule{
// V0: role.RoleKey,
// V1: m.Path,
// V2: m.Action,
// })
// }
// }
// // 执行批量插入sys_role_menu
// if err := tx.Exec(sysRoleMenuSql).Error; err != nil {
// tx.Rollback()
// return false, err
// }
//
// // 拼装'sys_casbin_rule'批量插入SQL语句
// // TODO: casbinRuleQueue队列不为空时才会拼装,否则直接忽略不执行'for'循环
// for i, v := range casbinRuleQueue {
// casbinRuleSql += fmt.Sprintf("('p','%s','%s','%s')", v.V0, v.V1, v.V2)
// if i == len(casbinRuleQueue)-1 {
// casbinRuleSql += ";"
// } else {
// casbinRuleSql += ","
// }
// }
// // 执行批量插入sys_casbin_rule
// if len(casbinRuleQueue) > 0 {
// if err := tx.Exec(casbinRuleSql).Error; err != nil {
// tx.Rollback()
// return false, err
// }
// }
//
// if err := tx.Commit().Error; err != nil {
// return false, err
// }
// return true, nil
//}
//func (rm *RoleMenu) Delete(RoleId string, MenuID string) (bool, error) {
// rm.RoleId, _ = tools.StringToInt(RoleId)
// table := orm.Eloquent.Table("sys_role_menu").Where("role_id = ?", RoleId)
// if MenuID != "" {
// table = table.Where("menu_id = ?", MenuID)
// }
// if err := table.Delete(&rm).Error; err != nil {
// return false, err
// }
// return true, nil
//
//}
+4 -6
View File
@@ -3,7 +3,6 @@ package models
import ( import (
"go-admin/common/models" "go-admin/common/models"
"gorm.io/gorm" "gorm.io/gorm"
"strconv"
) )
type SysJob struct { type SysJob struct {
@@ -18,9 +17,8 @@ type SysJob struct {
Concurrent int `json:"concurrent" gorm:"size:1;"` // 是否并发 Concurrent int `json:"concurrent" gorm:"size:1;"` // 是否并发
Status int `json:"status" gorm:"size:1;"` // 状态 Status int `json:"status" gorm:"size:1;"` // 状态
EntryId int `json:"entry_id" gorm:"size:11;"` // job启动时返回的id EntryId int `json:"entry_id" gorm:"size:11;"` // job启动时返回的id
CreateBy string `json:"createBy" gorm:"size:128;"` // models.ControlBy
UpdateBy string `json:"updateBy" gorm:"size:128;"` // models.ModelTime
BaseModel
DataScope string `json:"dataScope" gorm:"-"` DataScope string `json:"dataScope" gorm:"-"`
} }
@@ -39,11 +37,11 @@ func (e *SysJob) GetId() interface{} {
} }
func (e *SysJob) SetCreateBy(createBy int) { func (e *SysJob) SetCreateBy(createBy int) {
e.CreateBy = strconv.Itoa(int(createBy)) e.CreateBy = createBy
} }
func (e *SysJob) SetUpdateBy(updateBy int) { func (e *SysJob) SetUpdateBy(updateBy int) {
e.UpdateBy = strconv.Itoa(int(updateBy)) e.UpdateBy = updateBy
} }
// 创建SysJob // 创建SysJob
+4 -3
View File
@@ -2,18 +2,19 @@ package system
import ( import (
"fmt" "fmt"
"github.com/go-admin-team/go-admin-core/sdk/pkg"
"github.com/casbin/casbin/v2" "github.com/casbin/casbin/v2"
"github.com/go-admin-team/go-admin-core/sdk/pkg"
"gorm.io/gorm" "gorm.io/gorm"
"go-admin/common/models"
) )
type RoleMenu struct { type RoleMenu struct {
RoleId int `gorm:""` RoleId int `gorm:""`
MenuId int `gorm:""` MenuId int `gorm:""`
RoleName string `gorm:"size:128"` RoleName string `gorm:"size:128"`
CreateBy string `gorm:"size:128"` models.ControlBy
UpdateBy string `gorm:"size:128"`
} }
func (RoleMenu) TableName() string { func (RoleMenu) TableName() string {
+2 -3
View File
@@ -11,10 +11,9 @@ type DictData struct {
IsDefault string `gorm:"size:8;" json:"isDefault"` // IsDefault string `gorm:"size:8;" json:"isDefault"` //
Status string `gorm:"size:4;" json:"status"` //状态 Status string `gorm:"size:4;" json:"status"` //状态
Default string `gorm:"size:8;" json:"default"` // Default string `gorm:"size:8;" json:"default"` //
CreateBy string `gorm:"size:64;" json:"createBy"` //
UpdateBy string `gorm:"size:64;" json:"updateBy"` //
Remark string `gorm:"size:255;" json:"remark"` //备注 Remark string `gorm:"size:255;" json:"remark"` //备注
BaseModel ControlBy
ModelTime
} }
func (DictData) TableName() string { func (DictData) TableName() string {
+2 -3
View File
@@ -5,10 +5,9 @@ type DictType struct {
DictName string `gorm:"size:128;" json:"dictName"` //字典名称 DictName string `gorm:"size:128;" json:"dictName"` //字典名称
DictType string `gorm:"size:128;" json:"dictType"` //字典类型 DictType string `gorm:"size:128;" json:"dictType"` //字典类型
Status string `gorm:"size:4;" json:"status"` //状态 Status string `gorm:"size:4;" json:"status"` //状态
CreateBy string `gorm:"size:11;" json:"createBy"` //创建者
UpdateBy string `gorm:"size:11;" json:"updateBy"` //更新者
Remark string `gorm:"size:255;" json:"remark"` //备注 Remark string `gorm:"size:255;" json:"remark"` //备注
BaseModel ControlBy
ModelTime
} }
func (DictType) TableName() string { func (DictType) TableName() string {
+8 -15
View File
@@ -1,21 +1,14 @@
package models package models
import (
"time"
)
type Post struct { type Post struct {
PostId int `gorm:"primaryKey;autoIncrement" json:"postId"` //岗位编号 PostId int `gorm:"primaryKey;autoIncrement" json:"postId"` //岗位编号
PostName string `gorm:"size:128;" json:"postName"` //岗位名称 PostName string `gorm:"size:128;" json:"postName"` //岗位名称
PostCode string `gorm:"size:128;" json:"postCode"` //岗位代码 PostCode string `gorm:"size:128;" json:"postCode"` //岗位代码
Sort int `gorm:"" json:"sort"` //岗位排序 Sort int `gorm:"" json:"sort"` //岗位排序
Status string `gorm:"size:4;" json:"status"` //状态 Status string `gorm:"size:4;" json:"status"` //状态
Remark string `gorm:"size:255;" json:"remark"` //描述 Remark string `gorm:"size:255;" json:"remark"` //描述
CreateBy string `gorm:"size:128;" json:"createBy"` ModelTime
UpdateBy string `gorm:"size:128;" json:"updateBy"` ControlBy
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
DeletedAt *time.Time `json:"deletedAt"`
} }
func (Post) TableName() string { func (Post) TableName() string {
+2 -3
View File
@@ -7,12 +7,11 @@ type SysRole struct {
RoleKey string `json:"roleKey" gorm:"size:128;"` //角色代码 RoleKey string `json:"roleKey" gorm:"size:128;"` //角色代码
RoleSort int `json:"roleSort" gorm:""` //角色排序 RoleSort int `json:"roleSort" gorm:""` //角色排序
Flag string `json:"flag" gorm:"size:128;"` // Flag string `json:"flag" gorm:"size:128;"` //
CreateBy string `json:"createBy" gorm:"size:128;"` //
UpdateBy string `json:"updateBy" gorm:"size:128;"` //
Remark string `json:"remark" gorm:"size:255;"` //备注 Remark string `json:"remark" gorm:"size:255;"` //备注
Admin bool `json:"admin" gorm:"size:4;"` Admin bool `json:"admin" gorm:"size:4;"`
DataScope string `json:"dataScope" gorm:"size:128;"` DataScope string `json:"dataScope" gorm:"size:128;"`
BaseModel ModelTime
ControlBy
} }
func (SysRole) TableName() string { func (SysRole) TableName() string {
+1 -2
View File
@@ -4,8 +4,7 @@ type RoleMenu struct {
RoleId int `gorm:""` RoleId int `gorm:""`
MenuId int `gorm:""` MenuId int `gorm:""`
RoleName string `gorm:"size:128)"` RoleName string `gorm:"size:128)"`
CreateBy string `gorm:"size:128)"` ControlBy
UpdateBy string `gorm:"size:128)"`
} }
func (RoleMenu) TableName() string { func (RoleMenu) TableName() string {
@@ -2,8 +2,6 @@ package models
import ( import (
"time" "time"
"go-admin/common/models"
) )
type SysOperaLog struct { type SysOperaLog struct {
@@ -28,7 +26,7 @@ type SysOperaLog struct {
UserAgent string `json:"userAgent" gorm:"type:varchar(255);comment:ua"` UserAgent string `json:"userAgent" gorm:"type:varchar(255);comment:ua"`
CreatedAt time.Time `json:"createdAt" gorm:"comment:创建时间"` CreatedAt time.Time `json:"createdAt" gorm:"comment:创建时间"`
UpdatedAt time.Time `json:"updatedAt" gorm:"comment:最后更新时间"` UpdatedAt time.Time `json:"updatedAt" gorm:"comment:最后更新时间"`
models.ControlBy ControlBy
} }
func (SysOperaLog) TableName() string { func (SysOperaLog) TableName() string {
+14 -18
View File
@@ -8,24 +8,20 @@ import (
type SysUser struct { type SysUser struct {
ControlBy ControlBy
ModelTime ModelTime
UserId int `gorm:"primaryKey;autoIncrement;comment:编码" json:"userId"` UserId int `gorm:"primaryKey;autoIncrement;comment:编码" json:"userId"`
Username string `json:"username" gorm:"type:varchar(64);comment:用户名"` Username string `json:"username" gorm:"type:varchar(64);comment:用户名"`
Password string `json:"-" gorm:"type:varchar(128);comment:密码"` Password string `json:"-" gorm:"type:varchar(128);comment:密码"`
NickName string `json:"nickName" gorm:"type:varchar(128);comment:昵称"` NickName string `json:"nickName" gorm:"type:varchar(128);comment:昵称"`
Phone string `json:"phone" gorm:"type:varchar(11);comment:手机号"` Phone string `json:"phone" gorm:"type:varchar(11);comment:手机号"`
RoleId int `json:"roleId" gorm:"type:bigint(20);comment:角色ID"` RoleId int `json:"roleId" gorm:"type:bigint(20);comment:角色ID"`
Salt string `json:"-" gorm:"type:varchar(255);comment:加盐"` Salt string `json:"-" gorm:"type:varchar(255);comment:加盐"`
Avatar string `json:"avatar" gorm:"type:varchar(255);comment:头像"` Avatar string `json:"avatar" gorm:"type:varchar(255);comment:头像"`
Sex string `json:"sex" gorm:"type:varchar(255);comment:性别"` Sex string `json:"sex" gorm:"type:varchar(255);comment:性别"`
Email string `json:"email" gorm:"type:varchar(128);comment:邮箱"` Email string `json:"email" gorm:"type:varchar(128);comment:邮箱"`
DeptId int `json:"deptId" gorm:"type:bigint(20);comment:部门"` DeptId int `json:"deptId" gorm:"type:bigint(20);comment:部门"`
PostId int `json:"postId" gorm:"type:bigint(20);comment:岗位"` PostId int `json:"postId" gorm:"type:bigint(20);comment:岗位"`
Remark string `json:"remark" gorm:"type:varchar(255);comment:备注"` Remark string `json:"remark" gorm:"type:varchar(255);comment:备注"`
Status string `json:"status" gorm:"type:varchar(4);comment:状态"` Status string `json:"status" gorm:"type:varchar(4);comment:状态"`
DeptIds []int `json:"deptIds" gorm:"-"`
PostIds []int `json:"postIds" gorm:"-"`
RoleIds []int `json:"roleIds" gorm:"-"`
Dept *SysDept `json:"dept"`
} }
func (SysUser) TableName() string { func (SysUser) TableName() string {
+36 -38
View File
@@ -1,44 +1,42 @@
package models package models
type SysColumns struct { type SysColumns struct {
ColumnId int `gorm:"primaryKey;autoIncrement" json:"columnId"` ColumnId int `gorm:"primaryKey;autoIncrement" json:"columnId"`
TableId int `gorm:"" json:"tableId"` TableId int `gorm:"" json:"tableId"`
ColumnName string `gorm:"size:128;" json:"columnName"` ColumnName string `gorm:"size:128;" json:"columnName"`
ColumnComment string `gorm:"column:column_comment;size:128;" json:"columnComment"` ColumnComment string `gorm:"column:column_comment;size:128;" json:"columnComment"`
ColumnType string `gorm:"column:column_type;size:128;" json:"columnType"` ColumnType string `gorm:"column:column_type;size:128;" json:"columnType"`
GoType string `gorm:"column:go_type;size:128;" json:"goType"` GoType string `gorm:"column:go_type;size:128;" json:"goType"`
GoField string `gorm:"column:go_field;size:128;" json:"goField"` GoField string `gorm:"column:go_field;size:128;" json:"goField"`
JsonField string `gorm:"column:json_field;size:128;" json:"jsonField"` JsonField string `gorm:"column:json_field;size:128;" json:"jsonField"`
IsPk string `gorm:"column:is_pk;size:4;" json:"isPk"` IsPk string `gorm:"column:is_pk;size:4;" json:"isPk"`
IsIncrement string `gorm:"column:is_increment;size:4;" json:"isIncrement"` IsIncrement string `gorm:"column:is_increment;size:4;" json:"isIncrement"`
IsRequired string `gorm:"column:is_required;size:4;" json:"isRequired"` IsRequired string `gorm:"column:is_required;size:4;" json:"isRequired"`
IsInsert string `gorm:"column:is_insert;size:4;" json:"isInsert"` IsInsert string `gorm:"column:is_insert;size:4;" json:"isInsert"`
IsEdit string `gorm:"column:is_edit;size:4;" json:"isEdit"` IsEdit string `gorm:"column:is_edit;size:4;" json:"isEdit"`
IsList string `gorm:"column:is_list;size:4;" json:"isList"` IsList string `gorm:"column:is_list;size:4;" json:"isList"`
IsQuery string `gorm:"column:is_query;size:4;" json:"isQuery"` IsQuery string `gorm:"column:is_query;size:4;" json:"isQuery"`
QueryType string `gorm:"column:query_type;size:128;" json:"queryType"` QueryType string `gorm:"column:query_type;size:128;" json:"queryType"`
HtmlType string `gorm:"column:html_type;size:128;" json:"htmlType"` HtmlType string `gorm:"column:html_type;size:128;" json:"htmlType"`
DictType string `gorm:"column:dict_type;size:128;" json:"dictType"` DictType string `gorm:"column:dict_type;size:128;" json:"dictType"`
Sort int `gorm:"column:sort;" json:"sort"` Sort int `gorm:"column:sort;" json:"sort"`
List string `gorm:"column:list;size:1;" json:"list"` List string `gorm:"column:list;size:1;" json:"list"`
Pk bool `gorm:"column:pk;size:1;" json:"pk"` Pk bool `gorm:"column:pk;size:1;" json:"pk"`
Required bool `gorm:"column:required;size:1;" json:"required"` Required bool `gorm:"column:required;size:1;" json:"required"`
SuperColumn bool `gorm:"column:super_column;size:1;" json:"superColumn"` SuperColumn bool `gorm:"column:super_column;size:1;" json:"superColumn"`
UsableColumn bool `gorm:"column:usable_column;size:1;" json:"usableColumn"` UsableColumn bool `gorm:"column:usable_column;size:1;" json:"usableColumn"`
Increment bool `gorm:"column:increment;size:1;" json:"increment"` Increment bool `gorm:"column:increment;size:1;" json:"increment"`
Insert bool `gorm:"column:insert;size:1;" json:"insert"` Insert bool `gorm:"column:insert;size:1;" json:"insert"`
Edit bool `gorm:"column:edit;size:1;" json:"edit"` Edit bool `gorm:"column:edit;size:1;" json:"edit"`
Query bool `gorm:"column:query;size:1;" json:"query"` Query bool `gorm:"column:query;size:1;" json:"query"`
Remark string `gorm:"column:remark;size:255;" json:"remark"` Remark string `gorm:"column:remark;size:255;" json:"remark"`
FkTableName string `gorm:"" json:"fkTableName"` FkTableName string `gorm:"" json:"fkTableName"`
FkTableNameClass string `gorm:"" json:"fkTableNameClass"` FkTableNameClass string `gorm:"" json:"fkTableNameClass"`
FkTableNamePackage string `gorm:"" json:"fkTableNamePackage"` FkTableNamePackage string `gorm:"" json:"fkTableNamePackage"`
FkCol []SysColumns `gorm:"-" json:"fkCol"` FkLabelId string `gorm:"" json:"fkLabelId"`
FkLabelId string `gorm:"" json:"fkLabelId"` FkLabelName string `gorm:"size:255;" json:"fkLabelName"`
FkLabelName string `gorm:"size:255;" json:"fkLabelName"` ModelTime
CreateBy string `gorm:"column:create_by;size:128;" json:"createBy"` ControlBy
UpdateBy string `gorm:"column:update_By;size:128;" json:"updateBy"`
BaseModel
} }
func (SysColumns) TableName() string { func (SysColumns) TableName() string {
+2 -5
View File
@@ -12,11 +12,8 @@ type SysJob struct {
Concurrent int `json:"concurrent" gorm:"size:1;"` // 是否并发 Concurrent int `json:"concurrent" gorm:"size:1;"` // 是否并发
Status int `json:"status" gorm:"size:1;"` // 状态 Status int `json:"status" gorm:"size:1;"` // 状态
EntryId int `json:"entry_id" gorm:"size:11;"` // job启动时返回的id EntryId int `json:"entry_id" gorm:"size:11;"` // job启动时返回的id
CreateBy string `json:"createBy" gorm:"size:128;"` // ModelTime
UpdateBy string `json:"updateBy" gorm:"size:128;"` // ControlBy
BaseModel
DataScope string `json:"dataScope" gorm:"-"`
} }
func (SysJob) TableName() string { func (SysJob) TableName() string {
+2 -4
View File
@@ -27,10 +27,8 @@ type SysTables struct {
IsLogicalDelete string `gorm:"size:1;" json:"isLogicalDelete"` IsLogicalDelete string `gorm:"size:1;" json:"isLogicalDelete"`
LogicalDelete bool `gorm:"size:1;" json:"logicalDelete"` LogicalDelete bool `gorm:"size:1;" json:"logicalDelete"`
LogicalDeleteColumn string `gorm:"size:128;" json:"logicalDeleteColumn"` LogicalDeleteColumn string `gorm:"size:128;" json:"logicalDeleteColumn"`
CreateBy string `gorm:"size:128;" json:"createBy"` ModelTime
UpdateBy string `gorm:"size:128;" json:"updateBy"` ControlBy
BaseModel
} }
func (SysTables) TableName() string { func (SysTables) TableName() string {
@@ -34,26 +34,38 @@ func _1599190683670Test(db *gorm.DB, version string) error {
} }
list5 := []models.Post{ list5 := []models.Post{
{PostId: 1, PostName: "首席执行官", PostCode: "CEO", Sort: 0, Status: "2", Remark: "首席执行官", CreateBy: "1", UpdateBy: "1", CreatedAt: time.Now(), UpdatedAt: time.Now()}, {PostId: 1, PostName: "首席执行官", PostCode: "CEO", Sort: 0, Status: "2", Remark: "首席执行官", ControlBy: models.ControlBy{CreateBy: 1, UpdateBy: 1}, ModelTime: models.ModelTime{CreatedAt: time.Now(), UpdatedAt: time.Now()}},
{PostId: 2, PostName: "首席技术执行官", PostCode: "CTO", Sort: 2, Status: "2", Remark: "首席技术执行官", CreateBy: "1", UpdateBy: "1", CreatedAt: time.Now(), UpdatedAt: time.Now()}, {PostId: 2, PostName: "首席技术执行官", PostCode: "CTO", Sort: 2, Status: "2", Remark: "首席技术执行官", ControlBy: models.ControlBy{CreateBy: 1, UpdateBy: 1}, ModelTime: models.ModelTime{CreatedAt: time.Now(), UpdatedAt: time.Now()}},
{PostId: 3, PostName: "首席运营官", PostCode: "COO", Sort: 3, Status: "2", Remark: "测试工程师", CreateBy: "1", UpdateBy: "1", CreatedAt: time.Now(), UpdatedAt: time.Now()}, {PostId: 3, PostName: "首席运营官", PostCode: "COO", Sort: 3, Status: "2", Remark: "测试工程师", ControlBy: models.ControlBy{CreateBy: 1, UpdateBy: 1}, ModelTime: models.ModelTime{CreatedAt: time.Now(), UpdatedAt: time.Now()}},
} }
list6 := []models.SysRole{ list6 := []models.SysRole{
{1, "系统管理员", "2", "admin", 1, "", "1", "0", "", true, "", models.BaseModel{CreatedAt: time.Now(), UpdatedAt: time.Now()}}, {
RoleId: 1,
RoleName: "系统管理员",
Status: "2",
RoleKey: "admin",
RoleSort: 1,
Flag: "",
Remark: "",
Admin: true,
DataScope: "",
ModelTime: models.ModelTime{CreatedAt: time.Now(), UpdatedAt: time.Now()},
ControlBy: models.ControlBy{CreateBy: 1, UpdateBy: 1},
},
} }
list7 := []models.DictType{ list7 := []models.DictType{
{DictId: 1, DictName: "系统开关", DictType: "sys_normal_disable", Status: "2", CreateBy: "1", UpdateBy: "1", Remark: "系统开关列表", BaseModel: models.BaseModel{CreatedAt: time.Now(), UpdatedAt: time.Now()}}, {DictId: 1, DictName: "系统开关", DictType: "sys_normal_disable", Status: "2", ControlBy: models.ControlBy{CreateBy: 1, UpdateBy: 1}, Remark: "系统开关列表", ModelTime: models.ModelTime{CreatedAt: time.Now(), UpdatedAt: time.Now()}},
{DictId: 2, DictName: "用户性别", DictType: "sys_user_sex", Status: "2", CreateBy: "1", UpdateBy: "", Remark: "用户性别列表", BaseModel: models.BaseModel{CreatedAt: time.Now(), UpdatedAt: time.Now()}}, {DictId: 2, DictName: "用户性别", DictType: "sys_user_sex", Status: "2", ControlBy: models.ControlBy{CreateBy: 1, UpdateBy: 1}, Remark: "用户性别列表", ModelTime: models.ModelTime{CreatedAt: time.Now(), UpdatedAt: time.Now()}},
{DictId: 3, DictName: "菜单状态", DictType: "sys_show_hide", Status: "2", CreateBy: "1", UpdateBy: "", Remark: "菜单状态列表", BaseModel: models.BaseModel{CreatedAt: time.Now(), UpdatedAt: time.Now()}}, {DictId: 3, DictName: "菜单状态", DictType: "sys_show_hide", Status: "2", ControlBy: models.ControlBy{CreateBy: 1, UpdateBy: 1}, Remark: "菜单状态列表", ModelTime: models.ModelTime{CreatedAt: time.Now(), UpdatedAt: time.Now()}},
{DictId: 4, DictName: "系统是否", DictType: "sys_yes_no", Status: "2", CreateBy: "1", UpdateBy: "", Remark: "系统是否列表", BaseModel: models.BaseModel{CreatedAt: time.Now(), UpdatedAt: time.Now()}}, {DictId: 4, DictName: "系统是否", DictType: "sys_yes_no", Status: "2", ControlBy: models.ControlBy{CreateBy: 1, UpdateBy: 1}, Remark: "系统是否列表", ModelTime: models.ModelTime{CreatedAt: time.Now(), UpdatedAt: time.Now()}},
{DictId: 5, DictName: "任务状态", DictType: "sys_job_status", Status: "2", CreateBy: "1", UpdateBy: "", Remark: "任务状态列表", BaseModel: models.BaseModel{CreatedAt: time.Now(), UpdatedAt: time.Now()}}, {DictId: 5, DictName: "任务状态", DictType: "sys_job_status", Status: "2", ControlBy: models.ControlBy{CreateBy: 1, UpdateBy: 1}, Remark: "任务状态列表", ModelTime: models.ModelTime{CreatedAt: time.Now(), UpdatedAt: time.Now()}},
{DictId: 6, DictName: "任务分组", DictType: "sys_job_group", Status: "2", CreateBy: "1", UpdateBy: "", Remark: "任务分组列表", BaseModel: models.BaseModel{CreatedAt: time.Now(), UpdatedAt: time.Now()}}, {DictId: 6, DictName: "任务分组", DictType: "sys_job_group", Status: "2", ControlBy: models.ControlBy{CreateBy: 1, UpdateBy: 1}, Remark: "任务分组列表", ModelTime: models.ModelTime{CreatedAt: time.Now(), UpdatedAt: time.Now()}},
{DictId: 7, DictName: "通知类型", DictType: "sys_notice_type", Status: "2", CreateBy: "1", UpdateBy: "", Remark: "通知类型列表", BaseModel: models.BaseModel{CreatedAt: time.Now(), UpdatedAt: time.Now()}}, {DictId: 7, DictName: "通知类型", DictType: "sys_notice_type", Status: "2", ControlBy: models.ControlBy{CreateBy: 1, UpdateBy: 1}, Remark: "通知类型列表", ModelTime: models.ModelTime{CreatedAt: time.Now(), UpdatedAt: time.Now()}},
{DictId: 8, DictName: "系统状态", DictType: "sys_common_status", Status: "2", CreateBy: "1", UpdateBy: "", Remark: "登录状态列表", BaseModel: models.BaseModel{CreatedAt: time.Now(), UpdatedAt: time.Now()}}, {DictId: 8, DictName: "系统状态", DictType: "sys_common_status", Status: "2", ControlBy: models.ControlBy{CreateBy: 1, UpdateBy: 1}, Remark: "登录状态列表", ModelTime: models.ModelTime{CreatedAt: time.Now(), UpdatedAt: time.Now()}},
{DictId: 9, DictName: "操作类型", DictType: "sys_oper_type", Status: "2", CreateBy: "1", UpdateBy: "", Remark: "操作类型列表", BaseModel: models.BaseModel{CreatedAt: time.Now(), UpdatedAt: time.Now()}}, {DictId: 9, DictName: "操作类型", DictType: "sys_oper_type", Status: "2", ControlBy: models.ControlBy{CreateBy: 1, UpdateBy: 1}, Remark: "操作类型列表", ModelTime: models.ModelTime{CreatedAt: time.Now(), UpdatedAt: time.Now()}},
{DictId: 10, DictName: "通知状态", DictType: "sys_notice_status", Status: "2", CreateBy: "1", UpdateBy: "", Remark: "通知状态列表", BaseModel: models.BaseModel{CreatedAt: time.Now(), UpdatedAt: time.Now()}}, {DictId: 10, DictName: "通知状态", DictType: "sys_notice_status", Status: "2", ControlBy: models.ControlBy{CreateBy: 1, UpdateBy: 1}, Remark: "通知状态列表", ModelTime: models.ModelTime{CreatedAt: time.Now(), UpdatedAt: time.Now()}},
} }
list8 := []models.SysUser{ list8 := []models.SysUser{
@@ -85,37 +97,37 @@ func _1599190683670Test(db *gorm.DB, version string) error {
} }
list9 := []models.DictData{ list9 := []models.DictData{
{DictCode: 1, DictSort: 0, DictLabel: "正常", DictValue: "2", DictType: "sys_normal_disable", CssClass: "", ListClass: "", IsDefault: "", Status: "2", Default: "", CreateBy: "1", UpdateBy: "", Remark: "系统正常", BaseModel: models.BaseModel{CreatedAt: time.Now(), UpdatedAt: time.Now()}}, {DictCode: 1, DictSort: 0, DictLabel: "正常", DictValue: "2", DictType: "sys_normal_disable", CssClass: "", ListClass: "", IsDefault: "", Status: "2", Default: "", ControlBy: models.ControlBy{CreateBy: 1, UpdateBy: 1}, Remark: "系统正常", ModelTime: models.ModelTime{CreatedAt: time.Now(), UpdatedAt: time.Now()}},
{DictCode: 2, DictSort: 0, DictLabel: "停用", DictValue: "1", DictType: "sys_normal_disable", CssClass: "", ListClass: "", IsDefault: "", Status: "2", Default: "", CreateBy: "1", UpdateBy: "", Remark: "系统停用", BaseModel: models.BaseModel{CreatedAt: time.Now(), UpdatedAt: time.Now()}}, {DictCode: 2, DictSort: 0, DictLabel: "停用", DictValue: "1", DictType: "sys_normal_disable", CssClass: "", ListClass: "", IsDefault: "", Status: "2", Default: "", ControlBy: models.ControlBy{CreateBy: 1, UpdateBy: 1}, Remark: "系统停用", ModelTime: models.ModelTime{CreatedAt: time.Now(), UpdatedAt: time.Now()}},
{DictCode: 3, DictSort: 0, DictLabel: "男", DictValue: "0", DictType: "sys_user_sex", CssClass: "", ListClass: "", IsDefault: "", Status: "2", Default: "", CreateBy: "1", UpdateBy: "", Remark: "性别男", BaseModel: models.BaseModel{CreatedAt: time.Now(), UpdatedAt: time.Now()}}, {DictCode: 3, DictSort: 0, DictLabel: "男", DictValue: "0", DictType: "sys_user_sex", CssClass: "", ListClass: "", IsDefault: "", Status: "2", Default: "", ControlBy: models.ControlBy{CreateBy: 1, UpdateBy: 1}, Remark: "性别男", ModelTime: models.ModelTime{CreatedAt: time.Now(), UpdatedAt: time.Now()}},
{DictCode: 4, DictSort: 0, DictLabel: "女", DictValue: "1", DictType: "sys_user_sex", CssClass: "", ListClass: "", IsDefault: "", Status: "2", Default: "", CreateBy: "1", UpdateBy: "", Remark: "性别女", BaseModel: models.BaseModel{CreatedAt: time.Now(), UpdatedAt: time.Now()}}, {DictCode: 4, DictSort: 0, DictLabel: "女", DictValue: "1", DictType: "sys_user_sex", CssClass: "", ListClass: "", IsDefault: "", Status: "2", Default: "", ControlBy: models.ControlBy{CreateBy: 1, UpdateBy: 1}, Remark: "性别女", ModelTime: models.ModelTime{CreatedAt: time.Now(), UpdatedAt: time.Now()}},
{DictCode: 5, DictSort: 0, DictLabel: "未知", DictValue: "2", DictType: "sys_user_sex", CssClass: "", ListClass: "", IsDefault: "", Status: "2", Default: "", CreateBy: "1", UpdateBy: "", Remark: "性别未知", BaseModel: models.BaseModel{CreatedAt: time.Now(), UpdatedAt: time.Now()}}, {DictCode: 5, DictSort: 0, DictLabel: "未知", DictValue: "2", DictType: "sys_user_sex", CssClass: "", ListClass: "", IsDefault: "", Status: "2", Default: "", ControlBy: models.ControlBy{CreateBy: 1, UpdateBy: 1}, Remark: "性别未知", ModelTime: models.ModelTime{CreatedAt: time.Now(), UpdatedAt: time.Now()}},
{DictCode: 6, DictSort: 0, DictLabel: "显示", DictValue: "0", DictType: "sys_show_hide", CssClass: "", ListClass: "", IsDefault: "", Status: "2", Default: "", CreateBy: "1", UpdateBy: "", Remark: "显示菜单", BaseModel: models.BaseModel{CreatedAt: time.Now(), UpdatedAt: time.Now()}}, {DictCode: 6, DictSort: 0, DictLabel: "显示", DictValue: "0", DictType: "sys_show_hide", CssClass: "", ListClass: "", IsDefault: "", Status: "2", Default: "", ControlBy: models.ControlBy{CreateBy: 1, UpdateBy: 1}, Remark: "显示菜单", ModelTime: models.ModelTime{CreatedAt: time.Now(), UpdatedAt: time.Now()}},
{DictCode: 7, DictSort: 0, DictLabel: "隐藏", DictValue: "1", DictType: "sys_show_hide", CssClass: "", ListClass: "", IsDefault: "", Status: "2", Default: "", CreateBy: "1", UpdateBy: "", Remark: "隐藏菜单", BaseModel: models.BaseModel{CreatedAt: time.Now(), UpdatedAt: time.Now()}}, {DictCode: 7, DictSort: 0, DictLabel: "隐藏", DictValue: "1", DictType: "sys_show_hide", CssClass: "", ListClass: "", IsDefault: "", Status: "2", Default: "", ControlBy: models.ControlBy{CreateBy: 1, UpdateBy: 1}, Remark: "隐藏菜单", ModelTime: models.ModelTime{CreatedAt: time.Now(), UpdatedAt: time.Now()}},
{DictCode: 8, DictSort: 0, DictLabel: "是", DictValue: "Y", DictType: "sys_yes_no", CssClass: "", ListClass: "", IsDefault: "", Status: "2", Default: "", CreateBy: "1", UpdateBy: "", Remark: "系统默认是", BaseModel: models.BaseModel{CreatedAt: time.Now(), UpdatedAt: time.Now()}}, {DictCode: 8, DictSort: 0, DictLabel: "是", DictValue: "Y", DictType: "sys_yes_no", CssClass: "", ListClass: "", IsDefault: "", Status: "2", Default: "", ControlBy: models.ControlBy{CreateBy: 1, UpdateBy: 1}, Remark: "系统默认是", ModelTime: models.ModelTime{CreatedAt: time.Now(), UpdatedAt: time.Now()}},
{DictCode: 9, DictSort: 0, DictLabel: "否", DictValue: "N", DictType: "sys_yes_no", CssClass: "", ListClass: "", IsDefault: "", Status: "2", Default: "", CreateBy: "1", UpdateBy: "", Remark: "系统默认否", BaseModel: models.BaseModel{CreatedAt: time.Now(), UpdatedAt: time.Now()}}, {DictCode: 9, DictSort: 0, DictLabel: "否", DictValue: "N", DictType: "sys_yes_no", CssClass: "", ListClass: "", IsDefault: "", Status: "2", Default: "", ControlBy: models.ControlBy{CreateBy: 1, UpdateBy: 1}, Remark: "系统默认否", ModelTime: models.ModelTime{CreatedAt: time.Now(), UpdatedAt: time.Now()}},
{DictCode: 10, DictSort: 0, DictLabel: "正常", DictValue: "2", DictType: "sys_job_status", CssClass: "", ListClass: "", IsDefault: "", Status: "2", Default: "", CreateBy: "1", UpdateBy: "", Remark: "正常状态", BaseModel: models.BaseModel{CreatedAt: time.Now(), UpdatedAt: time.Now()}}, {DictCode: 10, DictSort: 0, DictLabel: "正常", DictValue: "2", DictType: "sys_job_status", CssClass: "", ListClass: "", IsDefault: "", Status: "2", Default: "", ControlBy: models.ControlBy{CreateBy: 1, UpdateBy: 1}, Remark: "正常状态", ModelTime: models.ModelTime{CreatedAt: time.Now(), UpdatedAt: time.Now()}},
{DictCode: 11, DictSort: 0, DictLabel: "停用", DictValue: "1", DictType: "sys_job_status", CssClass: "", ListClass: "", IsDefault: "", Status: "2", Default: "", CreateBy: "1", UpdateBy: "", Remark: "停用状态", BaseModel: models.BaseModel{CreatedAt: time.Now(), UpdatedAt: time.Now()}}, {DictCode: 11, DictSort: 0, DictLabel: "停用", DictValue: "1", DictType: "sys_job_status", CssClass: "", ListClass: "", IsDefault: "", Status: "2", Default: "", ControlBy: models.ControlBy{CreateBy: 1, UpdateBy: 1}, Remark: "停用状态", ModelTime: models.ModelTime{CreatedAt: time.Now(), UpdatedAt: time.Now()}},
{DictCode: 12, DictSort: 0, DictLabel: "默认", DictValue: "DEFAULT", DictType: "sys_job_group", CssClass: "", ListClass: "", IsDefault: "", Status: "2", Default: "", CreateBy: "1", UpdateBy: "", Remark: "默认分组", BaseModel: models.BaseModel{CreatedAt: time.Now(), UpdatedAt: time.Now()}}, {DictCode: 12, DictSort: 0, DictLabel: "默认", DictValue: "DEFAULT", DictType: "sys_job_group", CssClass: "", ListClass: "", IsDefault: "", Status: "2", Default: "", ControlBy: models.ControlBy{CreateBy: 1, UpdateBy: 1}, Remark: "默认分组", ModelTime: models.ModelTime{CreatedAt: time.Now(), UpdatedAt: time.Now()}},
{DictCode: 13, DictSort: 0, DictLabel: "系统", DictValue: "SYSTEM", DictType: "sys_job_group", CssClass: "", ListClass: "", IsDefault: "", Status: "2", Default: "", CreateBy: "1", UpdateBy: "", Remark: "系统分组", BaseModel: models.BaseModel{CreatedAt: time.Now(), UpdatedAt: time.Now()}}, {DictCode: 13, DictSort: 0, DictLabel: "系统", DictValue: "SYSTEM", DictType: "sys_job_group", CssClass: "", ListClass: "", IsDefault: "", Status: "2", Default: "", ControlBy: models.ControlBy{CreateBy: 1, UpdateBy: 1}, Remark: "系统分组", ModelTime: models.ModelTime{CreatedAt: time.Now(), UpdatedAt: time.Now()}},
{DictCode: 14, DictSort: 0, DictLabel: "通知", DictValue: "1", DictType: "sys_notice_type", CssClass: "", ListClass: "", IsDefault: "", Status: "2", Default: "", CreateBy: "1", UpdateBy: "", Remark: "通知", BaseModel: models.BaseModel{CreatedAt: time.Now(), UpdatedAt: time.Now()}}, {DictCode: 14, DictSort: 0, DictLabel: "通知", DictValue: "1", DictType: "sys_notice_type", CssClass: "", ListClass: "", IsDefault: "", Status: "2", Default: "", ControlBy: models.ControlBy{CreateBy: 1, UpdateBy: 1}, Remark: "通知", ModelTime: models.ModelTime{CreatedAt: time.Now(), UpdatedAt: time.Now()}},
{DictCode: 15, DictSort: 0, DictLabel: "公告", DictValue: "2", DictType: "sys_notice_type", CssClass: "", ListClass: "", IsDefault: "", Status: "2", Default: "", CreateBy: "1", UpdateBy: "", Remark: "公告", BaseModel: models.BaseModel{CreatedAt: time.Now(), UpdatedAt: time.Now()}}, {DictCode: 15, DictSort: 0, DictLabel: "公告", DictValue: "2", DictType: "sys_notice_type", CssClass: "", ListClass: "", IsDefault: "", Status: "2", Default: "", ControlBy: models.ControlBy{CreateBy: 1, UpdateBy: 1}, Remark: "公告", ModelTime: models.ModelTime{CreatedAt: time.Now(), UpdatedAt: time.Now()}},
{DictCode: 16, DictSort: 0, DictLabel: "正常", DictValue: "0", DictType: "sys_common_status", CssClass: "", ListClass: "", IsDefault: "", Status: "2", Default: "", CreateBy: "1", UpdateBy: "", Remark: "正常状态", BaseModel: models.BaseModel{CreatedAt: time.Now(), UpdatedAt: time.Now()}}, {DictCode: 16, DictSort: 0, DictLabel: "正常", DictValue: "0", DictType: "sys_common_status", CssClass: "", ListClass: "", IsDefault: "", Status: "2", Default: "", ControlBy: models.ControlBy{CreateBy: 1, UpdateBy: 1}, Remark: "正常状态", ModelTime: models.ModelTime{CreatedAt: time.Now(), UpdatedAt: time.Now()}},
{DictCode: 17, DictSort: 0, DictLabel: "关闭", DictValue: "1", DictType: "sys_common_status", CssClass: "", ListClass: "", IsDefault: "", Status: "2", Default: "", CreateBy: "1", UpdateBy: "", Remark: "关闭状态", BaseModel: models.BaseModel{CreatedAt: time.Now(), UpdatedAt: time.Now()}}, {DictCode: 17, DictSort: 0, DictLabel: "关闭", DictValue: "1", DictType: "sys_common_status", CssClass: "", ListClass: "", IsDefault: "", Status: "2", Default: "", ControlBy: models.ControlBy{CreateBy: 1, UpdateBy: 1}, Remark: "关闭状态", ModelTime: models.ModelTime{CreatedAt: time.Now(), UpdatedAt: time.Now()}},
{DictCode: 18, DictSort: 0, DictLabel: "新增", DictValue: "1", DictType: "sys_oper_type", CssClass: "", ListClass: "", IsDefault: "", Status: "2", Default: "", CreateBy: "1", UpdateBy: "", Remark: "新增操作", BaseModel: models.BaseModel{CreatedAt: time.Now(), UpdatedAt: time.Now()}}, {DictCode: 18, DictSort: 0, DictLabel: "新增", DictValue: "1", DictType: "sys_oper_type", CssClass: "", ListClass: "", IsDefault: "", Status: "2", Default: "", ControlBy: models.ControlBy{CreateBy: 1, UpdateBy: 1}, Remark: "新增操作", ModelTime: models.ModelTime{CreatedAt: time.Now(), UpdatedAt: time.Now()}},
{DictCode: 19, DictSort: 0, DictLabel: "修改", DictValue: "2", DictType: "sys_oper_type", CssClass: "", ListClass: "", IsDefault: "", Status: "2", Default: "", CreateBy: "1", UpdateBy: "", Remark: "修改操作", BaseModel: models.BaseModel{CreatedAt: time.Now(), UpdatedAt: time.Now()}}, {DictCode: 19, DictSort: 0, DictLabel: "修改", DictValue: "2", DictType: "sys_oper_type", CssClass: "", ListClass: "", IsDefault: "", Status: "2", Default: "", ControlBy: models.ControlBy{CreateBy: 1, UpdateBy: 1}, Remark: "修改操作", ModelTime: models.ModelTime{CreatedAt: time.Now(), UpdatedAt: time.Now()}},
{DictCode: 20, DictSort: 0, DictLabel: "删除", DictValue: "3", DictType: "sys_oper_type", CssClass: "", ListClass: "", IsDefault: "", Status: "2", Default: "", CreateBy: "1", UpdateBy: "", Remark: "删除操作", BaseModel: models.BaseModel{CreatedAt: time.Now(), UpdatedAt: time.Now()}}, {DictCode: 20, DictSort: 0, DictLabel: "删除", DictValue: "3", DictType: "sys_oper_type", CssClass: "", ListClass: "", IsDefault: "", Status: "2", Default: "", ControlBy: models.ControlBy{CreateBy: 1, UpdateBy: 1}, Remark: "删除操作", ModelTime: models.ModelTime{CreatedAt: time.Now(), UpdatedAt: time.Now()}},
{DictCode: 21, DictSort: 0, DictLabel: "授权", DictValue: "4", DictType: "sys_oper_type", CssClass: "", ListClass: "", IsDefault: "", Status: "2", Default: "", CreateBy: "1", UpdateBy: "", Remark: "授权操作", BaseModel: models.BaseModel{CreatedAt: time.Now(), UpdatedAt: time.Now()}}, {DictCode: 21, DictSort: 0, DictLabel: "授权", DictValue: "4", DictType: "sys_oper_type", CssClass: "", ListClass: "", IsDefault: "", Status: "2", Default: "", ControlBy: models.ControlBy{CreateBy: 1, UpdateBy: 1}, Remark: "授权操作", ModelTime: models.ModelTime{CreatedAt: time.Now(), UpdatedAt: time.Now()}},
{DictCode: 22, DictSort: 0, DictLabel: "导出", DictValue: "5", DictType: "sys_oper_type", CssClass: "", ListClass: "", IsDefault: "", Status: "2", Default: "", CreateBy: "1", UpdateBy: "", Remark: "导出操作", BaseModel: models.BaseModel{CreatedAt: time.Now(), UpdatedAt: time.Now()}}, {DictCode: 22, DictSort: 0, DictLabel: "导出", DictValue: "5", DictType: "sys_oper_type", CssClass: "", ListClass: "", IsDefault: "", Status: "2", Default: "", ControlBy: models.ControlBy{CreateBy: 1, UpdateBy: 1}, Remark: "导出操作", ModelTime: models.ModelTime{CreatedAt: time.Now(), UpdatedAt: time.Now()}},
{DictCode: 23, DictSort: 0, DictLabel: "导入", DictValue: "6", DictType: "sys_oper_type", CssClass: "", ListClass: "", IsDefault: "", Status: "2", Default: "", CreateBy: "1", UpdateBy: "", Remark: "导入操作", BaseModel: models.BaseModel{CreatedAt: time.Now(), UpdatedAt: time.Now()}}, {DictCode: 23, DictSort: 0, DictLabel: "导入", DictValue: "6", DictType: "sys_oper_type", CssClass: "", ListClass: "", IsDefault: "", Status: "2", Default: "", ControlBy: models.ControlBy{CreateBy: 1, UpdateBy: 1}, Remark: "导入操作", ModelTime: models.ModelTime{CreatedAt: time.Now(), UpdatedAt: time.Now()}},
{DictCode: 24, DictSort: 0, DictLabel: "强退", DictValue: "7", DictType: "sys_oper_type", CssClass: "", ListClass: "", IsDefault: "", Status: "2", Default: "", CreateBy: "1", UpdateBy: "", Remark: "强退操作", BaseModel: models.BaseModel{CreatedAt: time.Now(), UpdatedAt: time.Now()}}, {DictCode: 24, DictSort: 0, DictLabel: "强退", DictValue: "7", DictType: "sys_oper_type", CssClass: "", ListClass: "", IsDefault: "", Status: "2", Default: "", ControlBy: models.ControlBy{CreateBy: 1, UpdateBy: 1}, Remark: "强退操作", ModelTime: models.ModelTime{CreatedAt: time.Now(), UpdatedAt: time.Now()}},
{DictCode: 25, DictSort: 0, DictLabel: "生成代码", DictValue: "8", DictType: "sys_oper_type", CssClass: "", ListClass: "", IsDefault: "", Status: "2", Default: "", CreateBy: "1", UpdateBy: "", Remark: "生成操作", BaseModel: models.BaseModel{CreatedAt: time.Now(), UpdatedAt: time.Now()}}, {DictCode: 25, DictSort: 0, DictLabel: "生成代码", DictValue: "8", DictType: "sys_oper_type", CssClass: "", ListClass: "", IsDefault: "", Status: "2", Default: "", ControlBy: models.ControlBy{CreateBy: 1, UpdateBy: 1}, Remark: "生成操作", ModelTime: models.ModelTime{CreatedAt: time.Now(), UpdatedAt: time.Now()}},
{DictCode: 26, DictSort: 0, DictLabel: "清空数据", DictValue: "9", DictType: "sys_oper_type", CssClass: "", ListClass: "", IsDefault: "", Status: "2", Default: "", CreateBy: "1", UpdateBy: "", Remark: "清空操作", BaseModel: models.BaseModel{CreatedAt: time.Now(), UpdatedAt: time.Now()}}, {DictCode: 26, DictSort: 0, DictLabel: "清空数据", DictValue: "9", DictType: "sys_oper_type", CssClass: "", ListClass: "", IsDefault: "", Status: "2", Default: "", ControlBy: models.ControlBy{CreateBy: 1, UpdateBy: 1}, Remark: "清空操作", ModelTime: models.ModelTime{CreatedAt: time.Now(), UpdatedAt: time.Now()}},
{DictCode: 27, DictSort: 0, DictLabel: "成功", DictValue: "0", DictType: "sys_notice_status", CssClass: "", ListClass: "", IsDefault: "", Status: "2", Default: "", CreateBy: "1", UpdateBy: "", Remark: "成功状态", BaseModel: models.BaseModel{CreatedAt: time.Now(), UpdatedAt: time.Now()}}, {DictCode: 27, DictSort: 0, DictLabel: "成功", DictValue: "0", DictType: "sys_notice_status", CssClass: "", ListClass: "", IsDefault: "", Status: "2", Default: "", ControlBy: models.ControlBy{CreateBy: 1, UpdateBy: 1}, Remark: "成功状态", ModelTime: models.ModelTime{CreatedAt: time.Now(), UpdatedAt: time.Now()}},
{DictCode: 28, DictSort: 0, DictLabel: "失败", DictValue: "1", DictType: "sys_notice_status", CssClass: "", ListClass: "", IsDefault: "", Status: "2", Default: "", CreateBy: "1", UpdateBy: "", Remark: "失败状态", BaseModel: models.BaseModel{CreatedAt: time.Now(), UpdatedAt: time.Now()}}, {DictCode: 28, DictSort: 0, DictLabel: "失败", DictValue: "1", DictType: "sys_notice_status", CssClass: "", ListClass: "", IsDefault: "", Status: "2", Default: "", ControlBy: models.ControlBy{CreateBy: 1, UpdateBy: 1}, Remark: "失败状态", ModelTime: models.ModelTime{CreatedAt: time.Now(), UpdatedAt: time.Now()}},
{DictCode: 29, DictSort: 0, DictLabel: "登录", DictValue: "10", DictType: "sys_oper_type", CssClass: "", ListClass: "", IsDefault: "", Status: "2", Default: "", CreateBy: "1", UpdateBy: "1", Remark: "登录操作", BaseModel: models.BaseModel{CreatedAt: time.Now(), UpdatedAt: time.Now()}}, {DictCode: 29, DictSort: 0, DictLabel: "登录", DictValue: "10", DictType: "sys_oper_type", CssClass: "", ListClass: "", IsDefault: "", Status: "2", Default: "", ControlBy: models.ControlBy{CreateBy: 1, UpdateBy: 1}, Remark: "登录操作", ModelTime: models.ModelTime{CreatedAt: time.Now(), UpdatedAt: time.Now()}},
{DictCode: 30, DictSort: 0, DictLabel: "退出", DictValue: "11", DictType: "sys_oper_type", CssClass: "", ListClass: "", IsDefault: "", Status: "2", Default: "", CreateBy: "1", UpdateBy: "1", Remark: "", BaseModel: models.BaseModel{CreatedAt: time.Now(), UpdatedAt: time.Now()}}, {DictCode: 30, DictSort: 0, DictLabel: "退出", DictValue: "11", DictType: "sys_oper_type", CssClass: "", ListClass: "", IsDefault: "", Status: "2", Default: "", ControlBy: models.ControlBy{CreateBy: 1, UpdateBy: 1}, Remark: "", ModelTime: models.ModelTime{CreatedAt: time.Now(), UpdatedAt: time.Now()}},
{DictCode: 31, DictSort: 0, DictLabel: "获取验证码", DictValue: "12", DictType: "sys_oper_type", CssClass: "", ListClass: "", IsDefault: "", Status: "2", Default: "", CreateBy: "1", UpdateBy: "1", Remark: "获取验证码", BaseModel: models.BaseModel{CreatedAt: time.Now(), UpdatedAt: time.Now()}}, {DictCode: 31, DictSort: 0, DictLabel: "获取验证码", DictValue: "12", DictType: "sys_oper_type", CssClass: "", ListClass: "", IsDefault: "", Status: "2", Default: "", ControlBy: models.ControlBy{CreateBy: 1, UpdateBy: 1}, Remark: "获取验证码", ModelTime: models.ModelTime{CreatedAt: time.Now(), UpdatedAt: time.Now()}},
} }
list10 := []models.SysSetting{ list10 := []models.SysSetting{
@@ -123,8 +135,48 @@ func _1599190683670Test(db *gorm.DB, version string) error {
} }
list11 := []models.SysJob{ list11 := []models.SysJob{
{1, "接口测试", "DEFAULT", 1, "0/5 * * * * ", "http://localhost:8000", "", 1, 1, 1, 0, "", "", models.BaseModel{CreatedAt: time.Now(), UpdatedAt: time.Now()}, ""}, {
{2, "函数测试", "DEFAULT", 2, "0/5 * * * * ", "ExamplesOne", "参数", 1, 1, 1, 0, "", "", models.BaseModel{CreatedAt: time.Now(), UpdatedAt: time.Now()}, ""}, JobId: 1,
JobName: "接口测试",
JobGroup: "DEFAULT",
JobType: 1,
CronExpression: "0/5 * * * * ",
InvokeTarget: "http://localhost:8000",
Args: "",
MisfirePolicy: 1,
Concurrent: 1,
Status: 1,
EntryId: 0,
ControlBy: models.ControlBy{
CreateBy: 1,
UpdateBy: 1,
},
ModelTime: models.ModelTime{
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
},
},
models.SysJob{
JobId: 2,
JobName: "函数测试",
JobGroup: "DEFAULT",
JobType: 2,
CronExpression: "0/5 * * * * ",
InvokeTarget: "ExamplesOne",
Args: "参数",
MisfirePolicy: 1,
Concurrent: 1,
Status: 1,
EntryId: 0,
ControlBy: models.ControlBy{
CreateBy: 1,
UpdateBy: 1,
},
ModelTime: models.ModelTime{
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
},
},
} }
err := tx.Create(list3).Error err := tx.Create(list3).Error
@@ -20,11 +20,10 @@ func _1613720892819Test(db *gorm.DB, version string) error {
// TODO: 这里开始写入要变更的内容 // TODO: 这里开始写入要变更的内容
t := &models.DictType{ t := &models.DictType{
DictName: "内容状态", DictName: "内容状态",
DictType: "sys_content_status", DictType: "sys_content_status",
Status: "2", Status: "2",
CreateBy: "1", ControlBy: models.ControlBy{CreateBy: 1, UpdateBy: 1},
UpdateBy: "1",
} }
err := tx.Create(t).Error err := tx.Create(t).Error
if err != nil { if err != nil {
@@ -38,8 +37,7 @@ func _1613720892819Test(db *gorm.DB, version string) error {
DictValue: "1", DictValue: "1",
DictType: "sys_content_status", DictType: "sys_content_status",
Status: "1", Status: "1",
CreateBy: "1", ControlBy: models.ControlBy{CreateBy: 1, UpdateBy: 1},
UpdateBy: "1",
} }
data[1] = models.DictData{ data[1] = models.DictData{
DictSort: 1, DictSort: 1,
@@ -47,8 +45,7 @@ func _1613720892819Test(db *gorm.DB, version string) error {
DictValue: "2", DictValue: "2",
DictType: "sys_content_status", DictType: "sys_content_status",
Status: "1", Status: "1",
CreateBy: "1", ControlBy: models.ControlBy{CreateBy: 1, UpdateBy: 1},
UpdateBy: "1",
} }
err = tx.Create(data).Error err = tx.Create(data).Error
if err != nil { if err != nil {
@@ -0,0 +1,64 @@
package version
import (
"go-admin/cmd/migrate/migration/models"
"gorm.io/gorm"
"runtime"
"go-admin/cmd/migrate/migration"
common "go-admin/common/models"
)
func init() {
_, fileName, _, _ := runtime.Caller(0)
migration.Migrate.SetVersion(migration.GetFilename(fileName), _1619418811873Test)
}
func _1619418811873Test(db *gorm.DB, version string) error {
return db.Transaction(func(tx *gorm.DB) error {
// TODO: 这里开始写入要变更的内容
err := tx.Migrator().AlterColumn(&models.SysRole{}, "CreateBy")
if err != nil {
return err
}
err = tx.Migrator().AlterColumn(&models.SysRole{}, "UpdateBy")
if err != nil {
return err
}
err = tx.Migrator().AlterColumn(&models.SysJob{}, "CreateBy")
if err != nil {
return err
}
err = tx.Migrator().AlterColumn(&models.SysJob{}, "UpdateBy")
if err != nil {
return err
}
err = tx.Migrator().AlterColumn(&models.RoleMenu{}, "CreateBy")
if err != nil {
return err
}
err = tx.Migrator().AlterColumn(&models.RoleMenu{}, "UpdateBy")
if err != nil {
return err
}
// TODO: 例如 修改表字段 使用过程中请删除此段代码
//err := tx.Migrator().RenameColumn(&models.SysConfig{}, "config_id", "id")
//if err != nil {
// return err
//}
// TODO: 例如 新增表结构 使用过程中请删除此段代码
//err = tx.Debug().Migrator().AutoMigrate(
// new(models.CasbinRule),
// )
//if err != nil {
// return err
//}
return tx.Create(&common.Migration{
Version: version,
}).Error
})
}