style: linker

This commit is contained in:
songzhibin97
2021-12-06 12:44:26 +08:00
parent 2b9365da17
commit 0fe4750991
95 changed files with 208 additions and 235 deletions
+10 -11
View File
@@ -7,37 +7,36 @@ import (
uuid "github.com/satori/go.uuid"
)
func GetClaims(c *gin.Context) (*systemReq.CustomClaims,error) {
func GetClaims(c *gin.Context) (*systemReq.CustomClaims, error) {
token := c.Request.Header.Get("x-token")
j := NewJWT()
claims, err := j.ParseToken(token)
if err != nil {
global.GVA_LOG.Error("从Gin的Context中获取从jwt解析信息失败, 请检查请求头是否存在x-token且claims是否为规定结构")
}
return claims,err
return claims, err
}
// 从Gin的Context中获取从jwt解析出来的用户ID
func GetUserID(c *gin.Context) uint {
if claims, exists := c.Get("claims"); !exists {
if cl,err:= GetClaims(c);err!=nil{
if cl, err := GetClaims(c); err != nil {
return 0
}else{
} else {
return cl.ID
}
} else {
waitUse := claims.(*systemReq.CustomClaims)
return waitUse.ID
}
}
// 从Gin的Context中获取从jwt解析出来的用户UUID
func GetUserUuid(c *gin.Context) uuid.UUID {
if claims, exists := c.Get("claims"); !exists {
if cl,err:= GetClaims(c);err!=nil{
if cl, err := GetClaims(c); err != nil {
return uuid.UUID{}
}else{
} else {
return cl.UUID
}
} else {
@@ -49,9 +48,9 @@ func GetUserUuid(c *gin.Context) uuid.UUID {
// 从Gin的Context中获取从jwt解析出来的用户角色id
func GetUserAuthorityId(c *gin.Context) string {
if claims, exists := c.Get("claims"); !exists {
if cl,err:= GetClaims(c);err!=nil{
if cl, err := GetClaims(c); err != nil {
return ""
}else{
} else {
return cl.AuthorityId
}
} else {
@@ -63,9 +62,9 @@ func GetUserAuthorityId(c *gin.Context) string {
// 从Gin的Context中获取从jwt解析出来的用户角色id
func GetUserInfo(c *gin.Context) *systemReq.CustomClaims {
if claims, exists := c.Get("claims"); !exists {
if cl,err:= GetClaims(c);err!=nil{
if cl, err := GetClaims(c); err != nil {
return nil
}else{
} else {
return cl
}
} else {