using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Meezi.Core.Interfaces;
using Meezi.Shared;

namespace Meezi.Admin.API.Controllers;

[Authorize(Roles = "SystemAdmin")]
[ApiController]
public abstract class AdminApiControllerBase : ControllerBase
{
    protected string RequireAdminId(ITenantContext tenant)
    {
        if (!tenant.IsSystemAdmin || string.IsNullOrEmpty(tenant.UserId))
            throw new InvalidOperationException("System admin context required.");
        return tenant.UserId;
    }
}
