using MediatR;
using TakeoutSaaS.Application.App.Tenants.Dto;
using TakeoutSaaS.Application.App.Tenants.Queries;
using TakeoutSaaS.Domain.Tenants.Repositories;

namespace TakeoutSaaS.Application.App.Tenants.Handlers;

/// <summary>
/// 获取租户审核领取信息查询处理器。
/// </summary>
public sealed class GetTenantReviewClaimQueryHandler(ITenantRepository tenantRepository)
    : IRequestHandler<GetTenantReviewClaimQuery, TenantReviewClaimDto?>
{
    /// <inheritdoc />
    public async Task<TenantReviewClaimDto?> Handle(GetTenantReviewClaimQuery request, CancellationToken cancellationToken)
    {
        // 1. 查询当前领取信息（未领取返回 null）
        var claim = await tenantRepository.GetActiveReviewClaimAsync(request.TenantId, cancellationToken);
        return claim?.ToDto();
    }
}
