Sfoglia il codice sorgente

Migrate the gva project to the cmd folder, delete other redundant database configurations, optimize the initialization method of viper, zap, and gorm

SliverHorn 4 anni fa
parent
commit
c2145dd5c9

+ 7 - 0
server/cmd/datas/AuthorityMenu.go

@@ -0,0 +1,7 @@
+package datas
+
+import "gorm.io/gorm"
+
+func InitAuthorityMenu(db *gorm.DB) (err error) {
+	return 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`.`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
+}

+ 86 - 0
server/cmd/datas/apis.go

@@ -0,0 +1,86 @@
+package datas
+
+import (
+	"gin-vue-admin/model"
+	"time"
+
+	"gorm.io/gorm"
+)
+
+var Apis = []model.SysApi{
+	{gorm.Model{ID: 1, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/base/login", "用户登录", "base", "POST"},
+	{gorm.Model{ID: 2, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/base/register", "用户注册", "base", "POST"},
+	{gorm.Model{ID: 3, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/api/createApi", "创建api", "api", "POST"},
+	{gorm.Model{ID: 4, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/api/getApiList", "获取api列表", "api", "POST"},
+	{gorm.Model{ID: 5, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/api/getApiById", "获取api详细信息", "api", "POST"},
+	{gorm.Model{ID: 6, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/api/deleteApi", "删除Api", "api", "POST"},
+	{gorm.Model{ID: 7, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/api/updateApi", "更新Api", "api", "POST"},
+	{gorm.Model{ID: 8, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/api/getAllApis", "获取所有api", "api", "POST"},
+	{gorm.Model{ID: 9, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/authority/createAuthority", "创建角色", "authority", "POST"},
+	{gorm.Model{ID: 10, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/authority/deleteAuthority", "删除角色", "authority", "POST"},
+	{gorm.Model{ID: 11, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/authority/getAuthorityList", "获取角色列表", "authority", "POST"},
+	{gorm.Model{ID: 12, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/menu/getMenu", "获取菜单树", "menu", "POST"},
+	{gorm.Model{ID: 13, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/menu/getMenuList", "分页获取基础menu列表", "menu", "POST"},
+	{gorm.Model{ID: 14, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/menu/addBaseMenu", "新增菜单", "menu", "POST"},
+	{gorm.Model{ID: 15, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/menu/getBaseMenuTree", "获取用户动态路由", "menu", "POST"},
+	{gorm.Model{ID: 16, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/menu/addMenuAuthority", "增加menu和角色关联关系", "menu", "POST"},
+	{gorm.Model{ID: 17, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/menu/getMenuAuthority", "获取指定角色menu", "menu", "POST"},
+	{gorm.Model{ID: 18, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/menu/deleteBaseMenu", "删除菜单", "menu", "POST"},
+	{gorm.Model{ID: 19, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/menu/updateBaseMenu", "更新菜单", "menu", "POST"},
+	{gorm.Model{ID: 20, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/menu/getBaseMenuById", "根据id获取菜单", "menu", "POST"},
+	{gorm.Model{ID: 21, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/user/changePassword", "修改密码", "user", "POST"},
+	{gorm.Model{ID: 23, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/user/getUserList", "获取用户列表", "user", "POST"},
+	{gorm.Model{ID: 24, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/user/setUserAuthority", "修改用户角色", "user", "POST"},
+	{gorm.Model{ID: 25, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/fileUploadAndDownload/upload", "文件上传示例", "fileUploadAndDownload", "POST"},
+	{gorm.Model{ID: 26, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/fileUploadAndDownload/getFileList", "获取上传文件列表", "fileUploadAndDownload", "POST"},
+	{gorm.Model{ID: 27, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/casbin/updateCasbin", "更改角色api权限", "casbin", "POST"},
+	{gorm.Model{ID: 28, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/casbin/getPolicyPathByAuthorityId", "获取权限列表", "casbin", "POST"},
+	{gorm.Model{ID: 29, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/fileUploadAndDownload/deleteFile", "删除文件", "fileUploadAndDownload", "POST"},
+	{gorm.Model{ID: 30, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/jwt/jsonInBlacklist", "jwt加入黑名单", "jwt", "POST"},
+	{gorm.Model{ID: 31, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/authority/setDataAuthority", "设置角色资源权限", "authority", "POST"},
+	{gorm.Model{ID: 32, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/system/getSystemConfig", "获取配置文件内容", "system", "POST"},
+	{gorm.Model{ID: 33, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/system/setSystemConfig", "设置配置文件内容", "system", "POST"},
+	{gorm.Model{ID: 34, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/customer/customer", "创建客户", "customer", "POST"},
+	{gorm.Model{ID: 35, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/customer/customer", "更新客户", "customer", "PUT"},
+	{gorm.Model{ID: 36, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/customer/customer", "删除客户", "customer", "DELETE"},
+	{gorm.Model{ID: 37, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/customer/customer", "获取单一客户", "customer", "GET"},
+	{gorm.Model{ID: 38, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/customer/customerList", "获取客户列表", "customer", "GET"},
+	{gorm.Model{ID: 39, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/casbin/casbinTest/:pathParam", "RESTFUL模式测试", "casbin", "GET"},
+	{gorm.Model{ID: 40, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/autoCode/createTemp", "自动化代码", "autoCode", "POST"},
+	{gorm.Model{ID: 41, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/authority/updateAuthority", "更新角色信息", "authority", "PUT"},
+	{gorm.Model{ID: 42, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/authority/copyAuthority", "拷贝角色", "authority", "POST"},
+	{gorm.Model{ID: 43, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/user/deleteUser", "删除用户", "user", "DELETE"},
+	{gorm.Model{ID: 44, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysDictionaryDetail/createSysDictionaryDetail", "新增字典内容", "sysDictionaryDetail", "POST"},
+	{gorm.Model{ID: 45, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysDictionaryDetail/deleteSysDictionaryDetail", "删除字典内容", "sysDictionaryDetail", "DELETE"},
+	{gorm.Model{ID: 46, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysDictionaryDetail/updateSysDictionaryDetail", "更新字典内容", "sysDictionaryDetail", "PUT"},
+	{gorm.Model{ID: 47, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysDictionaryDetail/findSysDictionaryDetail", "根据ID获取字典内容", "sysDictionaryDetail", "GET"},
+	{gorm.Model{ID: 48, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysDictionaryDetail/getSysDictionaryDetailList", "获取字典内容列表", "sysDictionaryDetail", "GET"},
+	{gorm.Model{ID: 49, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysDictionary/createSysDictionary", "新增字典", "sysDictionary", "POST"},
+	{gorm.Model{ID: 50, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysDictionary/deleteSysDictionary", "删除字典", "sysDictionary", "DELETE"},
+	{gorm.Model{ID: 51, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysDictionary/updateSysDictionary", "更新字典", "sysDictionary", "PUT"},
+	{gorm.Model{ID: 52, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysDictionary/findSysDictionary", "根据ID获取字典", "sysDictionary", "GET"},
+	{gorm.Model{ID: 53, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysDictionary/getSysDictionaryList", "获取字典列表", "sysDictionary", "GET"},
+	{gorm.Model{ID: 54, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysOperationRecord/createSysOperationRecord", "新增操作记录", "sysOperationRecord", "POST"},
+	{gorm.Model{ID: 55, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysOperationRecord/deleteSysOperationRecord", "删除操作记录", "sysOperationRecord", "DELETE"},
+	{gorm.Model{ID: 56, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysOperationRecord/findSysOperationRecord", "根据ID获取操作记录", "sysOperationRecord", "GET"},
+	{gorm.Model{ID: 57, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysOperationRecord/getSysOperationRecordList", "获取操作记录列表", "sysOperationRecord", "GET"},
+	{gorm.Model{ID: 58, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/autoCode/getTables", "获取数据库表", "autoCode", "GET"},
+	{gorm.Model{ID: 59, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/autoCode/getDB", "获取所有数据库", "autoCode", "GET"},
+	{gorm.Model{ID: 60, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/autoCode/getColume", "获取所选table的所有字段", "autoCode", "GET"},
+	{gorm.Model{ID: 61, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysOperationRecord/deleteSysOperationRecordByIds", "批量删除操作历史", "sysOperationRecord", "DELETE"},
+	{gorm.Model{ID: 62, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/simpleUploader/upload", "插件版分片上传", "simpleUploader", "POST"},
+	{gorm.Model{ID: 63, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/simpleUploader/checkFileMd5", "文件完整度验证", "simpleUploader", "GET"},
+	{gorm.Model{ID: 64, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/simpleUploader/mergeFileMd5", "上传完成合并文件", "simpleUploader", "GET"},
+	{gorm.Model{ID: 65, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/user/setUserInfo", "设置用户信息", "user", "PUT"},
+	{gorm.Model{ID: 66, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/system/getServerInfo", "获取服务器信息", "system", "POST"},
+	{gorm.Model{ID: 67, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/email/emailTest", "发送测试邮件", "email", "POST"},
+}
+
+func InitSysApi(db *gorm.DB) (err error) {
+	return db.Transaction(func(tx *gorm.DB) error {
+		if tx.Create(&Apis).Error != nil { // 遇到错误时回滚事务
+			return err
+		}
+		return nil
+	})
+}

+ 23 - 0
server/cmd/datas/authorities.go

@@ -0,0 +1,23 @@
+package datas
+
+import (
+	"time"
+
+	"gin-vue-admin/model"
+	"gorm.io/gorm"
+)
+
+var Authorities = []model.SysAuthority{
+	{CreatedAt: time.Now(), UpdatedAt: time.Now(), AuthorityId: "888", AuthorityName: "普通用户", ParentId: "0"},
+	{CreatedAt: time.Now(), UpdatedAt: time.Now(), AuthorityId: "8881", AuthorityName: "普通用户子角色", ParentId: "888"},
+	{CreatedAt: time.Now(), UpdatedAt: time.Now(), AuthorityId: "9528", AuthorityName: "测试角色", ParentId: "0"},
+}
+
+func InitSysAuthority(db *gorm.DB) (err error) {
+	return db.Transaction(func(tx *gorm.DB) error {
+		if tx.Create(&Authorities).Error != nil { // 遇到错误时回滚事务
+			return err
+		}
+		return nil
+	})
+}

+ 27 - 0
server/cmd/datas/authority_Ids.go

@@ -0,0 +1,27 @@
+package datas
+
+import (
+	"gorm.io/gorm"
+)
+
+type SysDataAuthorityId struct {
+	SysAuthorityAuthorityId    string
+	DataAuthorityIdAuthorityId string
+}
+
+var DataAuthorityId = []SysDataAuthorityId{
+	{"888", "888"},
+	{"888", "8881"},
+	{"888", "9528"},
+	{"9528", "8881"},
+	{"9528", "9528"},
+}
+
+func InitSysDataAuthorityId(db *gorm.DB) (err error) {
+	return db.Transaction(func(tx *gorm.DB) error {
+		if tx.Create(&DataAuthorityId).Error != nil { // 遇到错误时回滚事务
+			return err
+		}
+		return nil
+	})
+}

+ 75 - 0
server/cmd/datas/authority_menus.go

@@ -0,0 +1,75 @@
+package datas
+
+import (
+	"gorm.io/gorm"
+)
+
+type SysAuthorityMenus struct {
+	SysAuthorityAuthorityId string
+	SysBaseMenuId           uint
+}
+
+var AuthorityMenus = []SysAuthorityMenus{
+	{"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", 21},
+	{"888", 22},
+	{"888", 23},
+	{"888", 24},
+	{"888", 25},
+	{"888", 26},
+	{"888", 27},
+	{"8881", 1},
+	{"8881", 2},
+	{"8881", 8},
+	{"8881", 17},
+	{"8881", 18},
+	{"8881", 19},
+	{"8881", 20},
+	{"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", 13},
+	{"9528", 14},
+	{"9528", 15},
+	{"9528", 17},
+	{"9528", 18},
+	{"9528", 19},
+	{"9528", 20},
+}
+
+func InitSysAuthorityMenus(db *gorm.DB) (err error) {
+	return db.Transaction(func(tx *gorm.DB) error {
+		if tx.Create(&AuthorityMenus).Error != nil { // 遇到错误时回滚事务
+			return err
+		}
+		return nil
+	})
+}

+ 161 - 0
server/cmd/datas/casbins.go

@@ -0,0 +1,161 @@
+package datas
+
+import (
+	gormadapter "github.com/casbin/gorm-adapter/v3"
+	"gorm.io/gorm"
+)
+
+var Carbines = []gormadapter.CasbinRule{
+	{PType: "p", V0: "888", V1: "/base/login", V2: "POST"},
+	{PType: "p", V0: "888", V1: "/base/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: "/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/getTables", V2: "GET"},
+	{PType: "p", V0: "888", V1: "/autoCode/getDB", V2: "GET"},
+	{PType: "p", V0: "888", V1: "/autoCode/getColume", 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: "8881", V1: "/base/login", V2: "POST"},
+	{PType: "p", V0: "8881", V1: "/base/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: "9528", V1: "/base/login", V2: "POST"},
+	{PType: "p", V0: "9528", V1: "/base/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"},
+}
+
+func InitCasbinModel(db *gorm.DB) (err error) {
+	return db.Transaction(func(tx *gorm.DB) error {
+		if !tx.Migrator().HasTable("casbin_rule") {
+			if err := tx.Migrator().CreateTable(&gormadapter.CasbinRule{}); err != nil {
+				return err
+			}
+		}
+		if tx.Create(&Carbines).Error != nil { // 遇到错误时回滚事务
+			return err
+		}
+		return nil
+	})
+}

+ 21 - 0
server/cmd/datas/customers.go

@@ -0,0 +1,21 @@
+package datas
+
+import (
+	"time"
+
+	"gin-vue-admin/model"
+	"gorm.io/gorm"
+)
+
+var Customers = []model.ExaCustomer{
+	{Model: gorm.Model{ID: 1, CreatedAt: time.Now(), UpdatedAt: time.Now()}, CustomerName: "测试客户", CustomerPhoneData: "1761111111", SysUserID: 1, SysUserAuthorityID: "888"},
+}
+
+func InitExaCustomer(db *gorm.DB) (err error) {
+	return db.Transaction(func(tx *gorm.DB) error {
+		if tx.Create(&Customers).Error != nil { // 遇到错误时回滚事务
+			return err
+		}
+		return nil
+	})
+}

+ 54 - 0
server/cmd/datas/dictionaries.go

@@ -0,0 +1,54 @@
+package datas
+
+import (
+	"time"
+
+	"gin-vue-admin/model"
+	"gorm.io/gorm"
+)
+
+type SysDictionaryToPostgresql struct {
+	gorm.Model
+	Name                 string                `json:"name" form:"name" gorm:"column:name;comment:字典名(中)"`
+	Type                 string                `json:"type" form:"type" gorm:"column:type;comment:字典名(英)"`
+	Status               *bool                 `json:"status" form:"status" gorm:"column:status;comment:状态"`
+	Description          string                `json:"description" form:"description" gorm:"column:description;comment:'描述'"`
+	SysDictionaryDetails []model.SysDictionaryDetail `json:"sysDictionaryDetails" form:"sysDictionaryDetails"`
+}
+
+func InitSysDictionary(db *gorm.DB) (err error) {
+	var status = new(bool)
+	*status = true
+	Dictionaries := []model.SysDictionary{
+		{Model: gorm.Model{ID: 1, CreatedAt: time.Now(), UpdatedAt: time.Now()}, Name: "性别", Type: "sex", Status: status, Desc: "性别字典"},
+		{Model: gorm.Model{ID: 2, CreatedAt: time.Now(), UpdatedAt: time.Now()}, Name: "数据库int类型", Type: "int", Status: status, Desc: "int类型对应的数据库类型"},
+		{Model: gorm.Model{ID: 3, CreatedAt: time.Now(), UpdatedAt: time.Now()}, Name: "数据库时间日期类型", Type: "time.Time", Status: status, Desc: "数据库时间日期类型"},
+		{Model: gorm.Model{ID: 4, CreatedAt: time.Now(), UpdatedAt: time.Now()}, Name: "数据库浮点型", Type: "float64", Status: status, Desc: "数据库浮点型"},
+		{Model: gorm.Model{ID: 5, CreatedAt: time.Now(), UpdatedAt: time.Now()}, Name: "数据库字符串", Type: "string", Status: status, Desc: "数据库字符串"},
+		{Model: gorm.Model{ID: 6, CreatedAt: time.Now(), UpdatedAt: time.Now()}, Name: "数据库bool类型", Type: "bool", Status: status, Desc: "数据库bool类型"},
+	}
+	return db.Transaction(func(tx *gorm.DB) error {
+		if tx.Create(&Dictionaries).Error != nil { // 遇到错误时回滚事务
+			return err
+		}
+		return nil
+	})
+}
+
+func InitSysDictionaryToPostgresql(db *gorm.DB) (err error) {
+	status := new(bool)
+	*status = true
+	tx := db.Begin() // 开始事务
+	insert := []SysDictionaryToPostgresql{
+		{Model: gorm.Model{ID: 1, CreatedAt: time.Now(), UpdatedAt: time.Now()}, Name: "性别", Type: "sex", Status: status, Description: "性别字典"},
+		{Model: gorm.Model{ID: 2, CreatedAt: time.Now(), UpdatedAt: time.Now()}, Name: "数据库int类型", Type: "int", Status: status, Description: "int类型对应的数据库类型"},
+		{Model: gorm.Model{ID: 3, CreatedAt: time.Now(), UpdatedAt: time.Now()}, Name: "数据库时间日期类型", Type: "time.Time", Status: status, Description: "数据库时间日期类型"},
+		{Model: gorm.Model{ID: 4, CreatedAt: time.Now(), UpdatedAt: time.Now()}, Name: "数据库浮点型", Type: "float64", Status: status, Description: "数据库浮点型"},
+		{Model: gorm.Model{ID: 5, CreatedAt: time.Now(), UpdatedAt: time.Now()}, Name: "数据库字符串", Type: "string", Status: status, Description: "数据库字符串"},
+		{Model: gorm.Model{ID: 6, CreatedAt: time.Now(), UpdatedAt: time.Now()}, Name: "数据库bool类型", Type: "bool", Status: status, Description: "数据库bool类型"},
+	}
+	if tx.Create(&insert).Error != nil { // 遇到错误时回滚事务
+		tx.Rollback()
+	}
+	return tx.Commit().Error
+}

+ 44 - 0
server/cmd/datas/dictionary_details.go

@@ -0,0 +1,44 @@
+package datas
+
+import (
+	"time"
+
+	"gin-vue-admin/model"
+	"gorm.io/gorm"
+)
+
+func InitSysDictionaryDetail(db *gorm.DB) (err error) {
+	status := new(bool)
+	*status = true
+	DictionaryDetail := []model.SysDictionaryDetail{
+		{gorm.Model{ID: 1, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "smallint", 1, status, 1, 2},
+		{gorm.Model{ID: 2, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "mediumint", 2, status, 2, 2},
+		{gorm.Model{ID: 3, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "int", 3, status, 3, 2},
+		{gorm.Model{ID: 4, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "bigint", 4, status, 4, 2},
+		{gorm.Model{ID: 5, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "data", 0, status, 0, 3},
+		{gorm.Model{ID: 6, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "time", 1, status, 1, 3},
+		{gorm.Model{ID: 7, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "year", 2, status, 2, 3},
+		{gorm.Model{ID: 8, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "datetime", 3, status, 3, 3},
+		{gorm.Model{ID: 9, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "timestamp", 5, status, 5, 3},
+		{gorm.Model{ID: 10, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "float", 0, status, 0, 4},
+		{gorm.Model{ID: 11, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "double", 1, status, 1, 4},
+		{gorm.Model{ID: 12, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "decimal", 2, status, 2, 4},
+		{gorm.Model{ID: 13, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "char", 0, status, 0, 5},
+		{gorm.Model{ID: 14, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "varchar", 1, status, 1, 5},
+		{gorm.Model{ID: 15, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "tinyblob", 2, status, 2, 5},
+		{gorm.Model{ID: 16, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "tinytext", 3, status, 3, 5},
+		{gorm.Model{ID: 17, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "text", 4, status, 4, 5},
+		{gorm.Model{ID: 18, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "blob", 5, status, 5, 5},
+		{gorm.Model{ID: 19, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "mediumblob", 6, status, 6, 5},
+		{gorm.Model{ID: 20, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "mediumtext", 7, status, 7, 5},
+		{gorm.Model{ID: 21, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "longblob", 8, status, 8, 5},
+		{gorm.Model{ID: 22, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "longtext", 9, status, 9, 5},
+		{gorm.Model{ID: 23, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "tinyint", 0, status, 0, 6},
+	}
+	return db.Transaction(func(tx *gorm.DB) error {
+		if tx.Create(&DictionaryDetail).Error != nil { // 遇到错误时回滚事务
+			return err
+		}
+		return nil
+	})
+}

+ 22 - 0
server/cmd/datas/files.go

@@ -0,0 +1,22 @@
+package datas
+
+import (
+	"time"
+
+	"gin-vue-admin/model"
+	"gorm.io/gorm"
+)
+
+var Files = []model.ExaFileUploadAndDownload{
+	{gorm.Model{ID: 1, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "10.png", "http://qmplusimg.henrongyi.top/gvalogo.png", "png", "158787308910.png"},
+	{gorm.Model{ID: 2, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "logo.png", "http://qmplusimg.henrongyi.top/1576554439myAvatar.png", "png", "1587973709logo.png"},
+}
+
+func InitExaFileUploadAndDownload(db *gorm.DB) (err error) {
+	return db.Transaction(func(tx *gorm.DB) error {
+		if tx.Create(&Files).Error != nil { // 遇到错误时回滚事务
+			return err
+		}
+		return nil
+	})
+}

+ 108 - 0
server/cmd/datas/init.go

@@ -0,0 +1,108 @@
+package datas
+
+import (
+	"gin-vue-admin/model"
+	gormadapter "github.com/casbin/gorm-adapter/v3"
+	"github.com/gookit/color"
+	"gorm.io/gorm"
+	"os"
+)
+
+func InitMysqlData(db *gorm.DB) {
+	var err error
+	err = InitSysApi(db)
+	err = InitSysUser(db)
+	err = InitExaCustomer(db)
+	err = InitCasbinModel(db)
+	err = InitSysAuthority(db)
+	err = InitSysBaseMenus(db)
+	err = InitAuthorityMenu(db)
+	err = InitSysDictionary(db)
+	err = InitSysAuthorityMenus(db)
+	err = InitSysDataAuthorityId(db)
+	err = InitSysDictionaryDetail(db)
+	err = InitExaFileUploadAndDownload(db)
+	if err != nil {
+		color.Warn.Printf("[Mysql]-->初始化数据失败,err: %v\n", err)
+		os.Exit(0)
+	}
+	color.Info.Println("[Mysql]-->初始化数据成功")
+}
+
+func InitMysqlTables(db *gorm.DB) {
+	var err error
+	err = db.AutoMigrate(
+		model.SysApi{},
+		model.SysUser{},
+		model.ExaFile{},
+		model.ExaCustomer{},
+		model.SysBaseMenu{},
+		model.SysWorkflow{},
+		model.SysAuthority{},
+		model.JwtBlacklist{},
+		model.ExaFileChunk{},
+		model.SysDictionary{},
+		model.ExaSimpleUploader{},
+		model.SysOperationRecord{},
+		model.SysWorkflowStepInfo{},
+		model.SysDictionaryDetail{},
+		model.SysBaseMenuParameter{},
+		model.ExaFileUploadAndDownload{},
+	)
+	if err != nil {
+		color.Warn.Printf("[Mysql]-->初始化数据表失败,err: %v\n", err)
+		os.Exit(0)
+	}
+	color.Info.Println("[Mysql]-->初始化数据表成功")
+}
+
+func InitPostgresqlData(db *gorm.DB) {
+	var err error
+	err = InitSysApi(db)
+	err = InitSysUser(db)
+	err = InitExaCustomer(db)
+	err = InitCasbinModel(db)
+	err = InitSysAuthority(db)
+	err = InitSysBaseMenus(db)
+	err = InitAuthorityMenu(db)
+	err = InitSysAuthorityMenus(db)
+	err = InitSysDataAuthorityId(db)
+	err = InitSysDictionaryDetail(db)
+	err = InitExaFileUploadAndDownload(db)
+	err = InitSysDictionaryToPostgresql(db)
+	if err != nil {
+		color.Error.Printf("[Postgresql]-->初始化数据失败,err: %v\n", err)
+		os.Exit(0)
+	}
+	color.Info.Println("[Postgresql]-->初始化数据成功")
+}
+
+func InitPostgresqlTables(db *gorm.DB) {
+	var err error
+	if !db.Migrator().HasTable("casbin_rule") {
+		err = db.Migrator().CreateTable(&gormadapter.CasbinRule{})
+	}
+	err = db.AutoMigrate(
+		model.SysApi{},
+		model.SysUser{},
+		model.ExaFile{},
+		model.ExaCustomer{},
+		model.SysBaseMenu{},
+		model.SysWorkflow{},
+		model.SysAuthority{},
+		model.JwtBlacklist{},
+		model.ExaFileChunk{},
+		model.ExaSimpleUploader{},
+		model.SysOperationRecord{},
+		model.SysWorkflowStepInfo{},
+		model.SysDictionaryDetail{},
+		model.SysBaseMenuParameter{},
+		model.ExaFileUploadAndDownload{},
+		SysDictionaryToPostgresql{},
+	)
+	if err != nil {
+		color.Error.Printf("[Postgresql]-->初始化数据表失败,err: %v\n", err)
+		os.Exit(0)
+	}
+	color.Info.Println("[Postgresql]-->初始化数据表成功")
+}

+ 47 - 0
server/cmd/datas/menus.go

@@ -0,0 +1,47 @@
+package datas
+
+import (
+	"time"
+
+	"gin-vue-admin/model"
+	"gorm.io/gorm"
+)
+
+var BaseMenus = []model.SysBaseMenu{
+	{Model: gorm.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: model.Meta{Title: "仪表盘", Icon: "setting"}},
+	{Model: gorm.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: model.Meta{Title: "关于我们", Icon: "info"}},
+	{Model: gorm.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: model.Meta{Title: "超级管理员", Icon: "user-solid"}},
+	{Model: gorm.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: model.Meta{Title: "角色管理", Icon: "s-custom"}},
+	{Model: gorm.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: model.Meta{Title: "菜单管理", Icon: "s-order", KeepAlive: true}},
+	{Model: gorm.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: model.Meta{Title: "api管理", Icon: "s-platform", KeepAlive: true}},
+	{Model: gorm.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: model.Meta{Title: "用户管理", Icon: "coordinate"}},
+	{Model: gorm.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: model.Meta{Title: "个人信息", Icon: "message-solid"}},
+	{Model: gorm.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: model.Meta{Title: "示例文件", Icon: "s-management"}},
+	{Model: gorm.Model{ID: 10, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, Hidden: false, ParentId: "9", Path: "table", Name: "table", Component: "view/example/table/table.vue", Sort: 1, Meta: model.Meta{Title: "表格示例", Icon: "s-order"}},
+	{Model: gorm.Model{ID: 11, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, Hidden: false, ParentId: "9", Path: "form", Name: "form", Component: "view/example/form/form.vue", Sort: 2, Meta: model.Meta{Title: "表单示例", Icon: "document"}},
+	{Model: gorm.Model{ID: 12, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, Hidden: false, ParentId: "9", Path: "rte", Name: "rte", Component: "view/example/rte/rte.vue", Sort: 3, Meta: model.Meta{Title: "富文本编辑器", Icon: "reading"}},
+	{Model: gorm.Model{ID: 13, 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: model.Meta{Title: "excel导入导出", Icon: "s-marketing"}},
+	{Model: gorm.Model{ID: 14, 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: model.Meta{Title: "上传下载", Icon: "upload"}},
+	{Model: gorm.Model{ID: 15, 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: model.Meta{Title: "断点续传", Icon: "upload"}},
+	{Model: gorm.Model{ID: 16, 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: model.Meta{Title: "客户列表(资源示例)", Icon: "s-custom"}},
+	{Model: gorm.Model{ID: 17, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, Hidden: false, ParentId: "0", Path: "systemTools", Name: "systemTools", Component: "view/systemTools/index.vue", Sort: 5, Meta: model.Meta{Title: "系统工具", Icon: "s-cooperation"}},
+	{Model: gorm.Model{ID: 18, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, Hidden: false, ParentId: "17", Path: "autoCode", Name: "autoCode", Component: "view/systemTools/autoCode/index.vue", Sort: 1, Meta: model.Meta{Title: "代码生成器", Icon: "cpu", KeepAlive: true}},
+	{Model: gorm.Model{ID: 19, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, Hidden: false, ParentId: "17", Path: "formCreate", Name: "formCreate", Component: "view/systemTools/formCreate/index.vue", Sort: 2, Meta: model.Meta{Title: "表单生成器", Icon: "magic-stick", KeepAlive: true}},
+	{Model: gorm.Model{ID: 20, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, Hidden: false, ParentId: "17", Path: "system", Name: "system", Component: "view/systemTools/system/system.vue", Sort: 3, Meta: model.Meta{Title: "系统配置", Icon: "s-operation"}},
+	{Model: gorm.Model{ID: 21, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, Hidden: false, ParentId: "0", Path: "iconList", Name: "iconList", Component: "view/iconList/index.vue", Sort: 2, Meta: model.Meta{Title: "图标集合", Icon: "star-on"}},
+	{Model: gorm.Model{ID: 22, 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: model.Meta{Title: "字典管理", Icon: "notebook-2"}},
+	{Model: gorm.Model{ID: 23, 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: model.Meta{Title: "字典详情", Icon: "s-order"}},
+	{Model: gorm.Model{ID: 24, 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: model.Meta{Title: "操作历史", Icon: "time"}},
+	{Model: gorm.Model{ID: 25, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, Hidden: false, ParentId: "9", Path: "simpleUploader", Name: "simpleUploader", Component: "view/example/simpleUploader/simpleUploader", Sort: 6, Meta: model.Meta{Title: "断点续传(插件版)", Icon: "upload"}},
+	{Model: gorm.Model{ID: 26, 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: model.Meta{Title: "官方网站", Icon: "s-home"}},
+	{Model: gorm.Model{ID: 27, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, ParentId: "0", Path: "state", Name: "state", Hidden: false, Component: "view/system/state.vue", Sort: 6, Meta: model.Meta{Title: "服务器状态", Icon: "cloudy"}},
+}
+
+func InitSysBaseMenus(db *gorm.DB) (err error) {
+	return db.Transaction(func(tx *gorm.DB) error {
+		if tx.Create(&BaseMenus).Error != nil { // 遇到错误时回滚事务
+			return err
+		}
+		return nil
+	})
+}

+ 23 - 0
server/cmd/datas/users.go

@@ -0,0 +1,23 @@
+package datas
+
+import (
+	"time"
+
+	"gin-vue-admin/model"
+	uuid "github.com/satori/go.uuid"
+	"gorm.io/gorm"
+)
+
+var Users = []model.SysUser{
+	{Model: gorm.Model{ID: 1, CreatedAt: time.Now(), UpdatedAt: time.Now()}, UUID: uuid.NewV4(), Username: "admin", Password: "e10adc3949ba59abbe56e057f20f883e", NickName: "超级管理员", HeaderImg: "http://qmplusimg.henrongyi.top/1571627762timg.jpg", AuthorityId: "888"},
+	{Model: gorm.Model{ID: 2, CreatedAt: time.Now(), UpdatedAt: time.Now()}, UUID: uuid.NewV4(), Username: "a303176530", Password: "3ec063004a6f31642261936a379fde3d", NickName: "QMPlusUser", HeaderImg: "http://qmplusimg.henrongyi.top/1572075907logo.png", AuthorityId: "9528"},
+}
+
+func InitSysUser(db *gorm.DB) (err error) {
+	return db.Transaction(func(tx *gorm.DB) error {
+		if tx.Create(&Users).Error != nil { // 遇到错误时回滚事务
+			return err
+		}
+		return nil
+	})
+}

+ 75 - 0
server/cmd/gva/initdb.go

@@ -0,0 +1,75 @@
+/*
+Copyright © 2020 SliverHorn
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+package gva
+
+import (
+	"gin-vue-admin/cmd/datas"
+	"gin-vue-admin/core"
+	"gin-vue-admin/initialize"
+
+	"github.com/gookit/color"
+
+	_ "gin-vue-admin/core"
+	"gin-vue-admin/global"
+
+	"github.com/spf13/cobra"
+)
+
+// initdbCmd represents the initdb command
+var initdbCmd = &cobra.Command{
+	Use:   "initdb",
+	Short: "gin-vue-admin初始化数据",
+	Long: `gin-vue-admin初始化数据适配数据库情况: 
+1. mysql完美适配,
+2. postgresql不能保证完美适配,
+3. sqlite未适配,
+4. sqlserver未适配`,
+	Run: func(cmd *cobra.Command, args []string) {
+		path, _ := cmd.Flags().GetString("path")
+		core.Viper(path)
+		db := initialize.GormMysql()
+		switch global.GVA_CONFIG.System.DbType {
+		case "mysql":
+			datas.InitMysqlTables(db)
+			datas.InitMysqlData(db)
+		case "postgresql":
+			datas.InitPostgresqlTables(db)
+			datas.InitPostgresqlData(db)
+		case "sqlite":
+			color.Info.Println("sqlite功能开发中")
+		case "sqlserver":
+			color.Info.Println("sqlserver功能开发中")
+		default:
+			datas.InitMysqlTables(db)
+			datas.InitMysqlData(db)
+			color.Info.Println("sqlserver功能开发中")
+		}
+		frame, _ := cmd.Flags().GetString("frame")
+		if frame == "gf" {
+			color.Info.Println("gf功能开发中")
+			return
+		} else {
+			return
+		}
+	},
+}
+
+func init() {
+	rootCmd.AddCommand(initdbCmd)
+	initdbCmd.Flags().StringP("path", "p", "./config.yaml", "自定配置文件路径(绝对路径)")
+	initdbCmd.Flags().StringP("frame", "f", "gin", "可选参数为gin,gf")
+	initdbCmd.Flags().StringP("type", "t", "mysql", "可选参数为mysql,postgresql,sqlite,sqlserver")
+}

+ 94 - 0
server/cmd/gva/root.go

@@ -0,0 +1,94 @@
+/*
+Copyright © 2020 SliverHorn
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+package gva
+
+import (
+	"github.com/mitchellh/go-homedir"
+	"os"
+
+	"github.com/gookit/color"
+	"github.com/spf13/cobra"
+
+	"github.com/spf13/viper"
+)
+
+var cfgFile string
+
+// rootCmd represents the base command when called without any subcommands
+var rootCmd = &cobra.Command{
+	Use:   "gva",
+	Short: "这是一款amazing的终端工具",
+	Long: `欢迎使用gva终端工具
+ ________ ____   ____   _____   
+ /  _____/ \   \ /   /  /  _  \  
+/   \  ___  \   Y   /  /  /_\  \ 
+\    \_\  \  \     /  /    |    \
+ \______  /   \___/   \____|__  /
+        \/                    \/ 
+`,
+	// Uncomment the following line if your bare application
+	// has an action associated with it:
+	//	Run: func(cmd *cobra.Command, args []string) { },
+}
+
+// Execute adds all child commands to the root command and sets flags appropriately.
+// This is called by main.main(). It only needs to happen once to the rootCmd.
+func Execute() {
+	if err := rootCmd.Execute(); err != nil {
+		color.Warn.Println(err)
+		os.Exit(1)
+	}
+}
+
+func init() {
+	cobra.OnInitialize(initConfig)
+
+	// Here you will define your flags and configuration settings.
+	// Cobra supports persistent flags, which, if defined here,
+	// will be global for your application.
+
+	rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.gva.yaml)")
+
+	// Cobra also supports local flags, which will only run
+	// when this action is called directly.
+	rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
+}
+
+// initConfig reads in config file and ENV variables if set.
+func initConfig() {
+	if cfgFile != "" {
+		// Use config file from the flag.
+		viper.SetConfigFile(cfgFile)
+	} else {
+		// Find home directory.
+		home, err := homedir.Dir()
+		if err != nil {
+			color.Warn.Println(err)
+			os.Exit(1)
+		}
+
+		// Search config in home directory with name ".gva" (without extension).
+		viper.AddConfigPath(home)
+		viper.SetConfigName(".gva")
+	}
+
+	viper.AutomaticEnv() // read in environment variables that match
+
+	// If a config file is found, read it in.
+	if err := viper.ReadInConfig(); err == nil {
+		color.Warn.Println("Using config file:", viper.ConfigFileUsed())
+	}
+}

+ 36 - 0
server/cmd/gva/version.go

@@ -0,0 +1,36 @@
+/*
+Copyright © 2020 SliverHorn
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+package gva
+
+import (
+	"github.com/gookit/color"
+
+	"github.com/spf13/cobra"
+)
+
+// versionCmd represents the version command
+var versionCmd = &cobra.Command{
+	Use:   "version",
+	Short: "版本信息",
+	Long:  `版本的长信息`,
+	Run: func(cmd *cobra.Command, args []string) {
+		color.Green.Println("v0.0.2")
+	},
+}
+
+func init() {
+	rootCmd.AddCommand(versionCmd)
+}

+ 22 - 0
server/cmd/main.go

@@ -0,0 +1,22 @@
+/*
+Copyright © 2020 SliverHorn
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+package main
+
+import "gin-vue-admin/cmd/gva"
+
+func main() {
+	gva.Execute()
+}

+ 0 - 31
server/config.yaml

@@ -42,7 +42,6 @@ system:
   addr: 8888
   db-type: 'mysql'
   oss-type: 'local'
-  need-init-data: false
   use-multipoint: false
 
 # captcha configuration
@@ -62,36 +61,6 @@ mysql:
   max-open-conns: 10
   log-mode: false
 
-# sqlite connect configuration (sqlite需要gcc支持 windows用户需要自行安装gcc)
-sqlite:
-  path: 'db.db'
-  max-idle-conns: 10
-  max-open-conns: 10
-  logger: true
-
-# Sqlserver connect configuration
-sqlserver:
-  path: 'localhost:9930'
-  db-name: 'gorm'
-  username: 'gorm'
-  password: 'LoremIpsum86'
-  max-idle-conns: 10
-  max-open-conns: 10
-  logger: true
-
-# Postgresql connect configuration
-postgresql:
-  host: '127.0.0.1'
-  port: '9920'
-  config: 'sslmode=disable TimeZone=Asia/Shanghai'
-  db-name: 'gorm'
-  username: 'gorm'
-  password: 'gorm'
-  max-idle-conns: 10
-  max-open-conns: 10
-  prefer-simple-protocol: true
-  logger: false
-
 # local configuration
 local:
   path: 'uploads/file'

+ 0 - 3
server/config/config.go

@@ -10,9 +10,6 @@ type Server struct {
 	Captcha Captcha `mapstructure:"captcha" json:"captcha" yaml:"captcha"`
 	// gorm
 	Mysql      Mysql      `mapstructure:"mysql" json:"mysql" yaml:"mysql"`
-	Sqlite     Sqlite     `mapstructure:"sqlite" json:"sqlite" yaml:"sqlite"`
-	Sqlserver  Sqlserver  `mapstructure:"sqlserver" json:"sqlserver" yaml:"sqlserver"`
-	Postgresql Postgresql `mapstructure:"postgresql" json:"postgresql" yaml:"postgresql"`
 	// oss
 	Local Local `mapstructure:"local" json:"local" yaml:"local"`
 	Qiniu Qiniu `mapstructure:"qiniu" json:"qiniu" yaml:"qiniu"`

+ 0 - 31
server/config/gorm.go

@@ -10,34 +10,3 @@ type Mysql struct {
 	MaxOpenConns int    `mapstructure:"max-open-conns" json:"maxOpenConns" yaml:"max-open-conns"`
 	LogMode      bool   `mapstructure:"log-mode" json:"logMode" yaml:"log-mode"`
 }
-
-type Sqlite struct {
-	Path         string `mapstructure:"path" json:"path" yaml:"path"`
-	MaxIdleConns int    `mapstructure:"max-idle-conns" json:"maxIdleConns" yaml:"max-idle-conns"`
-	MaxOpenConns int    `mapstructure:"max-open-conns" json:"maxOpenConns" yaml:"max-open-conns"`
-	Logger       bool   `mapstructure:"logger" json:"logger" yaml:"logger"`
-}
-
-type Sqlserver struct {
-	Path         string `mapstructure:"path" json:"path" yaml:"path"`
-	Dbname       string `mapstructure:"db-name" json:"dbname" yaml:"db-name"`
-	Username     string `mapstructure:"username" json:"username" yaml:"username"`
-	Password     string `mapstructure:"password" json:"password" yaml:"password"`
-	MaxIdleConns int    `mapstructure:"max-idle-conns" json:"maxIdleConns" yaml:"max-idle-conns"`
-	MaxOpenConns int    `mapstructure:"max-open-conns" json:"maxOpenConns" yaml:"max-open-conns"`
-	Logger       bool   `mapstructure:"logger" json:"logger" yaml:"logger"`
-}
-
-type Postgresql struct {
-	Host                 string `mapstructure:"host" json:"host" yaml:"host"`
-	Port                 string `mapstructure:"port" json:"port" yaml:"port"`
-	Config               string `mapstructure:"config" json:"config" yaml:"config"`
-	Dbname               string `mapstructure:"db-name" json:"dbname" yaml:"db-name"`
-	Username             string `mapstructure:"username" json:"username" yaml:"username"`
-	Password             string `mapstructure:"password" json:"password" yaml:"password"`
-	MaxIdleConns         int    `mapstructure:"max-idle-conns" json:"maxIdleConns" yaml:"max-idle-conns"`
-	MaxOpenConns         int    `mapstructure:"max-open-conns" json:"maxOpenConns" yaml:"max-open-conns"`
-	PreferSimpleProtocol bool   `mapstructure:"prefer-simple-protocol" json:"preferSimpleProtocol" yaml:"prefer-simple-protocol"`
-	Logger               bool   `mapstructure:"logger" json:"logger" yaml:"logger"`
-}
-

+ 0 - 1
server/config/system.go

@@ -5,6 +5,5 @@ type System struct {
 	Addr          int    `mapstructure:"addr" json:"addr" yaml:"addr"`
 	DbType        string `mapstructure:"db-type" json:"dbType" yaml:"db-type"`
 	OssType       string `mapstructure:"oss-type" json:"ossType" yaml:"oss-type"`
-	NeedInitData  bool   `mapstructure:"need-init-data" json:"needInitData" yaml:"need-init-data"`
 	UseMultipoint bool   `mapstructure:"use-multipoint" json:"useMultipoint" yaml:"use-multipoint"`
 }

+ 0 - 48
server/core/config.go

@@ -1,48 +0,0 @@
-package core
-
-import (
-	"flag"
-	"fmt"
-	"gin-vue-admin/global"
-	_ "gin-vue-admin/packfile"
-	"gin-vue-admin/utils"
-	"github.com/fsnotify/fsnotify"
-	"github.com/spf13/viper"
-	"os"
-)
-
-var config string
-
-func init() {
-	flag.StringVar(&config, "c", "", "choose config file.")
-	flag.Parse()
-	if config == "" { // 优先级: 命令行 > 环境变量 > 默认值
-		if configEnv := os.Getenv(utils.ConfigEnv); configEnv == "" {
-			config = utils.ConfigFile
-			fmt.Printf("您正在使用config的默认值,config的路径为%v\n", utils.ConfigFile)
-		} else {
-			config = configEnv
-			fmt.Printf("您正在使用GVA_CONFIG环境变量,config的路径为%v\n", config)
-		}
-	} else {
-		fmt.Printf("您正在使用命令行的-c参数传递的值,config的路径为%v\n", config)
-	}
-	v := viper.New()
-	v.SetConfigFile(config)
-	err := v.ReadInConfig()
-	if err != nil {
-		panic(fmt.Errorf("Fatal error config file: %s \n", err))
-	}
-	v.WatchConfig()
-
-	v.OnConfigChange(func(e fsnotify.Event) {
-		fmt.Println("config file changed:", e.Name)
-		if err := v.Unmarshal(&global.GVA_CONFIG); err != nil {
-			fmt.Println(err)
-		}
-	})
-	if err := v.Unmarshal(&global.GVA_CONFIG); err != nil {
-		fmt.Println(err)
-	}
-	global.GVA_VP = v
-}

+ 54 - 0
server/core/viper.go

@@ -0,0 +1,54 @@
+package core
+
+import (
+	"flag"
+	"fmt"
+	"gin-vue-admin/global"
+	_ "gin-vue-admin/packfile"
+	"gin-vue-admin/utils"
+	"github.com/fsnotify/fsnotify"
+	"github.com/spf13/viper"
+	"os"
+)
+
+func Viper(path ...string) *viper.Viper {
+	var config string
+	if len(path) == 0 {
+		flag.StringVar(&config, "c", "", "choose config file.")
+		flag.Parse()
+		if config == "" { // 优先级: 命令行 > 环境变量 > 默认值
+			if configEnv := os.Getenv(utils.ConfigEnv); configEnv == "" {
+				config = utils.ConfigFile
+				fmt.Printf("您正在使用config的默认值,config的路径为%v\n", utils.ConfigFile)
+			} else {
+				config = configEnv
+				fmt.Printf("您正在使用GVA_CONFIG环境变量,config的路径为%v\n", config)
+			}
+		} else {
+			fmt.Printf("您正在使用命令行的-c参数传递的值,config的路径为%v\n", config)
+		}
+	} else {
+		config = path[0]
+		fmt.Printf("您正在使用func Viper()传递的值,config的路径为%v\n", config)
+	}
+
+	v := viper.New()
+	v.SetConfigFile(config)
+	err := v.ReadInConfig()
+	if err != nil {
+		panic(fmt.Errorf("Fatal error config file: %s \n", err))
+	}
+	v.WatchConfig()
+
+	v.OnConfigChange(func(e fsnotify.Event) {
+		fmt.Println("config file changed:", e.Name)
+		if err := v.Unmarshal(&global.GVA_CONFIG); err != nil {
+			fmt.Println(err)
+		}
+	})
+
+	if err := v.Unmarshal(&global.GVA_CONFIG); err != nil {
+		fmt.Println(err)
+	}
+	return v
+}

+ 6 - 5
server/core/zap.go

@@ -17,7 +17,7 @@ var (
 	writer zapcore.WriteSyncer
 )
 
-func init() {
+func Zap() (logger *zap.Logger) {
 	if ok, _ := utils.PathExists(global.GVA_CONFIG.Zap.Director); !ok { // 判断是否有Director文件夹
 		fmt.Printf("create %v directory\n", global.GVA_CONFIG.Zap.Director)
 		_ = os.Mkdir(global.GVA_CONFIG.Zap.Director, os.ModePerm)
@@ -49,13 +49,14 @@ func init() {
 	}
 
 	if level == zap.DebugLevel || level == zap.ErrorLevel {
-		global.GVA_LOG = zap.New(getEncoderCore(), zap.AddStacktrace(level))
+		logger = zap.New(getEncoderCore(), zap.AddStacktrace(level))
 	} else {
-		global.GVA_LOG = zap.New(getEncoderCore())
+		logger = zap.New(getEncoderCore())
 	}
 	if global.GVA_CONFIG.Zap.ShowLine {
-		global.GVA_LOG.WithOptions(zap.AddCaller())
+		logger.WithOptions(zap.AddCaller())
 	}
+	return logger
 }
 
 // getWriteSyncer zap logger中加入file-rotatelogs
@@ -87,7 +88,7 @@ func getEncoderConfig() (config zapcore.EncoderConfig) {
 		EncodeDuration: zapcore.SecondsDurationEncoder,
 		EncodeCaller:   zapcore.FullCallerEncoder,
 	}
-	switch  {
+	switch {
 	case global.GVA_CONFIG.Zap.EncodeLevel == "LowercaseLevelEncoder": // 小写编码器(默认)
 		config.EncodeLevel = zapcore.LowercaseLevelEncoder
 	case global.GVA_CONFIG.Zap.EncodeLevel == "LowercaseColorLevelEncoder": // 小写编码器带颜色

+ 6 - 1
server/go.mod

@@ -5,6 +5,7 @@ go 1.12
 require (
 	github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d // indirect
 	github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751
+	github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6 // indirect
 	github.com/casbin/casbin v1.9.1
 	github.com/casbin/casbin/v2 v2.11.0
 	github.com/casbin/gorm-adapter/v3 v3.0.2
@@ -20,12 +21,14 @@ require (
 	github.com/go-redis/redis v6.15.7+incompatible
 	github.com/go-sql-driver/mysql v1.5.0
 	github.com/golang/protobuf v1.4.2 // indirect
+	github.com/gookit/color v1.3.1
 	github.com/jehiah/go-strftime v0.0.0-20171201141054-1d33003b3869 // indirect
 	github.com/jordan-wright/email v0.0.0-20200824153738-3f5bafa1cd84
 	github.com/json-iterator/go v1.1.10 // indirect
 	github.com/lestrrat-go/file-rotatelogs v2.3.0+incompatible
 	github.com/lestrrat-go/strftime v1.0.3 // indirect
 	github.com/mailru/easyjson v0.7.1 // indirect
+	github.com/mitchellh/go-homedir v1.1.0
 	github.com/mitchellh/mapstructure v1.2.2 // indirect
 	github.com/mojocn/base64Captcha v1.3.1
 	github.com/onsi/ginkgo v1.7.0 // indirect
@@ -37,12 +40,14 @@ require (
 	github.com/shirou/gopsutil v2.20.8+incompatible
 	github.com/spf13/afero v1.2.2 // indirect
 	github.com/spf13/cast v1.3.1 // indirect
+	github.com/spf13/cobra v1.1.1
 	github.com/spf13/jwalterweatherman v1.1.0 // indirect
-	github.com/spf13/viper v1.6.2
+	github.com/spf13/viper v1.7.0
 	github.com/swaggo/gin-swagger v1.2.0
 	github.com/swaggo/swag v1.6.7
 	github.com/tebeka/strftime v0.1.3 // indirect
 	github.com/unrolled/secure v1.0.7
+	github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77 // indirect
 	go.uber.org/zap v1.10.0
 	golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e // indirect
 	golang.org/x/sys v0.0.0-20200610111108-226ff32320da // indirect

+ 0 - 497
server/gva/init_data/init_data.go

@@ -1,497 +0,0 @@
-package init_data
-
-import (
-	"gin-vue-admin/global"
-	"gin-vue-admin/model"
-	gormadapter "github.com/casbin/gorm-adapter/v3"
-	"github.com/satori/go.uuid"
-	"go.uber.org/zap"
-	"gorm.io/gorm"
-	"time"
-)
-
-type SysAuthorityMenus struct {
-	SysAuthorityAuthorityId string
-	SysBaseMenuId           uint
-}
-
-type SysDataAuthorityId struct {
-	SysAuthorityAuthorityId    string
-	DataAuthorityIdAuthorityId string
-}
-
-func InitSysApi() (err error) {
-	tx := global.GVA_DB.Begin() // 开始事务
-	insert := []model.SysApi{
-		{gorm.Model{ID: 1, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/base/login", "用户登录", "base", "POST"},
-		{gorm.Model{ID: 2, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/user/register", "用户注册", "user", "POST"},
-		{gorm.Model{ID: 3, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/api/createApi", "创建api", "api", "POST"},
-		{gorm.Model{ID: 4, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/api/getApiList", "获取api列表", "api", "POST"},
-		{gorm.Model{ID: 5, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/api/getApiById", "获取api详细信息", "api", "POST"},
-		{gorm.Model{ID: 6, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/api/deleteApi", "删除Api", "api", "POST"},
-		{gorm.Model{ID: 7, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/api/updateApi", "更新Api", "api", "POST"},
-		{gorm.Model{ID: 8, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/api/getAllApis", "获取所有api", "api", "POST"},
-		{gorm.Model{ID: 9, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/authority/createAuthority", "创建角色", "authority", "POST"},
-		{gorm.Model{ID: 10, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/authority/deleteAuthority", "删除角色", "authority", "POST"},
-		{gorm.Model{ID: 11, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/authority/getAuthorityList", "获取角色列表", "authority", "POST"},
-		{gorm.Model{ID: 12, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/menu/getMenu", "获取菜单树", "menu", "POST"},
-		{gorm.Model{ID: 13, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/menu/getMenuList", "分页获取基础menu列表", "menu", "POST"},
-		{gorm.Model{ID: 14, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/menu/addBaseMenu", "新增菜单", "menu", "POST"},
-		{gorm.Model{ID: 15, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/menu/getBaseMenuTree", "获取用户动态路由", "menu", "POST"},
-		{gorm.Model{ID: 16, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/menu/addMenuAuthority", "增加menu和角色关联关系", "menu", "POST"},
-		{gorm.Model{ID: 17, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/menu/getMenuAuthority", "获取指定角色menu", "menu", "POST"},
-		{gorm.Model{ID: 18, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/menu/deleteBaseMenu", "删除菜单", "menu", "POST"},
-		{gorm.Model{ID: 19, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/menu/updateBaseMenu", "更新菜单", "menu", "POST"},
-		{gorm.Model{ID: 20, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/menu/getBaseMenuById", "根据id获取菜单", "menu", "POST"},
-		{gorm.Model{ID: 21, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/user/changePassword", "修改密码", "user", "POST"},
-		{gorm.Model{ID: 23, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/user/getUserList", "获取用户列表", "user", "POST"},
-		{gorm.Model{ID: 24, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/user/setUserAuthority", "修改用户角色", "user", "POST"},
-		{gorm.Model{ID: 25, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/fileUploadAndDownload/upload", "文件上传示例", "fileUploadAndDownload", "POST"},
-		{gorm.Model{ID: 26, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/fileUploadAndDownload/getFileList", "获取上传文件列表", "fileUploadAndDownload", "POST"},
-		{gorm.Model{ID: 27, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/casbin/updateCasbin", "更改角色api权限", "casbin", "POST"},
-		{gorm.Model{ID: 28, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/casbin/getPolicyPathByAuthorityId", "获取权限列表", "casbin", "POST"},
-		{gorm.Model{ID: 29, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/fileUploadAndDownload/deleteFile", "删除文件", "fileUploadAndDownload", "POST"},
-		{gorm.Model{ID: 30, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/jwt/jsonInBlacklist", "jwt加入黑名单", "jwt", "POST"},
-		{gorm.Model{ID: 31, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/authority/setDataAuthority", "设置角色资源权限", "authority", "POST"},
-		{gorm.Model{ID: 32, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/system/getSystemConfig", "获取配置文件内容", "system", "POST"},
-		{gorm.Model{ID: 33, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/system/setSystemConfig", "设置配置文件内容", "system", "POST"},
-		{gorm.Model{ID: 34, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/customer/customer", "创建客户", "customer", "POST"},
-		{gorm.Model{ID: 35, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/customer/customer", "更新客户", "customer", "PUT"},
-		{gorm.Model{ID: 36, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/customer/customer", "删除客户", "customer", "DELETE"},
-		{gorm.Model{ID: 37, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/customer/customer", "获取单一客户", "customer", "GET"},
-		{gorm.Model{ID: 38, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/customer/customerList", "获取客户列表", "customer", "GET"},
-		{gorm.Model{ID: 39, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/casbin/casbinTest/:pathParam", "RESTFUL模式测试", "casbin", "GET"},
-		{gorm.Model{ID: 40, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/autoCode/createTemp", "自动化代码", "autoCode", "POST"},
-		{gorm.Model{ID: 41, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/authority/updateAuthority", "更新角色信息", "authority", "PUT"},
-		{gorm.Model{ID: 42, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/authority/copyAuthority", "拷贝角色", "authority", "POST"},
-		{gorm.Model{ID: 43, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/user/deleteUser", "删除用户", "user", "DELETE"},
-		{gorm.Model{ID: 44, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysDictionaryDetail/createSysDictionaryDetail", "新增字典内容", "sysDictionaryDetail", "POST"},
-		{gorm.Model{ID: 45, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysDictionaryDetail/deleteSysDictionaryDetail", "删除字典内容", "sysDictionaryDetail", "DELETE"},
-		{gorm.Model{ID: 46, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysDictionaryDetail/updateSysDictionaryDetail", "更新字典内容", "sysDictionaryDetail", "PUT"},
-		{gorm.Model{ID: 47, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysDictionaryDetail/findSysDictionaryDetail", "根据ID获取字典内容", "sysDictionaryDetail", "GET"},
-		{gorm.Model{ID: 48, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysDictionaryDetail/getSysDictionaryDetailList", "获取字典内容列表", "sysDictionaryDetail", "GET"},
-		{gorm.Model{ID: 49, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysDictionary/createSysDictionary", "新增字典", "sysDictionary", "POST"},
-		{gorm.Model{ID: 50, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysDictionary/deleteSysDictionary", "删除字典", "sysDictionary", "DELETE"},
-		{gorm.Model{ID: 51, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysDictionary/updateSysDictionary", "更新字典", "sysDictionary", "PUT"},
-		{gorm.Model{ID: 52, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysDictionary/findSysDictionary", "根据ID获取字典", "sysDictionary", "GET"},
-		{gorm.Model{ID: 53, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysDictionary/getSysDictionaryList", "获取字典列表", "sysDictionary", "GET"},
-		{gorm.Model{ID: 54, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysOperationRecord/createSysOperationRecord", "新增操作记录", "sysOperationRecord", "POST"},
-		{gorm.Model{ID: 55, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysOperationRecord/deleteSysOperationRecord", "删除操作记录", "sysOperationRecord", "DELETE"},
-		{gorm.Model{ID: 56, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysOperationRecord/findSysOperationRecord", "根据ID获取操作记录", "sysOperationRecord", "GET"},
-		{gorm.Model{ID: 57, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysOperationRecord/getSysOperationRecordList", "获取操作记录列表", "sysOperationRecord", "GET"},
-		{gorm.Model{ID: 58, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/autoCode/getTables", "获取数据库表", "autoCode", "GET"},
-		{gorm.Model{ID: 59, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/autoCode/getDB", "获取所有数据库", "autoCode", "GET"},
-		{gorm.Model{ID: 60, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/autoCode/getColume", "获取所选table的所有字段", "autoCode", "GET"},
-		{gorm.Model{ID: 61, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/sysOperationRecord/deleteSysOperationRecordByIds", "批量删除操作历史", "sysOperationRecord", "DELETE"},
-		{gorm.Model{ID: 62, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/simpleUploader/upload", "插件版分片上传", "simpleUploader", "POST"},
-		{gorm.Model{ID: 63, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/simpleUploader/checkFileMd5", "文件完整度验证", "simpleUploader", "GET"},
-		{gorm.Model{ID: 64, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/simpleUploader/mergeFileMd5", "上传完成合并文件", "simpleUploader", "GET"},
-		{gorm.Model{ID: 65, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/user/setUserInfo", "设置用户信息", "user", "PUT"},
-		{gorm.Model{ID: 66, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/system/getServerInfo", "获取服务器信息", "system", "POST"},
-		{gorm.Model{ID: 67, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/email/emailTest", "发送测试邮件", "email", "POST"},
-	}
-	if tx.Create(&insert).Error != nil { // 遇到错误时回滚事务
-		tx.Rollback()
-	}
-	return tx.Commit().Error
-}
-
-func InitSysUser() (err error) {
-	tx := global.GVA_DB.Begin() // 开始事务
-	insert := []model.SysUser{
-		{Model: gorm.Model{ID: 1, CreatedAt: time.Now(), UpdatedAt: time.Now()}, UUID: uuid.NewV4(), Username: "admin", Password: "e10adc3949ba59abbe56e057f20f883e", NickName: "超级管理员", HeaderImg: "http://qmplusimg.henrongyi.top/1571627762timg.jpg", AuthorityId: "888"},
-		{Model: gorm.Model{ID: 2, CreatedAt: time.Now(), UpdatedAt: time.Now()}, UUID: uuid.NewV4(), Username: "a303176530", Password: "3ec063004a6f31642261936a379fde3d", NickName: "QMPlusUser", HeaderImg: "http://qmplusimg.henrongyi.top/1572075907logo.png", AuthorityId: "9528"},
-	}
-	if tx.Create(&insert).Error != nil { // 遇到错误时回滚事务
-		tx.Rollback()
-	}
-	return tx.Commit().Error
-}
-
-func InitExaCustomer() (err error) {
-	tx := global.GVA_DB.Begin() // 开始事务
-	insert := []model.ExaCustomer{
-		{Model: gorm.Model{ID: 1, CreatedAt: time.Now(), UpdatedAt: time.Now()}, CustomerName: "测试客户", CustomerPhoneData: "1761111111", SysUserID: 1, SysUserAuthorityID: "888"},
-	}
-	if tx.Create(&insert).Error != nil { // 遇到错误时回滚事务
-		tx.Rollback()
-	}
-	return tx.Commit().Error
-}
-
-func InitCasbinModel() (err error) {
-	if !global.GVA_DB.Migrator().HasTable("casbin_rule") {
-		if err := global.GVA_DB.Migrator().CreateTable(&gormadapter.CasbinRule{}); err != nil {
-			return err
-		}
-	}
-	tx := global.GVA_DB.Begin() // 开始事务
-	insert := []model.CasbinModel{
-		{"p", "888", "/base/login", "POST"},
-		{"p", "888", "/user/register", "POST"},
-		{"p", "888", "/api/createApi", "POST"},
-		{"p", "888", "/api/getApiList", "POST"},
-		{"p", "888", "/api/getApiById", "POST"},
-		{"p", "888", "/api/deleteApi", "POST"},
-		{"p", "888", "/api/updateApi", "POST"},
-		{"p", "888", "/api/getAllApis", "POST"},
-		{"p", "888", "/authority/createAuthority", "POST"},
-		{"p", "888", "/authority/deleteAuthority", "POST"},
-		{"p", "888", "/authority/getAuthorityList", "POST"},
-		{"p", "888", "/authority/setDataAuthority", "POST"},
-		{"p", "888", "/authority/updateAuthority", "PUT"},
-		{"p", "888", "/authority/copyAuthority", "POST"},
-		{"p", "888", "/menu/getMenu", "POST"},
-		{"p", "888", "/menu/getMenuList", "POST"},
-		{"p", "888", "/menu/addBaseMenu", "POST"},
-		{"p", "888", "/menu/getBaseMenuTree", "POST"},
-		{"p", "888", "/menu/addMenuAuthority", "POST"},
-		{"p", "888", "/menu/getMenuAuthority", "POST"},
-		{"p", "888", "/menu/deleteBaseMenu", "POST"},
-		{"p", "888", "/menu/updateBaseMenu", "POST"},
-		{"p", "888", "/menu/getBaseMenuById", "POST"},
-		{"p", "888", "/user/changePassword", "POST"},
-		{"p", "888", "/user/getUserList", "POST"},
-		{"p", "888", "/user/setUserAuthority", "POST"},
-		{"p", "888", "/user/deleteUser", "DELETE"},
-		{"p", "888", "/fileUploadAndDownload/upload", "POST"},
-		{"p", "888", "/fileUploadAndDownload/getFileList", "POST"},
-		{"p", "888", "/fileUploadAndDownload/deleteFile", "POST"},
-		{"p", "888", "/casbin/updateCasbin", "POST"},
-		{"p", "888", "/casbin/getPolicyPathByAuthorityId", "POST"},
-		{"p", "888", "/casbin/casbinTest/:pathParam", "GET"},
-		{"p", "888", "/jwt/jsonInBlacklist", "POST"},
-		{"p", "888", "/system/getSystemConfig", "POST"},
-		{"p", "888", "/system/setSystemConfig", "POST"},
-		{"p", "888", "/system/getServerInfo", "POST"},
-		{"p", "888", "/customer/customer", "POST"},
-		{"p", "888", "/customer/customer", "PUT"},
-		{"p", "888", "/customer/customer", "DELETE"},
-		{"p", "888", "/customer/customer", "GET"},
-		{"p", "888", "/customer/customerList", "GET"},
-		{"p", "888", "/autoCode/createTemp", "POST"},
-		{"p", "888", "/autoCode/getTables", "GET"},
-		{"p", "888", "/autoCode/getDB", "GET"},
-		{"p", "888", "/autoCode/getColume", "GET"},
-		{"p", "888", "/sysDictionaryDetail/createSysDictionaryDetail", "POST"},
-		{"p", "888", "/sysDictionaryDetail/deleteSysDictionaryDetail", "DELETE"},
-		{"p", "888", "/sysDictionaryDetail/updateSysDictionaryDetail", "PUT"},
-		{"p", "888", "/sysDictionaryDetail/findSysDictionaryDetail", "GET"},
-		{"p", "888", "/sysDictionaryDetail/getSysDictionaryDetailList", "GET"},
-		{"p", "888", "/sysDictionary/createSysDictionary", "POST"},
-		{"p", "888", "/sysDictionary/deleteSysDictionary", "DELETE"},
-		{"p", "888", "/sysDictionary/updateSysDictionary", "PUT"},
-		{"p", "888", "/sysDictionary/findSysDictionary", "GET"},
-		{"p", "888", "/sysDictionary/getSysDictionaryList", "GET"},
-		{"p", "888", "/sysOperationRecord/createSysOperationRecord", "POST"},
-		{"p", "888", "/sysOperationRecord/deleteSysOperationRecord", "DELETE"},
-		{"p", "888", "/sysOperationRecord/updateSysOperationRecord", "PUT"},
-		{"p", "888", "/sysOperationRecord/findSysOperationRecord", "GET"},
-		{"p", "888", "/sysOperationRecord/getSysOperationRecordList", "GET"},
-		{"p", "888", "/sysOperationRecord/deleteSysOperationRecordByIds", "DELETE"},
-		{"p", "888", "/user/setUserInfo", "PUT"},
-		{"p", "888", "/email/emailTest", "POST"},
-		{"p", "8881", "/base/login", "POST"},
-		{"p", "8881", "/user/register", "POST"},
-		{"p", "8881", "/api/createApi", "POST"},
-		{"p", "8881", "/api/getApiList", "POST"},
-		{"p", "8881", "/api/getApiById", "POST"},
-		{"p", "8881", "/api/deleteApi", "POST"},
-		{"p", "8881", "/api/updateApi", "POST"},
-		{"p", "8881", "/api/getAllApis", "POST"},
-		{"p", "8881", "/authority/createAuthority", "POST"},
-		{"p", "8881", "/authority/deleteAuthority", "POST"},
-		{"p", "8881", "/authority/getAuthorityList", "POST"},
-		{"p", "8881", "/authority/setDataAuthority", "POST"},
-		{"p", "8881", "/menu/getMenu", "POST"},
-		{"p", "8881", "/menu/getMenuList", "POST"},
-		{"p", "8881", "/menu/addBaseMenu", "POST"},
-		{"p", "8881", "/menu/getBaseMenuTree", "POST"},
-		{"p", "8881", "/menu/addMenuAuthority", "POST"},
-		{"p", "8881", "/menu/getMenuAuthority", "POST"},
-		{"p", "8881", "/menu/deleteBaseMenu", "POST"},
-		{"p", "8881", "/menu/updateBaseMenu", "POST"},
-		{"p", "8881", "/menu/getBaseMenuById", "POST"},
-		{"p", "8881", "/user/changePassword", "POST"},
-		{"p", "8881", "/user/getUserList", "POST"},
-		{"p", "8881", "/user/setUserAuthority", "POST"},
-		{"p", "8881", "/fileUploadAndDownload/upload", "POST"},
-		{"p", "8881", "/fileUploadAndDownload/getFileList", "POST"},
-		{"p", "8881", "/fileUploadAndDownload/deleteFile", "POST"},
-		{"p", "8881", "/casbin/updateCasbin", "POST"},
-		{"p", "8881", "/casbin/getPolicyPathByAuthorityId", "POST"},
-		{"p", "8881", "/jwt/jsonInBlacklist", "POST"},
-		{"p", "8881", "/system/getSystemConfig", "POST"},
-		{"p", "8881", "/system/setSystemConfig", "POST"},
-		{"p", "8881", "/customer/customer", "POST"},
-		{"p", "8881", "/customer/customer", "PUT"},
-		{"p", "8881", "/customer/customer", "DELETE"},
-		{"p", "8881", "/customer/customer", "GET"},
-		{"p", "8881", "/customer/customerList", "GET"},
-		{"p", "9528", "/base/login", "POST"},
-		{"p", "9528", "/user/register", "POST"},
-		{"p", "9528", "/api/createApi", "POST"},
-		{"p", "9528", "/api/getApiList", "POST"},
-		{"p", "9528", "/api/getApiById", "POST"},
-		{"p", "9528", "/api/deleteApi", "POST"},
-		{"p", "9528", "/api/updateApi", "POST"},
-		{"p", "9528", "/api/getAllApis", "POST"},
-		{"p", "9528", "/authority/createAuthority", "POST"},
-		{"p", "9528", "/authority/deleteAuthority", "POST"},
-		{"p", "9528", "/authority/getAuthorityList", "POST"},
-		{"p", "9528", "/authority/setDataAuthority", "POST"},
-		{"p", "9528", "/menu/getMenu", "POST"},
-		{"p", "9528", "/menu/getMenuList", "POST"},
-		{"p", "9528", "/menu/addBaseMenu", "POST"},
-		{"p", "9528", "/menu/getBaseMenuTree", "POST"},
-		{"p", "9528", "/menu/addMenuAuthority", "POST"},
-		{"p", "9528", "/menu/getMenuAuthority", "POST"},
-		{"p", "9528", "/menu/deleteBaseMenu", "POST"},
-		{"p", "9528", "/menu/updateBaseMenu", "POST"},
-		{"p", "9528", "/menu/getBaseMenuById", "POST"},
-		{"p", "9528", "/user/changePassword", "POST"},
-		{"p", "9528", "/user/getUserList", "POST"},
-		{"p", "9528", "/user/setUserAuthority", "POST"},
-		{"p", "9528", "/fileUploadAndDownload/upload", "POST"},
-		{"p", "9528", "/fileUploadAndDownload/getFileList", "POST"},
-		{"p", "9528", "/fileUploadAndDownload/deleteFile", "POST"},
-		{"p", "9528", "/casbin/updateCasbin", "POST"},
-		{"p", "9528", "/casbin/getPolicyPathByAuthorityId", "POST"},
-		{"p", "9528", "/jwt/jsonInBlacklist", "POST"},
-		{"p", "9528", "/system/getSystemConfig", "POST"},
-		{"p", "9528", "/system/setSystemConfig", "POST"},
-		{"p", "9528", "/customer/customer", "POST"},
-		{"p", "9528", "/customer/customer", "PUT"},
-		{"p", "9528", "/customer/customer", "DELETE"},
-		{"p", "9528", "/customer/customer", "GET"},
-		{"p", "9528", "/customer/customerList", "GET"},
-		{"p", "9528", "/autoCode/createTemp", "POST"},
-	}
-	if tx.Table("casbin_rule").Create(&insert).Error != nil { // 遇到错误时回滚事务
-		tx.Rollback()
-	}
-	return tx.Commit().Error
-}
-
-func InitSysAuthority() (err error) {
-	tx := global.GVA_DB.Begin() // 开始事务
-	insert := []model.SysAuthority{
-		{CreatedAt: time.Now(), UpdatedAt: time.Now(), AuthorityId: "888", AuthorityName: "普通用户", ParentId: "0"},
-		{CreatedAt: time.Now(), UpdatedAt: time.Now(), AuthorityId: "8881", AuthorityName: "普通用户子角色", ParentId: "888"},
-		{CreatedAt: time.Now(), UpdatedAt: time.Now(), AuthorityId: "9528", AuthorityName: "测试角色", ParentId: "0"},
-	}
-	if tx.Create(&insert).Error != nil { // 遇到错误时回滚事务
-		tx.Rollback()
-	}
-	return tx.Commit().Error
-}
-
-func InitSysBaseMenus() (err error) {
-	tx := global.GVA_DB.Begin() // 开始事务
-	insert := []model.SysBaseMenu{
-		{Model: gorm.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: model.Meta{Title: "仪表盘", Icon: "setting"}},
-		{Model: gorm.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: model.Meta{Title: "关于我们", Icon: "info"}},
-		{Model: gorm.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: model.Meta{Title: "超级管理员", Icon: "user-solid"}},
-		{Model: gorm.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: model.Meta{Title: "角色管理", Icon: "s-custom"}},
-		{Model: gorm.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: model.Meta{Title: "菜单管理", Icon: "s-order", KeepAlive: true}},
-		{Model: gorm.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: model.Meta{Title: "api管理", Icon: "s-platform", KeepAlive: true}},
-		{Model: gorm.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: model.Meta{Title: "用户管理", Icon: "coordinate"}},
-		{Model: gorm.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: model.Meta{Title: "个人信息", Icon: "message-solid"}},
-		{Model: gorm.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: model.Meta{Title: "示例文件", Icon: "s-management"}},
-		{Model: gorm.Model{ID: 10, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, Hidden: false, ParentId: "9", Path: "table", Name: "table", Component: "view/example/table/table.vue", Sort: 1, Meta: model.Meta{Title: "表格示例", Icon: "s-order"}},
-		{Model: gorm.Model{ID: 11, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, Hidden: false, ParentId: "9", Path: "form", Name: "form", Component: "view/example/form/form.vue", Sort: 2, Meta: model.Meta{Title: "表单示例", Icon: "document"}},
-		{Model: gorm.Model{ID: 12, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, Hidden: false, ParentId: "9", Path: "rte", Name: "rte", Component: "view/example/rte/rte.vue", Sort: 3, Meta: model.Meta{Title: "富文本编辑器", Icon: "reading"}},
-		{Model: gorm.Model{ID: 13, 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: model.Meta{Title: "excel导入导出", Icon: "s-marketing"}},
-		{Model: gorm.Model{ID: 14, 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: model.Meta{Title: "上传下载", Icon: "upload"}},
-		{Model: gorm.Model{ID: 15, 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: model.Meta{Title: "断点续传", Icon: "upload"}},
-		{Model: gorm.Model{ID: 16, 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: model.Meta{Title: "客户列表(资源示例)", Icon: "s-custom"}},
-		{Model: gorm.Model{ID: 17, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, Hidden: false, ParentId: "0", Path: "systemTools", Name: "systemTools", Component: "view/systemTools/index.vue", Sort: 5, Meta: model.Meta{Title: "系统工具", Icon: "s-cooperation"}},
-		{Model: gorm.Model{ID: 18, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, Hidden: false, ParentId: "17", Path: "autoCode", Name: "autoCode", Component: "view/systemTools/autoCode/index.vue", Sort: 1, Meta: model.Meta{Title: "代码生成器", Icon: "cpu", KeepAlive: true}},
-		{Model: gorm.Model{ID: 19, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, Hidden: false, ParentId: "17", Path: "formCreate", Name: "formCreate", Component: "view/systemTools/formCreate/index.vue", Sort: 2, Meta: model.Meta{Title: "表单生成器", Icon: "magic-stick", KeepAlive: true}},
-		{Model: gorm.Model{ID: 20, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, Hidden: false, ParentId: "17", Path: "system", Name: "system", Component: "view/systemTools/system/system.vue", Sort: 3, Meta: model.Meta{Title: "系统配置", Icon: "s-operation"}},
-		{Model: gorm.Model{ID: 21, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, Hidden: false, ParentId: "0", Path: "iconList", Name: "iconList", Component: "view/iconList/index.vue", Sort: 2, Meta: model.Meta{Title: "图标集合", Icon: "star-on"}},
-		{Model: gorm.Model{ID: 22, 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: model.Meta{Title: "字典管理", Icon: "notebook-2"}},
-		{Model: gorm.Model{ID: 23, 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: model.Meta{Title: "字典详情", Icon: "s-order"}},
-		{Model: gorm.Model{ID: 24, 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: model.Meta{Title: "操作历史", Icon: "time"}},
-		{Model: gorm.Model{ID: 25, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, Hidden: false, ParentId: "9", Path: "simpleUploader", Name: "simpleUploader", Component: "view/example/simpleUploader/simpleUploader", Sort: 6, Meta: model.Meta{Title: "断点续传(插件版)", Icon: "upload"}},
-		{Model: gorm.Model{ID: 26, 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: model.Meta{Title: "官方网站", Icon: "s-home"}},
-		{Model: gorm.Model{ID: 27, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, ParentId: "0", Path: "state", Name: "state", Hidden: false, Component: "view/system/state.vue", Sort: 6, Meta: model.Meta{Title: "服务器状态", Icon: "cloudy"}},
-	}
-	if tx.Create(&insert).Error != nil { // 遇到错误时回滚事务
-		tx.Rollback()
-	}
-	return tx.Commit().Error
-}
-
-func InitAuthorityMenu() (err error) {
-	return 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`.`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
-}
-
-func InitSysDictionary() (err error) {
-	status := new(bool)
-	*status = true
-	tx := global.GVA_DB.Begin() // 开始事务
-	insert := []model.SysDictionary{
-		{Model: gorm.Model{ID: 1, CreatedAt: time.Now(), UpdatedAt: time.Now()}, Name: "性别", Type: "sex", Status: status, Desc: "性别字典"},
-		{Model: gorm.Model{ID: 2, CreatedAt: time.Now(), UpdatedAt: time.Now()}, Name: "数据库int类型", Type: "int", Status: status, Desc: "int类型对应的数据库类型"},
-		{Model: gorm.Model{ID: 3, CreatedAt: time.Now(), UpdatedAt: time.Now()}, Name: "数据库时间日期类型", Type: "time.Time", Status: status, Desc: "数据库时间日期类型"},
-		{Model: gorm.Model{ID: 4, CreatedAt: time.Now(), UpdatedAt: time.Now()}, Name: "数据库浮点型", Type: "float64", Status: status, Desc: "数据库浮点型"},
-		{Model: gorm.Model{ID: 5, CreatedAt: time.Now(), UpdatedAt: time.Now()}, Name: "数据库字符串", Type: "string", Status: status, Desc: "数据库字符串"},
-		{Model: gorm.Model{ID: 6, CreatedAt: time.Now(), UpdatedAt: time.Now()}, Name: "数据库bool类型", Type: "bool", Status: status, Desc: "数据库bool类型"},
-	}
-	if tx.Create(&insert).Error != nil { // 遇到错误时回滚事务
-		tx.Rollback()
-	}
-	return tx.Commit().Error
-}
-
-func InitSysAuthorityMenus() (err error) {
-	tx := global.GVA_DB.Begin() // 开始事务
-	insert := []SysAuthorityMenus{
-		{"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", 21},
-		{"888", 22},
-		{"888", 23},
-		{"888", 24},
-		{"888", 25},
-		{"888", 26},
-		{"888", 27},
-		{"8881", 1},
-		{"8881", 2},
-		{"8881", 8},
-		{"8881", 17},
-		{"8881", 18},
-		{"8881", 19},
-		{"8881", 20},
-		{"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", 13},
-		{"9528", 14},
-		{"9528", 15},
-		{"9528", 17},
-		{"9528", 18},
-		{"9528", 19},
-		{"9528", 20},
-	}
-	if tx.Table("sys_authority_menus").Create(&insert).Error != nil { // 遇到错误时回滚事务
-		tx.Rollback()
-	}
-	return tx.Commit().Error
-}
-
-func InitSysDataAuthorityId() (err error) {
-	tx := global.GVA_DB.Begin() // 开始事务
-	insert := []SysDataAuthorityId{
-		{"888", "888"},
-		{"888", "8881"},
-		{"888", "9528"},
-		{"9528", "8881"},
-		{"9528", "9528"},
-	}
-	if global.GVA_DB.Migrator().HasTable("sys_data_authority_ids") {
-		if tx.Table("sys_data_authority_ids").Create(&insert).Error != nil { // 遇到错误时回滚事务
-			tx.Rollback()
-		}
-		return tx.Commit().Error
-	}
-	if tx.Table("sys_data_authority_id").Create(&insert).Error != nil { // 遇到错误时回滚事务
-		tx.Rollback()
-	}
-	return tx.Commit().Error
-}
-
-func InitSysDictionaryDetail() (err error) {
-	status := new(bool)
-	*status = true
-	tx := global.GVA_DB.Begin() // 开始事务
-	insert := []model.SysDictionaryDetail{
-		{gorm.Model{ID: 1, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "smallint", 1, status, 1, 2},
-		{gorm.Model{ID: 2, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "mediumint", 2, status, 2, 2},
-		{gorm.Model{ID: 3, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "int", 3, status, 3, 2},
-		{gorm.Model{ID: 4, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "bigint", 4, status, 4, 2},
-		{gorm.Model{ID: 5, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "data", 0, status, 0, 3},
-		{gorm.Model{ID: 6, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "time", 1, status, 1, 3},
-		{gorm.Model{ID: 7, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "year", 2, status, 2, 3},
-		{gorm.Model{ID: 8, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "datetime", 3, status, 3, 3},
-		{gorm.Model{ID: 9, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "timestamp", 5, status, 5, 3},
-		{gorm.Model{ID: 10, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "float", 0, status, 0, 4},
-		{gorm.Model{ID: 11, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "double", 1, status, 1, 4},
-		{gorm.Model{ID: 12, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "decimal", 2, status, 2, 4},
-		{gorm.Model{ID: 13, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "char", 0, status, 0, 5},
-		{gorm.Model{ID: 14, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "varchar", 1, status, 1, 5},
-		{gorm.Model{ID: 15, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "tinyblob", 2, status, 2, 5},
-		{gorm.Model{ID: 16, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "tinytext", 3, status, 3, 5},
-		{gorm.Model{ID: 17, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "text", 4, status, 4, 5},
-		{gorm.Model{ID: 18, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "blob", 5, status, 5, 5},
-		{gorm.Model{ID: 19, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "mediumblob", 6, status, 6, 5},
-		{gorm.Model{ID: 20, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "mediumtext", 7, status, 7, 5},
-		{gorm.Model{ID: 21, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "longblob", 8, status, 8, 5},
-		{gorm.Model{ID: 22, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "longtext", 9, status, 9, 5},
-		{gorm.Model{ID: 23, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "tinyint", 0, status, 0, 6},
-	}
-	if tx.Create(&insert).Error != nil { // 遇到错误时回滚事务
-		tx.Rollback()
-	}
-	return tx.Commit().Error
-}
-
-func InitExaFileUploadAndDownload() (err error) {
-	tx := global.GVA_DB.Begin() // 开始事务
-	insert := []model.ExaFileUploadAndDownload{
-		{gorm.Model{ID: 1, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "10.png", "http://qmplusimg.henrongyi.top/gvalogo.png", "png", "158787308910.png"},
-		{gorm.Model{ID: 2, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "logo.png", "http://qmplusimg.henrongyi.top/1576554439myAvatar.png", "png", "1587973709logo.png"},
-	}
-	if tx.Create(&insert).Error != nil { // 遇到错误时回滚事务
-		tx.Rollback()
-	}
-	return tx.Commit().Error
-}
-
-func InitData() {
-	var err error
-	err = InitSysApi()
-	err = InitSysUser()
-	err = InitExaCustomer()
-	err = InitCasbinModel()
-	err = InitSysAuthority()
-	err = InitSysBaseMenus()
-	err = InitAuthorityMenu()
-	err = InitSysDictionary()
-	err = InitSysAuthorityMenus()
-	err = InitSysDataAuthorityId()
-	err = InitSysDictionaryDetail()
-	err = InitExaFileUploadAndDownload()
-	if err != nil {
-		global.GVA_LOG.Error("initialize data failed", zap.Any("err", err))
-	}
-	global.GVA_LOG.Info("initialize data success")
-}

+ 15 - 76
server/initialize/gorm.go

@@ -5,33 +5,23 @@ import (
 	"gin-vue-admin/model"
 	"go.uber.org/zap"
 	"gorm.io/driver/mysql"
-	"gorm.io/driver/postgres"
-	"gorm.io/driver/sqlserver"
 	"gorm.io/gorm"
 	"gorm.io/gorm/logger"
 	"os"
 )
 
-var err error
-
 // Gorm 初始化数据库并产生数据库全局变量
-func Gorm() {
+func Gorm() *gorm.DB {
 	switch global.GVA_CONFIG.System.DbType {
 	case "mysql":
-		GormMysql()
-	case "postgresql":
-		GormPostgreSql()
-	//case "sqlite": // sqlite需要gcc支持 windows用户需要自行安装gcc 如需使用打开注释即可
-	//	GormSqlite()
-	case "sqlserver":
-		GormSqlServer()
+		return GormMysql()
 	default:
-		GormMysql()
+		return GormMysql()
 	}
 }
 
-// GormDBTables 注册数据库表专用
-func GormDBTables(db *gorm.DB) {
+// MysqlTables 注册数据库表专用
+func MysqlTables(db *gorm.DB) {
 	err := db.AutoMigrate(
 		model.SysUser{},
 		model.SysAuthority{},
@@ -58,7 +48,7 @@ func GormDBTables(db *gorm.DB) {
 }
 
 // GormMysql 初始化Mysql数据库
-func GormMysql() {
+func GormMysql() *gorm.DB {
 	m := global.GVA_CONFIG.Mysql
 	dsn := m.Username + ":" + m.Password + "@tcp(" + m.Path + ")/" + m.Dbname + "?" + m.Config
 	mysqlConfig := mysql.Config{
@@ -69,80 +59,29 @@ func GormMysql() {
 		DontSupportRenameColumn:   true,  // 用 `change` 重命名列,MySQL 8 之前的数据库和 MariaDB 不支持重命名列
 		SkipInitializeWithVersion: false, // 根据版本自动配置
 	}
-	gormConfig := config(m.LogMode)
-	if global.GVA_DB, err = gorm.Open(mysql.New(mysqlConfig), gormConfig); err != nil {
+	if db, err := gorm.Open(mysql.New(mysqlConfig), gormConfig(m.LogMode)); err != nil {
 		global.GVA_LOG.Error("MySQL启动异常", zap.Any("err", err))
 		os.Exit(0)
+		return nil
 	} else {
-		GormDBTables(global.GVA_DB)
-		sqlDB, _ := global.GVA_DB.DB()
+		sqlDB, _ := db.DB()
 		sqlDB.SetMaxIdleConns(m.MaxIdleConns)
 		sqlDB.SetMaxOpenConns(m.MaxOpenConns)
+		return db
 	}
 }
 
-// GormPostgreSql 初始化PostgreSql数据库
-func GormPostgreSql() {
-	p := global.GVA_CONFIG.Postgresql
-	dsn := "host="+ p.Host + " user=" + p.Username + " password=" + p.Password + " dbname=" + p.Dbname + " port=" + p.Port + " " + p.Config
-	postgresConfig := postgres.Config{
-		DSN:                  dsn,                    // DSN data source name
-		PreferSimpleProtocol: p.PreferSimpleProtocol, // 禁用隐式 prepared statement
-	}
-	gormConfig := config(p.Logger)
-	if global.GVA_DB, err = gorm.Open(postgres.New(postgresConfig), gormConfig); err != nil {
-		global.GVA_LOG.Error("PostgreSql启动异常", zap.Any("err", err))
-		os.Exit(0)
-	} else {
-		GormDBTables(global.GVA_DB)
-		sqlDB, _ := global.GVA_DB.DB()
-		sqlDB.SetMaxIdleConns(p.MaxIdleConns)
-		sqlDB.SetMaxOpenConns(p.MaxOpenConns)
-	}
-}
-
-// GormSqlite 初始化Sqlite数据库 sqlite需要gcc支持 windows用户需要自行安装gcc 如需使用打开注释即可
-//func GormSqlite() {
-//	s := global.GVA_CONFIG.Sqlite
-//	gormConfig := config(s.Logger)
-//	if global.GVA_DB, err = gorm.Open(sqlite.Open(s.Path), gormConfig); err != nil {
-//		global.GVA_LOG.Error("Sqlite启动异常", zap.Any("err", err))
-//		os.Exit(0)
-//	} else {
-//      GormDBTables(global.GVA_DB)
-//		sqlDB, _ := global.GVA_DB.DB()
-//		sqlDB.SetMaxIdleConns(s.MaxIdleConns)
-//		sqlDB.SetMaxOpenConns(s.MaxOpenConns)
-//	}
-//}
-
-// GormSqlServer 初始化SqlServer数据库
-func GormSqlServer() {
-	ss := global.GVA_CONFIG.Sqlserver
-	dsn := "sqlserver://" + ss.Username + ":" + ss.Password + "@" + ss.Path + "?database=" + ss.Dbname
-	if global.GVA_DB, err = gorm.Open(sqlserver.Open(dsn), &gorm.Config{}); err != nil {
-		global.GVA_LOG.Error("SqlServer启动异常", zap.Any("err", err))
-		os.Exit(0)
-	} else {
-		GormDBTables(global.GVA_DB)
-		sqlDB, _ := global.GVA_DB.DB()
-		sqlDB.SetMaxIdleConns(ss.MaxIdleConns)
-		sqlDB.SetMaxOpenConns(ss.MaxOpenConns)
-	}
-}
-
-// config 根据配置决定是否开启日志
-func config(mod bool) (c *gorm.Config) {
+// gormConfig 根据配置决定是否开启日志
+func gormConfig(mod bool) *gorm.Config {
 	if mod {
-		c = &gorm.Config{
+		return &gorm.Config{
 			Logger:                                   logger.Default.LogMode(logger.Info),
 			DisableForeignKeyConstraintWhenMigrating: true,
 		}
 	} else {
-		c = &gorm.Config{
+		return &gorm.Config{
 			Logger:                                   logger.Default.LogMode(logger.Silent),
 			DisableForeignKeyConstraintWhenMigrating: true,
 		}
 	}
-	return
-}
+}

+ 4 - 5
server/main.go

@@ -3,7 +3,6 @@ package main
 import (
 	"gin-vue-admin/core"
 	"gin-vue-admin/global"
-	"gin-vue-admin/gva/init_data"
 	"gin-vue-admin/initialize"
 )
 
@@ -15,10 +14,10 @@ import (
 // @name x-token
 // @BasePath /
 func main() {
-	initialize.Gorm()
-	if global.GVA_CONFIG.System.NeedInitData {
-		init_data.InitData() // 通过配置文件初始化数据 默认为 false 首次运行需要将 ./config.yaml中 system下的 need-init-data 修改为true
-	}
+	global.GVA_VP = core.Viper()          // 初始化Viper
+	global.GVA_LOG = core.Zap()           // 初始化zap日志库
+	global.GVA_DB = initialize.Gorm()     // gorm连接数据库
+	initialize.MysqlTables(global.GVA_DB) // 初始化表
 	// 程序结束前关闭数据库链接
 	db, _ := global.GVA_DB.DB()
 	defer db.Close()