feat: 系统升级支持数据库自动迁移,避免手动执行升级脚本

This commit is contained in:
meilin.huang
2025-02-13 21:11:23 +08:00
parent efb2b7368c
commit aa393590b2
78 changed files with 1965 additions and 1827 deletions

View File

@@ -1,7 +1,7 @@
package form
type ResourceForm struct {
Pid int `json:"pid"`
Pid int64 `json:"pid"`
Id int `json:"id"`
Code string `json:"code" binding:"required"`
Name string `json:"name" binding:"required"`

View File

@@ -11,13 +11,13 @@ import (
type Account struct {
model.Model
Name string `json:"name"`
Username string `json:"username"`
Password string `json:"-"`
Status AccountStatus `json:"status"`
Name string `json:"name" gorm:"size:30;not null;"`
Username string `json:"username" gorm:"size:30;not null;"`
Password string `json:"-" gorm:"size:64;not null;"`
Status AccountStatus `json:"status" gorm:"not null;"`
LastLoginTime *time.Time `json:"lastLoginTime"`
LastLoginIp string `json:"lastLoginIp"`
OtpSecret string `json:"-"`
LastLoginIp string `json:"lastLoginIp" gorm:"size:50;"`
OtpSecret string `json:"-" gorm:"size:100;"`
}
func (a *Account) TableName() string {

View File

@@ -13,12 +13,12 @@ const (
type Config struct {
model.Model
Name string `json:"name"` // 配置名
Key string `json:"key"` // 配置key
Params string `json:"params" gorm:"column:params;type:varchar(1500)"`
Value string `json:"value" gorm:"column:value;type:varchar(1500)"`
Remark string `json:"remark"`
Permission string `json:"permission"` // 可操作该配置的权限
Name string `json:"name" gorm:"size:60;not null;"` // 配置名
Key string `json:"key" gorm:"size:60;not null;"` // 配置key
Params string `json:"params" gorm:"size:1500"`
Value string `json:"value" gorm:"size:1500"`
Remark string `json:"remark" gorm:"size:255"`
Permission string `json:"permission" gorm:"size:255;comment:操作权限"` // 可操作该配置的权限
}
func (a *Config) TableName() string {

View File

@@ -4,14 +4,14 @@ import "mayfly-go/pkg/model"
type Resource struct {
model.Model
Pid int `json:"pid"`
UiPath string `json:"ui_path"` // 唯一标识路径
Type int8 `json:"type"` // 1菜单路由2资源按钮等
Status int8 `json:"status"` // 1可用-1不可用
Code string `json:"code"`
Name string `json:"name"`
Pid int64 `json:"pid" gorm:"not null;comment:父节点id;"`
UiPath string `json:"ui_path" gorm:"size:300;not null;comment:唯一标识路径;"` // 唯一标识路径
Type int8 `json:"type" gorm:"not null;comment:1菜单路由2资源按钮等;"` // 1菜单路由2资源按钮等
Status int8 `json:"status" gorm:"not null;comment:状态1:可用,-1:禁用;"` // 1可用-1不可用
Code string `json:"code" gorm:"size:300;comment:菜单路由为path其他为唯一标识;"`
Name string `json:"name" gorm:"size:255;not null;"`
Weight int `json:"weight"`
Meta string `json:"meta"`
Meta string `json:"meta" gorm:"size:500;"`
}
func (a *Resource) TableName() string {

View File

@@ -12,11 +12,11 @@ const (
type Role struct {
model.Model
Status int `json:"status"` // 1可用-1不可用
Name string `json:"name"`
Remark string `json:"remark"`
Code string `json:"code"`
Type int `json:"type"`
Status int `json:"status" gorm:"not null;"` // 1可用-1不可用
Name string `json:"name" gorm:"size:32;not null;"`
Remark string `json:"remark" gorm:"size:255;not null;"`
Code string `json:"code" gorm:"size:64;not null;"`
Type int8 `json:"type" gorm:"not null;comment:类型1:公共角色2:特殊角色;"`
}
func (a *Role) TableName() string {
@@ -27,11 +27,11 @@ func (a *Role) TableName() string {
type RoleResource struct {
model.DeletedModel
RoleId uint64 `json:"roleId"`
ResourceId uint64 `json:"resourceId"`
CreateTime *time.Time `json:"createTime"`
CreatorId uint64 `json:"creatorId"`
Creator string `json:"creator"`
RoleId uint64 `json:"roleId" gorm:"not null;"`
ResourceId uint64 `json:"resourceId" gorm:"not null;"`
CreateTime *time.Time `json:"createTime" gorm:"not null;"`
CreatorId uint64 `json:"creatorId" gorm:"not null;"`
Creator string `json:"creator" gorm:"size:32;not null;"`
}
func (a *RoleResource) TableName() string {
@@ -42,11 +42,11 @@ func (a *RoleResource) TableName() string {
type AccountRole struct {
model.DeletedModel
AccountId uint64 `json:"accountId"`
RoleId uint64 `json:"roleId"`
CreateTime *time.Time `json:"createTime"`
CreatorId uint64 `json:"creatorId"`
Creator string `json:"creator"`
AccountId uint64 `json:"accountId" gorm:"not null;"`
RoleId uint64 `json:"roleId" gorm:"not null;"`
CreateTime *time.Time `json:"createTime" gorm:"not null;"`
CreatorId uint64 `json:"creatorId" gorm:"not null;"`
Creator string `json:"creator" gorm:"size:32;not null;"`
}
func (a *AccountRole) TableName() string {

View File

@@ -8,11 +8,11 @@ import (
type SysLog struct {
model.CreateModel
Type int8 `json:"type"`
Description string `json:"description"`
ReqParam string `json:"reqParam" gorm:"column:req_param;type:varchar(1000)"` // 请求参数
Resp string `json:"resp" gorm:"column:resp;type:varchar(10000)"` // 响应结构
Extra string `json:"extra"` // 日志额外信息
Type int8 `json:"type" gorm:"not null;"`
Description string `json:"description" gorm:"size:255;"`
ReqParam string `json:"reqParam" gorm:"size:2000"` // 请求参数
Resp string `json:"resp" gorm:"type:text;"` // 响应结构
Extra string `json:"extra" gorm:"type:text;"` // 日志额外信息
}
func (a *SysLog) TableName() string {