feat(jd-admin): 2026-11-18 客户三条反馈闭环——公司超管收窄到名下+京东类目一级/二级可选中(IN 下推)+级联触发框 34px 对齐

【一、用户管理:公司超管「各自看各自名下」(backend-java AdminUserService)】
客户口径(11-18 截图:阿华66 公司超管看到了 admin 直建的 ssss):平台超管看所有,
其余公司超管只看自己名下。读侧 listUsers 公司超管分支由「本公司全部(role≠super_admin)」
改为 company_id=本公司 AND (id=本人 OR created_by_id=本人)——与组长档同一形状;
自己那行永远可见(保证能改自己密码/额度)。写侧 updateUser/deleteUser 公司超管分支
在「同公司」闸之外加同形「目标 created_by_id=本人」谓词,不留「列表看不见、API 照样改」
的洞(停用/改密/额度全走这条闸)。createUser 不动(新建天然落本人名下)。
口径为直接下级:组长再建的普通号归组长看,不在公司超管列表(如需整棵下级树另拍板)。
判据:AdminUserServiceCompanySuperAdminTest 改 1 增 5(名下可见谓词/超管档反向不收窄/
写侧越权 403 两支+本人建的可编辑);其余 admin 测试类夹具全用超管/组长档,核过不受影响。

【二、京东类目一级/二级可选中(前端展开+后端 IN,零表结构变更,用户拍板路线)】
后端:AdminJdProductController.page 的 category 参数改 List<String>(重复 query key 绑定,
参数名不变、单值形状照常);JdProductQueryService.Filter 逐项 trim/去空白/去重、空集合归
null=不过滤;JdProductMapper.xml productConds 类目谓词 eq→IN+foreach(仍 SQL 侧下推,
铁律 20 同形)。落库仍只有末级类目名,无 schema/迁移改动。
前端:jd-category-tree.ts 新增 jdCategoryAllNodes/jdCategorySearchNodes(搜索铺全层级)
+jdCategoryNamesUnder(path)(选中节点→自身+全部后代类目名集合,含自身因实际末级可能
就在这一级;路径失效回 null 兜单名)。JdCategoryCascader.vue:非末级行圆点点击=选中
(emit change 带名称路径)、行体/箭头仍下钻;选中态按路径比对(同名跨支不串);搜索
结果含一级/二级行。JdDatabasePage/jd-product-filter/jd-product-api:categoryPath 入筛选态,
序列化按子树展开集合,axios paramsSerializer indexes:false 出重复 category= 参数。
已知代价(路线自带、用户已选):不同父级下同名末级会随展开集合一起命中(B112-05 同口径)。

【三、样式(JdCategoryCascader.vue)】
触发框 min-height 42→34px+padding 5x10:main.css:245-248 全局密度收口把相邻 input/
el-select/.btn 压到 34,自绘 button 不在收口清单里才显高;非末级圆点不再永远空心。

【台账】source-pin-ledger.json 重录(UPDATE_SOURCE_PIN_BASELINE=1 官方口):本笔
jd-category-tree.test.ts 用例 6→8;同时把 2a8bdd7d 已提交未记账的
user-menu-tree-platform-filter.test.ts(8 例 0 钉 0 读点)一并登记——基线在该窗陈旧,
此处为台账记账、非卷码。

【验证】mvn -o test-compile rc=0;定向 mvn -o test(AdminUserService* 七类+
AdminJdProductControllerTest)rc=0;admin vue-tsc rc=0;node --test jd-category-tree/
jd-database-page/jd-product-group/cascader-position 全绿;vitest mount jd-database-page
44/44(含本笔新增一级/二级选中用例);ops _push_gate.py --fast overall=pass 四面绿
(首轮后管 readSource 格红=本笔用例数,重录基线后复跑绿)。
发版未做:jar+后管随下一窗口走既有流程;full 闸门未跑(模式 D 口径)。
This commit is contained in:
2026-11-18 16:53:36 +08:00
parent 96afb685c2
commit 4de78adfc7
16 changed files with 444 additions and 84 deletions
@@ -172,7 +172,9 @@ class AdminUserServiceCompanySuperAdminTest {
// ---------- 列表 ----------
@Test
void companySuperAdminListsOwnCompanyWithoutSiteSuperAdmin() {
void companySuperAdminOnlyListsOwnSubordinates() {
// 2026-11-18 客户口径:公司超管只看「本人那行+自己直接创建的」,不再看本公司全部。
// 判据形状:谓词必须同时出现 company_id、created_by_id 与 id=本人(读侧与组长档同形)。
AdminUserEntity operator = user(9L, "company_super_admin", 2L, null);
when(authSupport.currentRole(operator)).thenReturn("company_super_admin");
when(userMapper.selectCount(any())).thenReturn(0L);
@@ -184,8 +186,27 @@ class AdminUserServiceCompanySuperAdminTest {
ArgumentCaptor.forClass(LambdaQueryWrapper.class);
verify(userMapper).selectCount(captor.capture());
// 先碰一次 SqlSegment 才会铺出参数(MP 惯例)
captor.getValue().getSqlSegment();
assertThat(captor.getValue().getParamNameValuePairs().values()).contains(2L);
String sql = captor.getValue().getSqlSegment();
assertThat(sql).contains("company_id").contains("created_by_id");
assertThat(captor.getValue().getParamNameValuePairs().values())
.contains(2L) // 本公司
.contains(9L); // 本人(id=本人 OR created_by_id=本人,两处同一值)
}
@Test
void siteSuperAdminListStillUnscopedBySubordinates() {
// 反向保险:收窄只落在公司超管档——平台超管「看所有」,谓词里不得出现 created_by_id 强制项
AdminUserEntity operator = user(1L, "super_admin", 1L, null);
when(authSupport.currentRole(operator)).thenReturn("super_admin");
when(userMapper.selectCount(any())).thenReturn(0L);
when(userMapper.selectList(any())).thenReturn(List.of());
service.listUsers(operator, 1, 15, null, null, null, null);
ArgumentCaptor<LambdaQueryWrapper<AdminUserEntity>> captor =
ArgumentCaptor.forClass(LambdaQueryWrapper.class);
verify(userMapper).selectCount(captor.capture());
assertThat(captor.getValue().getSqlSegment()).doesNotContain("created_by_id");
}
// ---------- 编辑 ----------
@@ -244,6 +265,52 @@ class AdminUserServiceCompanySuperAdminTest {
.hasMessageContaining("只有超级管理员可以修改公司超级管理员");
}
@Test
void companySuperAdminCannotEditAccountCreatedByOthers() {
// 2026-11-18 写侧与读侧同口径:本公司但由别人(组长8/站点超管)创建的账号,
// 列表已不可见,API 也必须 403——不留「看不见但改得动」的洞。
AdminUserEntity operator = user(9L, "company_super_admin", 1L, 2L);
AdminUserEntity target = user(12L, "admin", 1L, 8L);
when(authSupport.currentRole(operator)).thenReturn("company_super_admin");
when(userMapper.selectById(12L)).thenReturn(target);
AdminUserUpdateRequest request = new AdminUserUpdateRequest();
request.setPassword("secret1");
assertThatThrownBy(() -> service.updateUser(operator, 12L, request))
.isInstanceOf(BusinessException.class)
.hasMessageContaining("只能编辑自己名下创建的账号");
verify(userMapper, never()).update(any(), any());
}
@Test
void companySuperAdminCanEditOwnCreatedAdmin() {
AdminUserEntity operator = user(9L, "company_super_admin", 1L, 2L);
AdminUserEntity target = user(12L, "admin", 1L, 9L);
when(authSupport.currentRole(operator)).thenReturn("company_super_admin");
when(userMapper.selectById(12L)).thenReturn(target);
AdminUserUpdateRequest request = new AdminUserUpdateRequest();
request.setPassword("secret1");
service.updateUser(operator, 12L, request);
verify(userMapper).update(any(), any());
}
@Test
void companySuperAdminCannotDeleteAccountCreatedByOthers() {
AdminUserEntity operator = user(9L, "company_super_admin", 1L, 2L);
AdminUserEntity target = user(12L, "normal", 1L, 8L);
when(authSupport.currentRole(operator)).thenReturn("company_super_admin");
when(userMapper.selectById(12L)).thenReturn(target);
assertThatThrownBy(() -> service.deleteUser(operator, 12L))
.isInstanceOf(BusinessException.class)
.hasMessageContaining("只能删除自己名下创建的账号");
verify(userMapper, never()).deleteById(12L);
}
@Test
void companySuperAdminCannotDeleteCompanySuperAdminTarget() {
AdminUserEntity operator = user(9L, "company_super_admin", 1L, 2L);
@@ -726,15 +726,48 @@ class AdminJdProductControllerTest {
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, " 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, " SKU-1 ", " 连衣裙 ", List.of(" 艺考形体服 "), 7L, null, null, null, null);
verify(mapper).countProducts("SKU-1", "连衣裙", List.of("艺考形体服"), 7L, null, null, null, null);
verify(mapper).selectProductPage("SKU-1", "连衣裙", List.of("艺考形体服"), 7L, 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-18 一级/二级类目可选(前端展开子树类目名集合下发):
* ① 服务侧逐项 trim、去空白、去重后进 mapper;全空白集合归 null=不过滤该面;
* ② XML 绊线:类目谓词必须是 IN+foreach 下推(改回单值 eq 即红,铁律 20 同形)。
*/
@Test
void 类目多值必须逐项归一并IN下推() throws IOException {
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,
java.util.Arrays.asList(" 女装 ", "女装", "", null, " 汉服/旗袍 "),
null, null, null, null, null);
verify(mapper).countProducts(null, null, List.of("女装", "汉服/旗袍"),
null, null, null, null, null);
verify(mapper).selectProductPage(null, null, List.of("女装", "汉服/旗袍"),
null, null, null, null, null, 0L, 20);
// 全空白/空集合=不过滤该面(与「全部类目」清选同口径,不得下发空 IN)
service.page(1L, 20L, null, null, java.util.Arrays.asList(" ", ""), null, null, null, null, null);
verify(mapper).countProducts(null, null, null, null, null, null, null, null);
Path xml = findJdProductMapperXml();
String xmlText = stripComments(Files.readString(xml)).replaceAll("(?s)<!--.*?-->", "");
assertTrue(xmlText.contains("p.category_path IN"),
"类目谓词必须是 IN 下推(2026-11-18 父级类目展开集合)");
assertTrue(xmlText.contains("<foreach collection=\"categories\""),
"IN 集合必须由 foreach 展开(拼串即红)");
assertFalse(xmlText.contains("p.category_path = #{category}"),
"改回单值 eq 即红——一级/二级类目展开会整体失效");
}
/**
* 分类状态快筛(2026-11-17 用户口径「加个已分类和未分类的筛选」):
* ① classified+ownerGroupId 必须原样下传给 mapper(谓词在 XML 的 EXISTS/NOT EXISTS 段,