|
|
@ -55,7 +55,7 @@ func AddCasbin(cm model.CasbinModel) bool { |
|
|
|
// @return error
|
|
|
|
func UpdateCasbinApi(oldPath string, newPath string, oldMethod string, newMethod string) error { |
|
|
|
var cs []model.CasbinModel |
|
|
|
err := global.GVA_DB.Table("casbin_rule").Where("v1 = ? AND v2 = ?", oldPath,oldMethod).Find(&cs).Updates(map[string]string{ |
|
|
|
err := global.GVA_DB.Table("casbin_rule").Where("v1 = ? AND v2 = ?", oldPath, oldMethod).Find(&cs).Updates(map[string]string{ |
|
|
|
"v1": newPath, |
|
|
|
"v2": newMethod, |
|
|
|
}).Error |
|
|
@ -67,14 +67,16 @@ func UpdateCasbinApi(oldPath string, newPath string, oldMethod string, newMetho |
|
|
|
// @auth (2020/04/05 20:22)
|
|
|
|
// @param authorityId string
|
|
|
|
// @return []string
|
|
|
|
func GetPolicyPathByAuthorityId(authorityId string) []string { |
|
|
|
func GetPolicyPathByAuthorityId(authorityId string) (pathMaps []map[string]string) { |
|
|
|
e := Casbin() |
|
|
|
var pathList []string |
|
|
|
list := e.GetFilteredPolicy(0, authorityId) |
|
|
|
for _, v := range list { |
|
|
|
pathList = append(pathList, v[1]) |
|
|
|
pathMaps = append(pathMaps, map[string]string{ |
|
|
|
"path": v[1], |
|
|
|
"method": v[2], |
|
|
|
}) |
|
|
|
} |
|
|
|
return pathList |
|
|
|
return pathMaps |
|
|
|
} |
|
|
|
|
|
|
|
// @title ClearCasbin
|
|
|
|