You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

16 lines
446 B

package cur_userinfo
import (
"github.com/gin-gonic/gin"
"goskeleton/app/global/variable"
"goskeleton/app/http/middleware/my_jwt"
)
// GetCurrentUserId 获取当前用户的id
// @context 请求上下文
func GetCurrentUserId(context *gin.Context) (int64, bool) {
tokenKey := variable.ConfigYml.GetString("Token.BindContextKeyName")
currentUser, exist := context.MustGet(tokenKey).(my_jwt.CustomClaims)
return currentUser.UserId, exist
}