基础架构变更 增加模块化
This commit is contained in:
40
server/utils/clamis.go
Normal file
40
server/utils/clamis.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"gin-vue-admin/global"
|
||||
systemReq "gin-vue-admin/model/system/request"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// 从Gin的Context中获取从jwt解析出来的用户ID
|
||||
func GetUserID(c *gin.Context) uint {
|
||||
if claims, exists := c.Get("claims"); !exists {
|
||||
global.GVA_LOG.Error("从Gin的Context中获取从jwt解析出来的用户ID失败, 请检查路由是否使用jwt中间件!")
|
||||
return 0
|
||||
} else {
|
||||
waitUse := claims.(*systemReq.CustomClaims)
|
||||
return waitUse.ID
|
||||
}
|
||||
}
|
||||
|
||||
// 从Gin的Context中获取从jwt解析出来的用户UUID
|
||||
func GetUserUuid(c *gin.Context) string {
|
||||
if claims, exists := c.Get("claims"); !exists {
|
||||
global.GVA_LOG.Error("从Gin的Context中获取从jwt解析出来的用户UUID失败, 请检查路由是否使用jwt中间件!")
|
||||
return ""
|
||||
} else {
|
||||
waitUse := claims.(*systemReq.CustomClaims)
|
||||
return waitUse.UUID.String()
|
||||
}
|
||||
}
|
||||
|
||||
// 从Gin的Context中获取从jwt解析出来的用户角色id
|
||||
func GetUserAuthorityId(c *gin.Context) string {
|
||||
if claims, exists := c.Get("claims"); !exists {
|
||||
global.GVA_LOG.Error("从Gin的Context中获取从jwt解析出来的用户UUID失败, 请检查路由是否使用jwt中间件!")
|
||||
return ""
|
||||
} else {
|
||||
waitUse := claims.(*systemReq.CustomClaims)
|
||||
return waitUse.AuthorityId
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user