Browse Source
Merge pull request #496 from flipped-aurora/gva_gormv2_dev
修复casbin map占用问题
main
v2.4.2
奇淼(piexlmax
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with
16 additions and
8 deletions
-
server/core/server.go
-
server/service/sys_casbin.go
-
web/src/main.js
|
|
@ -29,7 +29,7 @@ func RunWindowsServer() { |
|
|
|
|
|
|
|
fmt.Printf(` |
|
|
|
欢迎使用 Gin-Vue-Admin |
|
|
|
当前版本:V2.4.1 |
|
|
|
当前版本:V2.4.2 |
|
|
|
加群方式:微信号:shouzi_1994 QQ群:622360840 |
|
|
|
默认自动化文档地址:http://127.0.0.1%s/swagger/index.html
|
|
|
|
默认前端文件运行地址:http://127.0.0.1:8080
|
|
|
|
|
|
@ -10,6 +10,7 @@ import ( |
|
|
|
gormadapter "github.com/casbin/gorm-adapter/v3" |
|
|
|
_ "github.com/go-sql-driver/mysql" |
|
|
|
"strings" |
|
|
|
"sync" |
|
|
|
) |
|
|
|
|
|
|
|
//@author: [piexlmax](https://github.com/piexlmax)
|
|
|
@ -88,12 +89,19 @@ func ClearCasbin(v int, p ...string) bool { |
|
|
|
//@description: 持久化到数据库 引入自定义规则
|
|
|
|
//@return: *casbin.Enforcer
|
|
|
|
|
|
|
|
func Casbin() *casbin.Enforcer { |
|
|
|
a, _ := gormadapter.NewAdapterByDB(global.GVA_DB) |
|
|
|
e, _ := casbin.NewEnforcer(global.GVA_CONFIG.Casbin.ModelPath, a) |
|
|
|
e.AddFunction("ParamsMatch", ParamsMatchFunc) |
|
|
|
_ = e.LoadPolicy() |
|
|
|
return e |
|
|
|
var ( |
|
|
|
syncedEnforcer *casbin.SyncedEnforcer |
|
|
|
once sync.Once |
|
|
|
) |
|
|
|
|
|
|
|
func Casbin() *casbin.SyncedEnforcer { |
|
|
|
once.Do(func() { |
|
|
|
a, _ := gormadapter.NewAdapterByDB(global.GVA_DB) |
|
|
|
syncedEnforcer, _ = casbin.NewSyncedEnforcer(global.GVA_CONFIG.Casbin.ModelPath, a) |
|
|
|
syncedEnforcer.AddFunction("ParamsMatch", ParamsMatchFunc) |
|
|
|
}) |
|
|
|
_ = syncedEnforcer.LoadPolicy() |
|
|
|
return syncedEnforcer |
|
|
|
} |
|
|
|
|
|
|
|
//@author: [piexlmax](https://github.com/piexlmax)
|
|
|
|
|
|
@ -149,7 +149,7 @@ export default new Vue({ |
|
|
|
|
|
|
|
console.log(`
|
|
|
|
欢迎使用 Gin-Vue-Admin |
|
|
|
当前版本:V2.4.1 |
|
|
|
当前版本:V2.4.2 |
|
|
|
加群方式:微信:shouzi_1994 QQ群:622360840 |
|
|
|
默认自动化文档地址:http://127.0.0.1:${process.env.VUE_APP_SERVER_PORT}/swagger/index.html
|
|
|
|
默认前端文件运行地址:http://127.0.0.1:${process.env.VUE_APP_CLI_PORT}
|
|
|
|