From ed644384cc322c3b44105e31362f7df8234af3b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E8=87=AA=E8=BE=BE?= <980324341@qq.com> Date: Tue, 17 Nov 2026 17:14:29 +0800 Subject: [PATCH] =?UTF-8?q?feat(jd):=20=E5=88=86=E7=B1=BB=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E5=BF=AB=E7=AD=9B=20backend-only=20pick=EF=BC=88d25c9?= =?UTF-8?q?1f6=20=E7=9A=84=20backend-java=20=E5=B7=AE=E9=9B=86=E6=89=93?= =?UTF-8?q?=E5=9C=A8=20ee613db0=20=E4=B8=8A=EF=BC=9Bjar=20=E4=B8=8D?= =?UTF-8?q?=E5=90=AB=20V209=E2=80=94=E2=80=9420ee7334=20=E7=95=99=E5=8E=9F?= =?UTF-8?q?=E7=AA=97=E9=9A=8F=E5=85=B6=E9=85=8D=E5=A5=97=E5=89=8D=E7=AB=AF?= =?UTF-8?q?=E5=8F=91=EF=BC=9B=E5=90=8E=E7=AE=A1=E9=9D=A2=E4=BB=8E=E4=B8=BB?= =?UTF-8?q?=E6=A0=91=20HEAD=20=E5=8D=95=E7=8B=AC=E5=87=BA=E5=8C=85?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/AdminJdProductController.java | 6 +- .../modules/jd/mapper/JdProductMapper.java | 9 +- .../jd/service/JdProductQueryService.java | 27 ++-- .../resources/mapper/jd/JdProductMapper.xml | 23 ++++ .../AdminJdProductControllerTest.java | 116 +++++++++++++----- 5 files changed, 139 insertions(+), 42 deletions(-) diff --git a/backend-java/src/main/java/com/nanri/aiimage/modules/jd/controller/AdminJdProductController.java b/backend-java/src/main/java/com/nanri/aiimage/modules/jd/controller/AdminJdProductController.java index 8572ea1ed..a689c5c57 100644 --- a/backend-java/src/main/java/com/nanri/aiimage/modules/jd/controller/AdminJdProductController.java +++ b/backend-java/src/main/java/com/nanri/aiimage/modules/jd/controller/AdminJdProductController.java @@ -120,6 +120,9 @@ public class AdminJdProductController { @RequestParam(name = "synced_from", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDateTime syncedFrom, @Parameter(description = "同步结束时间(包含,ISO datetime)") @RequestParam(name = "synced_to", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDateTime syncedTo, + @Parameter(description = "分类状态快筛(2026-11-17 用户口径「加个已分类和未分类的筛选」):" + + "true=当前分组下有分类,false=未分类,缺省=全部;按 V203 归属表 SQL 侧下推") + @RequestParam(name = "classified", required = false) Boolean classified, HttpServletRequest request) { RequestOperator operator = requireJdAccess(request); if (request.getParameter("grouped") != null || request.getParameter("ungrouped") != null) { @@ -131,7 +134,8 @@ public class AdminJdProductController { requireVisibleCategory(scope, groupId); } return ApiResponse.success(jdProductQueryService.page(page, pageSize, - productCode, titleKeyword, category, groupId, syncedFrom, syncedTo, scopedOwnerGroupId)); + productCode, titleKeyword, category, groupId, syncedFrom, syncedTo, classified, + scopedOwnerGroupId)); } @GetMapping("/categories") diff --git a/backend-java/src/main/java/com/nanri/aiimage/modules/jd/mapper/JdProductMapper.java b/backend-java/src/main/java/com/nanri/aiimage/modules/jd/mapper/JdProductMapper.java index 299384bde..98d21bf2b 100644 --- a/backend-java/src/main/java/com/nanri/aiimage/modules/jd/mapper/JdProductMapper.java +++ b/backend-java/src/main/java/com/nanri/aiimage/modules/jd/mapper/JdProductMapper.java @@ -49,13 +49,18 @@ public interface JdProductMapper extends BaseMapper { * 「分类不要了,全部整合到类目里」撤掉(独立「分类」筛选框前端下线, * {@code groupId} 改由类目面板「自定义分类」选中驱动)。 * 店铺名过滤参数已随 2026-11-15 客户口径「店铺不需要」同窗撤掉(DB 列与详情/回传链不动)。 + * {@code classified}+{@code ownerGroupId}(2026-11-17 用户口径「加个已分类和未分类的筛选」): + * 按 V203 归属表 EXISTS/NOT EXISTS 快筛分类状态,NULL=不过滤;与 11-16 撤掉的旧 + * grouped/ungrouped(读已停用的 biz_jd_product.group_id 列)不是一回事。 */ long countProducts(@Param("productCode") String productCode, @Param("titleKeyword") String titleKeyword, @Param("category") String category, @Param("groupId") Long groupId, @Param("syncedFrom") LocalDateTime syncedFrom, - @Param("syncedTo") LocalDateTime syncedTo); + @Param("syncedTo") LocalDateTime syncedTo, + @Param("classified") Boolean classified, + @Param("ownerGroupId") Long ownerGroupId); /** * 商品上架配额计数({@code JdPublishQuotaService}):按 owner uid 集(管理员本人+ @@ -95,6 +100,8 @@ public interface JdProductMapper extends BaseMapper { @Param("groupId") Long groupId, @Param("syncedFrom") LocalDateTime syncedFrom, @Param("syncedTo") LocalDateTime syncedTo, + @Param("classified") Boolean classified, + @Param("ownerGroupId") Long ownerGroupId, @Param("offset") long offset, @Param("limit") int limit); diff --git a/backend-java/src/main/java/com/nanri/aiimage/modules/jd/service/JdProductQueryService.java b/backend-java/src/main/java/com/nanri/aiimage/modules/jd/service/JdProductQueryService.java index 68843d219..09e792670 100644 --- a/backend-java/src/main/java/com/nanri/aiimage/modules/jd/service/JdProductQueryService.java +++ b/backend-java/src/main/java/com/nanri/aiimage/modules/jd/service/JdProductQueryService.java @@ -79,14 +79,18 @@ public class JdProductQueryService { * 分页查询商品行({@code synced_at} 倒序)。 * *

过滤面:商品编码 contains、标题关键词 contains、类目 eq、分组 eq(2026-11-16 起 - * 由类目面板「自定义分类」选中驱动)、同步起止(datetime 闭区间)。 - * 未分类/已分类两档(ungrouped/grouped)与独立「分类」筛选框随同日口径 - * 「分类不要了,全部整合到类目里」整批撤掉。 + * 由类目面板「自定义分类」选中驱动)、同步起止(datetime 闭区间)、分类状态档 + * {@code classified}(2026-11-17 用户口径「加个已分类和未分类的筛选」:true=当前分组下 + * 有分类、false=没有、null=全部;按 V203 归属表 EXISTS/NOT EXISTS 在 SQL 侧下推, + * 判据与 {@link #fillGroupNames} 填分类列的条件同形——「筛选说未分类的行,列表分类列 + * 也必须是未分类」)。 + * 2026-11-16 撤掉的旧 ungrouped/grouped 两档读的是已停用的 biz_jd_product.group_id 列, + * 与本档不是一回事;独立「分类」筛选框的撤掉口径不变。 * 公司维过滤已随 2026-11-16 摘公司 tab 整批撤掉(全平台公共)。

*/ public JdProductPageVo page(Long page, Long pageSize, String productCode, String titleKeyword, String category, Long groupId, - LocalDateTime syncedFrom, LocalDateTime syncedTo, Long ownerGroupId) { + LocalDateTime syncedFrom, LocalDateTime syncedTo, Boolean classified, Long ownerGroupId) { if (syncedFrom != null && syncedTo != null && syncedFrom.isAfter(syncedTo)) { throw new BusinessException("开始时间不能晚于结束时间"); } @@ -94,14 +98,14 @@ public class JdProductQueryService { long safeSize = pageSize == null ? PageDefaults.JD_PRODUCTS_PAGE_SIZE_INT : Math.min(Math.max(pageSize, 1), MAX_PAGE_SIZE); Filter filter = filter(productCode, titleKeyword, category, - groupId, syncedFrom, syncedTo); + groupId, syncedFrom, syncedTo, classified); long total = jdProductMapper.countProducts(filter.productCode(), filter.titleKeyword(), filter.category(), filter.groupId(), - filter.syncedFrom(), filter.syncedTo()); + filter.syncedFrom(), filter.syncedTo(), filter.classified(), ownerGroupId); List rows = total <= 0 ? List.of() : jdProductMapper.selectProductPage(filter.productCode(), filter.titleKeyword(), filter.category(), filter.groupId(), - filter.syncedFrom(), filter.syncedTo(), + filter.syncedFrom(), filter.syncedTo(), filter.classified(), ownerGroupId, (safePage - 1) * safeSize, (int) safeSize); List items = rows.stream().map(this::toListItem).toList(); fillGroupNames(items, ownerGroupId); @@ -176,18 +180,19 @@ public class JdProductQueryService { // ---------------------------------------------------------------- 过滤面 - /** 服务侧过滤面归一:groupId ≤0 按没选处理,文本 trim 后空串归 null(无公司维,2026-11-16 摘)。 */ + /** 服务侧过滤面归一:groupId ≤0 按没选处理,文本 trim 后空串归 null(无公司维,2026-11-16 摘); + * classified 原样直传(null=不过滤该面,2026-11-17 分类状态快筛)。 */ private record Filter(String productCode, String titleKeyword, String category, Long groupId, - LocalDateTime syncedFrom, LocalDateTime syncedTo) { + LocalDateTime syncedFrom, LocalDateTime syncedTo, Boolean classified) { } private static Filter filter(String productCode, String titleKeyword, String category, Long groupId, - LocalDateTime syncedFrom, LocalDateTime syncedTo) { + LocalDateTime syncedFrom, LocalDateTime syncedTo, Boolean classified) { Long safeGroupId = groupId != null && groupId > 0 ? groupId : null; return new Filter(trimToNull(productCode), trimToNull(titleKeyword), - trimToNull(category), safeGroupId, syncedFrom, syncedTo); + trimToNull(category), safeGroupId, syncedFrom, syncedTo, classified); } // ---------------------------------------------------------------- 列表/详情搬运 diff --git a/backend-java/src/main/resources/mapper/jd/JdProductMapper.xml b/backend-java/src/main/resources/mapper/jd/JdProductMapper.xml index 8297d5f4f..f838e156c 100644 --- a/backend-java/src/main/resources/mapper/jd/JdProductMapper.xml +++ b/backend-java/src/main/resources/mapper/jd/JdProductMapper.xml @@ -122,6 +122,29 @@ WHERE a.product_id = p.id AND a.category_id = #{groupId} ) + + + + + AND EXISTS ( + SELECT 1 FROM biz_jd_product_group_assign cs + WHERE cs.product_id = p.id AND cs.owner_group_id = #{ownerGroupId} AND cs.category_id IS NOT NULL + ) + + + AND NOT EXISTS ( + SELECT 1 FROM biz_jd_product_group_assign cs + WHERE cs.product_id = p.id AND cs.owner_group_id = #{ownerGroupId} AND cs.category_id IS NOT NULL + ) + + + AND p.synced_at >= #{syncedFrom} AND p.synced_at <= #{syncedTo} diff --git a/backend-java/src/test/java/com/nanri/aiimage/modules/jd/controller/AdminJdProductControllerTest.java b/backend-java/src/test/java/com/nanri/aiimage/modules/jd/controller/AdminJdProductControllerTest.java index 9b9bb51c5..92b2c3207 100644 --- a/backend-java/src/test/java/com/nanri/aiimage/modules/jd/controller/AdminJdProductControllerTest.java +++ b/backend-java/src/test/java/com/nanri/aiimage/modules/jd/controller/AdminJdProductControllerTest.java @@ -164,6 +164,10 @@ class AdminJdProductControllerTest { } assertFalse(source.contains("@RequestParam(name = \"ungrouped\"")); assertFalse(source.contains("@RequestParam(name = \"grouped\"")); + // 2026-11-17 分类状态快筛:新参数名 classified(不复用旧 grouped/ungrouped 两档—— + // 那两档读已停用的 biz_jd_product.group_id 列,语义不同,旧参数仍必须被拒收)。 + assertTrue(source.contains("@RequestParam(name = \"classified\""), + "分类状态快筛参数 classified 必须在册(2026-11-17 用户口径)"); // company_id 参数已随 2026-11-16「删除掉公司 tab」整批摘除(读侧零公司维度支另有反向钉)。 assertFalse(source.contains("company_id"), "company_id 请求参数必须已删除,不得回潜"); // 商品状态筛选框已随 2026-11-15 客户口径从前端下线 ⇒ 服务端同名参数一起撤(反向钉住防回潜)。 @@ -279,8 +283,8 @@ class AdminJdProductControllerTest { // 读:菜单权限命中即放行(公共库一人一份全量)。 JdProductPageVo pageVo = new JdProductPageVo(); pageVo.setItems(List.of()); - when(queryService.page(1L, 20L, null, null, null, null, null, null, GROUP_ID)).thenReturn(pageVo); - assertEquals(Boolean.TRUE, controller.page(1L, 20L, null, null, null, null, null, null, null, request) + when(queryService.page(1L, 20L, null, null, null, null, null, null, null, GROUP_ID)).thenReturn(pageVo); + assertEquals(Boolean.TRUE, controller.page(1L, 20L, null, null, null, null, null, null, null, null, request) .isSuccess(), "非超管有菜单权限时读必须放行(读写分档只收窄写)"); // 商品行写:四条写入口一律 403,且业务服务一次都没被调到(不能「先写再拒」)。 @@ -429,11 +433,11 @@ class AdminJdProductControllerTest { when(groupService.requireCategory(8L)).thenReturn(category(8L, 20L)); BusinessException ex = assertThrows(BusinessException.class, - () -> controller.page(1L, 20L, null, null, null, 8L, null, null, null, request)); + () -> controller.page(1L, 20L, null, null, null, 8L, null, null, null, null, request)); assertTrue(ex.getMessage().contains("无权查看该分组的分类"), "跨组分类筛选必须 403 点名分组,不做空结果降级"); - verify(queryService, never()).page(any(), any(), any(), any(), any(), any(), any(), any(), any()); + verify(queryService, never()).page(any(), any(), any(), any(), any(), any(), any(), any(), any(), any()); } // ===================== 行为样本 ===================== @@ -461,13 +465,13 @@ class AdminJdProductControllerTest { pageVo.setTotal(0L); pageVo.setPage(1L); pageVo.setPageSize((long) PageDefaults.JD_PRODUCTS_PAGE_SIZE_INT); - when(queryService.page(1L, 20L, null, null, null, null, null, null, GROUP_ID)).thenReturn(pageVo); + when(queryService.page(1L, 20L, null, null, null, null, null, null, null, GROUP_ID)).thenReturn(pageVo); // 请求面没有 company_id:任何授权身份看到的都是同一份全量;分类列按 owner_group_id 取。 ApiResponse response = controller.page(1L, 20L, null, null, null, null, - GROUP_ID, null, null, request); + GROUP_ID, null, null, null, request); - verify(queryService).page(1L, 20L, null, null, null, null, null, null, GROUP_ID); + verify(queryService).page(1L, 20L, null, null, null, null, null, null, null, GROUP_ID); assertEquals(Boolean.TRUE, response.isSuccess(), "拒绝走 403 业务码,放行必须是 success 信封(B80-03)"); assertEquals(pageVo, response.getData()); } @@ -491,12 +495,12 @@ class AdminJdProductControllerTest { for (String value : List.of("true", "false", "")) { when(request.getParameter(name)).thenReturn(value); BusinessException ex = assertThrows(BusinessException.class, - () -> controller.page(1L, 20L, null, null, null, 7L, null, null, null, request)); + () -> controller.page(1L, 20L, null, null, null, 7L, null, null, null, null, request)); assertTrue(ex.getMessage().contains("刷新页面")); when(request.getParameter(name)).thenReturn(null); } } - verify(queryService, never()).page(any(), any(), any(), any(), any(), any(), any(), any(), any()); + verify(queryService, never()).page(any(), any(), any(), any(), any(), any(), any(), any(), any(), any()); } @Test @@ -615,23 +619,23 @@ class AdminJdProductControllerTest { void 查询服务分页钳制防溢出() { JdProductMapper mapper = mock(JdProductMapper.class); JdProductQueryService service = queryService(mapper); - when(mapper.countProducts(any(), any(), any(), any(), any(), any())).thenReturn(1L); + when(mapper.countProducts(any(), any(), any(), any(), any(), any(), any(), any())).thenReturn(1L); // page=0 / size=null ⇒ 归一为第 1 页、默认 20 条;offset = 0。 - service.page(0L, null, null, null, null, null, null, null, null); + service.page(0L, null, null, null, null, null, null, null, null, null); ArgumentCaptor offset = ArgumentCaptor.forClass(Long.class); ArgumentCaptor limit = ArgumentCaptor.forClass(Integer.class); verify(mapper).selectProductPage(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), - offset.capture(), limit.capture()); + isNull(), isNull(), offset.capture(), limit.capture()); assertEquals(0L, offset.getValue()); assertEquals(PageDefaults.JD_PRODUCTS_PAGE_SIZE_INT, limit.getValue()); // page=Long.MAX_VALUE / size=500 ⇒ 钳到 10_000 页、100 条;乘积 999_900 不得变负(铁律 15)。 - service.page(Long.MAX_VALUE, 500L, null, null, null, null, null, null, null); + service.page(Long.MAX_VALUE, 500L, null, null, null, null, null, null, null, null); ArgumentCaptor offsetMax = ArgumentCaptor.forClass(Long.class); ArgumentCaptor limitMax = ArgumentCaptor.forClass(Integer.class); verify(mapper, times(2)).selectProductPage(any(), any(), any(), any(), any(), any(), - offsetMax.capture(), limitMax.capture()); + any(), any(), offsetMax.capture(), limitMax.capture()); assertEquals(999_900L, offsetMax.getValue(), "(page-1)*page_size 最大 999_900,钳制后不得溢出变负"); assertEquals(100, limitMax.getValue()); } @@ -643,23 +647,77 @@ class AdminJdProductControllerTest { LocalDateTime from = LocalDateTime.of(2026, 11, 14, 12, 0); LocalDateTime to = LocalDateTime.of(2026, 11, 14, 8, 0); BusinessException ex = assertThrows(BusinessException.class, - () -> service.page(1L, 20L, null, null, null, null, from, to, null)); + () -> service.page(1L, 20L, null, null, null, null, from, to, null, null)); assertTrue(ex.getMessage().contains("开始时间不能晚于结束时间"), "倒挂时间按业务异常拒绝"); - verify(mapper, never()).countProducts(any(), any(), any(), any(), any(), any()); + verify(mapper, never()).countProducts(any(), any(), any(), any(), any(), any(), any(), any()); } @Test void 查询服务过滤面原样直传且空串归null() { JdProductMapper mapper = mock(JdProductMapper.class); JdProductQueryService service = queryService(mapper); - when(mapper.countProducts(any(), any(), any(), any(), any(), any())).thenReturn(1L); - service.page(1L, 20L, " SKU-1 ", " 连衣裙 ", " 艺考形体服 ", 7L, null, null, null); - verify(mapper).countProducts("SKU-1", "连衣裙", "艺考形体服", 7L, null, null); - verify(mapper).selectProductPage("SKU-1", "连衣裙", "艺考形体服", 7L, null, null, 0L, 20); + when(mapper.countProducts(any(), any(), any(), any(), any(), any(), any(), any())).thenReturn(1L); + service.page(1L, 20L, " SKU-1 ", " 连衣裙 ", " 艺考形体服 ", 7L, null, null, null, null); + verify(mapper).countProducts("SKU-1", "连衣裙", "艺考形体服", 7L, null, null, null, null); + verify(mapper).selectProductPage("SKU-1", "连衣裙", "艺考形体服", 7L, null, null, null, null, 0L, 20); - service.page(1L, 20L, " ", null, null, 0L, null, null, null); - verify(mapper).countProducts(null, null, null, null, null, null); - verify(mapper).selectProductPage(null, null, null, null, null, null, 0L, 20); + service.page(1L, 20L, " ", null, null, 0L, null, null, null, null); + verify(mapper).countProducts(null, null, null, null, null, null, null, null); + verify(mapper).selectProductPage(null, null, null, null, null, null, null, null, 0L, 20); + } + + /** + * 分类状态快筛(2026-11-17 用户口径「加个已分类和未分类的筛选」): + * ① classified+ownerGroupId 必须原样下传给 mapper(谓词在 XML 的 EXISTS/NOT EXISTS 段, + * 铁律 20 同形——不得 Java 侧对已取页 filter); + * ② XML 绊线:两分支谓词逐字在册(改回 Java filter 或摘掉 owner_group_id 关联即红); + * ③ 控制器把请求的 classified 直传服务(不吞、不改写)。 + */ + @Test + void 分类状态快筛必须SQL下推且classified与ownerGroupId成对直传() throws IOException { + // ② XML 绊线:classified 档的 EXISTS/NOT EXISTS 两分支都在 productConds 里, + // 且按「当前分组」owner_group_id+category_id 非空判——与读侧填分类列同形。 + Path xml = findJdProductMapperXml(); + String xmlText = stripComments(Files.readString(xml)).replaceAll("(?s)", ""); + assertTrue(xmlText.contains("classified == true"), + "XML 必须有 classified==true 的已分类分支(SQL 侧下推,铁律 20 同形)"); + assertTrue(xmlText.contains("cs.owner_group_id = #{ownerGroupId}") + && xmlText.contains("cs.category_id IS NOT NULL"), + "已分类判据必须按当前分组归属行且 category_id 非空(与 fillGroupNames 同形)"); + assertTrue(xmlText.contains("NOT EXISTS"), "未分类档必须是 NOT EXISTS(不是空结果降级)"); + assertEquals(2, count(xmlText, "cs.product_id = p.id"), + "EXISTS/NOT EXISTS 两分支各一处商品关联,缺一个即红"); + + // ① 服务直传:classified 与 ownerGroupId 成对进 mapper(计数与分页同一过滤面)。 + JdProductMapper mapper = mock(JdProductMapper.class); + JdProductQueryService service = queryService(mapper); + when(mapper.countProducts(any(), any(), any(), any(), any(), any(), any(), any())).thenReturn(1L); + service.page(1L, 20L, null, null, null, null, null, null, Boolean.TRUE, GROUP_ID); + verify(mapper).countProducts(null, null, null, null, null, null, true, GROUP_ID); + verify(mapper).selectProductPage(null, null, null, null, null, null, true, GROUP_ID, 0L, 20); + + service.page(1L, 20L, null, null, null, null, null, null, Boolean.FALSE, GROUP_ID); + verify(mapper).countProducts(null, null, null, null, null, null, false, GROUP_ID); + verify(mapper).selectProductPage(null, null, null, null, null, null, false, GROUP_ID, 0L, 20); + + // ③ 控制器直传:classified 原样进服务(owner_group_id 仍按作用域收敛后的值)。 + JdProductQueryService queryService = mock(JdProductQueryService.class); + JdCategoryScopeService scopeService = mock(JdCategoryScopeService.class); + AdminAuthSupport authSupport = mock(AdminAuthSupport.class); + AdminJdProductController controller = new AdminJdProductController( + queryService, mock(JdProductDeleteService.class), mock(JdProductUpdateService.class), + mock(JdProductGroupService.class), scopeService, authSupport, + mock(PermissionMenuService.class)); + AdminUserEntity operator = new AdminUserEntity(); + operator.setId(7L); + HttpServletRequest request = mock(HttpServletRequest.class); + when(authSupport.requireUser(request)).thenReturn(operator); + when(authSupport.currentRole(operator)).thenReturn("super_admin"); + JdCategoryScopeService.JdCategoryScope scope = writableScope(GROUP_ID, COMPANY_ID); + when(scopeService.resolve(operator)).thenReturn(scope); + when(scopeService.readGroupOrNull(scope, null)).thenReturn(GROUP_ID); + controller.page(1L, 20L, null, null, null, null, null, null, null, Boolean.TRUE, request); + verify(queryService).page(1L, 20L, null, null, null, null, null, null, Boolean.TRUE, GROUP_ID); } @Test @@ -807,8 +865,8 @@ class AdminJdProductControllerTest { JdProductEntity categorized = productEntity(1L); JdProductEntity missing = productEntity(2L); - when(mapper.countProducts(any(), any(), any(), any(), any(), any())).thenReturn(2L); - when(mapper.selectProductPage(any(), any(), any(), any(), any(), any(), + when(mapper.countProducts(any(), any(), any(), any(), any(), any(), any(), any())).thenReturn(2L); + when(mapper.selectProductPage(any(), any(), any(), any(), any(), any(), any(), any(), anyLong(), anyInt())).thenReturn(List.of(categorized, missing)); when(assignMapper.selectList(any())).thenReturn(List.of( assign(1L, GROUP_ID, 3L), assign(2L, GROUP_ID, 99L))); @@ -817,7 +875,7 @@ class AdminJdProductControllerTest { category.setName("秋冬款"); when(categoryMapper.selectBatchIds(any())).thenReturn(List.of(category)); - JdProductPageVo vo = service.page(1L, 20L, null, null, null, null, null, null, GROUP_ID); + JdProductPageVo vo = service.page(1L, 20L, null, null, null, null, null, null, null, GROUP_ID); assertEquals(3L, vo.getItems().get(0).getGroupId(), "分类 id 取本组归属行"); assertEquals("秋冬款", vo.getItems().get(0).getGroupName(), "行集归属一次取齐分类名(无逐行查询)"); @@ -832,11 +890,11 @@ class AdminJdProductControllerTest { JdProductGroupAssignMapper assignMapper = mock(JdProductGroupAssignMapper.class); JdProductQueryService service = queryService(mapper, mock(JdProductImageMapper.class), mock(JdProductSkuMapper.class), mock(JdProductGroupMapper.class), assignMapper); - when(mapper.countProducts(any(), any(), any(), any(), any(), any())).thenReturn(1L); - when(mapper.selectProductPage(any(), any(), any(), any(), any(), any(), + when(mapper.countProducts(any(), any(), any(), any(), any(), any(), any(), any())).thenReturn(1L); + when(mapper.selectProductPage(any(), any(), any(), any(), any(), any(), any(), any(), anyLong(), anyInt())).thenReturn(List.of(productEntity(1L))); - JdProductPageVo vo = service.page(1L, 20L, null, null, null, null, null, null, null); + JdProductPageVo vo = service.page(1L, 20L, null, null, null, null, null, null, null, null); assertNull(vo.getItems().get(0).getGroupId(), "不属于任何分组的账号:分类列一律空(未分类)"); assertNull(vo.getItems().get(0).getGroupName());