update
This commit is contained in:
+29
@@ -0,0 +1,29 @@
|
||||
namespace BackOffice.BFF.Application.CommissionCQ.Queries.GetUserWeeklyBalances;
|
||||
|
||||
public record GetUserWeeklyBalancesQuery : IRequest<GetUserWeeklyBalancesResponseDto>
|
||||
{
|
||||
/// <summary>
|
||||
/// شناسه کاربر (فیلتر اختیاری)
|
||||
/// </summary>
|
||||
public long? UserId { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// شماره هفته (فیلتر اختیاری)
|
||||
/// </summary>
|
||||
public string? WeekNumber { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// فقط تعادلهای فعال (منقضی نشده)
|
||||
/// </summary>
|
||||
public bool OnlyActive { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// شماره صفحه
|
||||
/// </summary>
|
||||
public int PageIndex { get; init; } = 1;
|
||||
|
||||
/// <summary>
|
||||
/// تعداد در صفحه
|
||||
/// </summary>
|
||||
public int PageSize { get; init; } = 10;
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
using BackOffice.BFF.Commission.Protobuf;
|
||||
|
||||
namespace BackOffice.BFF.Application.CommissionCQ.Queries.GetUserWeeklyBalances;
|
||||
|
||||
public class GetUserWeeklyBalancesQueryHandler : IRequestHandler<GetUserWeeklyBalancesQuery, GetUserWeeklyBalancesResponseDto>
|
||||
{
|
||||
private readonly IApplicationContractContext _context;
|
||||
|
||||
public GetUserWeeklyBalancesQueryHandler(IApplicationContractContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public async Task<GetUserWeeklyBalancesResponseDto> Handle(GetUserWeeklyBalancesQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
var grpcRequest = new GetUserWeeklyBalancesRequest
|
||||
{
|
||||
OnlyActive = request.OnlyActive,
|
||||
PageIndex = request.PageIndex,
|
||||
PageSize = request.PageSize
|
||||
};
|
||||
|
||||
if (request.UserId.HasValue)
|
||||
{
|
||||
grpcRequest.UserId = request.UserId.Value;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(request.WeekNumber))
|
||||
{
|
||||
grpcRequest.WeekNumber = request.WeekNumber;
|
||||
}
|
||||
|
||||
var response = await _context.Commissions.GetUserWeeklyBalancesAsync(grpcRequest, cancellationToken: cancellationToken);
|
||||
|
||||
return response.Adapt<GetUserWeeklyBalancesResponseDto>();
|
||||
}
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
namespace BackOffice.BFF.Application.CommissionCQ.Queries.GetUserWeeklyBalances;
|
||||
|
||||
public record GetUserWeeklyBalancesResponseDto
|
||||
{
|
||||
public MetaDataDto MetaData { get; init; } = new();
|
||||
public List<UserWeeklyBalanceDto> Models { get; init; } = new();
|
||||
}
|
||||
|
||||
public record UserWeeklyBalanceDto
|
||||
{
|
||||
public long Id { get; init; }
|
||||
public long UserId { get; init; }
|
||||
public string WeekNumber { get; init; } = string.Empty;
|
||||
public int LeftLegBalances { get; init; }
|
||||
public int RightLegBalances { get; init; }
|
||||
public int TotalBalances { get; init; }
|
||||
public long WeeklyPoolContribution { get; init; }
|
||||
public DateTime? CalculatedAt { get; init; }
|
||||
public bool IsExpired { get; init; }
|
||||
public DateTime Created { get; init; }
|
||||
}
|
||||
|
||||
public record MetaDataDto
|
||||
{
|
||||
public int TotalCount { get; init; }
|
||||
public int PageSize { get; init; }
|
||||
public int CurrentPage { get; init; }
|
||||
public int TotalPages { get; init; }
|
||||
}
|
||||
Reference in New Issue
Block a user