feat: 租户账单公告通知接口
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
using System.Linq;
|
||||
using MediatR;
|
||||
using TakeoutSaaS.Application.App.Tenants.Dto;
|
||||
using TakeoutSaaS.Application.App.Tenants.Queries;
|
||||
using TakeoutSaaS.Domain.Tenants.Repositories;
|
||||
using TakeoutSaaS.Shared.Abstractions.Results;
|
||||
|
||||
namespace TakeoutSaaS.Application.App.Tenants.Handlers;
|
||||
|
||||
/// <summary>
|
||||
/// 账单分页查询处理器。
|
||||
/// </summary>
|
||||
public sealed class SearchTenantBillsQueryHandler(ITenantBillingRepository billingRepository)
|
||||
: IRequestHandler<SearchTenantBillsQuery, PagedResult<TenantBillingDto>>
|
||||
{
|
||||
public async Task<PagedResult<TenantBillingDto>> Handle(SearchTenantBillsQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
var bills = await billingRepository.SearchAsync(request.TenantId, request.Status, request.From, request.To, cancellationToken);
|
||||
|
||||
var ordered = bills.OrderByDescending(x => x.PeriodEnd).ToList();
|
||||
var page = request.Page <= 0 ? 1 : request.Page;
|
||||
var size = request.PageSize <= 0 ? 20 : request.PageSize;
|
||||
var items = ordered.Skip((page - 1) * size).Take(size).Select(x => x.ToDto()).ToList();
|
||||
|
||||
return new PagedResult<TenantBillingDto>(items, page, size, ordered.Count);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user