From 316832fdb619ae0d895f0687ff3b6a7fd4fd8699 Mon Sep 17 00:00:00 2001 From: SliverHorn <503551462@qq.com> Date: Thu, 18 Nov 2021 22:09:41 +0800 Subject: [PATCH] =?UTF-8?q?fixed:=20-=20casbin=20=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E9=97=AE=E9=A2=98=20-=20AuthoritiesMenus=20=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20-=20DataAuthorities=20=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20-=20File=20=E9=97=AE=E9=A2=98=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=20-=20=E5=88=9D=E5=A7=8B=E5=8C=96=E8=A1=A8=20add=20Ca?= =?UTF-8?q?sbinRule=20-=20ViewAuthorityMenuMysql=20=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/service/system/sys_initdb.go | 4 +- server/source/example/file.go | 2 +- server/source/system/authorities_menus.go | 2 +- server/source/system/casbin.go | 350 +++++++++--------- server/source/system/data_authorities.go | 6 +- .../system/view_authority_menu_mysql.go | 23 +- 6 files changed, 205 insertions(+), 182 deletions(-) diff --git a/server/service/system/sys_initdb.go b/server/service/system/sys_initdb.go index ca676739..23bcf249 100644 --- a/server/service/system/sys_initdb.go +++ b/server/service/system/sys_initdb.go @@ -1,11 +1,11 @@ package system import ( + adapter "github.com/casbin/gorm-adapter/v3" "github.com/flipped-aurora/gin-vue-admin/server/global" "github.com/flipped-aurora/gin-vue-admin/server/model/example" "github.com/flipped-aurora/gin-vue-admin/server/model/system" "github.com/flipped-aurora/gin-vue-admin/server/model/system/request" - _ "github.com/jackc/pgx/v4" ) type InitDBService struct{} @@ -40,6 +40,8 @@ func (initDBService *InitDBService) initTables() error { system.SysDictionaryDetail{}, system.SysBaseMenuParameter{}, + adapter.CasbinRule{}, + example.ExaFile{}, example.ExaCustomer{}, example.ExaFileChunk{}, diff --git a/server/source/example/file.go b/server/source/example/file.go index e5240215..cb1a3c60 100644 --- a/server/source/example/file.go +++ b/server/source/example/file.go @@ -27,7 +27,7 @@ func (f *file) Initialize() error { } func (f *file) CheckDataExist() bool { - if errors.Is(global.GVA_DB.Where("name = ? AND key = ?", "logo.png", "1587973709logo.png").First(&example.ExaFileUploadAndDownload{}).Error, gorm.ErrRecordNotFound) { + if errors.Is(global.GVA_DB.Where("`name` = ? AND `key` = ?", "logo.png", "1587973709logo.png").First(&example.ExaFileUploadAndDownload{}).Error, gorm.ErrRecordNotFound) { return false } return true diff --git a/server/source/system/authorities_menus.go b/server/source/system/authorities_menus.go index 46d98666..c823ca48 100644 --- a/server/source/system/authorities_menus.go +++ b/server/source/system/authorities_menus.go @@ -73,7 +73,7 @@ func (a *authoritiesMenus) Initialize() error { } func (a *authoritiesMenus) CheckDataExist() bool { - if errors.Is(global.GVA_DB.Where("menu_id = ? AND authority_id = ?", 17, "9528").First(&AuthorityMenus{}).Error, gorm.ErrRecordNotFound) { // 判断是否存在数据 + if errors.Is(global.GVA_DB.Where("sys_base_menu_id = ? AND sys_authority_authority_id = ?", 17, "9528").First(&AuthorityMenus{}).Error, gorm.ErrRecordNotFound) { // 判断是否存在数据 return false } return true diff --git a/server/source/system/casbin.go b/server/source/system/casbin.go index b7965a42..a1fc438e 100644 --- a/server/source/system/casbin.go +++ b/server/source/system/casbin.go @@ -18,181 +18,181 @@ func (c *casbin) TableName() string { 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"}, + {PType: "p", V0: "888", V1: "/base/login", V2: "POST"}, + {PType: "p", V0: "888", V1: "/user/register", V2: "POST"}, + + {PType: "p", V0: "888", V1: "/api/createApi", V2: "POST"}, + {PType: "p", V0: "888", V1: "/api/getApiList", V2: "POST"}, + {PType: "p", V0: "888", V1: "/api/getApiById", V2: "POST"}, + {PType: "p", V0: "888", V1: "/api/deleteApi", V2: "POST"}, + {PType: "p", V0: "888", V1: "/api/updateApi", V2: "POST"}, + {PType: "p", V0: "888", V1: "/api/getAllApis", V2: "POST"}, + {PType: "p", V0: "888", V1: "/api/deleteApisByIds", V2: "DELETE"}, + + {PType: "p", V0: "888", V1: "/authority/copyAuthority", V2: "POST"}, + {PType: "p", V0: "888", V1: "/authority/updateAuthority", V2: "PUT"}, + {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: "/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/getUserInfo", V2: "GET"}, + {PType: "p", V0: "888", V1: "/user/setUserInfo", V2: "PUT"}, + {PType: "p", V0: "888", V1: "/user/getUserList", V2: "POST"}, + {PType: "p", V0: "888", V1: "/user/deleteUser", V2: "DELETE"}, + {PType: "p", V0: "888", V1: "/user/changePassword", V2: "POST"}, + {PType: "p", V0: "888", V1: "/user/setUserAuthority", V2: "POST"}, + {PType: "p", V0: "888", V1: "/user/setUserAuthorities", V2: "POST"}, + + {PType: "p", V0: "888", V1: "/fileUploadAndDownload/upload", V2: "POST"}, + {PType: "p", V0: "888", V1: "/fileUploadAndDownload/deleteFile", V2: "POST"}, + {PType: "p", V0: "888", V1: "/fileUploadAndDownload/getFileList", 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: "/jwt/jsonInBlacklist", V2: "POST"}, + + {PType: "p", V0: "888", V1: "/system/getSystemConfig", V2: "POST"}, + {PType: "p", V0: "888", V1: "/system/setSystemConfig", V2: "POST"}, + {PType: "p", V0: "888", V1: "/system/getServerInfo", V2: "POST"}, + + {PType: "p", V0: "888", V1: "/customer/customer", V2: "GET"}, + {PType: "p", V0: "888", V1: "/customer/customer", V2: "PUT"}, + {PType: "p", V0: "888", V1: "/customer/customer", V2: "POST"}, + {PType: "p", V0: "888", V1: "/customer/customer", V2: "DELETE"}, + {PType: "p", V0: "888", V1: "/customer/customerList", V2: "GET"}, + + {PType: "p", V0: "888", V1: "/autoCode/getDB", V2: "GET"}, + {PType: "p", V0: "888", V1: "/autoCode/getMeta", V2: "POST"}, + {PType: "p", V0: "888", V1: "/autoCode/preview", V2: "POST"}, + {PType: "p", V0: "888", V1: "/autoCode/getTables", V2: "GET"}, + {PType: "p", V0: "888", V1: "/autoCode/getColumn", V2: "GET"}, + {PType: "p", V0: "888", V1: "/autoCode/rollback", V2: "POST"}, + {PType: "p", V0: "888", V1: "/autoCode/createTemp", V2: "POST"}, + {PType: "p", V0: "888", V1: "/autoCode/delSysHistory", V2: "POST"}, + {PType: "p", V0: "888", V1: "/autoCode/getSysHistory", V2: "POST"}, + + {PType: "p", V0: "888", V1: "/sysDictionaryDetail/findSysDictionaryDetail", V2: "GET"}, + {PType: "p", V0: "888", V1: "/sysDictionaryDetail/updateSysDictionaryDetail", V2: "PUT"}, + {PType: "p", V0: "888", V1: "/sysDictionaryDetail/createSysDictionaryDetail", V2: "POST"}, + {PType: "p", V0: "888", V1: "/sysDictionaryDetail/getSysDictionaryDetailList", V2: "GET"}, + {PType: "p", V0: "888", V1: "/sysDictionaryDetail/deleteSysDictionaryDetail", V2: "DELETE"}, + + {PType: "p", V0: "888", V1: "/sysDictionary/findSysDictionary", V2: "GET"}, + {PType: "p", V0: "888", V1: "/sysDictionary/updateSysDictionary", V2: "PUT"}, + {PType: "p", V0: "888", V1: "/sysDictionary/getSysDictionaryList", 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: "/sysOperationRecord/findSysOperationRecord", V2: "GET"}, + {PType: "p", V0: "888", V1: "/sysOperationRecord/updateSysOperationRecord", V2: "PUT"}, + {PType: "p", V0: "888", V1: "/sysOperationRecord/createSysOperationRecord", V2: "POST"}, + {PType: "p", V0: "888", V1: "/sysOperationRecord/getSysOperationRecordList", V2: "GET"}, + {PType: "p", V0: "888", V1: "/sysOperationRecord/deleteSysOperationRecord", V2: "DELETE"}, + {PType: "p", V0: "888", V1: "/sysOperationRecord/deleteSysOperationRecordByIds", V2: "DELETE"}, + + {PType: "p", V0: "888", V1: "/email/emailTest", V2: "POST"}, + + {PType: "p", V0: "888", V1: "/simpleUploader/upload", V2: "POST"}, + {PType: "p", V0: "888", V1: "/simpleUploader/checkFileMd5", V2: "GET"}, + {PType: "p", V0: "888", V1: "/simpleUploader/mergeFileMd5", V2: "GET"}, + + {PType: "p", V0: "888", V1: "/excel/importExcel", V2: "POST"}, + {PType: "p", V0: "888", V1: "/excel/loadExcel", V2: "GET"}, + {PType: "p", V0: "888", V1: "/excel/exportExcel", V2: "POST"}, + {PType: "p", V0: "888", V1: "/excel/downloadTemplate", V2: "GET"}, + + {PType: "p", V0: "8881", V1: "/base/login", V2: "POST"}, + {PType: "p", V0: "8881", V1: "/user/register", V2: "POST"}, + {PType: "p", V0: "8881", V1: "/api/createApi", V2: "POST"}, + {PType: "p", V0: "8881", V1: "/api/getApiList", V2: "POST"}, + {PType: "p", V0: "8881", V1: "/api/getApiById", V2: "POST"}, + {PType: "p", V0: "8881", V1: "/api/deleteApi", V2: "POST"}, + {PType: "p", V0: "8881", V1: "/api/updateApi", V2: "POST"}, + {PType: "p", V0: "8881", V1: "/api/getAllApis", V2: "POST"}, + {PType: "p", V0: "8881", V1: "/authority/createAuthority", V2: "POST"}, + {PType: "p", V0: "8881", V1: "/authority/deleteAuthority", V2: "POST"}, + {PType: "p", V0: "8881", V1: "/authority/getAuthorityList", V2: "POST"}, + {PType: "p", V0: "8881", V1: "/authority/setDataAuthority", V2: "POST"}, + {PType: "p", V0: "8881", V1: "/menu/getMenu", V2: "POST"}, + {PType: "p", V0: "8881", V1: "/menu/getMenuList", V2: "POST"}, + {PType: "p", V0: "8881", V1: "/menu/addBaseMenu", V2: "POST"}, + {PType: "p", V0: "8881", V1: "/menu/getBaseMenuTree", V2: "POST"}, + {PType: "p", V0: "8881", V1: "/menu/addMenuAuthority", V2: "POST"}, + {PType: "p", V0: "8881", V1: "/menu/getMenuAuthority", V2: "POST"}, + {PType: "p", V0: "8881", V1: "/menu/deleteBaseMenu", V2: "POST"}, + {PType: "p", V0: "8881", V1: "/menu/updateBaseMenu", V2: "POST"}, + {PType: "p", V0: "8881", V1: "/menu/getBaseMenuById", V2: "POST"}, + {PType: "p", V0: "8881", V1: "/user/changePassword", V2: "POST"}, + {PType: "p", V0: "8881", V1: "/user/getUserList", V2: "POST"}, + {PType: "p", V0: "8881", V1: "/user/setUserAuthority", V2: "POST"}, + {PType: "p", V0: "8881", V1: "/fileUploadAndDownload/upload", V2: "POST"}, + {PType: "p", V0: "8881", V1: "/fileUploadAndDownload/getFileList", V2: "POST"}, + {PType: "p", V0: "8881", V1: "/fileUploadAndDownload/deleteFile", V2: "POST"}, + {PType: "p", V0: "8881", V1: "/casbin/updateCasbin", V2: "POST"}, + {PType: "p", V0: "8881", V1: "/casbin/getPolicyPathByAuthorityId", V2: "POST"}, + {PType: "p", V0: "8881", V1: "/jwt/jsonInBlacklist", V2: "POST"}, + {PType: "p", V0: "8881", V1: "/system/getSystemConfig", V2: "POST"}, + {PType: "p", V0: "8881", V1: "/system/setSystemConfig", V2: "POST"}, + {PType: "p", V0: "8881", V1: "/customer/customer", V2: "POST"}, + {PType: "p", V0: "8881", V1: "/customer/customer", V2: "PUT"}, + {PType: "p", V0: "8881", V1: "/customer/customer", V2: "DELETE"}, + {PType: "p", V0: "8881", V1: "/customer/customer", V2: "GET"}, + {PType: "p", V0: "8881", V1: "/customer/customerList", V2: "GET"}, + {PType: "p", V0: "8881", V1: "/user/getUserInfo", V2: "GET"}, + + {PType: "p", V0: "9528", V1: "/base/login", V2: "POST"}, + {PType: "p", V0: "9528", V1: "/user/register", V2: "POST"}, + {PType: "p", V0: "9528", V1: "/api/createApi", V2: "POST"}, + {PType: "p", V0: "9528", V1: "/api/getApiList", V2: "POST"}, + {PType: "p", V0: "9528", V1: "/api/getApiById", V2: "POST"}, + {PType: "p", V0: "9528", V1: "/api/deleteApi", V2: "POST"}, + {PType: "p", V0: "9528", V1: "/api/updateApi", V2: "POST"}, + {PType: "p", V0: "9528", V1: "/api/getAllApis", V2: "POST"}, + + {PType: "p", V0: "9528", V1: "/authority/createAuthority", V2: "POST"}, + {PType: "p", V0: "9528", V1: "/authority/deleteAuthority", V2: "POST"}, + {PType: "p", V0: "9528", V1: "/authority/getAuthorityList", V2: "POST"}, + {PType: "p", V0: "9528", V1: "/authority/setDataAuthority", V2: "POST"}, + + {PType: "p", V0: "9528", V1: "/menu/getMenu", V2: "POST"}, + {PType: "p", V0: "9528", V1: "/menu/getMenuList", V2: "POST"}, + {PType: "p", V0: "9528", V1: "/menu/addBaseMenu", V2: "POST"}, + {PType: "p", V0: "9528", V1: "/menu/getBaseMenuTree", V2: "POST"}, + {PType: "p", V0: "9528", V1: "/menu/addMenuAuthority", V2: "POST"}, + {PType: "p", V0: "9528", V1: "/menu/getMenuAuthority", V2: "POST"}, + {PType: "p", V0: "9528", V1: "/menu/deleteBaseMenu", V2: "POST"}, + {PType: "p", V0: "9528", V1: "/menu/updateBaseMenu", V2: "POST"}, + {PType: "p", V0: "9528", V1: "/menu/getBaseMenuById", V2: "POST"}, + {PType: "p", V0: "9528", V1: "/user/changePassword", V2: "POST"}, + {PType: "p", V0: "9528", V1: "/user/getUserList", V2: "POST"}, + {PType: "p", V0: "9528", V1: "/user/setUserAuthority", V2: "POST"}, + {PType: "p", V0: "9528", V1: "/fileUploadAndDownload/upload", V2: "POST"}, + {PType: "p", V0: "9528", V1: "/fileUploadAndDownload/getFileList", V2: "POST"}, + {PType: "p", V0: "9528", V1: "/fileUploadAndDownload/deleteFile", V2: "POST"}, + {PType: "p", V0: "9528", V1: "/casbin/updateCasbin", V2: "POST"}, + {PType: "p", V0: "9528", V1: "/casbin/getPolicyPathByAuthorityId", V2: "POST"}, + {PType: "p", V0: "9528", V1: "/jwt/jsonInBlacklist", V2: "POST"}, + {PType: "p", V0: "9528", V1: "/system/getSystemConfig", V2: "POST"}, + {PType: "p", V0: "9528", V1: "/system/setSystemConfig", V2: "POST"}, + {PType: "p", V0: "9528", V1: "/customer/customer", V2: "PUT"}, + {PType: "p", V0: "9528", V1: "/customer/customer", V2: "GET"}, + {PType: "p", V0: "9528", V1: "/customer/customer", V2: "POST"}, + {PType: "p", V0: "9528", V1: "/customer/customer", V2: "DELETE"}, + {PType: "p", V0: "9528", V1: "/customer/customerList", V2: "GET"}, + {PType: "p", V0: "9528", V1: "/autoCode/createTemp", V2: "POST"}, + {PType: "p", V0: "9528", V1: "/user/getUserInfo", V2: "GET"}, } if err := global.GVA_DB.Create(&entities).Error; err != nil { return errors.Wrap(err, c.TableName()+"表数据初始化失败!") diff --git a/server/source/system/data_authorities.go b/server/source/system/data_authorities.go index f43c1ef8..70ec51e1 100644 --- a/server/source/system/data_authorities.go +++ b/server/source/system/data_authorities.go @@ -33,7 +33,7 @@ func (a *dataAuthorities) Initialize() error { } func (a *dataAuthorities) CheckDataExist() bool { - if errors.Is(global.GVA_DB.Where("authority_id = ? AND resources_id = ?", "9528", "9528").First(&AuthoritiesResources{}).Error, gorm.ErrRecordNotFound) { // 判断是否存在数据 + if errors.Is(global.GVA_DB.Where("sys_authority_authority_id = ? AND data_authority_id_authority_id = ?", "9528", "9528").First(&AuthoritiesResources{}).Error, gorm.ErrRecordNotFound) { // 判断是否存在数据 return false } return true @@ -41,8 +41,8 @@ func (a *dataAuthorities) CheckDataExist() bool { // AuthoritiesResources 角色资源表 type AuthoritiesResources struct { - AuthorityId string `gorm:"column:authority_id"` - ResourcesId string `gorm:"column:resources_id"` + AuthorityId string `gorm:"column:sys_authority_authority_id"` + ResourcesId string `gorm:"column:data_authority_id_authority_id"` } func (a *AuthoritiesResources) TableName() string { diff --git a/server/source/system/view_authority_menu_mysql.go b/server/source/system/view_authority_menu_mysql.go index b0c500e8..4ddf49b3 100644 --- a/server/source/system/view_authority_menu_mysql.go +++ b/server/source/system/view_authority_menu_mysql.go @@ -19,7 +19,28 @@ func (v *viewAuthorityMenuMysql) TableName() string { 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 := ` + 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.sys_base_menu_id AS menu_id, + @authorities_menus.sys_authority_authority_id AS authority_id + from (@authorities_menus + join @menus on ((@authorities_menus.sys_base_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())