refactor:
- source 初始化数据 new 实现 - service mysql 与 pgsql 分开实现 - 代码备注优化
This commit is contained in:
126
server/source/system/api.go
Normal file
126
server/source/system/api.go
Normal file
@@ -0,0 +1,126 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/global"
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/model/system"
|
||||
"github.com/pkg/errors"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
var Api = new(api)
|
||||
|
||||
type api struct{}
|
||||
|
||||
func (a *api) TableName() string {
|
||||
return "sys_apis"
|
||||
}
|
||||
|
||||
func (a *api) Initialize() error {
|
||||
entities := []system.SysApi{{ApiGroup: "base", Method: "POST", Path: "/base/login", Description: "用户登录(必选)"},
|
||||
|
||||
{ApiGroup: "jwt", Method: "POST", Path: "/jwt/jsonInBlacklist", Description: "jwt加入黑名单(退出,必选)"},
|
||||
|
||||
{ApiGroup: "系统用户", Method: "DELETE", Path: "/user/deleteUser", Description: "删除用户"},
|
||||
{ApiGroup: "系统用户", Method: "POST", Path: "/user/register", Description: "用户注册(必选)"},
|
||||
{ApiGroup: "系统用户", Method: "user", Path: "/user/getUserList", Description: "获取用户列表"},
|
||||
{ApiGroup: "系统用户", Method: "PUT", Path: "/user/setUserInfo", Description: "设置用户信息(必选)"},
|
||||
{ApiGroup: "系统用户", Method: "GET", Path: "/user/getUserInfo", Description: "获取自身信息(必选)"},
|
||||
{ApiGroup: "系统用户", Method: "POST", Path: "/user/setUserAuthorities", Description: "设置权限组"},
|
||||
{ApiGroup: "系统用户", Method: "POST", Path: "/user/changePassword", Description: "修改密码(建(选择)"},
|
||||
{ApiGroup: "系统用户", Method: "POST", Path: "/user/setUserAuthority", Description: "修改用户角色(必选)"},
|
||||
|
||||
{ApiGroup: "api", Method: "POST", Path: "/api/createApi", Description: "创建api"},
|
||||
{ApiGroup: "api", Method: "POST", Path: "/api/deleteApi", Description: "删除Api"},
|
||||
{ApiGroup: "api", Method: "POST", Path: "/api/updateApi", Description: "更新Api"},
|
||||
{ApiGroup: "api", Method: "POST", Path: "/api/getApiList", Description: "获取api列表"},
|
||||
{ApiGroup: "api", Method: "POST", Path: "/api/getAllApis", Description: "获取所有api"},
|
||||
{ApiGroup: "api", Method: "POST", Path: "/api/getApiById", Description: "获取api详细信息"},
|
||||
{ApiGroup: "api", Method: "DELETE", Path: "/api/deleteApisByIds", Description: "批量删除api"},
|
||||
|
||||
{ApiGroup: "角色", Method: "POST", Path: "/authority/copyAuthority", Description: "拷贝角色"},
|
||||
{ApiGroup: "角色", Method: "POST", Path: "/authority/createAuthority", Description: "创建角色"},
|
||||
{ApiGroup: "角色", Method: "POST", Path: "/authority/deleteAuthority", Description: "删除角色"},
|
||||
{ApiGroup: "角色", Method: "PUT", Path: "/authority/updateAuthority", Description: "更新角色信息"},
|
||||
{ApiGroup: "角色", Method: "POST", Path: "/authority/getAuthorityList", Description: "获取角色列表"},
|
||||
{ApiGroup: "角色", Method: "POST", Path: "/authority/setDataAuthority", Description: "设置角色资源权限"},
|
||||
|
||||
{ApiGroup: "casbin", Method: "POST", Path: "/casbin/updateCasbin", Description: "更改角色api权限"},
|
||||
{ApiGroup: "casbin", Method: "POST", Path: "/casbin/getPolicyPathByAuthorityId", Description: "获取权限列表"},
|
||||
|
||||
{ApiGroup: "菜单", Method: "POST", Path: "/menu/addBaseMenu", Description: "新增菜单"},
|
||||
{ApiGroup: "菜单", Method: "POST", Path: "/menu/getMenu", Description: "获取菜单树(必选)"},
|
||||
{ApiGroup: "菜单", Method: "POST", Path: "/menu/deleteBaseMenu", Description: "删除菜单"},
|
||||
{ApiGroup: "菜单", Method: "POST", Path: "/menu/updateBaseMenu", Description: "更新菜单"},
|
||||
{ApiGroup: "菜单", Method: "POST", Path: "/menu/getBaseMenuById", Description: "根据id获取菜单"},
|
||||
{ApiGroup: "菜单", Method: "POST", Path: "/menu/getMenuList", Description: "分页获取基础menu列表"},
|
||||
{ApiGroup: "菜单", Method: "POST", Path: "/menu/getBaseMenuTree", Description: "获取用户动态路由"},
|
||||
{ApiGroup: "菜单", Method: "POST", Path: "/menu/getMenuAuthority", Description: "获取指定角色menu"},
|
||||
{ApiGroup: "菜单", Method: "POST", Path: "/menu/addMenuAuthority", Description: "增加menu和角色关联关系"},
|
||||
|
||||
{ApiGroup: "文件上传与下载", Method: "POST", Path: "/fileUploadAndDownload/upload", Description: "文件上传示例"},
|
||||
{ApiGroup: "文件上传与下载", Method: "POST", Path: "/fileUploadAndDownload/deleteFile", Description: "删除文件"},
|
||||
{ApiGroup: "文件上传与下载", Method: "POST", Path: "/fileUploadAndDownload/getFileList", Description: "获取上传文件列表"},
|
||||
|
||||
{ApiGroup: "系统服务", Method: "POST", Path: "/system/getServerInfo", Description: "获取服务器信息"},
|
||||
{ApiGroup: "系统服务", Method: "POST", Path: "/system/getSystemConfig", Description: "获取配置文件内容"},
|
||||
{ApiGroup: "系统服务", Method: "POST", Path: "/system/setSystemConfig", Description: "设置配置文件内容"},
|
||||
|
||||
{ApiGroup: "客户", Method: "PUT", Path: "/customer/customer", Description: "更新客户"},
|
||||
{ApiGroup: "客户", Method: "POST", Path: "/customer/customer", Description: "创建客户"},
|
||||
{ApiGroup: "客户", Method: "DELETE", Path: "/customer/customer", Description: "删除客户"},
|
||||
{ApiGroup: "客户", Method: "GET", Path: "/customer/customer", Description: "获取单一客户"},
|
||||
{ApiGroup: "客户", Method: "GET", Path: "/customer/customerList", Description: "获取客户列表"},
|
||||
|
||||
{ApiGroup: "代码生成器", Method: "GET", Path: "/autoCode/getDB", Description: "获取所有数据库"},
|
||||
{ApiGroup: "代码生成器", Method: "GET", Path: "/autoCode/getTables", Description: "获取数据库表"},
|
||||
{ApiGroup: "代码生成器", Method: "POST", Path: "/autoCode/createTemp", Description: "自动化代码"},
|
||||
{ApiGroup: "代码生成器", Method: "POST", Path: "/autoCode/preview", Description: "预览自动化代码"},
|
||||
{ApiGroup: "代码生成器", Method: "GET", Path: "/autoCode/getColumn", Description: "获取所选table的所有字段"},
|
||||
|
||||
{ApiGroup: "代码生成器历史", Method: "POST", Path: "/autoCode/getMeta", Description: "获取meta信息"},
|
||||
{ApiGroup: "代码生成器历史", Method: "POST", Path: "/autoCode/rollback", Description: "回滚自动生成代码"},
|
||||
{ApiGroup: "代码生成器历史", Method: "POST", Path: "/autoCode/getSysHistory", Description: "查询回滚记录"},
|
||||
{ApiGroup: "代码生成器历史", Method: "POST", Path: "/autoCode/delSysHistory", Description: "删除回滚记录"},
|
||||
|
||||
{ApiGroup: "系统字典详情", Method: "PUT", Path: "/sysDictionaryDetail/updateSysDictionaryDetail", Description: "更新字典内容"},
|
||||
{ApiGroup: "系统字典详情", Method: "POST", Path: "/sysDictionaryDetail/createSysDictionaryDetail", Description: "新增字典内容"},
|
||||
{ApiGroup: "系统字典详情", Method: "DELETE", Path: "/sysDictionaryDetail/deleteSysDictionaryDetail", Description: "删除字典内容"},
|
||||
{ApiGroup: "系统字典详情", Method: "GET", Path: "/sysDictionaryDetail/findSysDictionaryDetail", Description: "根据ID获取字典内容"},
|
||||
{ApiGroup: "系统字典详情", Method: "GET", Path: "/sysDictionaryDetail/getSysDictionaryDetailList", Description: "获取字典内容列表"},
|
||||
|
||||
{ApiGroup: "系统字典", Method: "POST", Path: "/sysDictionary/createSysDictionary", Description: "新增字典"},
|
||||
{ApiGroup: "系统字典", Method: "DELETE", Path: "/sysDictionary/deleteSysDictionary", Description: "删除字典"},
|
||||
{ApiGroup: "系统字典", Method: "PUT", Path: "/sysDictionary/updateSysDictionary", Description: "更新字典"},
|
||||
{ApiGroup: "系统字典", Method: "GET", Path: "/sysDictionary/findSysDictionary", Description: "根据ID获取字典"},
|
||||
{ApiGroup: "系统字典", Method: "GET", Path: "/sysDictionary/getSysDictionaryList", Description: "获取字典列表"},
|
||||
|
||||
{ApiGroup: "操作记录", Method: "POST", Path: "/sysOperationRecord/createSysOperationRecord", Description: "新增操作记录"},
|
||||
{ApiGroup: "操作记录", Method: "删除操作记录", Path: "/sysOperationRecord/deleteSysOperationRecord", Description: "DELETE"},
|
||||
{ApiGroup: "操作记录", Method: "GET", Path: "/sysOperationRecord/findSysOperationRecord", Description: "根据ID获取操作记录"},
|
||||
{ApiGroup: "操作记录", Method: "GET", Path: "/sysOperationRecord/getSysOperationRecordList", Description: "获取操作记录列表"},
|
||||
{ApiGroup: "操作记录", Method: "DELETE", Path: "/sysOperationRecord/deleteSysOperationRecordByIds", Description: "批量删除操作历史"},
|
||||
|
||||
{ApiGroup: "断点续传(插件版)", Method: "POST", Path: "/simpleUploader/upload", Description: "插件版分片上传"},
|
||||
{ApiGroup: "断点续传(插件版)", Method: "GET", Path: "/simpleUploader/checkFileMd5", Description: "文件完整度验证"},
|
||||
{ApiGroup: "断点续传(插件版)", Method: "GET", Path: "/simpleUploader/mergeFileMd5", Description: "上传完成合并文件"},
|
||||
|
||||
{ApiGroup: "email", Method: "POST", Path: "/email/emailTest", Description: "发送测试邮件"},
|
||||
{ApiGroup: "email", Method: "POST", Path: "/email/emailSend", Description: "发送邮件示例"},
|
||||
|
||||
{ApiGroup: "excel", Method: "POST", Path: "/excel/importExcel", Description: "导入excel"},
|
||||
{ApiGroup: "excel", Method: "GET", Path: "/excel/loadExcel", Description: "下载excel"},
|
||||
{ApiGroup: "excel", Method: "POST", Path: "/excel/exportExcel", Description: "导出excel"},
|
||||
{ApiGroup: "excel", Method: "GET", Path: "/excel/downloadTemplate", Description: "下载excel模板"},
|
||||
}
|
||||
if err := global.GVA_DB.Create(&entities).Error; err != nil {
|
||||
return errors.Wrap(err, a.TableName()+"表数据初始化失败!")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *api) CheckDataExist() bool {
|
||||
if errors.Is(global.GVA_DB.Where("path = ? AND method = ?", "/excel/downloadTemplate", "GET").First(&system.SysApi{}).Error, gorm.ErrRecordNotFound) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
95
server/source/system/authorities_menus.go
Normal file
95
server/source/system/authorities_menus.go
Normal file
@@ -0,0 +1,95 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/global"
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/model/system"
|
||||
"github.com/pkg/errors"
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/schema"
|
||||
"reflect"
|
||||
)
|
||||
|
||||
var AuthoritiesMenus = new(authoritiesMenus)
|
||||
|
||||
type authoritiesMenus struct{}
|
||||
|
||||
func (a *authoritiesMenus) TableName() string {
|
||||
var entity AuthorityMenus
|
||||
return entity.TableName()
|
||||
}
|
||||
|
||||
func (a *authoritiesMenus) Initialize() error {
|
||||
entities := []AuthorityMenus{
|
||||
{BaseMenuId: 1, AuthorityId: "888"},
|
||||
{BaseMenuId: 2, AuthorityId: "888"},
|
||||
{BaseMenuId: 3, AuthorityId: "888"},
|
||||
{BaseMenuId: 4, AuthorityId: "888"},
|
||||
{BaseMenuId: 5, AuthorityId: "888"},
|
||||
{BaseMenuId: 6, AuthorityId: "888"},
|
||||
{BaseMenuId: 7, AuthorityId: "888"},
|
||||
{BaseMenuId: 8, AuthorityId: "888"},
|
||||
{BaseMenuId: 9, AuthorityId: "888"},
|
||||
{BaseMenuId: 10, AuthorityId: "888"},
|
||||
{BaseMenuId: 11, AuthorityId: "888"},
|
||||
{BaseMenuId: 12, AuthorityId: "888"},
|
||||
{BaseMenuId: 13, AuthorityId: "888"},
|
||||
{BaseMenuId: 14, AuthorityId: "888"},
|
||||
{BaseMenuId: 15, AuthorityId: "888"},
|
||||
{BaseMenuId: 16, AuthorityId: "888"},
|
||||
{BaseMenuId: 17, AuthorityId: "888"},
|
||||
{BaseMenuId: 18, AuthorityId: "888"},
|
||||
{BaseMenuId: 19, AuthorityId: "888"},
|
||||
{BaseMenuId: 20, AuthorityId: "888"},
|
||||
{BaseMenuId: 22, AuthorityId: "888"},
|
||||
{BaseMenuId: 23, AuthorityId: "888"},
|
||||
{BaseMenuId: 24, AuthorityId: "888"},
|
||||
{BaseMenuId: 25, AuthorityId: "888"},
|
||||
|
||||
{BaseMenuId: 1, AuthorityId: "8881"},
|
||||
{BaseMenuId: 2, AuthorityId: "8881"},
|
||||
{BaseMenuId: 8, AuthorityId: "8881"},
|
||||
|
||||
{BaseMenuId: 1, AuthorityId: "9528"},
|
||||
{BaseMenuId: 2, AuthorityId: "9528"},
|
||||
{BaseMenuId: 3, AuthorityId: "9528"},
|
||||
{BaseMenuId: 4, AuthorityId: "9528"},
|
||||
{BaseMenuId: 5, AuthorityId: "9528"},
|
||||
{BaseMenuId: 6, AuthorityId: "9528"},
|
||||
{BaseMenuId: 7, AuthorityId: "9528"},
|
||||
{BaseMenuId: 8, AuthorityId: "9528"},
|
||||
{BaseMenuId: 9, AuthorityId: "9528"},
|
||||
{BaseMenuId: 10, AuthorityId: "9528"},
|
||||
{BaseMenuId: 11, AuthorityId: "9528"},
|
||||
{BaseMenuId: 12, AuthorityId: "9528"},
|
||||
{BaseMenuId: 14, AuthorityId: "9528"},
|
||||
{BaseMenuId: 15, AuthorityId: "9528"},
|
||||
{BaseMenuId: 16, AuthorityId: "9528"},
|
||||
{BaseMenuId: 17, AuthorityId: "9528"},
|
||||
}
|
||||
if err := global.GVA_DB.Create(&entities).Error; err != nil {
|
||||
return errors.Wrap(err, a.TableName()+"表数据初始化失败!")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *authoritiesMenus) CheckDataExist() bool {
|
||||
if errors.Is(global.GVA_DB.Where("menu_id = ? AND authority_id = ?", 17, "9528").First(&AuthorityMenus{}).Error, gorm.ErrRecordNotFound) { // 判断是否存在数据
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
type AuthorityMenus struct {
|
||||
AuthorityId string `gorm:"column:sys_authority_authority_id"`
|
||||
BaseMenuId uint `gorm:"column:sys_base_menu_id"`
|
||||
}
|
||||
|
||||
func (a *AuthorityMenus) TableName() string {
|
||||
var entity system.SysAuthority
|
||||
types := reflect.TypeOf(entity)
|
||||
if s, o := types.FieldByName("SysBaseMenus"); o {
|
||||
m1 := schema.ParseTagSetting(s.Tag.Get("gorm"), ";")
|
||||
return m1["MANY2MANY"]
|
||||
}
|
||||
return ""
|
||||
}
|
35
server/source/system/authority.go
Normal file
35
server/source/system/authority.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/global"
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/model/system"
|
||||
"github.com/pkg/errors"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
var Authority = new(authority)
|
||||
|
||||
type authority struct{}
|
||||
|
||||
func (a *authority) TableName() string {
|
||||
return "sys_authorities"
|
||||
}
|
||||
|
||||
func (a *authority) Initialize() error {
|
||||
entities := []system.SysAuthority{
|
||||
{AuthorityId: "888", AuthorityName: "普通用户", ParentId: "0", DefaultRouter: "dashboard"},
|
||||
{AuthorityId: "9528", AuthorityName: "测试角色", ParentId: "0", DefaultRouter: "dashboard"},
|
||||
{AuthorityId: "8881", AuthorityName: "普通用户子角色", ParentId: "888", DefaultRouter: "dashboard"},
|
||||
}
|
||||
if err := global.GVA_DB.Create(&entities).Error; err != nil {
|
||||
return errors.Wrapf(err, "%s表数据初始化失败!", a.TableName())
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *authority) CheckDataExist() bool {
|
||||
if errors.Is(global.GVA_DB.Where("authority_id = ?", "8881").First(&system.SysAuthority{}).Error, gorm.ErrRecordNotFound) { // 判断是否存在数据
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
208
server/source/system/casbin.go
Normal file
208
server/source/system/casbin.go
Normal file
@@ -0,0 +1,208 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
adapter "github.com/casbin/gorm-adapter/v3"
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/global"
|
||||
"github.com/pkg/errors"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
var Casbin = new(casbin)
|
||||
|
||||
type casbin struct{}
|
||||
|
||||
func (c *casbin) TableName() string {
|
||||
var entity adapter.CasbinRule
|
||||
return entity.TableName()
|
||||
}
|
||||
|
||||
func (c *casbin) Initialize() error {
|
||||
entities := []adapter.CasbinRule{
|
||||
{PType: "p", V0: "888", V1: "POST", V2: "/base/login"},
|
||||
{PType: "p", V0: "888", V1: "POST", V2: "/user/register"},
|
||||
|
||||
{PType: "p", V0: "888", V1: "POST", V2: "/api/createApi"},
|
||||
{PType: "p", V0: "888", V1: "POST", V2: "/api/getApiList"},
|
||||
{PType: "p", V0: "888", V1: "POST", V2: "/api/getApiById"},
|
||||
{PType: "p", V0: "888", V1: "POST", V2: "/api/deleteApi"},
|
||||
{PType: "p", V0: "888", V1: "POST", V2: "/api/updateApi"},
|
||||
{PType: "p", V0: "888", V1: "POST", V2: "/api/getAllApis"},
|
||||
{PType: "p", V0: "888", V1: "DELETE", V2: "/api/deleteApisByIds"},
|
||||
|
||||
{PType: "p", V0: "888", V1: "POST", V2: "/authority/copyAuthority"},
|
||||
{PType: "p", V0: "888", V1: "PUT", V2: "/authority/updateAuthority"},
|
||||
{PType: "p", V0: "888", V1: "POST", V2: "/authority/createAuthority"},
|
||||
{PType: "p", V0: "888", V1: "POST", V2: "/authority/deleteAuthority"},
|
||||
{PType: "p", V0: "888", V1: "POST", V2: "/authority/getAuthorityList"},
|
||||
{PType: "p", V0: "888", V1: "POST", V2: "/authority/setDataAuthority"},
|
||||
|
||||
{PType: "p", V0: "888", V1: "POST", V2: "/menu/getMenu"},
|
||||
{PType: "p", V0: "888", V1: "POST", V2: "/menu/getMenuList"},
|
||||
{PType: "p", V0: "888", V1: "POST", V2: "/menu/addBaseMenu"},
|
||||
{PType: "p", V0: "888", V1: "POST", V2: "/menu/getBaseMenuTree"},
|
||||
{PType: "p", V0: "888", V1: "POST", V2: "/menu/addMenuAuthority"},
|
||||
{PType: "p", V0: "888", V1: "POST", V2: "/menu/getMenuAuthority"},
|
||||
{PType: "p", V0: "888", V1: "POST", V2: "/menu/deleteBaseMenu"},
|
||||
{PType: "p", V0: "888", V1: "POST", V2: "/menu/updateBaseMenu"},
|
||||
{PType: "p", V0: "888", V1: "POST", V2: "/menu/getBaseMenuById"},
|
||||
|
||||
{PType: "p", V0: "888", V1: "GET", V2: "/user/getUserInfo"},
|
||||
{PType: "p", V0: "888", V1: "PUT", V2: "/user/setUserInfo"},
|
||||
{PType: "p", V0: "888", V1: "POST", V2: "/user/getUserList"},
|
||||
{PType: "p", V0: "888", V1: "DELETE", V2: "/user/deleteUser"},
|
||||
{PType: "p", V0: "888", V1: "POST", V2: "/user/changePassword"},
|
||||
{PType: "p", V0: "888", V1: "POST", V2: "/user/setUserAuthority"},
|
||||
{PType: "p", V0: "888", V1: "POST", V2: "/user/setUserAuthorities"},
|
||||
|
||||
{PType: "p", V0: "888", V1: "POST", V2: "/fileUploadAndDownload/upload"},
|
||||
{PType: "p", V0: "888", V1: "POST", V2: "/fileUploadAndDownload/deleteFile"},
|
||||
{PType: "p", V0: "888", V1: "POST", V2: "/fileUploadAndDownload/getFileList"},
|
||||
|
||||
{PType: "p", V0: "888", V1: "POST", V2: "/casbin/updateCasbin"},
|
||||
{PType: "p", V0: "888", V1: "POST", V2: "/casbin/getPolicyPathByAuthorityId"},
|
||||
|
||||
{PType: "p", V0: "888", V1: "POST", V2: "/jwt/jsonInBlacklist"},
|
||||
|
||||
{PType: "p", V0: "888", V1: "POST", V2: "/system/getSystemConfig"},
|
||||
{PType: "p", V0: "888", V1: "POST", V2: "/system/setSystemConfig"},
|
||||
{PType: "p", V0: "888", V1: "POST", V2: "/system/getServerInfo"},
|
||||
|
||||
{PType: "p", V0: "888", V1: "GET", V2: "/customer/customer"},
|
||||
{PType: "p", V0: "888", V1: "PUT", V2: "/customer/customer"},
|
||||
{PType: "p", V0: "888", V1: "POST", V2: "/customer/customer"},
|
||||
{PType: "p", V0: "888", V1: "DELETE", V2: "/customer/customer"},
|
||||
{PType: "p", V0: "888", V1: "GET", V2: "/customer/customerList"},
|
||||
|
||||
{PType: "p", V0: "888", V1: "GET", V2: "/autoCode/getDB"},
|
||||
{PType: "p", V0: "888", V1: "POST", V2: "/autoCode/getMeta"},
|
||||
{PType: "p", V0: "888", V1: "POST", V2: "/autoCode/preview"},
|
||||
{PType: "p", V0: "888", V1: "GET", V2: "/autoCode/getTables"},
|
||||
{PType: "p", V0: "888", V1: "GET", V2: "/autoCode/getColumn"},
|
||||
{PType: "p", V0: "888", V1: "POST", V2: "/autoCode/rollback"},
|
||||
{PType: "p", V0: "888", V1: "POST", V2: "/autoCode/createTemp"},
|
||||
{PType: "p", V0: "888", V1: "POST", V2: "/autoCode/delSysHistory"},
|
||||
{PType: "p", V0: "888", V1: "POST", V2: "/autoCode/getSysHistory"},
|
||||
|
||||
{PType: "p", V0: "888", V1: "GET", V2: "/sysDictionaryDetail/findSysDictionaryDetail"},
|
||||
{PType: "p", V0: "888", V1: "PUT", V2: "/sysDictionaryDetail/updateSysDictionaryDetail"},
|
||||
{PType: "p", V0: "888", V1: "POST", V2: "/sysDictionaryDetail/createSysDictionaryDetail"},
|
||||
{PType: "p", V0: "888", V1: "GET", V2: "/sysDictionaryDetail/getSysDictionaryDetailList"},
|
||||
{PType: "p", V0: "888", V1: "DELETE", V2: "/sysDictionaryDetail/deleteSysDictionaryDetail"},
|
||||
|
||||
{PType: "p", V0: "888", V1: "GET", V2: "/sysDictionary/findSysDictionary"},
|
||||
{PType: "p", V0: "888", V1: "PUT", V2: "/sysDictionary/updateSysDictionary"},
|
||||
{PType: "p", V0: "888", V1: "GET", V2: "/sysDictionary/getSysDictionaryList"},
|
||||
{PType: "p", V0: "888", V1: "POST", V2: "/sysDictionary/createSysDictionary"},
|
||||
{PType: "p", V0: "888", V1: "DELETE", V2: "/sysDictionary/deleteSysDictionary"},
|
||||
|
||||
{PType: "p", V0: "888", V1: "GET", V2: "/sysOperationRecord/findSysOperationRecord"},
|
||||
{PType: "p", V0: "888", V1: "PUT", V2: "/sysOperationRecord/updateSysOperationRecord"},
|
||||
{PType: "p", V0: "888", V1: "POST", V2: "/sysOperationRecord/createSysOperationRecord"},
|
||||
{PType: "p", V0: "888", V1: "GET", V2: "/sysOperationRecord/getSysOperationRecordList"},
|
||||
{PType: "p", V0: "888", V1: "DELETE", V2: "/sysOperationRecord/deleteSysOperationRecord"},
|
||||
{PType: "p", V0: "888", V1: "DELETE", V2: "/sysOperationRecord/deleteSysOperationRecordByIds"},
|
||||
|
||||
{PType: "p", V0: "888", V1: "POST", V2: "/email/emailTest"},
|
||||
|
||||
{PType: "p", V0: "888", V1: "POST", V2: "/simpleUploader/upload"},
|
||||
{PType: "p", V0: "888", V1: "GET", V2: "/simpleUploader/checkFileMd5"},
|
||||
{PType: "p", V0: "888", V1: "GET", V2: "/simpleUploader/mergeFileMd5"},
|
||||
|
||||
{PType: "p", V0: "888", V1: "POST", V2: "/excel/importExcel"},
|
||||
{PType: "p", V0: "888", V1: "GET", V2: "/excel/loadExcel"},
|
||||
{PType: "p", V0: "888", V1: "POST", V2: "/excel/exportExcel"},
|
||||
{PType: "p", V0: "888", V1: "GET", V2: "/excel/downloadTemplate"},
|
||||
|
||||
{PType: "p", V0: "8881", V1: "POST", V2: "/base/login"},
|
||||
{PType: "p", V0: "8881", V1: "POST", V2: "/user/register"},
|
||||
{PType: "p", V0: "8881", V1: "POST", V2: "/api/createApi"},
|
||||
{PType: "p", V0: "8881", V1: "POST", V2: "/api/getApiList"},
|
||||
{PType: "p", V0: "8881", V1: "POST", V2: "/api/getApiById"},
|
||||
{PType: "p", V0: "8881", V1: "POST", V2: "/api/deleteApi"},
|
||||
{PType: "p", V0: "8881", V1: "POST", V2: "/api/updateApi"},
|
||||
{PType: "p", V0: "8881", V1: "POST", V2: "/api/getAllApis"},
|
||||
{PType: "p", V0: "8881", V1: "POST", V2: "/authority/createAuthority"},
|
||||
{PType: "p", V0: "8881", V1: "POST", V2: "/authority/deleteAuthority"},
|
||||
{PType: "p", V0: "8881", V1: "POST", V2: "/authority/getAuthorityList"},
|
||||
{PType: "p", V0: "8881", V1: "POST", V2: "/authority/setDataAuthority"},
|
||||
{PType: "p", V0: "8881", V1: "POST", V2: "/menu/getMenu"},
|
||||
{PType: "p", V0: "8881", V1: "POST", V2: "/menu/getMenuList"},
|
||||
{PType: "p", V0: "8881", V1: "POST", V2: "/menu/addBaseMenu"},
|
||||
{PType: "p", V0: "8881", V1: "POST", V2: "/menu/getBaseMenuTree"},
|
||||
{PType: "p", V0: "8881", V1: "POST", V2: "/menu/addMenuAuthority"},
|
||||
{PType: "p", V0: "8881", V1: "POST", V2: "/menu/getMenuAuthority"},
|
||||
{PType: "p", V0: "8881", V1: "POST", V2: "/menu/deleteBaseMenu"},
|
||||
{PType: "p", V0: "8881", V1: "POST", V2: "/menu/updateBaseMenu"},
|
||||
{PType: "p", V0: "8881", V1: "POST", V2: "/menu/getBaseMenuById"},
|
||||
{PType: "p", V0: "8881", V1: "POST", V2: "/user/changePassword"},
|
||||
{PType: "p", V0: "8881", V1: "POST", V2: "/user/getUserList"},
|
||||
{PType: "p", V0: "8881", V1: "POST", V2: "/user/setUserAuthority"},
|
||||
{PType: "p", V0: "8881", V1: "POST", V2: "/fileUploadAndDownload/upload"},
|
||||
{PType: "p", V0: "8881", V1: "POST", V2: "/fileUploadAndDownload/getFileList"},
|
||||
{PType: "p", V0: "8881", V1: "POST", V2: "/fileUploadAndDownload/deleteFile"},
|
||||
{PType: "p", V0: "8881", V1: "POST", V2: "/casbin/updateCasbin"},
|
||||
{PType: "p", V0: "8881", V1: "POST", V2: "/casbin/getPolicyPathByAuthorityId"},
|
||||
{PType: "p", V0: "8881", V1: "POST", V2: "/jwt/jsonInBlacklist"},
|
||||
{PType: "p", V0: "8881", V1: "POST", V2: "/system/getSystemConfig"},
|
||||
{PType: "p", V0: "8881", V1: "POST", V2: "/system/setSystemConfig"},
|
||||
{PType: "p", V0: "8881", V1: "POST", V2: "/customer/customer"},
|
||||
{PType: "p", V0: "8881", V1: "PUT", V2: "/customer/customer"},
|
||||
{PType: "p", V0: "8881", V1: "DELETE", V2: "/customer/customer"},
|
||||
{PType: "p", V0: "8881", V1: "GET", V2: "/customer/customer"},
|
||||
{PType: "p", V0: "8881", V1: "GET", V2: "/customer/customerList"},
|
||||
{PType: "p", V0: "8881", V1: "GET", V2: "/user/getUserInfo"},
|
||||
|
||||
{PType: "p", V0: "9528", V1: "POST", V2: "/base/login"},
|
||||
{PType: "p", V0: "9528", V1: "POST", V2: "/user/register"},
|
||||
{PType: "p", V0: "9528", V1: "POST", V2: "/api/createApi"},
|
||||
{PType: "p", V0: "9528", V1: "POST", V2: "/api/getApiList"},
|
||||
{PType: "p", V0: "9528", V1: "POST", V2: "/api/getApiById"},
|
||||
{PType: "p", V0: "9528", V1: "POST", V2: "/api/deleteApi"},
|
||||
{PType: "p", V0: "9528", V1: "POST", V2: "/api/updateApi"},
|
||||
{PType: "p", V0: "9528", V1: "POST", V2: "/api/getAllApis"},
|
||||
|
||||
{PType: "p", V0: "9528", V1: "POST", V2: "/authority/createAuthority"},
|
||||
{PType: "p", V0: "9528", V1: "POST", V2: "/authority/deleteAuthority"},
|
||||
{PType: "p", V0: "9528", V1: "POST", V2: "/authority/getAuthorityList"},
|
||||
{PType: "p", V0: "9528", V1: "POST", V2: "/authority/setDataAuthority"},
|
||||
|
||||
{PType: "p", V0: "9528", V1: "POST", V2: "/menu/getMenu"},
|
||||
{PType: "p", V0: "9528", V1: "POST", V2: "/menu/getMenuList"},
|
||||
{PType: "p", V0: "9528", V1: "POST", V2: "/menu/addBaseMenu"},
|
||||
{PType: "p", V0: "9528", V1: "POST", V2: "/menu/getBaseMenuTree"},
|
||||
{PType: "p", V0: "9528", V1: "POST", V2: "/menu/addMenuAuthority"},
|
||||
{PType: "p", V0: "9528", V1: "POST", V2: "/menu/getMenuAuthority"},
|
||||
{PType: "p", V0: "9528", V1: "POST", V2: "/menu/deleteBaseMenu"},
|
||||
{PType: "p", V0: "9528", V1: "POST", V2: "/menu/updateBaseMenu"},
|
||||
{PType: "p", V0: "9528", V1: "POST", V2: "/menu/getBaseMenuById"},
|
||||
{PType: "p", V0: "9528", V1: "POST", V2: "/user/changePassword"},
|
||||
{PType: "p", V0: "9528", V1: "POST", V2: "/user/getUserList"},
|
||||
{PType: "p", V0: "9528", V1: "POST", V2: "/user/setUserAuthority"},
|
||||
{PType: "p", V0: "9528", V1: "POST", V2: "/fileUploadAndDownload/upload"},
|
||||
{PType: "p", V0: "9528", V1: "POST", V2: "/fileUploadAndDownload/getFileList"},
|
||||
{PType: "p", V0: "9528", V1: "POST", V2: "/fileUploadAndDownload/deleteFile"},
|
||||
{PType: "p", V0: "9528", V1: "POST", V2: "/casbin/updateCasbin"},
|
||||
{PType: "p", V0: "9528", V1: "POST", V2: "/casbin/getPolicyPathByAuthorityId"},
|
||||
{PType: "p", V0: "9528", V1: "POST", V2: "/jwt/jsonInBlacklist"},
|
||||
{PType: "p", V0: "9528", V1: "POST", V2: "/system/getSystemConfig"},
|
||||
{PType: "p", V0: "9528", V1: "POST", V2: "/system/setSystemConfig"},
|
||||
{PType: "p", V0: "9528", V1: "PUT", V2: "/customer/customer"},
|
||||
{PType: "p", V0: "9528", V1: "GET", V2: "/customer/customer"},
|
||||
{PType: "p", V0: "9528", V1: "POST", V2: "/customer/customer"},
|
||||
{PType: "p", V0: "9528", V1: "DELETE", V2: "/customer/customer"},
|
||||
{PType: "p", V0: "9528", V1: "GET", V2: "/customer/customerList"},
|
||||
{PType: "p", V0: "9528", V1: "POST", V2: "/autoCode/createTemp"},
|
||||
{PType: "p", V0: "9528", V1: "GET", V2: "/user/getUserInfo"},
|
||||
}
|
||||
if err := global.GVA_DB.Create(&entities).Error; err != nil {
|
||||
return errors.Wrap(err, c.TableName()+"表数据初始化失败!")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *casbin) CheckDataExist() bool {
|
||||
if errors.Is(global.GVA_DB.Where(adapter.CasbinRule{PType: "p", V0: "9528", V1: "GET", V2: "/user/getUserInfo"}).First(&adapter.CasbinRule{}).Error, gorm.ErrRecordNotFound) { // 判断是否存在数据
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
56
server/source/system/data_authorities.go
Normal file
56
server/source/system/data_authorities.go
Normal file
@@ -0,0 +1,56 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/global"
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/model/system"
|
||||
"github.com/pkg/errors"
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/schema"
|
||||
"reflect"
|
||||
)
|
||||
|
||||
var DataAuthorities = new(dataAuthorities)
|
||||
|
||||
type dataAuthorities struct{}
|
||||
|
||||
func (a *dataAuthorities) TableName() string {
|
||||
var entity AuthoritiesResources
|
||||
return entity.TableName()
|
||||
}
|
||||
|
||||
func (a *dataAuthorities) Initialize() error {
|
||||
entities := []AuthoritiesResources{
|
||||
{AuthorityId: "888", ResourcesId: "888"},
|
||||
{AuthorityId: "888", ResourcesId: "8881"},
|
||||
{AuthorityId: "888", ResourcesId: "9528"},
|
||||
{AuthorityId: "9528", ResourcesId: "8881"},
|
||||
{AuthorityId: "9528", ResourcesId: "9528"},
|
||||
}
|
||||
if err := global.GVA_DB.Create(&entities).Error; err != nil {
|
||||
return errors.Wrap(err, a.TableName()+"表数据初始化失败!")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *dataAuthorities) CheckDataExist() bool {
|
||||
if errors.Is(global.GVA_DB.Where("authority_id = ? AND resources_id = ?", "9528", "9528").First(&AuthoritiesResources{}).Error, gorm.ErrRecordNotFound) { // 判断是否存在数据
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// AuthoritiesResources 角色资源表
|
||||
type AuthoritiesResources struct {
|
||||
AuthorityId string `gorm:"column:authority_id"`
|
||||
ResourcesId string `gorm:"column:resources_id"`
|
||||
}
|
||||
|
||||
func (a *AuthoritiesResources) TableName() string {
|
||||
var entity system.SysAuthority
|
||||
types := reflect.TypeOf(entity)
|
||||
if s, o := types.FieldByName("DataAuthorityId"); o {
|
||||
m1 := schema.ParseTagSetting(s.Tag.Get("gorm"), ";")
|
||||
return m1["MANY2MANY"]
|
||||
}
|
||||
return ""
|
||||
}
|
40
server/source/system/dictionary.go
Normal file
40
server/source/system/dictionary.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/global"
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/model/system"
|
||||
"github.com/pkg/errors"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
var Dictionary = new(dictionary)
|
||||
|
||||
type dictionary struct{}
|
||||
|
||||
func (d *dictionary) TableName() string {
|
||||
return "sys_dictionaries"
|
||||
}
|
||||
|
||||
func (d *dictionary) Initialize() error {
|
||||
status := new(bool)
|
||||
*status = true
|
||||
entities := []system.SysDictionary{
|
||||
{Name: "性别", Type: "gender", Status: status, Desc: "性别字典"},
|
||||
{Name: "数据库int类型", Type: "int", Status: status, Desc: "int类型对应的数据库类型"},
|
||||
{Name: "数据库时间日期类型", Type: "time.Time", Status: status, Desc: "数据库时间日期类型"},
|
||||
{Name: "数据库浮点型", Type: "float64", Status: status, Desc: "数据库浮点型"},
|
||||
{Name: "数据库字符串", Type: "string", Status: status, Desc: "数据库字符串"},
|
||||
{Name: "数据库bool类型", Type: "bool", Status: status, Desc: "数据库bool类型"},
|
||||
}
|
||||
if err := global.GVA_DB.Create(&entities).Error; err != nil {
|
||||
return errors.Wrap(err, d.TableName()+"表数据初始化失败!")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *dictionary) CheckDataExist() bool {
|
||||
if errors.Is(global.GVA_DB.Where("type = ?", "bool").First(&system.SysDictionary{}).Error, gorm.ErrRecordNotFound) { // 判断是否存在数据
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
57
server/source/system/dictionary_detail.go
Normal file
57
server/source/system/dictionary_detail.go
Normal file
@@ -0,0 +1,57 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/global"
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/model/system"
|
||||
"github.com/pkg/errors"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
var DictionaryDetail = new(dictionaryDetail)
|
||||
|
||||
type dictionaryDetail struct{}
|
||||
|
||||
func (d *dictionaryDetail) TableName() string {
|
||||
return "sys_dictionary_details"
|
||||
}
|
||||
|
||||
func (d *dictionaryDetail) Initialize() error {
|
||||
status := new(bool)
|
||||
*status = true
|
||||
entities := []system.SysDictionaryDetail{
|
||||
{Label: "smallint", Value: 1, Status: status, Sort: 1, SysDictionaryID: 2},
|
||||
{Label: "mediumint", Value: 2, Status: status, Sort: 2, SysDictionaryID: 2},
|
||||
{Label: "int", Value: 3, Status: status, Sort: 3, SysDictionaryID: 2},
|
||||
{Label: "bigint", Value: 4, Status: status, Sort: 4, SysDictionaryID: 2},
|
||||
{Label: "date", Status: status, SysDictionaryID: 3},
|
||||
{Label: "time", Value: 1, Status: status, Sort: 1, SysDictionaryID: 3},
|
||||
{Label: "year", Value: 2, Status: status, Sort: 2, SysDictionaryID: 3},
|
||||
{Label: "datetime", Value: 3, Status: status, Sort: 3, SysDictionaryID: 3},
|
||||
{Label: "timestamp", Value: 5, Status: status, Sort: 5, SysDictionaryID: 3},
|
||||
{Label: "float", Status: status, SysDictionaryID: 4},
|
||||
{Label: "double", Value: 1, Status: status, Sort: 1, SysDictionaryID: 4},
|
||||
{Label: "decimal", Value: 2, Status: status, Sort: 2, SysDictionaryID: 4},
|
||||
{Label: "char", Status: status, SysDictionaryID: 5},
|
||||
{Label: "varchar", Value: 1, Status: status, Sort: 1, SysDictionaryID: 5},
|
||||
{Label: "tinyblob", Value: 2, Status: status, Sort: 2, SysDictionaryID: 5},
|
||||
{Label: "tinytext", Value: 3, Status: status, Sort: 3, SysDictionaryID: 5},
|
||||
{Label: "text", Value: 4, Status: status, Sort: 4, SysDictionaryID: 5},
|
||||
{Label: "blob", Value: 5, Status: status, Sort: 5, SysDictionaryID: 5},
|
||||
{Label: "mediumblob", Value: 6, Status: status, Sort: 6, SysDictionaryID: 5},
|
||||
{Label: "mediumtext", Value: 7, Status: status, Sort: 7, SysDictionaryID: 5},
|
||||
{Label: "longblob", Value: 8, Status: status, Sort: 8, SysDictionaryID: 5},
|
||||
{Label: "longtext", Value: 9, Status: status, Sort: 9, SysDictionaryID: 5},
|
||||
{Label: "tinyint", Status: status, SysDictionaryID: 6},
|
||||
}
|
||||
if err := global.GVA_DB.Create(&entities).Error; err != nil {
|
||||
return errors.Wrap(err, d.TableName()+"表数据初始化失败!")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *dictionaryDetail) CheckDataExist() bool {
|
||||
if errors.Is(global.GVA_DB.Where("id = ?", 23).First(&system.SysDictionaryDetail{}).Error, gorm.ErrRecordNotFound) { // 判断是否存在数据
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
57
server/source/system/menu.go
Normal file
57
server/source/system/menu.go
Normal file
@@ -0,0 +1,57 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/global"
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/model/system"
|
||||
"github.com/pkg/errors"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
var BaseMenu = new(menu)
|
||||
|
||||
type menu struct{}
|
||||
|
||||
func (m *menu) TableName() string {
|
||||
return "sys_base_menus"
|
||||
}
|
||||
|
||||
func (m *menu) Initialize() error {
|
||||
entities := []system.SysBaseMenu{
|
||||
{MenuLevel: 0, Hidden: false, ParentId: "0", Path: "dashboard", Name: "dashboard", Component: "view/dashboard/index.vue", Sort: 1, Meta: system.Meta{Title: "仪表盘", Icon: "setting"}},
|
||||
{MenuLevel: 0, Hidden: false, ParentId: "0", Path: "about", Name: "about", Component: "view/about/index.vue", Sort: 7, Meta: system.Meta{Title: "关于我们", Icon: "info"}},
|
||||
{MenuLevel: 0, Hidden: false, ParentId: "0", Path: "admin", Name: "superAdmin", Component: "view/superAdmin/index.vue", Sort: 3, Meta: system.Meta{Title: "超级管理员", Icon: "user-solid"}},
|
||||
{MenuLevel: 0, Hidden: false, ParentId: "3", Path: "authority", Name: "authority", Component: "view/superAdmin/authority/authority.vue", Sort: 1, Meta: system.Meta{Title: "角色管理", Icon: "s-custom"}},
|
||||
{MenuLevel: 0, Hidden: false, ParentId: "3", Path: "menu", Name: "menu", Component: "view/superAdmin/menu/menu.vue", Sort: 2, Meta: system.Meta{Title: "菜单管理", Icon: "s-order", KeepAlive: true}},
|
||||
{MenuLevel: 0, Hidden: false, ParentId: "3", Path: "api", Name: "api", Component: "view/superAdmin/api/api.vue", Sort: 3, Meta: system.Meta{Title: "api管理", Icon: "s-platform", KeepAlive: true}},
|
||||
{MenuLevel: 0, Hidden: false, ParentId: "3", Path: "user", Name: "user", Component: "view/superAdmin/user/user.vue", Sort: 4, Meta: system.Meta{Title: "用户管理", Icon: "coordinate"}},
|
||||
{MenuLevel: 0, Hidden: true, ParentId: "0", Path: "person", Name: "person", Component: "view/person/person.vue", Sort: 4, Meta: system.Meta{Title: "个人信息", Icon: "message-solid"}},
|
||||
{MenuLevel: 0, Hidden: false, ParentId: "0", Path: "example", Name: "example", Component: "view/example/index.vue", Sort: 6, Meta: system.Meta{Title: "示例文件", Icon: "s-management"}},
|
||||
{MenuLevel: 0, Hidden: false, ParentId: "9", Path: "excel", Name: "excel", Component: "view/example/excel/excel.vue", Sort: 4, Meta: system.Meta{Title: "excel导入导出", Icon: "s-marketing"}},
|
||||
{MenuLevel: 0, Hidden: false, ParentId: "9", Path: "upload", Name: "upload", Component: "view/example/upload/upload.vue", Sort: 5, Meta: system.Meta{Title: "媒体库(上传下载)", Icon: "upload"}},
|
||||
{MenuLevel: 0, Hidden: false, ParentId: "9", Path: "breakpoint", Name: "breakpoint", Component: "view/example/breakpoint/breakpoint.vue", Sort: 6, Meta: system.Meta{Title: "断点续传", Icon: "upload"}},
|
||||
{MenuLevel: 0, Hidden: false, ParentId: "9", Path: "customer", Name: "customer", Component: "view/example/customer/customer.vue", Sort: 7, Meta: system.Meta{Title: "客户列表(资源示例)", Icon: "s-custom"}},
|
||||
{MenuLevel: 0, Hidden: false, ParentId: "0", Path: "systemTools", Name: "systemTools", Component: "view/systemTools/index.vue", Sort: 5, Meta: system.Meta{Title: "系统工具", Icon: "s-cooperation"}},
|
||||
{MenuLevel: 0, Hidden: false, ParentId: "14", Path: "autoCode", Name: "autoCode", Component: "view/systemTools/autoCode/index.vue", Sort: 1, Meta: system.Meta{Title: "代码生成器", Icon: "cpu", KeepAlive: true}},
|
||||
{MenuLevel: 0, Hidden: false, ParentId: "14", Path: "formCreate", Name: "formCreate", Component: "view/systemTools/formCreate/index.vue", Sort: 2, Meta: system.Meta{Title: "表单生成器", Icon: "magic-stick", KeepAlive: true}},
|
||||
{MenuLevel: 0, Hidden: false, ParentId: "14", Path: "system", Name: "system", Component: "view/systemTools/system/system.vue", Sort: 3, Meta: system.Meta{Title: "系统配置", Icon: "s-operation"}},
|
||||
{MenuLevel: 0, Hidden: false, ParentId: "3", Path: "dictionary", Name: "dictionary", Component: "view/superAdmin/dictionary/sysDictionary.vue", Sort: 5, Meta: system.Meta{Title: "字典管理", Icon: "notebook-2"}},
|
||||
{MenuLevel: 0, Hidden: true, ParentId: "3", Path: "dictionaryDetail/:id", Name: "dictionaryDetail", Component: "view/superAdmin/dictionary/sysDictionaryDetail.vue", Sort: 1, Meta: system.Meta{Title: "字典详情", Icon: "s-order"}},
|
||||
{MenuLevel: 0, Hidden: false, ParentId: "3", Path: "operation", Name: "operation", Component: "view/superAdmin/operation/sysOperationRecord.vue", Sort: 6, Meta: system.Meta{Title: "操作历史", Icon: "time"}},
|
||||
{MenuLevel: 0, Hidden: false, ParentId: "9", Path: "simpleUploader", Name: "simpleUploader", Component: "view/example/simpleUploader/simpleUploader", Sort: 6, Meta: system.Meta{Title: "断点续传(插件版)", Icon: "upload"}},
|
||||
{MenuLevel: 0, Hidden: false, ParentId: "0", Path: "https://www.gin-vue-admin.com", Name: "https://www.gin-vue-admin.com", Component: "/", Sort: 0, Meta: system.Meta{Title: "官方网站", Icon: "s-home"}},
|
||||
{MenuLevel: 0, Hidden: false, ParentId: "0", Path: "state", Name: "state", Component: "view/system/state.vue", Sort: 6, Meta: system.Meta{Title: "服务器状态", Icon: "cloudy"}},
|
||||
{MenuLevel: 0, Hidden: false, ParentId: "14", Path: "autoCodeAdmin", Name: "autoCodeAdmin", Component: "view/systemTools/autoCodeAdmin/index.vue", Sort: 1, Meta: system.Meta{Title: "自动化代码管理", Icon: "s-finance"}},
|
||||
{MenuLevel: 0, Hidden: true, ParentId: "14", Path: "autoCodeEdit/:id", Name: "autoCodeEdit", Component: "view/systemTools/autoCode/index.vue", Sort: 0, Meta: system.Meta{Title: "自动化代码(复用)", Icon: "s-finance"}},
|
||||
}
|
||||
if err := global.GVA_DB.Create(&entities).Error; err != nil { // 创建 model.User 初始化数据
|
||||
return errors.Wrap(err, m.TableName()+"表数据初始化失败!")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *menu) CheckDataExist() bool {
|
||||
if errors.Is(global.GVA_DB.Where("path = ?", "autoCodeEdit/:id").First(&system.SysBaseMenu{}).Error, gorm.ErrRecordNotFound) { // 判断是否存在数据
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
35
server/source/system/user.go
Normal file
35
server/source/system/user.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/global"
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/model/system"
|
||||
"github.com/pkg/errors"
|
||||
uuid "github.com/satori/go.uuid"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
var User = new(user)
|
||||
|
||||
type user struct{}
|
||||
|
||||
func (u *user) TableName() string {
|
||||
return "sys_users"
|
||||
}
|
||||
|
||||
func (u *user) Initialize() error {
|
||||
entities := []system.SysUser{
|
||||
{UUID: uuid.NewV4(), Username: "admin", Password: "e10adc3949ba59abbe56e057f20f883e", NickName: "超级管理员", HeaderImg: "https://qmplusimg.henrongyi.top/gva_header.jpg", AuthorityId: "888"},
|
||||
{UUID: uuid.NewV4(), Username: "a303176530", Password: "3ec063004a6f31642261936a379fde3d", NickName: "QMPlusUser", HeaderImg: "https:///qmplusimg.henrongyi.top/1572075907logo.png", AuthorityId: "9528"},
|
||||
}
|
||||
if err := global.GVA_DB.Create(&entities).Error; err != nil {
|
||||
return errors.Wrap(err, u.TableName()+"表数据初始化失败!")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (u *user) CheckDataExist() bool {
|
||||
if errors.Is(global.GVA_DB.Where("username = ?", "a303176530").First(&system.SysUser{}).Error, gorm.ErrRecordNotFound) { // 判断是否存在数据
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
37
server/source/system/user_authority.go
Normal file
37
server/source/system/user_authority.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/global"
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/model/system"
|
||||
"github.com/pkg/errors"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
var UserAuthority = new(userAuthority)
|
||||
|
||||
type userAuthority struct{}
|
||||
|
||||
func (a *userAuthority) TableName() string {
|
||||
var entity system.SysUseAuthority
|
||||
return entity.TableName()
|
||||
}
|
||||
|
||||
func (a *userAuthority) Initialize() error {
|
||||
entities := []system.SysUseAuthority{
|
||||
{SysUserId: 1, SysAuthorityAuthorityId: "888"},
|
||||
{SysUserId: 1, SysAuthorityAuthorityId: "8881"},
|
||||
{SysUserId: 1, SysAuthorityAuthorityId: "9528"},
|
||||
{SysUserId: 2, SysAuthorityAuthorityId: "888"},
|
||||
}
|
||||
if err := global.GVA_DB.Create(&entities).Error; err != nil {
|
||||
return errors.Wrap(err, a.TableName()+"表数据初始化失败!")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *userAuthority) CheckDataExist() bool {
|
||||
if errors.Is(global.GVA_DB.Where("sys_user_id = ? AND sys_authority_authority_id = ?", 2, "888").First(&system.SysUseAuthority{}).Error, gorm.ErrRecordNotFound) { // 判断是否存在数据
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
39
server/source/system/view_authority_menu_mysql.go
Normal file
39
server/source/system/view_authority_menu_mysql.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/global"
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/model/system"
|
||||
"github.com/pkg/errors"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var ViewAuthorityMenuMysql = new(viewAuthorityMenuMysql)
|
||||
|
||||
type viewAuthorityMenuMysql struct{}
|
||||
|
||||
func (v *viewAuthorityMenuMysql) TableName() string {
|
||||
var entity system.SysMenu
|
||||
return entity.TableName()
|
||||
}
|
||||
|
||||
func (v *viewAuthorityMenuMysql) Initialize() error {
|
||||
var entity AuthorityMenus
|
||||
sql := "CREATE ALGORITHM = UNDEFINED SQL SECURITY DEFINER VIEW `@table_name` AS select `@menus`.id AS id, `@menus`.path AS path, `@menus`.icon AS icon, `@menus`.name AS name, `@menus`.sort AS sort, `@menus`.title AS title, `@menus`.hidden AS hidden, `@menus`.component AS component, `@menus`.parent_id AS parent_id, `@menus`.created_at AS created_at, `@menus`.updated_at AS updated_at, `@menus`.deleted_at AS deleted_at, `@menus`.keep_alive AS keep_alive, `@menus`.menu_level AS menu_level, `@menus`.default_menu AS default_menu, `@authorities_menus`.menu_id AS menu_id, `@authorities_menus`.authority_id AS authority_id from (`@authorities_menus` join `@menus` on ((`@authorities_menus`.menu_id = `@menus`.id)));"
|
||||
sql = strings.ReplaceAll(sql, "@table_name", v.TableName())
|
||||
sql = strings.ReplaceAll(sql, "@menus", "sys_base_menus")
|
||||
sql = strings.ReplaceAll(sql, "@authorities_menus", entity.TableName())
|
||||
if err := global.GVA_DB.Exec(sql).Error; err != nil {
|
||||
return errors.Wrap(err, v.TableName()+"视图创建失败!")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (v *viewAuthorityMenuMysql) CheckDataExist() bool {
|
||||
err1 := global.GVA_DB.Find(&[]system.SysMenu{}).Error
|
||||
err2 := errors.New(fmt.Sprintf("Error 1146: Table '%v.%v' doesn't exist", global.GVA_CONFIG.Mysql.Dbname, v.TableName()))
|
||||
if errors.As(err1, &err2) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
58
server/source/system/view_authority_menu_postgres.go
Normal file
58
server/source/system/view_authority_menu_postgres.go
Normal file
@@ -0,0 +1,58 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/global"
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/model/system"
|
||||
"github.com/pkg/errors"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var ViewAuthorityMenuPostgres = new(viewAuthorityMenuPostgres)
|
||||
|
||||
type viewAuthorityMenuPostgres struct{}
|
||||
|
||||
func (a *viewAuthorityMenuPostgres) TableName() string {
|
||||
var entity system.SysMenu
|
||||
return entity.TableName()
|
||||
}
|
||||
|
||||
func (a *viewAuthorityMenuPostgres) Initialize() error {
|
||||
var entity AuthorityMenus
|
||||
sql := `
|
||||
CREATE VIEW @table_name as
|
||||
select @menus.id as id,
|
||||
@menus.path as path,
|
||||
@menus.name as name,
|
||||
@menus.icon as icon,
|
||||
@menus.sort as sort,
|
||||
@menus.title as title,
|
||||
@menus.hidden as hidden,
|
||||
@menus.parent_id as parent_id,
|
||||
@menus.component as component,
|
||||
@menus.keep_alive as keep_alive,
|
||||
@menus.created_at as created_at,
|
||||
@menus.updated_at as updated_at,
|
||||
@menus.deleted_at as deleted_at,
|
||||
@menus.menu_level as menu_level,
|
||||
@menus.default_menu as default_menu,
|
||||
@authorities_menus.menu_id as menu_id,
|
||||
@authorities_menus.authority_id as authority_id
|
||||
from (@authorities_menus join @menus on ((@authorities_menus.menu_id = @menus.id)));`
|
||||
sql = strings.ReplaceAll(sql, "@table_name", a.TableName())
|
||||
sql = strings.ReplaceAll(sql, "@menus", "sys_base_menus")
|
||||
sql = strings.ReplaceAll(sql, "@authorities_menus", entity.TableName())
|
||||
if err := global.GVA_DB.Exec(sql).Error; err != nil {
|
||||
return errors.Wrap(err, a.TableName()+"视图创建失败!")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *viewAuthorityMenuPostgres) CheckDataExist() bool {
|
||||
err1 := global.GVA_DB.Find(&[]system.SysMenu{}).Error
|
||||
err2 := errors.New(fmt.Sprintf("Error 1146: Table '%v.%v' doesn't exist", global.GVA_CONFIG.Pgsql.Dbname, a.TableName()))
|
||||
if errors.As(err1, &err2) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
Reference in New Issue
Block a user