api层写法统一

This commit is contained in:
linwenxiang committed 2021-03-12 16:02:29 +08:00
1 parent fa30b8db95
commit 9bf9330410
40 files changed
+430 -316

No files matched your search

+3 -4
View File
@@ -5,16 +5,15 @@ import (
"github.com/gin-gonic/gin"
"github.com/go-admin-team/go-admin-core/sdk"
"github.com/go-admin-team/go-admin-core/sdk/api"
"github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth"
"github.com/go-admin-team/go-admin-core/sdk/pkg/response"
"go-admin/common/apis"
)
//权限检查中间件
func AuthCheckRole() gin.HandlerFunc {
return func(c *gin.Context) {
log := apis.GetRequestLogger(c)
log := api.GetRequestLogger(c)
data, _ := c.Get(jwtauth.JwtPayloadKey)
v := data.(jwtauth.MapClaims)
e := sdk.Runtime.GetCasbinKey(c.Request.Host)
@@ -28,7 +27,7 @@ func AuthCheckRole() gin.HandlerFunc {
res, err = e.Enforce(v["rolekey"], c.Request.URL.Path, c.Request.Method)
if err != nil {
log.Errorf("AuthCheckRole error:%s method:%s path:%s", err, c.Request.Method, c.Request.URL.Path)
app.Error(c, 500, err, "")
response.Error(c, 500, err, "")
return
}
}