From 1256ea0c00f320e2abd1126808de050834e86152 Mon Sep 17 00:00:00 2001 From: Ho Ngoc Hai Date: Sun, 29 Mar 2026 00:15:21 +0700 Subject: [PATCH] fix(superadmin): add shops list to merchant detail view MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add AdminShopSummaryDto to AdminDtos.cs - Add Shops list to AdminMerchantDetailDto (optional, with default null) - Fetch shops in GetMerchantDetailQueryHandler with status + category name joins - Tab "Cửa hàng" now shows real shop data (name, category, status, created date) Co-Authored-By: Claude Opus 4.6 (1M context) --- .../Application/Queries/Admin/AdminDtos.cs | 10 +++++++- .../Queries/Admin/GetMerchantDetailQuery.cs | 25 ++++++++++++++----- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/services/merchant-service-net/src/MerchantService.API/Application/Queries/Admin/AdminDtos.cs b/services/merchant-service-net/src/MerchantService.API/Application/Queries/Admin/AdminDtos.cs index 0a4a1deb..de7c8e0f 100644 --- a/services/merchant-service-net/src/MerchantService.API/Application/Queries/Admin/AdminDtos.cs +++ b/services/merchant-service-net/src/MerchantService.API/Application/Queries/Admin/AdminDtos.cs @@ -78,7 +78,15 @@ public record AdminMerchantDetailDto( DateTime CreatedAt, DateTime? UpdatedAt, DateTime? VerifiedAt, - Guid? VerifiedBy); + Guid? VerifiedBy, + List? Shops = null); + +/// +/// EN: Shop summary for merchant detail view. +/// VI: Tóm tắt cửa hàng cho trang chi tiết merchant. +/// +public record AdminShopSummaryDto( + Guid Id, string Name, string? Category, string? Status, DateTime CreatedAt); #endregion diff --git a/services/merchant-service-net/src/MerchantService.API/Application/Queries/Admin/GetMerchantDetailQuery.cs b/services/merchant-service-net/src/MerchantService.API/Application/Queries/Admin/GetMerchantDetailQuery.cs index 7e6e915c..c5820458 100644 --- a/services/merchant-service-net/src/MerchantService.API/Application/Queries/Admin/GetMerchantDetailQuery.cs +++ b/services/merchant-service-net/src/MerchantService.API/Application/Queries/Admin/GetMerchantDetailQuery.cs @@ -4,6 +4,7 @@ using MediatR; using Microsoft.EntityFrameworkCore; using MerchantService.Domain.AggregatesModel.MerchantAggregate; +using MerchantService.Domain.AggregatesModel.ShopAggregate; using MerchantService.Domain.Exceptions; using MerchantService.Infrastructure; @@ -54,10 +55,21 @@ public class GetMerchantDetailQueryHandler : IRequestHandler EF.Property(s, "_merchantId") == request.MerchantId && !EF.Property(s, "_isDeleted")) - .CountAsync(cancellationToken); + .Join(_context.Set(), s => s.StatusId, st => st.Id, (s, st) => new { s, StatusName = st.Name }) + .Join(_context.Set(), x => x.s.CategoryId, c => c.Id, (x, c) => new { x.s, x.StatusName, CategoryName = c.Name }) + .Select(x => new AdminShopSummaryDto( + x.s.Id, + EF.Property(x.s, "_name"), + x.CategoryName, + x.StatusName, + EF.Property(x.s, "_createdAt"))) + .ToListAsync(cancellationToken); var staffCount = await _context.MerchantStaff .CountAsync(s => s.MerchantId == request.MerchantId, cancellationToken); @@ -69,15 +81,16 @@ public class GetMerchantDetailQueryHandler : IRequestHandler