File tree Expand file tree Collapse file tree 1 file changed +5
-14
lines changed Expand file tree Collapse file tree 1 file changed +5
-14
lines changed Original file line number Diff line number Diff line change @@ -5,13 +5,11 @@ import (
5
5
"gin-vue-admin/global"
6
6
"gin-vue-admin/model"
7
7
"gin-vue-admin/model/request"
8
- "strings"
9
- "sync"
10
-
11
8
"github.com/casbin/casbin/v2"
12
9
"github.com/casbin/casbin/v2/util"
13
10
gormadapter "github.com/casbin/gorm-adapter/v3"
14
11
_ "github.com/go-sql-driver/mysql"
12
+ "strings"
15
13
)
16
14
17
15
//@author: [piexlmax](https://github.com/piexlmax)
@@ -90,18 +88,11 @@ func ClearCasbin(v int, p ...string) bool {
90
88
//@description: 持久化到数据库 引入自定义规则
91
89
//@return: *casbin.Enforcer
92
90
93
- var (
94
- e * casbin.Enforcer
95
- once sync.Once
96
- )
97
-
98
91
func Casbin () * casbin.Enforcer {
99
- once .Do (func () {
100
- a , _ := gormadapter .NewAdapterByDB (global .GVA_DB )
101
- e , _ = casbin .NewEnforcer (global .GVA_CONFIG .Casbin .ModelPath , a )
102
- e .AddFunction ("ParamsMatch" , ParamsMatchFunc )
103
- _ = e .LoadPolicy ()
104
- })
92
+ a , _ := gormadapter .NewAdapterByDB (global .GVA_DB )
93
+ e , _ := casbin .NewEnforcer (global .GVA_CONFIG .Casbin .ModelPath , a )
94
+ e .AddFunction ("ParamsMatch" , ParamsMatchFunc )
95
+ _ = e .LoadPolicy ()
105
96
return e
106
97
}
107
98
You can’t perform that action at this time.
0 commit comments