修复格式问题,重构嵌套层数过深的函数

This commit is contained in:
Leonard Wang
2020-05-19 23:46:07 +08:00
parent 5e2687a742
commit b09e54c205
38 changed files with 168 additions and 173 deletions
+5 -5
View File
@@ -8,19 +8,19 @@ import (
"github.com/gin-gonic/gin"
)
//拦截器
// 拦截器
func CasbinHandler() gin.HandlerFunc {
return func(c *gin.Context) {
claims, _ := c.Get("claims")
waitUse := claims.(*request.CustomClaims)
//获取请求的URI
// 获取请求的URI
obj := c.Request.URL.RequestURI()
//获取请求方法
// 获取请求方法
act := c.Request.Method
//获取用户的角色
// 获取用户的角色
sub := waitUse.AuthorityId
e := service.Casbin()
//判断策略中是否存在
// 判断策略中是否存在
if global.GVA_CONFIG.System.Env == "develop" || e.Enforce(sub, obj, act) {
c.Next()
} else {