Files
TakeoutSaaS.AdminApi/src/Application/TakeoutSaaS.Application/App/QuotaPackages/Handlers/GetQuotaPackageListQueryHandler.cs
MSuMshk ab59e2e3e2 feat: 新增配额包/支付相关实体与迁移
App:新增 operation_logs/quota_packages/tenant_payments/tenant_quota_package_purchases 表

Identity:修正 Avatar 字段类型(varchar(256)->text),保持现有数据不变
2025-12-17 17:27:45 +08:00

42 lines
1.4 KiB
C#

using MediatR;
using TakeoutSaaS.Application.App.QuotaPackages.Dto;
using TakeoutSaaS.Application.App.QuotaPackages.Queries;
using TakeoutSaaS.Domain.Tenants.Repositories;
using TakeoutSaaS.Shared.Abstractions.Results;
namespace TakeoutSaaS.Application.App.QuotaPackages.Handlers;
/// <summary>
/// 获取配额包列表查询处理器。
/// </summary>
public sealed class GetQuotaPackageListQueryHandler(IQuotaPackageRepository quotaPackageRepository)
: IRequestHandler<GetQuotaPackageListQuery, PagedResult<QuotaPackageListDto>>
{
/// <inheritdoc />
public async Task<PagedResult<QuotaPackageListDto>> Handle(GetQuotaPackageListQuery request, CancellationToken cancellationToken)
{
// 1. 分页查询
var (items, total) = await quotaPackageRepository.SearchPagedAsync(
request.QuotaType,
request.IsActive,
request.Page,
request.PageSize,
cancellationToken);
// 2. 映射为 DTO
var dtos = items.Select(x => new QuotaPackageListDto
{
Id = x.Id,
Name = x.Name,
QuotaType = x.QuotaType,
QuotaValue = x.QuotaValue,
Price = x.Price,
IsActive = x.IsActive,
SortOrder = x.SortOrder
}).ToList();
// 3. 返回分页结果
return new PagedResult<QuotaPackageListDto>(dtos, request.Page, request.PageSize, total);
}
}