增加pgsql适配
This commit is contained in:
@@ -1,37 +0,0 @@
|
||||
package source
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/global"
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/model/system"
|
||||
"github.com/gookit/color"
|
||||
|
||||
uuid "github.com/satori/go.uuid"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
var Admin = new(admin)
|
||||
|
||||
type admin struct{}
|
||||
|
||||
var admins = []system.SysUser{
|
||||
{GVA_MODEL: global.GVA_MODEL{ID: 1, CreatedAt: time.Now(), UpdatedAt: time.Now()}, UUID: uuid.NewV4(), Username: "admin", Password: "e10adc3949ba59abbe56e057f20f883e", NickName: "超级管理员", HeaderImg: "https:///qmplusimg.henrongyi.top/gva_header.jpg", AuthorityId: "888"},
|
||||
{GVA_MODEL: global.GVA_MODEL{ID: 2, CreatedAt: time.Now(), UpdatedAt: time.Now()}, UUID: uuid.NewV4(), Username: "a303176530", Password: "3ec063004a6f31642261936a379fde3d", NickName: "QMPlusUser", HeaderImg: "https:///qmplusimg.henrongyi.top/1572075907logo.png", AuthorityId: "9528"},
|
||||
}
|
||||
|
||||
//@author: [SliverHorn](https://github.com/SliverHorn)
|
||||
//@description: sys_users 表数据初始化
|
||||
func (a *admin) Init() error {
|
||||
return global.GVA_DB.Transaction(func(tx *gorm.DB) error {
|
||||
if tx.Where("id IN ?", []int{1, 2}).Find(&[]system.SysUser{}).RowsAffected == 2 {
|
||||
color.Danger.Println("\n[Mysql] --> sys_users 表的初始数据已存在!")
|
||||
return nil
|
||||
}
|
||||
if err := tx.Create(&admins).Error; err != nil { // 遇到错误时回滚事务
|
||||
return err
|
||||
}
|
||||
color.Info.Println("\n[Mysql] --> sys_users 表初始数据成功!")
|
||||
return nil
|
||||
})
|
||||
}
|
@@ -1,113 +0,0 @@
|
||||
package source
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/global"
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/model/system"
|
||||
"github.com/gookit/color"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
var Api = new(api)
|
||||
|
||||
type api struct{}
|
||||
|
||||
var apis = []system.SysApi{
|
||||
{global.GVA_MODEL{ID: 1, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/base/login", "用户登录(必选)", "base", "POST"},
|
||||
{global.GVA_MODEL{ID: 2, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/user/register", "用户注册(必选)", "user", "POST"},
|
||||
{global.GVA_MODEL{ID: 3, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/api/createApi", "创建api", "api", "POST"},
|
||||
{global.GVA_MODEL{ID: 4, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/api/getApiList", "获取api列表", "api", "POST"},
|
||||
{global.GVA_MODEL{ID: 5, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/api/getApiById", "获取api详细信息", "api", "POST"},
|
||||
{global.GVA_MODEL{ID: 6, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/api/deleteApi", "删除Api", "api", "POST"},
|
||||
{global.GVA_MODEL{ID: 7, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/api/updateApi", "更新Api", "api", "POST"},
|
||||
{global.GVA_MODEL{ID: 8, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/api/getAllApis", "获取所有api", "api", "POST"},
|
||||
{global.GVA_MODEL{ID: 9, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/authority/createAuthority", "创建角色", "authority", "POST"},
|
||||
{global.GVA_MODEL{ID: 10, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/authority/deleteAuthority", "删除角色", "authority", "POST"},
|
||||
{global.GVA_MODEL{ID: 11, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/authority/getAuthorityList", "获取角色列表", "authority", "POST"},
|
||||
{global.GVA_MODEL{ID: 12, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/menu/getMenu", "获取菜单树(必选)", "menu", "POST"},
|
||||
{global.GVA_MODEL{ID: 13, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/menu/getMenuList", "分页获取基础menu列表", "menu", "POST"},
|
||||
{global.GVA_MODEL{ID: 14, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/menu/addBaseMenu", "新增菜单", "menu", "POST"},
|
||||
{global.GVA_MODEL{ID: 15, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/menu/getBaseMenuTree", "获取用户动态路由", "menu", "POST"},
|
||||
{global.GVA_MODEL{ID: 16, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/menu/addMenuAuthority", "增加menu和角色关联关系", "menu", "POST"},
|
||||
{global.GVA_MODEL{ID: 17, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/menu/getMenuAuthority", "获取指定角色menu", "menu", "POST"},
|
||||
{global.GVA_MODEL{ID: 18, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/menu/deleteBaseMenu", "删除菜单", "menu", "POST"},
|
||||
{global.GVA_MODEL{ID: 19, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/menu/updateBaseMenu", "更新菜单", "menu", "POST"},
|
||||
{global.GVA_MODEL{ID: 20, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/menu/getBaseMenuById", "根据id获取菜单", "menu", "POST"},
|
||||
{global.GVA_MODEL{ID: 21, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/user/changePassword", "修改密码(建议选择)", "user", "POST"},
|
||||
{global.GVA_MODEL{ID: 23, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/user/getUserList", "获取用户列表", "user", "POST"},
|
||||
{global.GVA_MODEL{ID: 24, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/user/setUserAuthority", "修改用户角色(必选)", "user", "POST"},
|
||||
{global.GVA_MODEL{ID: 25, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/fileUploadAndDownload/upload", "文件上传示例", "fileUploadAndDownload", "POST"},
|
||||
{global.GVA_MODEL{ID: 26, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/fileUploadAndDownload/getFileList", "获取上传文件列表", "fileUploadAndDownload", "POST"},
|
||||
{global.GVA_MODEL{ID: 27, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/casbin/updateCasbin", "更改角色api权限", "casbin", "POST"},
|
||||
{global.GVA_MODEL{ID: 28, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/casbin/getPolicyPathByAuthorityId", "获取权限列表", "casbin", "POST"},
|
||||
{global.GVA_MODEL{ID: 29, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/fileUploadAndDownload/deleteFile", "删除文件", "fileUploadAndDownload", "POST"},
|
||||
{global.GVA_MODEL{ID: 30, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/jwt/jsonInBlacklist", "jwt加入黑名单(退出,必选)", "jwt", "POST"},
|
||||
{global.GVA_MODEL{ID: 31, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/authority/setDataAuthority", "设置角色资源权限", "authority", "POST"},
|
||||
{global.GVA_MODEL{ID: 32, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/system/getSystemConfig", "获取配置文件内容", "system", "POST"},
|
||||
{global.GVA_MODEL{ID: 33, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/system/setSystemConfig", "设置配置文件内容", "system", "POST"},
|
||||
{global.GVA_MODEL{ID: 34, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/customer/customer", "创建客户", "customer", "POST"},
|
||||
{global.GVA_MODEL{ID: 35, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/customer/customer", "更新客户", "customer", "PUT"},
|
||||
{global.GVA_MODEL{ID: 36, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/customer/customer", "删除客户", "customer", "DELETE"},
|
||||
{global.GVA_MODEL{ID: 37, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/customer/customer", "获取单一客户", "customer", "GET"},
|
||||
{global.GVA_MODEL{ID: 38, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/customer/customerList", "获取客户列表", "customer", "GET"},
|
||||
{global.GVA_MODEL{ID: 39, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/casbin/casbinTest/:pathParam", "RESTFUL模式测试", "casbin", "GET"},
|
||||
{global.GVA_MODEL{ID: 40, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/autoCode/createTemp", "自动化代码", "autoCode", "POST"},
|
||||
{global.GVA_MODEL{ID: 41, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/authority/updateAuthority", "更新角色信息", "authority", "PUT"},
|
||||
{global.GVA_MODEL{ID: 42, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/authority/copyAuthority", "拷贝角色", "authority", "POST"},
|
||||
{global.GVA_MODEL{ID: 43, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/user/deleteUser", "删除用户", "user", "DELETE"},
|
||||
{global.GVA_MODEL{ID: 44, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysDictionaryDetail/createSysDictionaryDetail", "新增字典内容", "sysDictionaryDetail", "POST"},
|
||||
{global.GVA_MODEL{ID: 45, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysDictionaryDetail/deleteSysDictionaryDetail", "删除字典内容", "sysDictionaryDetail", "DELETE"},
|
||||
{global.GVA_MODEL{ID: 46, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysDictionaryDetail/updateSysDictionaryDetail", "更新字典内容", "sysDictionaryDetail", "PUT"},
|
||||
{global.GVA_MODEL{ID: 47, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysDictionaryDetail/findSysDictionaryDetail", "根据ID获取字典内容", "sysDictionaryDetail", "GET"},
|
||||
{global.GVA_MODEL{ID: 48, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysDictionaryDetail/getSysDictionaryDetailList", "获取字典内容列表", "sysDictionaryDetail", "GET"},
|
||||
{global.GVA_MODEL{ID: 49, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysDictionary/createSysDictionary", "新增字典", "sysDictionary", "POST"},
|
||||
{global.GVA_MODEL{ID: 50, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysDictionary/deleteSysDictionary", "删除字典", "sysDictionary", "DELETE"},
|
||||
{global.GVA_MODEL{ID: 51, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysDictionary/updateSysDictionary", "更新字典", "sysDictionary", "PUT"},
|
||||
{global.GVA_MODEL{ID: 52, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysDictionary/findSysDictionary", "根据ID获取字典", "sysDictionary", "GET"},
|
||||
{global.GVA_MODEL{ID: 53, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysDictionary/getSysDictionaryList", "获取字典列表", "sysDictionary", "GET"},
|
||||
{global.GVA_MODEL{ID: 54, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysOperationRecord/createSysOperationRecord", "新增操作记录", "sysOperationRecord", "POST"},
|
||||
{global.GVA_MODEL{ID: 55, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysOperationRecord/deleteSysOperationRecord", "删除操作记录", "sysOperationRecord", "DELETE"},
|
||||
{global.GVA_MODEL{ID: 56, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysOperationRecord/findSysOperationRecord", "根据ID获取操作记录", "sysOperationRecord", "GET"},
|
||||
{global.GVA_MODEL{ID: 57, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysOperationRecord/getSysOperationRecordList", "获取操作记录列表", "sysOperationRecord", "GET"},
|
||||
{global.GVA_MODEL{ID: 58, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/autoCode/getTables", "获取数据库表", "autoCode", "GET"},
|
||||
{global.GVA_MODEL{ID: 59, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/autoCode/getDB", "获取所有数据库", "autoCode", "GET"},
|
||||
{global.GVA_MODEL{ID: 60, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/autoCode/getColumn", "获取所选table的所有字段", "autoCode", "GET"},
|
||||
{global.GVA_MODEL{ID: 61, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysOperationRecord/deleteSysOperationRecordByIds", "批量删除操作历史", "sysOperationRecord", "DELETE"},
|
||||
{global.GVA_MODEL{ID: 62, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/simpleUploader/upload", "插件版分片上传", "simpleUploader", "POST"},
|
||||
{global.GVA_MODEL{ID: 63, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/simpleUploader/checkFileMd5", "文件完整度验证", "simpleUploader", "GET"},
|
||||
{global.GVA_MODEL{ID: 64, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/simpleUploader/mergeFileMd5", "上传完成合并文件", "simpleUploader", "GET"},
|
||||
{global.GVA_MODEL{ID: 65, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/user/setUserInfo", "设置用户信息(必选)", "user", "PUT"},
|
||||
{global.GVA_MODEL{ID: 66, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/system/getServerInfo", "获取服务器信息", "system", "POST"},
|
||||
{global.GVA_MODEL{ID: 67, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/email/emailTest", "发送测试邮件", "email", "POST"},
|
||||
{global.GVA_MODEL{ID: 80, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/autoCode/preview", "预览自动化代码", "autoCode", "POST"},
|
||||
{global.GVA_MODEL{ID: 81, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/excel/importExcel", "导入excel", "excel", "POST"},
|
||||
{global.GVA_MODEL{ID: 82, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/excel/loadExcel", "下载excel", "excel", "GET"},
|
||||
{global.GVA_MODEL{ID: 83, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/excel/exportExcel", "导出excel", "excel", "POST"},
|
||||
{global.GVA_MODEL{ID: 84, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/excel/downloadTemplate", "下载excel模板", "excel", "GET"},
|
||||
{global.GVA_MODEL{ID: 85, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/api/deleteApisByIds", "批量删除api", "api", "DELETE"},
|
||||
{global.GVA_MODEL{ID: 86, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/autoCode/getSysHistory", "查询回滚记录", "autoCode", "POST"},
|
||||
{global.GVA_MODEL{ID: 87, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/autoCode/rollback", "回滚自动生成代码", "autoCode", "POST"},
|
||||
{global.GVA_MODEL{ID: 88, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/autoCode/getMeta", "获取meta信息", "autoCode", "POST"},
|
||||
{global.GVA_MODEL{ID: 89, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/autoCode/delSysHistory", "删除回滚记录", "autoCode", "POST"},
|
||||
{global.GVA_MODEL{ID: 90, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/user/setUserAuthorities", "设置权限组", "user", "POST"},
|
||||
{global.GVA_MODEL{ID: 91, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/user/getUserInfo", "获取自身信息(必选)", "user", "GET"},
|
||||
{global.GVA_MODEL{ID: 92, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/user/resetPassword", "重置指定用户密码", "user", "POST"},
|
||||
}
|
||||
|
||||
//@author: [SliverHorn](https://github.com/SliverHorn)
|
||||
//@description: sys_apis 表数据初始化
|
||||
func (a *api) Init() error {
|
||||
return global.GVA_DB.Transaction(func(tx *gorm.DB) error {
|
||||
if tx.Where("id IN ?", []int{1, 67}).Find(&[]system.SysApi{}).RowsAffected == 2 {
|
||||
color.Danger.Println("\n[Mysql] --> sys_apis 表的初始数据已存在!")
|
||||
return nil
|
||||
}
|
||||
if err := tx.Create(&apis).Error; err != nil { // 遇到错误时回滚事务
|
||||
return err
|
||||
}
|
||||
color.Info.Println("\n[Mysql] --> sys_apis 表初始数据成功!")
|
||||
return nil
|
||||
})
|
||||
}
|
@@ -1,78 +0,0 @@
|
||||
package source
|
||||
|
||||
import (
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/global"
|
||||
"github.com/gookit/color"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
var AuthoritiesMenus = new(authoritiesMenus)
|
||||
|
||||
type authoritiesMenus struct{}
|
||||
|
||||
type AuthorityMenus struct {
|
||||
AuthorityId string `gorm:"column:sys_authority_authority_id"`
|
||||
BaseMenuId uint `gorm:"column:sys_base_menu_id"`
|
||||
}
|
||||
|
||||
var authorityMenus = []AuthorityMenus{
|
||||
{"888", 1},
|
||||
{"888", 2},
|
||||
{"888", 3},
|
||||
{"888", 4},
|
||||
{"888", 5},
|
||||
{"888", 6},
|
||||
{"888", 7},
|
||||
{"888", 8},
|
||||
{"888", 9},
|
||||
{"888", 10},
|
||||
{"888", 11},
|
||||
{"888", 12},
|
||||
{"888", 13},
|
||||
{"888", 14},
|
||||
{"888", 15},
|
||||
{"888", 16},
|
||||
{"888", 17},
|
||||
{"888", 18},
|
||||
{"888", 19},
|
||||
{"888", 20},
|
||||
{"888", 22},
|
||||
{"888", 23},
|
||||
{"888", 24},
|
||||
{"888", 25},
|
||||
{"8881", 1},
|
||||
{"8881", 2},
|
||||
{"8881", 8},
|
||||
{"9528", 1},
|
||||
{"9528", 2},
|
||||
{"9528", 3},
|
||||
{"9528", 4},
|
||||
{"9528", 5},
|
||||
{"9528", 6},
|
||||
{"9528", 7},
|
||||
{"9528", 8},
|
||||
{"9528", 9},
|
||||
{"9528", 10},
|
||||
{"9528", 11},
|
||||
{"9528", 12},
|
||||
{"9528", 14},
|
||||
{"9528", 15},
|
||||
{"9528", 16},
|
||||
{"9528", 17},
|
||||
}
|
||||
|
||||
//@author: [SliverHorn](https://github.com/SliverHorn)
|
||||
//@description: sys_authority_menus 表数据初始化
|
||||
func (a *authoritiesMenus) Init() error {
|
||||
return global.GVA_DB.Table("sys_authority_menus").Transaction(func(tx *gorm.DB) error {
|
||||
if tx.Where("sys_authority_authority_id IN ('888', '8881', '9528')").Find(&[]AuthorityMenus{}).RowsAffected == 48 {
|
||||
color.Danger.Println("\n[Mysql] --> sys_authority_menus 表的初始数据已存在!")
|
||||
return nil
|
||||
}
|
||||
if err := tx.Create(&authorityMenus).Error; err != nil { // 遇到错误时回滚事务
|
||||
return err
|
||||
}
|
||||
color.Info.Println("\n[Mysql] --> sys_authority_menus 表初始数据成功!")
|
||||
return nil
|
||||
})
|
||||
}
|
@@ -1,37 +0,0 @@
|
||||
package source
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/global"
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/model/system"
|
||||
"github.com/gookit/color"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
var Authority = new(authority)
|
||||
|
||||
type authority struct{}
|
||||
|
||||
var authorities = []system.SysAuthority{
|
||||
{CreatedAt: time.Now(), UpdatedAt: time.Now(), AuthorityId: "888", AuthorityName: "普通用户", ParentId: "0", DefaultRouter: "dashboard"},
|
||||
{CreatedAt: time.Now(), UpdatedAt: time.Now(), AuthorityId: "8881", AuthorityName: "普通用户子角色", ParentId: "888", DefaultRouter: "dashboard"},
|
||||
{CreatedAt: time.Now(), UpdatedAt: time.Now(), AuthorityId: "9528", AuthorityName: "测试角色", ParentId: "0", DefaultRouter: "dashboard"},
|
||||
}
|
||||
|
||||
//@author: [SliverHorn](https://github.com/SliverHorn)
|
||||
//@description: sys_authorities 表数据初始化
|
||||
func (a *authority) Init() error {
|
||||
return global.GVA_DB.Transaction(func(tx *gorm.DB) error {
|
||||
if tx.Where("authority_id IN ? ", []string{"888", "9528"}).Find(&[]system.SysAuthority{}).RowsAffected == 2 {
|
||||
color.Danger.Println("\n[Mysql] --> sys_authorities 表的初始数据已存在!")
|
||||
return nil
|
||||
}
|
||||
if err := tx.Create(&authorities).Error; err != nil { // 遇到错误时回滚事务
|
||||
return err
|
||||
}
|
||||
color.Info.Println("\n[Mysql] --> sys_authorities 表初始数据成功!")
|
||||
return nil
|
||||
})
|
||||
}
|
@@ -1,25 +0,0 @@
|
||||
package source
|
||||
|
||||
import (
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/global"
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/model/system"
|
||||
"github.com/gookit/color"
|
||||
)
|
||||
|
||||
var AuthorityMenu = new(authorityMenu)
|
||||
|
||||
type authorityMenu struct{}
|
||||
|
||||
//@author: [SliverHorn](https://github.com/SliverHorn)
|
||||
//@description: authority_menu 视图数据初始化
|
||||
func (a *authorityMenu) Init() error {
|
||||
if global.GVA_DB.Migrator().HasTable("authority_menu") && global.GVA_DB.Find(&[]system.SysMenu{}).RowsAffected > 0 {
|
||||
color.Danger.Println("\n[Mysql] --> authority_menu 视图已存在!")
|
||||
return nil
|
||||
}
|
||||
if err := global.GVA_DB.Exec("CREATE ALGORITHM = UNDEFINED SQL SECURITY DEFINER VIEW `authority_menu` AS select `sys_base_menus`.`id` AS `id`,`sys_base_menus`.`created_at` AS `created_at`, `sys_base_menus`.`updated_at` AS `updated_at`, `sys_base_menus`.`deleted_at` AS `deleted_at`, `sys_base_menus`.`menu_level` AS `menu_level`,`sys_base_menus`.`parent_id` AS `parent_id`,`sys_base_menus`.`path` AS `path`,`sys_base_menus`.`name` AS `name`,`sys_base_menus`.`hidden` AS `hidden`,`sys_base_menus`.`component` AS `component`, `sys_base_menus`.`title` AS `title`,`sys_base_menus`.`icon` AS `icon`,`sys_base_menus`.`sort` AS `sort`,`sys_authority_menus`.`sys_authority_authority_id` AS `authority_id`,`sys_authority_menus`.`sys_base_menu_id` AS `menu_id`,`sys_base_menus`.`keep_alive` AS `keep_alive`,`sys_base_menus`.`close_tab` AS `close_tab`,`sys_base_menus`.`default_menu` AS `default_menu` from (`sys_authority_menus` join `sys_base_menus` on ((`sys_authority_menus`.`sys_base_menu_id` = `sys_base_menus`.`id`)))").Error; err != nil {
|
||||
return err
|
||||
}
|
||||
color.Info.Println("\n[Mysql] --> authority_menu 视图创建成功!")
|
||||
return nil
|
||||
}
|
@@ -1,190 +0,0 @@
|
||||
package source
|
||||
|
||||
import (
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/global"
|
||||
|
||||
gormadapter "github.com/casbin/gorm-adapter/v3"
|
||||
"github.com/gookit/color"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
var Casbin = new(casbin)
|
||||
|
||||
type casbin struct{}
|
||||
|
||||
var carbines = []gormadapter.CasbinRule{
|
||||
{PType: "p", V0: "888", V1: "/base/login", V2: "POST"},
|
||||
{PType: "p", V0: "888", V1: "/user/register", V2: "POST"},
|
||||
{PType: "p", V0: "888", V1: "/api/createApi", V2: "POST"},
|
||||
{PType: "p", V0: "888", V1: "/api/getApiList", V2: "POST"},
|
||||
{PType: "p", V0: "888", V1: "/api/getApiById", V2: "POST"},
|
||||
{PType: "p", V0: "888", V1: "/api/deleteApi", V2: "POST"},
|
||||
{PType: "p", V0: "888", V1: "/api/updateApi", V2: "POST"},
|
||||
{PType: "p", V0: "888", V1: "/api/getAllApis", V2: "POST"},
|
||||
{PType: "p", V0: "888", V1: "/authority/createAuthority", V2: "POST"},
|
||||
{PType: "p", V0: "888", V1: "/authority/deleteAuthority", V2: "POST"},
|
||||
{PType: "p", V0: "888", V1: "/authority/getAuthorityList", V2: "POST"},
|
||||
{PType: "p", V0: "888", V1: "/authority/setDataAuthority", V2: "POST"},
|
||||
{PType: "p", V0: "888", V1: "/authority/updateAuthority", V2: "PUT"},
|
||||
{PType: "p", V0: "888", V1: "/authority/copyAuthority", V2: "POST"},
|
||||
{PType: "p", V0: "888", V1: "/menu/getMenu", V2: "POST"},
|
||||
{PType: "p", V0: "888", V1: "/menu/getMenuList", V2: "POST"},
|
||||
{PType: "p", V0: "888", V1: "/menu/addBaseMenu", V2: "POST"},
|
||||
{PType: "p", V0: "888", V1: "/menu/getBaseMenuTree", V2: "POST"},
|
||||
{PType: "p", V0: "888", V1: "/menu/addMenuAuthority", V2: "POST"},
|
||||
{PType: "p", V0: "888", V1: "/menu/getMenuAuthority", V2: "POST"},
|
||||
{PType: "p", V0: "888", V1: "/menu/deleteBaseMenu", V2: "POST"},
|
||||
{PType: "p", V0: "888", V1: "/menu/updateBaseMenu", V2: "POST"},
|
||||
{PType: "p", V0: "888", V1: "/menu/getBaseMenuById", V2: "POST"},
|
||||
{PType: "p", V0: "888", V1: "/user/changePassword", V2: "POST"},
|
||||
{PType: "p", V0: "888", V1: "/user/getUserList", V2: "POST"},
|
||||
{PType: "p", V0: "888", V1: "/user/setUserAuthority", V2: "POST"},
|
||||
{PType: "p", V0: "888", V1: "/user/deleteUser", V2: "DELETE"},
|
||||
{PType: "p", V0: "888", V1: "/fileUploadAndDownload/upload", V2: "POST"},
|
||||
{PType: "p", V0: "888", V1: "/fileUploadAndDownload/getFileList", V2: "POST"},
|
||||
{PType: "p", V0: "888", V1: "/fileUploadAndDownload/deleteFile", V2: "POST"},
|
||||
{PType: "p", V0: "888", V1: "/casbin/updateCasbin", V2: "POST"},
|
||||
{PType: "p", V0: "888", V1: "/casbin/getPolicyPathByAuthorityId", V2: "POST"},
|
||||
{PType: "p", V0: "888", V1: "/casbin/casbinTest/:pathParam", V2: "GET"},
|
||||
{PType: "p", V0: "888", V1: "/jwt/jsonInBlacklist", V2: "POST"},
|
||||
{PType: "p", V0: "888", V1: "/system/getSystemConfig", V2: "POST"},
|
||||
{PType: "p", V0: "888", V1: "/system/setSystemConfig", V2: "POST"},
|
||||
{PType: "p", V0: "888", V1: "/system/getServerInfo", V2: "POST"},
|
||||
{PType: "p", V0: "888", V1: "/customer/customer", V2: "POST"},
|
||||
{PType: "p", V0: "888", V1: "/customer/customer", V2: "PUT"},
|
||||
{PType: "p", V0: "888", V1: "/customer/customer", V2: "DELETE"},
|
||||
{PType: "p", V0: "888", V1: "/customer/customer", V2: "GET"},
|
||||
{PType: "p", V0: "888", V1: "/customer/customerList", V2: "GET"},
|
||||
{PType: "p", V0: "888", V1: "/autoCode/createTemp", V2: "POST"},
|
||||
{PType: "p", V0: "888", V1: "/autoCode/preview", V2: "POST"},
|
||||
{PType: "p", V0: "888", V1: "/autoCode/getTables", V2: "GET"},
|
||||
{PType: "p", V0: "888", V1: "/autoCode/getDB", V2: "GET"},
|
||||
{PType: "p", V0: "888", V1: "/autoCode/getColumn", V2: "GET"},
|
||||
{PType: "p", V0: "888", V1: "/sysDictionaryDetail/createSysDictionaryDetail", V2: "POST"},
|
||||
{PType: "p", V0: "888", V1: "/sysDictionaryDetail/deleteSysDictionaryDetail", V2: "DELETE"},
|
||||
{PType: "p", V0: "888", V1: "/sysDictionaryDetail/updateSysDictionaryDetail", V2: "PUT"},
|
||||
{PType: "p", V0: "888", V1: "/sysDictionaryDetail/findSysDictionaryDetail", V2: "GET"},
|
||||
{PType: "p", V0: "888", V1: "/sysDictionaryDetail/getSysDictionaryDetailList", V2: "GET"},
|
||||
{PType: "p", V0: "888", V1: "/sysDictionary/createSysDictionary", V2: "POST"},
|
||||
{PType: "p", V0: "888", V1: "/sysDictionary/deleteSysDictionary", V2: "DELETE"},
|
||||
{PType: "p", V0: "888", V1: "/sysDictionary/updateSysDictionary", V2: "PUT"},
|
||||
{PType: "p", V0: "888", V1: "/sysDictionary/findSysDictionary", V2: "GET"},
|
||||
{PType: "p", V0: "888", V1: "/sysDictionary/getSysDictionaryList", V2: "GET"},
|
||||
{PType: "p", V0: "888", V1: "/sysOperationRecord/createSysOperationRecord", V2: "POST"},
|
||||
{PType: "p", V0: "888", V1: "/sysOperationRecord/deleteSysOperationRecord", V2: "DELETE"},
|
||||
{PType: "p", V0: "888", V1: "/sysOperationRecord/updateSysOperationRecord", V2: "PUT"},
|
||||
{PType: "p", V0: "888", V1: "/sysOperationRecord/findSysOperationRecord", V2: "GET"},
|
||||
{PType: "p", V0: "888", V1: "/sysOperationRecord/getSysOperationRecordList", V2: "GET"},
|
||||
{PType: "p", V0: "888", V1: "/sysOperationRecord/deleteSysOperationRecordByIds", V2: "DELETE"},
|
||||
{PType: "p", V0: "888", V1: "/user/setUserInfo", V2: "PUT"},
|
||||
{PType: "p", V0: "888", V1: "/email/emailTest", V2: "POST"},
|
||||
{PType: "p", V0: "888", V1: "/simpleUploader/upload", V2: "POST"},
|
||||
{PType: "p", V0: "888", V1: "/simpleUploader/checkFileMd5", V2: "GET"},
|
||||
{PType: "p", V0: "888", V1: "/simpleUploader/mergeFileMd5", V2: "GET"},
|
||||
{PType: "p", V0: "888", V1: "/excel/importExcel", V2: "POST"},
|
||||
{PType: "p", V0: "888", V1: "/excel/loadExcel", V2: "GET"},
|
||||
{PType: "p", V0: "888", V1: "/excel/exportExcel", V2: "POST"},
|
||||
{PType: "p", V0: "888", V1: "/excel/downloadTemplate", V2: "GET"},
|
||||
{PType: "p", V0: "888", V1: "/api/deleteApisByIds", V2: "DELETE"},
|
||||
{PType: "p", V0: "888", V1: "/autoCode/getSysHistory", V2: "POST"},
|
||||
{PType: "p", V0: "888", V1: "/autoCode/rollback", V2: "POST"},
|
||||
{PType: "p", V0: "888", V1: "/autoCode/getMeta", V2: "POST"},
|
||||
{PType: "p", V0: "888", V1: "/autoCode/delSysHistory", V2: "POST"},
|
||||
{PType: "p", V0: "888", V1: "/user/setUserAuthorities", V2: "POST"},
|
||||
{PType: "p", V0: "888", V1: "/user/getUserInfo", V2: "GET"},
|
||||
{PType: "p", V0: "888", V1: "/user/resetPassword", V2: "POST"},
|
||||
{PType: "p", V0: "8881", V1: "/base/login", V2: "POST"},
|
||||
{PType: "p", V0: "8881", V1: "/user/register", V2: "POST"},
|
||||
{PType: "p", V0: "8881", V1: "/api/createApi", V2: "POST"},
|
||||
{PType: "p", V0: "8881", V1: "/api/getApiList", V2: "POST"},
|
||||
{PType: "p", V0: "8881", V1: "/api/getApiById", V2: "POST"},
|
||||
{PType: "p", V0: "8881", V1: "/api/deleteApi", V2: "POST"},
|
||||
{PType: "p", V0: "8881", V1: "/api/updateApi", V2: "POST"},
|
||||
{PType: "p", V0: "8881", V1: "/api/getAllApis", V2: "POST"},
|
||||
{PType: "p", V0: "8881", V1: "/authority/createAuthority", V2: "POST"},
|
||||
{PType: "p", V0: "8881", V1: "/authority/deleteAuthority", V2: "POST"},
|
||||
{PType: "p", V0: "8881", V1: "/authority/getAuthorityList", V2: "POST"},
|
||||
{PType: "p", V0: "8881", V1: "/authority/setDataAuthority", V2: "POST"},
|
||||
{PType: "p", V0: "8881", V1: "/menu/getMenu", V2: "POST"},
|
||||
{PType: "p", V0: "8881", V1: "/menu/getMenuList", V2: "POST"},
|
||||
{PType: "p", V0: "8881", V1: "/menu/addBaseMenu", V2: "POST"},
|
||||
{PType: "p", V0: "8881", V1: "/menu/getBaseMenuTree", V2: "POST"},
|
||||
{PType: "p", V0: "8881", V1: "/menu/addMenuAuthority", V2: "POST"},
|
||||
{PType: "p", V0: "8881", V1: "/menu/getMenuAuthority", V2: "POST"},
|
||||
{PType: "p", V0: "8881", V1: "/menu/deleteBaseMenu", V2: "POST"},
|
||||
{PType: "p", V0: "8881", V1: "/menu/updateBaseMenu", V2: "POST"},
|
||||
{PType: "p", V0: "8881", V1: "/menu/getBaseMenuById", V2: "POST"},
|
||||
{PType: "p", V0: "8881", V1: "/user/changePassword", V2: "POST"},
|
||||
{PType: "p", V0: "8881", V1: "/user/getUserList", V2: "POST"},
|
||||
{PType: "p", V0: "8881", V1: "/user/setUserAuthority", V2: "POST"},
|
||||
{PType: "p", V0: "8881", V1: "/fileUploadAndDownload/upload", V2: "POST"},
|
||||
{PType: "p", V0: "8881", V1: "/fileUploadAndDownload/getFileList", V2: "POST"},
|
||||
{PType: "p", V0: "8881", V1: "/fileUploadAndDownload/deleteFile", V2: "POST"},
|
||||
{PType: "p", V0: "8881", V1: "/casbin/updateCasbin", V2: "POST"},
|
||||
{PType: "p", V0: "8881", V1: "/casbin/getPolicyPathByAuthorityId", V2: "POST"},
|
||||
{PType: "p", V0: "8881", V1: "/jwt/jsonInBlacklist", V2: "POST"},
|
||||
{PType: "p", V0: "8881", V1: "/system/getSystemConfig", V2: "POST"},
|
||||
{PType: "p", V0: "8881", V1: "/system/setSystemConfig", V2: "POST"},
|
||||
{PType: "p", V0: "8881", V1: "/customer/customer", V2: "POST"},
|
||||
{PType: "p", V0: "8881", V1: "/customer/customer", V2: "PUT"},
|
||||
{PType: "p", V0: "8881", V1: "/customer/customer", V2: "DELETE"},
|
||||
{PType: "p", V0: "8881", V1: "/customer/customer", V2: "GET"},
|
||||
{PType: "p", V0: "8881", V1: "/customer/customerList", V2: "GET"},
|
||||
{PType: "p", V0: "8881", V1: "/user/getUserInfo", V2: "GET"},
|
||||
{PType: "p", V0: "9528", V1: "/base/login", V2: "POST"},
|
||||
{PType: "p", V0: "9528", V1: "/user/register", V2: "POST"},
|
||||
{PType: "p", V0: "9528", V1: "/api/createApi", V2: "POST"},
|
||||
{PType: "p", V0: "9528", V1: "/api/getApiList", V2: "POST"},
|
||||
{PType: "p", V0: "9528", V1: "/api/getApiById", V2: "POST"},
|
||||
{PType: "p", V0: "9528", V1: "/api/deleteApi", V2: "POST"},
|
||||
{PType: "p", V0: "9528", V1: "/api/updateApi", V2: "POST"},
|
||||
{PType: "p", V0: "9528", V1: "/api/getAllApis", V2: "POST"},
|
||||
{PType: "p", V0: "9528", V1: "/authority/createAuthority", V2: "POST"},
|
||||
{PType: "p", V0: "9528", V1: "/authority/deleteAuthority", V2: "POST"},
|
||||
{PType: "p", V0: "9528", V1: "/authority/getAuthorityList", V2: "POST"},
|
||||
{PType: "p", V0: "9528", V1: "/authority/setDataAuthority", V2: "POST"},
|
||||
{PType: "p", V0: "9528", V1: "/menu/getMenu", V2: "POST"},
|
||||
{PType: "p", V0: "9528", V1: "/menu/getMenuList", V2: "POST"},
|
||||
{PType: "p", V0: "9528", V1: "/menu/addBaseMenu", V2: "POST"},
|
||||
{PType: "p", V0: "9528", V1: "/menu/getBaseMenuTree", V2: "POST"},
|
||||
{PType: "p", V0: "9528", V1: "/menu/addMenuAuthority", V2: "POST"},
|
||||
{PType: "p", V0: "9528", V1: "/menu/getMenuAuthority", V2: "POST"},
|
||||
{PType: "p", V0: "9528", V1: "/menu/deleteBaseMenu", V2: "POST"},
|
||||
{PType: "p", V0: "9528", V1: "/menu/updateBaseMenu", V2: "POST"},
|
||||
{PType: "p", V0: "9528", V1: "/menu/getBaseMenuById", V2: "POST"},
|
||||
{PType: "p", V0: "9528", V1: "/user/changePassword", V2: "POST"},
|
||||
{PType: "p", V0: "9528", V1: "/user/getUserList", V2: "POST"},
|
||||
{PType: "p", V0: "9528", V1: "/user/setUserAuthority", V2: "POST"},
|
||||
{PType: "p", V0: "9528", V1: "/fileUploadAndDownload/upload", V2: "POST"},
|
||||
{PType: "p", V0: "9528", V1: "/fileUploadAndDownload/getFileList", V2: "POST"},
|
||||
{PType: "p", V0: "9528", V1: "/fileUploadAndDownload/deleteFile", V2: "POST"},
|
||||
{PType: "p", V0: "9528", V1: "/casbin/updateCasbin", V2: "POST"},
|
||||
{PType: "p", V0: "9528", V1: "/casbin/getPolicyPathByAuthorityId", V2: "POST"},
|
||||
{PType: "p", V0: "9528", V1: "/jwt/jsonInBlacklist", V2: "POST"},
|
||||
{PType: "p", V0: "9528", V1: "/system/getSystemConfig", V2: "POST"},
|
||||
{PType: "p", V0: "9528", V1: "/system/setSystemConfig", V2: "POST"},
|
||||
{PType: "p", V0: "9528", V1: "/customer/customer", V2: "POST"},
|
||||
{PType: "p", V0: "9528", V1: "/customer/customer", V2: "PUT"},
|
||||
{PType: "p", V0: "9528", V1: "/customer/customer", V2: "DELETE"},
|
||||
{PType: "p", V0: "9528", V1: "/customer/customer", V2: "GET"},
|
||||
{PType: "p", V0: "9528", V1: "/customer/customerList", V2: "GET"},
|
||||
{PType: "p", V0: "9528", V1: "/autoCode/createTemp", V2: "POST"},
|
||||
{PType: "p", V0: "9528", V1: "/user/getUserInfo", V2: "GET"},
|
||||
}
|
||||
|
||||
//@author: [SliverHorn](https://github.com/SliverHorn)
|
||||
//@description: casbin_rule 表数据初始化
|
||||
func (c *casbin) Init() error {
|
||||
global.GVA_DB.AutoMigrate(gormadapter.CasbinRule{})
|
||||
return global.GVA_DB.Transaction(func(tx *gorm.DB) error {
|
||||
if tx.Find(&[]gormadapter.CasbinRule{}).RowsAffected == 154 {
|
||||
color.Danger.Println("\n[Mysql] --> casbin_rule 表的初始数据已存在!")
|
||||
return nil
|
||||
}
|
||||
if err := tx.Create(&carbines).Error; err != nil { // 遇到错误时回滚事务
|
||||
return err
|
||||
}
|
||||
color.Info.Println("\n[Mysql] --> casbin_rule 表初始数据成功!")
|
||||
return nil
|
||||
})
|
||||
}
|
@@ -1,41 +0,0 @@
|
||||
package source
|
||||
|
||||
import (
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/global"
|
||||
|
||||
"github.com/gookit/color"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
var DataAuthorities = new(dataAuthorities)
|
||||
|
||||
type dataAuthorities struct{}
|
||||
|
||||
type DataAuthority struct {
|
||||
AuthorityId string `gorm:"column:sys_authority_authority_id"`
|
||||
DataAuthority string `gorm:"column:data_authority_id_authority_id"`
|
||||
}
|
||||
|
||||
var infos = []DataAuthority{
|
||||
{"888", "888"},
|
||||
{"888", "8881"},
|
||||
{"888", "9528"},
|
||||
{"9528", "8881"},
|
||||
{"9528", "9528"},
|
||||
}
|
||||
|
||||
//@author: [SliverHorn](https://github.com/SliverHorn)
|
||||
//@description: sys_data_authority_id 表数据初始化
|
||||
func (d *dataAuthorities) Init() error {
|
||||
return global.GVA_DB.Table("sys_data_authority_id").Transaction(func(tx *gorm.DB) error {
|
||||
if tx.Where("sys_authority_authority_id IN ('888', '9528') ").Find(&[]DataAuthority{}).RowsAffected == 5 {
|
||||
color.Danger.Println("\n[Mysql] --> sys_data_authority_id 表初始数据已存在!")
|
||||
return nil
|
||||
}
|
||||
if err := tx.Create(&infos).Error; err != nil { // 遇到错误时回滚事务
|
||||
return err
|
||||
}
|
||||
color.Info.Println("\n[Mysql] --> sys_data_authority_id 表初始数据成功!")
|
||||
return nil
|
||||
})
|
||||
}
|
@@ -1,42 +0,0 @@
|
||||
package source
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/global"
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/model/system"
|
||||
"github.com/gookit/color"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
var Dictionary = new(dictionary)
|
||||
|
||||
type dictionary struct{}
|
||||
|
||||
var status = new(bool)
|
||||
|
||||
//@author: [SliverHorn](https://github.com/SliverHorn)
|
||||
//@description: sys_dictionaries 表数据初始化
|
||||
func (d *dictionary) Init() error {
|
||||
*status = true
|
||||
var dictionaries = []system.SysDictionary{
|
||||
{GVA_MODEL: global.GVA_MODEL{ID: 1, CreatedAt: time.Now(), UpdatedAt: time.Now()}, Name: "性别", Type: "sex", Status: status, Desc: "性别字典"},
|
||||
{GVA_MODEL: global.GVA_MODEL{ID: 2, CreatedAt: time.Now(), UpdatedAt: time.Now()}, Name: "数据库int类型", Type: "int", Status: status, Desc: "int类型对应的数据库类型"},
|
||||
{GVA_MODEL: global.GVA_MODEL{ID: 3, CreatedAt: time.Now(), UpdatedAt: time.Now()}, Name: "数据库时间日期类型", Type: "time.Time", Status: status, Desc: "数据库时间日期类型"},
|
||||
{GVA_MODEL: global.GVA_MODEL{ID: 4, CreatedAt: time.Now(), UpdatedAt: time.Now()}, Name: "数据库浮点型", Type: "float64", Status: status, Desc: "数据库浮点型"},
|
||||
{GVA_MODEL: global.GVA_MODEL{ID: 5, CreatedAt: time.Now(), UpdatedAt: time.Now()}, Name: "数据库字符串", Type: "string", Status: status, Desc: "数据库字符串"},
|
||||
{GVA_MODEL: global.GVA_MODEL{ID: 6, CreatedAt: time.Now(), UpdatedAt: time.Now()}, Name: "数据库bool类型", Type: "bool", Status: status, Desc: "数据库bool类型"},
|
||||
}
|
||||
return global.GVA_DB.Transaction(func(tx *gorm.DB) error {
|
||||
if tx.Where("id IN ?", []int{1, 6}).Find(&[]system.SysDictionary{}).RowsAffected == 2 {
|
||||
color.Danger.Println("\n[Mysql] --> sys_dictionaries 表初始数据已存在!")
|
||||
return nil
|
||||
}
|
||||
if err := tx.Create(&dictionaries).Error; err != nil { // 遇到错误时回滚事务
|
||||
return err
|
||||
}
|
||||
color.Info.Println("\n[Mysql] --> sys_dictionaries 表初始数据成功!")
|
||||
return nil
|
||||
})
|
||||
}
|
@@ -1,58 +0,0 @@
|
||||
package source
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/global"
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/model/system"
|
||||
"github.com/gookit/color"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
var DictionaryDetail = new(dictionaryDetail)
|
||||
|
||||
type dictionaryDetail struct{}
|
||||
|
||||
//@author: [SliverHorn](https://github.com/SliverHorn)
|
||||
//@description: dictionary_details 表数据初始化
|
||||
func (d *dictionaryDetail) Init() error {
|
||||
var details = []system.SysDictionaryDetail{
|
||||
{global.GVA_MODEL{ID: 1, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "smallint", 1, status, 1, 2},
|
||||
{global.GVA_MODEL{ID: 2, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "mediumint", 2, status, 2, 2},
|
||||
{global.GVA_MODEL{ID: 3, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "int", 3, status, 3, 2},
|
||||
{global.GVA_MODEL{ID: 4, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "bigint", 4, status, 4, 2},
|
||||
{global.GVA_MODEL{ID: 5, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "date", 0, status, 0, 3},
|
||||
{global.GVA_MODEL{ID: 6, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "time", 1, status, 1, 3},
|
||||
{global.GVA_MODEL{ID: 7, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "year", 2, status, 2, 3},
|
||||
{global.GVA_MODEL{ID: 8, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "datetime", 3, status, 3, 3},
|
||||
{global.GVA_MODEL{ID: 9, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "timestamp", 5, status, 5, 3},
|
||||
{global.GVA_MODEL{ID: 10, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "float", 0, status, 0, 4},
|
||||
{global.GVA_MODEL{ID: 11, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "double", 1, status, 1, 4},
|
||||
{global.GVA_MODEL{ID: 12, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "decimal", 2, status, 2, 4},
|
||||
{global.GVA_MODEL{ID: 13, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "char", 0, status, 0, 5},
|
||||
{global.GVA_MODEL{ID: 14, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "varchar", 1, status, 1, 5},
|
||||
{global.GVA_MODEL{ID: 15, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "tinyblob", 2, status, 2, 5},
|
||||
{global.GVA_MODEL{ID: 16, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "tinytext", 3, status, 3, 5},
|
||||
{global.GVA_MODEL{ID: 17, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "text", 4, status, 4, 5},
|
||||
{global.GVA_MODEL{ID: 18, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "blob", 5, status, 5, 5},
|
||||
{global.GVA_MODEL{ID: 19, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "mediumblob", 6, status, 6, 5},
|
||||
{global.GVA_MODEL{ID: 20, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "mediumtext", 7, status, 7, 5},
|
||||
{global.GVA_MODEL{ID: 21, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "longblob", 8, status, 8, 5},
|
||||
{global.GVA_MODEL{ID: 22, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "longtext", 9, status, 9, 5},
|
||||
{global.GVA_MODEL{ID: 23, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "tinyint", 0, status, 0, 6},
|
||||
{global.GVA_MODEL{ID: 24, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "男", 0, status, 0, 1},
|
||||
{global.GVA_MODEL{ID: 25, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "女", 1, status, 1, 1},
|
||||
}
|
||||
return global.GVA_DB.Transaction(func(tx *gorm.DB) error {
|
||||
if tx.Where("id IN ?", []int{1, 23}).Find(&[]system.SysDictionaryDetail{}).RowsAffected == 2 {
|
||||
color.Danger.Println("\n[Mysql] --> sys_dictionary_details 表的初始数据已存在!")
|
||||
return nil
|
||||
}
|
||||
if err := tx.Create(&details).Error; err != nil { // 遇到错误时回滚事务
|
||||
return err
|
||||
}
|
||||
color.Info.Println("\n[Mysql] --> sys_dictionary_details 表初始数据成功!")
|
||||
return nil
|
||||
})
|
||||
}
|
@@ -7,7 +7,7 @@ import (
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
var FilePgsql = new(fileMysql)
|
||||
var FilePgsql = new(filePgsql)
|
||||
|
||||
type filePgsql struct{}
|
||||
|
||||
|
@@ -1,35 +0,0 @@
|
||||
package source
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/global"
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/model/example"
|
||||
"github.com/gookit/color"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
var File = new(file)
|
||||
|
||||
type file struct{}
|
||||
|
||||
var files = []example.ExaFileUploadAndDownload{
|
||||
{global.GVA_MODEL{ID: 1, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "10.png", "https://qmplusimg.henrongyi.top/gvalogo.png", "png", "158787308910.png"},
|
||||
{global.GVA_MODEL{ID: 2, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "logo.png", "https://qmplusimg.henrongyi.top/1576554439myAvatar.png", "png", "1587973709logo.png"},
|
||||
}
|
||||
|
||||
//@author: [SliverHorn](https://github.com/SliverHorn)
|
||||
//@description: exa_file_upload_and_downloads 表初始化数据
|
||||
func (f *file) Init() error {
|
||||
return global.GVA_DB.Transaction(func(tx *gorm.DB) error {
|
||||
if tx.Where("id IN ?", []int{1, 2}).Find(&[]example.ExaFileUploadAndDownload{}).RowsAffected == 2 {
|
||||
color.Danger.Println("\n[Mysql] --> exa_file_upload_and_downloads 表初始数据已存在!")
|
||||
return nil
|
||||
}
|
||||
if err := tx.Create(&files).Error; err != nil { // 遇到错误时回滚事务
|
||||
return err
|
||||
}
|
||||
color.Info.Println("\n[Mysql] --> exa_file_upload_and_downloads 表初始数据成功!")
|
||||
return nil
|
||||
})
|
||||
}
|
@@ -1,58 +0,0 @@
|
||||
package source
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/global"
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/model/system"
|
||||
"github.com/gookit/color"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
var BaseMenu = new(menu)
|
||||
|
||||
type menu struct{}
|
||||
|
||||
var menus = []system.SysBaseMenu{
|
||||
{GVA_MODEL: global.GVA_MODEL{ID: 1, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, ParentId: "0", Path: "dashboard", Name: "dashboard", Hidden: false, Component: "view/dashboard/index.vue", Sort: 1, Meta: system.Meta{Title: "仪表盘", Icon: "setting"}},
|
||||
{GVA_MODEL: global.GVA_MODEL{ID: 2, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, Hidden: false, ParentId: "0", Path: "about", Name: "about", Component: "view/about/index.vue", Sort: 7, Meta: system.Meta{Title: "关于我们", Icon: "info"}},
|
||||
{GVA_MODEL: global.GVA_MODEL{ID: 3, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, Hidden: false, ParentId: "0", Path: "admin", Name: "superAdmin", Component: "view/superAdmin/index.vue", Sort: 3, Meta: system.Meta{Title: "超级管理员", Icon: "user-solid"}},
|
||||
{GVA_MODEL: global.GVA_MODEL{ID: 4, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, Hidden: false, ParentId: "3", Path: "authority", Name: "authority", Component: "view/superAdmin/authority/authority.vue", Sort: 1, Meta: system.Meta{Title: "角色管理", Icon: "s-custom"}},
|
||||
{GVA_MODEL: global.GVA_MODEL{ID: 5, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, Hidden: false, ParentId: "3", Path: "menu", Name: "menu", Component: "view/superAdmin/menu/menu.vue", Sort: 2, Meta: system.Meta{Title: "菜单管理", Icon: "s-order", KeepAlive: true}},
|
||||
{GVA_MODEL: global.GVA_MODEL{ID: 6, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, Hidden: false, ParentId: "3", Path: "api", Name: "api", Component: "view/superAdmin/api/api.vue", Sort: 3, Meta: system.Meta{Title: "API管理", Icon: "s-platform", KeepAlive: true}},
|
||||
{GVA_MODEL: global.GVA_MODEL{ID: 7, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, Hidden: false, ParentId: "3", Path: "user", Name: "user", Component: "view/superAdmin/user/user.vue", Sort: 4, Meta: system.Meta{Title: "用户管理", Icon: "coordinate"}},
|
||||
{GVA_MODEL: global.GVA_MODEL{ID: 8, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, Hidden: true, ParentId: "0", Path: "person", Name: "person", Component: "view/person/person.vue", Sort: 4, Meta: system.Meta{Title: "个人信息", Icon: "message-solid"}},
|
||||
{GVA_MODEL: global.GVA_MODEL{ID: 9, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, Hidden: false, ParentId: "0", Path: "example", Name: "example", Component: "view/example/index.vue", Sort: 6, Meta: system.Meta{Title: "示例文件", Icon: "s-management"}},
|
||||
{GVA_MODEL: global.GVA_MODEL{ID: 10, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, Hidden: false, ParentId: "9", Path: "excel", Name: "excel", Component: "view/example/excel/excel.vue", Sort: 4, Meta: system.Meta{Title: "excel导入导出", Icon: "s-marketing"}},
|
||||
{GVA_MODEL: global.GVA_MODEL{ID: 11, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, Hidden: false, ParentId: "9", Path: "upload", Name: "upload", Component: "view/example/upload/upload.vue", Sort: 5, Meta: system.Meta{Title: "媒体库(上传下载)", Icon: "upload"}},
|
||||
{GVA_MODEL: global.GVA_MODEL{ID: 12, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, Hidden: false, ParentId: "9", Path: "breakpoint", Name: "breakpoint", Component: "view/example/breakpoint/breakpoint.vue", Sort: 6, Meta: system.Meta{Title: "断点续传", Icon: "upload"}},
|
||||
{GVA_MODEL: global.GVA_MODEL{ID: 13, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, Hidden: false, ParentId: "9", Path: "customer", Name: "customer", Component: "view/example/customer/customer.vue", Sort: 7, Meta: system.Meta{Title: "客户列表(资源示例)", Icon: "s-custom"}},
|
||||
{GVA_MODEL: global.GVA_MODEL{ID: 14, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, Hidden: false, ParentId: "0", Path: "systemTools", Name: "systemTools", Component: "view/systemTools/index.vue", Sort: 5, Meta: system.Meta{Title: "系统工具", Icon: "s-cooperation"}},
|
||||
{GVA_MODEL: global.GVA_MODEL{ID: 15, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, Hidden: false, ParentId: "14", Path: "autoCode", Name: "autoCode", Component: "view/systemTools/autoCode/index.vue", Sort: 1, Meta: system.Meta{Title: "代码生成器", Icon: "cpu", KeepAlive: true}},
|
||||
{GVA_MODEL: global.GVA_MODEL{ID: 16, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, Hidden: false, ParentId: "14", Path: "formCreate", Name: "formCreate", Component: "view/systemTools/formCreate/index.vue", Sort: 2, Meta: system.Meta{Title: "表单生成器", Icon: "magic-stick", KeepAlive: true}},
|
||||
{GVA_MODEL: global.GVA_MODEL{ID: 17, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, Hidden: false, ParentId: "14", Path: "system", Name: "system", Component: "view/systemTools/system/system.vue", Sort: 3, Meta: system.Meta{Title: "系统配置", Icon: "s-operation"}},
|
||||
{GVA_MODEL: global.GVA_MODEL{ID: 18, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, Hidden: false, ParentId: "3", Path: "dictionary", Name: "dictionary", Component: "view/superAdmin/dictionary/sysDictionary.vue", Sort: 5, Meta: system.Meta{Title: "字典管理", Icon: "notebook-2"}},
|
||||
{GVA_MODEL: global.GVA_MODEL{ID: 19, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, Hidden: true, ParentId: "3", Path: "dictionaryDetail/:id", Name: "dictionaryDetail", Component: "view/superAdmin/dictionary/sysDictionaryDetail.vue", Sort: 1, Meta: system.Meta{Title: "字典详情", Icon: "s-order"}},
|
||||
{GVA_MODEL: global.GVA_MODEL{ID: 20, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, Hidden: false, ParentId: "3", Path: "operation", Name: "operation", Component: "view/superAdmin/operation/sysOperationRecord.vue", Sort: 6, Meta: system.Meta{Title: "操作历史", Icon: "time"}},
|
||||
{GVA_MODEL: global.GVA_MODEL{ID: 22, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, ParentId: "0", Path: "https://www.gin-vue-admin.com", Name: "https://www.gin-vue-admin.com", Hidden: false, Component: "/", Sort: 0, Meta: system.Meta{Title: "官方网站", Icon: "s-home"}},
|
||||
{GVA_MODEL: global.GVA_MODEL{ID: 23, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, ParentId: "0", Path: "state", Name: "state", Hidden: false, Component: "view/system/state.vue", Sort: 6, Meta: system.Meta{Title: "服务器状态", Icon: "cloudy"}},
|
||||
{GVA_MODEL: global.GVA_MODEL{ID: 24, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, ParentId: "14", Path: "autoCodeAdmin", Name: "autoCodeAdmin", Hidden: false, Component: "view/systemTools/autoCodeAdmin/index.vue", Sort: 1, Meta: system.Meta{Title: "自动化代码管理", Icon: "s-finance"}},
|
||||
{GVA_MODEL: global.GVA_MODEL{ID: 25, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, ParentId: "14", Path: "autoCodeEdit/:id", Name: "autoCodeEdit", Hidden: true, Component: "view/systemTools/autoCode/index.vue", Sort: 0, Meta: system.Meta{Title: "自动化代码(复用)", Icon: "s-finance"}},
|
||||
}
|
||||
|
||||
//@author: [SliverHorn](https://github.com/SliverHorn)
|
||||
//@description: sys_base_menus 表数据初始化
|
||||
func (m *menu) Init() error {
|
||||
return global.GVA_DB.Transaction(func(tx *gorm.DB) error {
|
||||
if tx.Where("id IN ?", []int{1, 29}).Find(&[]system.SysBaseMenu{}).RowsAffected == 2 {
|
||||
color.Danger.Println("\n[Mysql] --> sys_base_menus 表的初始数据已存在!")
|
||||
return nil
|
||||
}
|
||||
if err := tx.Create(&menus).Error; err != nil { // 遇到错误时回滚事务
|
||||
return err
|
||||
}
|
||||
color.Info.Println("\n[Mysql] --> sys_base_menus 表初始数据成功!")
|
||||
return nil
|
||||
})
|
||||
}
|
@@ -1,34 +0,0 @@
|
||||
package source
|
||||
|
||||
import (
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/global"
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/model/system"
|
||||
"github.com/gookit/color"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
var UserAuthority = new(userAuthority)
|
||||
|
||||
type userAuthority struct{}
|
||||
|
||||
var userAuthorityModel = []system.SysUseAuthority{
|
||||
{1, "888"},
|
||||
{1, "8881"},
|
||||
{1, "9528"},
|
||||
{2, "888"},
|
||||
}
|
||||
|
||||
//@description: user_authority 数据初始化
|
||||
func (a *userAuthority) Init() error {
|
||||
return global.GVA_DB.Model(&system.SysUseAuthority{}).Transaction(func(tx *gorm.DB) error {
|
||||
if tx.Where("sys_user_id IN (1, 2)").Find(&[]system.SysUseAuthority{}).RowsAffected == 4 {
|
||||
color.Danger.Println("\n[Mysql] --> sys_user_authority 表的初始数据已存在!")
|
||||
return nil
|
||||
}
|
||||
if err := tx.Create(&userAuthorityModel).Error; err != nil { // 遇到错误时回滚事务
|
||||
return err
|
||||
}
|
||||
color.Info.Println("\n[Mysql] --> sys_user_authority 表初始数据成功!")
|
||||
return nil
|
||||
})
|
||||
}
|
Reference in New Issue
Block a user