package v1

import (
	"quyun/v2/database/models"
	"quyun/v2/pkg/consts"

	"github.com/gofiber/fiber/v3"
)

func getUserID(ctx fiber.Ctx) int64 {
	if u := ctx.Locals(consts.CtxKeyUser); u != nil {
		if user, ok := u.(*models.User); ok {
			return user.ID
		}
	}
	return 0
}

func getTenantID(ctx fiber.Ctx) int64 {
	if t := ctx.Locals(consts.CtxKeyTenant); t != nil {
		if tenant, ok := t.(*models.Tenant); ok {
			return tenant.ID
		}
	}
	return 0
}
