feat(club-membership): enhance club membership history queries and responses
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:
masoodafar-web
2026-06-22 22:19:44 +03:30
parent 6395f63ab5
commit f8794bbb63
41 changed files with 1590 additions and 74 deletions
@@ -0,0 +1,83 @@
using CMSMicroservice.Application.UserPackagePurchaseCQ.Queries.GetAllUserPackagePurchaseByFilter;
using CMSMicroservice.Application.UserPackagePurchaseCQ.Queries.GetUserPackagePurchaseSummary;
using CMSMicroservice.Protobuf.Protos.UserPackagePurchase;
using Google.Protobuf.WellKnownTypes;
using Mapster;
namespace CMSMicroservice.WebApi.Common.Mappings;
public class UserPackagePurchaseProfile : IRegister
{
public void Register(TypeAdapterConfig config)
{
config.NewConfig<GetAllUserPackagePurchaseByFilterRequest, GetAllUserPackagePurchaseByFilterQuery>()
.MapWith(src => new GetAllUserPackagePurchaseByFilterQuery
{
PaginationState = MapPagination(src.PaginationState),
SortBy = src.HasSortBy ? src.SortBy : null,
Filter = MapFilter(src.Filter)
});
config.NewConfig<GetAllUserPackagePurchaseByFilterResponseDto, GetAllUserPackagePurchaseByFilterResponse>()
.MapWith(src => new GetAllUserPackagePurchaseByFilterResponse
{
MetaData = MapMeta(src.MetaData),
Models = { src.Models?.Select(m => new UserPackagePurchaseModel
{
Id = m.Id,
UserId = m.UserId,
UserName = m.UserName,
UserMobile = m.UserMobile,
PackageId = m.PackageId,
PackageName = m.PackageName,
PurchaseMethod = (int)m.PurchaseMethod,
PurchasedAt = Timestamp.FromDateTime(DateTime.SpecifyKind(m.PurchasedAt, DateTimeKind.Utc)),
Amount = m.Amount,
OrderId = m.OrderId,
TransactionId = m.TransactionId,
CreatedAt = Timestamp.FromDateTimeOffset(m.Created)
}) ?? [] }
});
config.NewConfig<GetUserPackagePurchaseSummaryRequest, GetUserPackagePurchaseSummaryQuery>()
.MapWith(src => new GetUserPackagePurchaseSummaryQuery { Filter = MapFilter(src.Filter) });
config.NewConfig<GetUserPackagePurchaseSummaryResponseDto, GetUserPackagePurchaseSummaryResponse>()
.MapWith(src => new GetUserPackagePurchaseSummaryResponse
{
TotalCount = src.TotalCount,
TotalAmount = src.TotalAmount
});
}
private static GetAllUserPackagePurchaseByFilterFilter? MapFilter(GetAllUserPackagePurchaseByFilterFilter? src)
{
if (src == null) return null;
return new GetAllUserPackagePurchaseByFilterFilter
{
UserId = src.HasUserId ? src.UserId : null,
PackageId = src.HasPackageId ? src.PackageId : null,
PurchaseMethod = src.HasPurchaseMethod ? (Domain.Enums.PackagePurchaseMethod)src.PurchaseMethod : null,
PurchasedFrom = src.PurchasedFrom?.ToDateTime(),
PurchasedTo = src.PurchasedTo?.ToDateTime(),
MinAmount = src.HasMinAmount ? src.MinAmount : null,
MaxAmount = src.HasMaxAmount ? src.MaxAmount : null
};
}
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
};
}