File tree Expand file tree Collapse file tree 1 file changed +7
-16
lines changed Expand file tree Collapse file tree 1 file changed +7
-16
lines changed Original file line number Diff line number Diff line change @@ -21,31 +21,22 @@ import (
2121
2222func UpdateCasbin (authorityId string , casbinInfos []request.CasbinInfo ) error {
2323 ClearCasbin (0 , authorityId )
24+ rules := [][]string {}
2425 for _ , v := range casbinInfos {
2526 cm := model.CasbinModel {
2627 Ptype : "p" ,
2728 AuthorityId : authorityId ,
2829 Path : v .Path ,
2930 Method : v .Method ,
3031 }
31- addflag := AddCasbin (cm )
32- if addflag == false {
33- return errors .New ("存在相同api,添加失败,请联系管理员" )
34- }
32+ rules = append (rules , []string {cm .AuthorityId , cm .Path , cm .Method })
3533 }
36- return nil
37- }
38-
39- // @title AddCasbin
40- // @description add casbin authority, 添加权限
41- // @auth (2020/04/05 20:22)
42- // @param cm model.CasbinModel
43- // @return bool
44-
45- func AddCasbin (cm model.CasbinModel ) bool {
4634 e := Casbin ()
47- success , _ := e .AddPolicy (cm .AuthorityId , cm .Path , cm .Method )
48- return success
35+ success , _ := e .AddPolicies (rules )
36+ if success == false {
37+ return errors .New ("存在相同api,添加失败,请联系管理员" )
38+ }
39+ return nil
4940}
5041
5142// @title UpdateCasbinApi
You can’t perform that action at this time.
0 commit comments