feat(club-membership): enhance club membership history queries and responses
Build and Deploy to Kubernetes / build-and-deploy (push) Failing after 17m54s
Build and Deploy to Kubernetes / build-and-deploy (push) Failing after 17m54s
- Added filtering capabilities to GetClubMembershipHistoryQuery, allowing optional filters for UserId, ClubMembershipId, Action, and date range. - Updated GetClubMembershipHistoryQueryHandler to utilize the new filter structure. - Enhanced GetAllClubMembershipsQueryHandler to include LastPackage details in the response. - Introduced new properties in GetAllClubMembershipsResponseModel for PackageId and PackageName. - Updated Protobuf definitions to reflect changes in club membership history queries and responses. - Refactored mapping configurations to accommodate new DTOs and filters.
This commit is contained in:
@@ -0,0 +1,102 @@
|
||||
using CMSMicroservice.Application.PaymentTransactionCQ.Queries.GetAllPaymentTransactionByFilter;
|
||||
using CMSMicroservice.Application.PaymentTransactionCQ.Queries.GetPaymentTransactionSummary;
|
||||
using CMSMicroservice.Protobuf.Protos.PaymentTransaction;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
using Mapster;
|
||||
|
||||
namespace CMSMicroservice.WebApi.Common.Mappings;
|
||||
|
||||
public class PaymentTransactionProfile : IRegister
|
||||
{
|
||||
public void Register(TypeAdapterConfig config)
|
||||
{
|
||||
config.NewConfig<GetAllPaymentTransactionByFilterRequest, GetAllPaymentTransactionByFilterQuery>()
|
||||
.MapWith(MapListQuery);
|
||||
|
||||
config.NewConfig<GetAllPaymentTransactionByFilterResponseDto, GetAllPaymentTransactionByFilterResponse>()
|
||||
.MapWith(MapListResponse);
|
||||
|
||||
config.NewConfig<GetPaymentTransactionSummaryRequest, GetPaymentTransactionSummaryQuery>()
|
||||
.MapWith(src => new GetPaymentTransactionSummaryQuery
|
||||
{
|
||||
Filter = MapFilter(src.Filter)
|
||||
});
|
||||
|
||||
config.NewConfig<GetPaymentTransactionSummaryResponseDto, GetPaymentTransactionSummaryResponse>()
|
||||
.MapWith(src => new GetPaymentTransactionSummaryResponse
|
||||
{
|
||||
TotalCount = src.TotalCount,
|
||||
TotalAmount = src.TotalAmount,
|
||||
SuccessfulCount = src.SuccessfulCount,
|
||||
PendingCount = src.PendingCount
|
||||
});
|
||||
}
|
||||
|
||||
private static GetAllPaymentTransactionByFilterQuery MapListQuery(GetAllPaymentTransactionByFilterRequest src) =>
|
||||
new()
|
||||
{
|
||||
PaginationState = MapPagination(src.PaginationState),
|
||||
SortBy = src.HasSortBy ? src.SortBy : null,
|
||||
Filter = MapFilter(src.Filter)
|
||||
};
|
||||
|
||||
private static GetAllPaymentTransactionByFilterResponse MapListResponse(GetAllPaymentTransactionByFilterResponseDto src) =>
|
||||
new()
|
||||
{
|
||||
MetaData = MapMeta(src.MetaData),
|
||||
Models = { src.Models?.Select(MapModel) ?? [] }
|
||||
};
|
||||
|
||||
private static GetAllPaymentTransactionByFilterFilter? MapFilter(GetAllPaymentTransactionByFilterFilter? src)
|
||||
{
|
||||
if (src == null) return null;
|
||||
return new GetAllPaymentTransactionByFilterFilter
|
||||
{
|
||||
UserId = src.HasUserId ? src.UserId : null,
|
||||
Mobile = src.HasMobile ? src.Mobile : null,
|
||||
GatewayProvider = src.HasGatewayProvider ? src.GatewayProvider : null,
|
||||
PaymentStatus = src.HasPaymentStatus ? src.PaymentStatus : null,
|
||||
Authority = src.HasAuthority ? src.Authority : null,
|
||||
RefId = src.HasRefId ? src.RefId : null,
|
||||
OrderId = src.HasOrderId ? src.OrderId : null,
|
||||
CreatedFrom = src.CreatedFrom?.ToDateTime(),
|
||||
CreatedTo = src.CreatedTo?.ToDateTime()
|
||||
};
|
||||
}
|
||||
|
||||
private static PaymentTransactionModel MapModel(GetAllPaymentTransactionByFilterResponseModel m) =>
|
||||
new()
|
||||
{
|
||||
Id = m.Id,
|
||||
UserId = m.UserId ?? 0,
|
||||
Mobile = m.Mobile ?? string.Empty,
|
||||
GatewayProvider = m.GatewayProvider,
|
||||
Amount = m.Amount,
|
||||
Authority = m.Authority ?? string.Empty,
|
||||
PaymentStatus = m.PaymentStatus,
|
||||
VerificationStatusCode = m.VerificationStatusCode,
|
||||
VerificationStatusMessage = m.VerificationStatusMessage ?? string.Empty,
|
||||
RefId = m.RefId ?? string.Empty,
|
||||
CardPan = m.CardPan ?? string.Empty,
|
||||
OrderId = m.OrderId ?? string.Empty,
|
||||
TransactionId = m.TransactionId,
|
||||
Description = m.Description ?? string.Empty,
|
||||
CreatedAt = Timestamp.FromDateTimeOffset(m.Created)
|
||||
};
|
||||
|
||||
private static Application.Common.Models.PaginationState? MapPagination(CMSMicroservice.Protobuf.Protos.PaginationState? ps) =>
|
||||
ps == null ? null : new Application.Common.Models.PaginationState
|
||||
{
|
||||
PageNumber = ps.PageNumber > 0 ? ps.PageNumber : 1,
|
||||
PageSize = ps.PageSize > 0 ? ps.PageSize : 20
|
||||
};
|
||||
|
||||
private static CMSMicroservice.Protobuf.Protos.MetaData MapMeta(Application.Common.Models.MetaData meta) =>
|
||||
new()
|
||||
{
|
||||
CurrentPage = meta.CurrentPage,
|
||||
PageSize = meta.PageSize,
|
||||
TotalCount = meta.TotalCount,
|
||||
TotalPage = meta.TotalPage
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user