package jwt import ( "context" "encoding/json" "git.noahlan.cn/noahlan/ntool/nlog" ) // GetCurrentUserId 获取当前用户ID func GetCurrentUserId(ctx context.Context) int64 { var ( uid int64 err error ) if jsonUid, ok := ctx.Value(KeyUserId).(json.Number); ok { uid, err = jsonUid.Int64() if err != nil { nlog.WithContext(ctx).Errorw("get current userId err", nlog.Field("details", err)) } } return uid }