package helper

import (
	"context"
	"github.com/go-kratos/kratos/v2/transport/http"
	"strconv"
)

// GetLoginUserId 获取登录信息
func GetLoginUserId(ctx context.Context) int {
	rq, ok := http.RequestFromServerContext(ctx)
	if !ok {
		return 0
	}
	id := rq.Header.Get("User-Id")
	userId, _ := strconv.Atoi(id)
	return userId
}
