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
@@ -112,9 +112,15 @@ public class AdminUserService {
query.eq(AdminUserEntity::getCompanyId, companyIdFilter);
}
} else if (isCompanySuperAdmin) {
// 公司超管看本公司全部账号(站点超管账号除外——那是平台自己的身份)
// 2026-11-18 客户口径「admin 看所有,其余公司超管各自看各自名下的」:
// 公司超管只看本人那行+自己直接创建(created_by_id=本人)的账号,
// 本公司内由站点超管或其他组长建的行不再可见——与下面组长档同一形状。
// 站点超管行本来就不可能落进这个谓词(ne 只是对脏数据的保险,保留)。
Long selfId = currentUser.getId();
query.eq(AdminUserEntity::getCompanyId, currentUser.getCompanyId())
.ne(AdminUserEntity::getRole, "super_admin");
.ne(AdminUserEntity::getRole, "super_admin")
.and(w -> w.eq(AdminUserEntity::getId, selfId)
.or(inner -> inner.eq(AdminUserEntity::getCreatedById, selfId)));
if (!kw.isEmpty()) {
query.like(AdminUserEntity::getUsername, kw);
}
@@ -441,6 +447,11 @@ public class AdminUserService {
if (!currentUser.getCompanyId().equals(target.getCompanyId())) {
throw new BusinessException(403, "只能编辑本公司名下的账号");
}
// 2026-11-18 与读侧「各自看各自名下」同口径:目标必须是自己直接创建的,
// 否则就是「列表看不见、API 照样改」的洞(停用/改密/额度全走这条闸)。
if (!currentUser.getId().equals(target.getCreatedById())) {
throw new BusinessException(403, "只能编辑自己名下创建的账号");
}
}
if ("super_admin".equals(wantRole)) {
throw new BusinessException("不能将用户设为超级管理员");
@@ -610,6 +621,10 @@ public class AdminUserService {
if (!currentUser.getCompanyId().equals(target.getCompanyId())) {
throw new BusinessException(403, "只能删除本公司名下的账号");
}
// 2026-11-18 与读侧/updateUser 同口径:只清退自己直接创建的账号
if (!currentUser.getId().equals(target.getCreatedById())) {
throw new BusinessException(403, "只能删除自己名下创建的账号");
}
}
int affected = adminUserMapper.deleteById(uid);
if (affected == 0) {
@@ -114,7 +114,9 @@ public class AdminJdProductController {
@Parameter(description = "每页数量") @RequestParam(name = "page_size", defaultValue = PageDefaults.JD_PRODUCTS_PAGE_SIZE) Long pageSize,
@Parameter(description = "商品编码(包含匹配)") @RequestParam(name = "product_code", required = false) String productCode,
@Parameter(description = "标题关键词(包含匹配)") @RequestParam(name = "title_keyword", required = false) String titleKeyword,
@Parameter(description = "类目(京麦末级类目名,eq)") @RequestParam(name = "category", required = false) String category,
@Parameter(description = "类目(京麦类目名,多值 IN;2026-11-18 支持选一级/二级类目——"
+ "前端把选中节点展开为其子树全部类目名,用重复 category 参数下发,单值形状照常工作)")
@RequestParam(name = "category", required = false) List<String> categories,
@Parameter(description = "自定义分类 id(类目面板「自定义分类」选中驱动)") @RequestParam(name = "group_id", required = false) Long groupId,
@Parameter(description = "当前数据权限分组 id(分类列/分类筛选按它取;缺省=作用域默认分组)")
@RequestParam(name = "owner_group_id", required = false) Long ownerGroupId,
@@ -136,7 +138,7 @@ public class AdminJdProductController {
requireVisibleCategory(scope, groupId);
}
return ApiResponse.success(jdProductQueryService.page(page, pageSize,
productCode, titleKeyword, category, groupId, syncedFrom, syncedTo, classified,
productCode, titleKeyword, categories, groupId, syncedFrom, syncedTo, classified,
scopedOwnerGroupId));
}
@@ -43,6 +43,8 @@ public interface JdProductMapper extends BaseMapper<JdProductEntity> {
/**
* 后管只读页总数(Phase 5,v1.4):与 {@link #selectProductPage} 同一过滤面
* (商品编码/标题关键词/类目/自定义分类/同步起止,全部 SQL 侧下推,铁律 20)。
* {@code categories}(2026-11-18 一级/二级类目可选):类目名集合 IN,空/ null=不过滤;
* 选父级时由前端展开为子树类目名集合下发,单值=原 eq 形状。
* 公司维过滤已随 2026-11-16「删除掉公司 tab,参考品牌数据库」撤掉
* (数据全平台公共);{@code groupId} 为空或 ≤0=不过滤该面;
* {@code ungrouped}/{@code grouped} 两档(未分类/已分类)已随同日口径
@@ -55,7 +57,7 @@ public interface JdProductMapper extends BaseMapper<JdProductEntity> {
*/
long countProducts(@Param("productCode") String productCode,
@Param("titleKeyword") String titleKeyword,
@Param("category") String category,
@Param("categories") List<String> categories,
@Param("groupId") Long groupId,
@Param("syncedFrom") LocalDateTime syncedFrom,
@Param("syncedTo") LocalDateTime syncedTo,
@@ -96,7 +98,7 @@ public interface JdProductMapper extends BaseMapper<JdProductEntity> {
*/
List<JdProductEntity> selectProductPage(@Param("productCode") String productCode,
@Param("titleKeyword") String titleKeyword,
@Param("category") String category,
@Param("categories") List<String> categories,
@Param("groupId") Long groupId,
@Param("syncedFrom") LocalDateTime syncedFrom,
@Param("syncedTo") LocalDateTime syncedTo,
@@ -78,7 +78,9 @@ public class JdProductQueryService {
/**
* 分页查询商品行({@code synced_at} 倒序)。
*
* <p>过滤面:商品编码 contains、标题关键词 contains、类目 eq、分组 eq(2026-11-16 起
* <p>过滤面:商品编码 contains、标题关键词 contains、类目 IN(2026-11-18 起多值:
* 选一级/二级类目由前端展开为子树类目名集合下发,单值=原 eq 形状;空集合=不过滤该面)、
* 分组 eq(2026-11-16 起
* 由类目面板「自定义分类」选中驱动)、同步起止(datetime 闭区间)、分类状态档
* {@code classified}(2026-11-17 用户口径「加个已分类和未分类的筛选」:true=当前分组下
* 有分类、false=没有、null=全部;按 V203 归属表 EXISTS/NOT EXISTS 在 SQL 侧下推,
@@ -89,7 +91,7 @@ public class JdProductQueryService {
* 公司维过滤已随 2026-11-16 摘公司 tab 整批撤掉(全平台公共)。</p>
*/
public JdProductPageVo page(Long page, Long pageSize,
String productCode, String titleKeyword, String category, Long groupId,
String productCode, String titleKeyword, List<String> categories, Long groupId,
LocalDateTime syncedFrom, LocalDateTime syncedTo, Boolean classified, Long ownerGroupId) {
if (syncedFrom != null && syncedTo != null && syncedFrom.isAfter(syncedTo)) {
throw new BusinessException("开始时间不能晚于结束时间");
@@ -97,14 +99,14 @@ public class JdProductQueryService {
long safePage = page == null || page < 1 ? 1 : Math.min(page, MAX_PAGE);
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,
Filter filter = filter(productCode, titleKeyword, categories,
groupId, syncedFrom, syncedTo, classified);
long total = jdProductMapper.countProducts(filter.productCode(),
filter.titleKeyword(), filter.category(), filter.groupId(),
filter.titleKeyword(), filter.categories(), filter.groupId(),
filter.syncedFrom(), filter.syncedTo(), filter.classified(), ownerGroupId);
List<JdProductEntity> rows = total <= 0 ? List.of()
: jdProductMapper.selectProductPage(filter.productCode(),
filter.titleKeyword(), filter.category(), filter.groupId(),
filter.titleKeyword(), filter.categories(), filter.groupId(),
filter.syncedFrom(), filter.syncedTo(), filter.classified(), ownerGroupId,
(safePage - 1) * safeSize, (int) safeSize);
List<JdProductListItemVo> items = rows.stream().map(this::toListItem).toList();
@@ -228,18 +230,25 @@ public class JdProductQueryService {
// ---------------------------------------------------------------- 过滤面
/** 服务侧过滤面归一:groupId ≤0 按没选处理,文本 trim 后空串归 null(无公司维,2026-11-16 摘);
* classified 原样直传(null=不过滤该面,2026-11-17 分类状态快筛)。 */
* classified 原样直传(null=不过滤该面,2026-11-17 分类状态快筛);
* categories 逐项 trim、去空白、去重,空集合归 null=不过滤该面(2026-11-18 一级/二级类目展开)。 */
private record Filter(String productCode, String titleKeyword,
String category, Long groupId,
List<String> categories, Long groupId,
LocalDateTime syncedFrom, LocalDateTime syncedTo, Boolean classified) {
}
private static Filter filter(String productCode, String titleKeyword,
String category, Long groupId,
List<String> categories, Long groupId,
LocalDateTime syncedFrom, LocalDateTime syncedTo, Boolean classified) {
Long safeGroupId = groupId != null && groupId > 0 ? groupId : null;
List<String> safeCategories = categories == null ? null : categories.stream()
.map(JdProductQueryService::trimToNull)
.filter(java.util.Objects::nonNull)
.distinct()
.toList();
return new Filter(trimToNull(productCode), trimToNull(titleKeyword),
trimToNull(category), safeGroupId, syncedFrom, syncedTo, classified);
safeCategories == null || safeCategories.isEmpty() ? null : safeCategories,
safeGroupId, syncedFrom, syncedTo, classified);
}
// ---------------------------------------------------------------- 列表/详情搬运
@@ -115,7 +115,13 @@
<sql id="productConds">
<if test="productCode != null and productCode != ''">AND p.product_code LIKE CONCAT('%', #{productCode}, '%')</if>
<if test="titleKeyword != null and titleKeyword != ''">AND p.title LIKE CONCAT('%', #{titleKeyword}, '%')</if>
<if test="category != null and category != ''">AND p.category_path = #{category}</if>
<!-- 类目过滤(2026-11-18 一级/二级类目可选):单值=原 eq 形状;父级选中由前端展开为
子树类目名集合,这里 IN 下推(铁律 20:谓词必须在 SQL 侧,不得 Java 侧对已取页 filter)。
服务侧已逐项 trim/去空白/去重,空集合归 null 不进本分支。 -->
<if test="categories != null and categories.size() > 0">
AND p.category_path IN
<foreach collection="categories" item="cat" open="(" separator="," close=")">#{cat}</foreach>
</if>
<if test="groupId != null and groupId &gt; 0">
AND EXISTS (
SELECT 1 FROM biz_jd_product_group_assign a