fix(角色叫法): 管理员就叫管理员、normal 档统一「普通账号」
同一角色此前有两套叫法:admin 档在界面叫「管理员」、在后端 6 条 403 与 Swagger 说明里叫 「普通管理员」;normal 档在界面叫「普通用户」。清到第四轮才清净,所以把口径做进源码出口: 新增 task-048 的旧词扫描用例,两棵源码树(admin-frontend-vue/src 216 文件、 backend-java/src 1415 java 文件)里出现「普通管理员」「普通用户」即红,分母与出口文件成员 一起钉死,防"扫了个空集合"式假绿。 - 后端 6 条用户可见文案:PermissionMenuService 两判、ShopManageGroupService 一判、 ShopManageController 三条 @Operation 说明 - company_menu_grant_gate_mutation.py 的 DENIED_THROW 锚同步改,16 条锚命中数逐条复算=1 - 注释与 javadoc 同批收口(等长替换不动排版);NotificationControllerTest 那句讲的是 非后台账号,按本意改写而不是套「普通账号」
This commit is contained in:
@@ -70,7 +70,7 @@ SUPER_EARLY_RETURN = (
|
||||
" }")
|
||||
DENIED_THROW = (
|
||||
" if (!denied.isEmpty()) {\n"
|
||||
" throw new BusinessException(403, \"普通管理员只能分配自己已有的菜单权限\");\n"
|
||||
" throw new BusinessException(403, \"管理员只能分配自己已有的菜单权限\");\n"
|
||||
" }")
|
||||
STRIP_CALL = " requestedIds = stripSuperAdminOnlyGrantIds(requestedIds, operator);"
|
||||
MARKER_LOG = (" log.warn(\"GRANT_SUPER_ADMIN_ONLY_STRIPPED 已剥离超管专属菜单授权 ids={} operatorId={}\", stripped,")
|
||||
|
||||
+3
-3
@@ -19,9 +19,9 @@ import java.util.List;
|
||||
* <p><b>判定口径(库里不改值,全部现算):</b>生效到期 = 自身 expires_at 与所有上级约束里最早的那个。</p>
|
||||
* <ul>
|
||||
* <li>super_admin:永不适用(返回 null);</li>
|
||||
* <li>公司级:本公司所有 company_super_admin 的 expires_at 约束全公司(管理员/普通用户跟随);
|
||||
* <li>公司级:本公司所有 company_super_admin 的 expires_at 约束全公司(管理员/普通账号跟随);
|
||||
* 公司没有公司超管时无此约束(站点自己的公司通常如此);</li>
|
||||
* <li>组级:普通用户受两条链约束——所属分组组长(成员表)与创建人(管理员),
|
||||
* <li>组级:普通账号受两条链约束——所属分组组长(成员表)与创建人(管理员),
|
||||
* 与数据可见范围的派生口径一致(成员表基本未用、按创建人派生);</li>
|
||||
* <li>管理员(admin):自身 + 公司级。</li>
|
||||
* </ul>
|
||||
@@ -101,7 +101,7 @@ public class AccountExpiryService {
|
||||
LocalDateTime effective = ownExpiresAt;
|
||||
effective = min(effective, companyCascadeExpiresAt(companyId));
|
||||
if (role == null) {
|
||||
// 普通用户:组级约束(组长 + 创建人)。管理员不级联到组长(上级是公司超管/超管,走公司级)。
|
||||
// 普通账号:组级约束(组长 + 创建人)。管理员不级联到组长(上级是公司超管/超管,走公司级)。
|
||||
effective = min(effective, leaderCascadeExpiresAt(userId));
|
||||
effective = min(effective, creatorCascadeExpiresAt(createdById));
|
||||
}
|
||||
|
||||
+2
-2
@@ -360,7 +360,7 @@ public class AdminUserService {
|
||||
throw new BusinessException("不能修改超级管理员");
|
||||
}
|
||||
if ("company_super_admin".equals(role)) {
|
||||
// 公司超管只能编辑本公司管理员/普通用户;同公司的公司超管与站点超管都碰不得
|
||||
// 公司超管只能编辑本公司管理员/普通账号;同公司的公司超管与站点超管都碰不得
|
||||
if ("company_super_admin".equals(targetRole)) {
|
||||
throw new BusinessException(403, "只有超级管理员可以修改公司超级管理员");
|
||||
}
|
||||
@@ -500,7 +500,7 @@ public class AdminUserService {
|
||||
throw new BusinessException(403, "只能删除自己创建的普通账号");
|
||||
}
|
||||
} else if ("company_super_admin".equals(role)) {
|
||||
// 公司超管可清退本公司的管理员/普通用户;公司超管之间互删与站点超管一样被拒
|
||||
// 公司超管可清退本公司的管理员/普通账号;公司超管之间互删与站点超管一样被拒
|
||||
if ("company_super_admin".equals(targetRole)) {
|
||||
throw new BusinessException(403, "只有超级管理员可以删除公司超级管理员");
|
||||
}
|
||||
|
||||
+8
-8
@@ -92,7 +92,7 @@ public class PermissionMenuService {
|
||||
}
|
||||
// 出口 1(授权树):可授予集合里连超管都不含这些项——超管自己都拿不到,才授不出去。
|
||||
// 必须挂在 grantableOnly 上而不是 grantableIds != null 上:resolveGrantableMenuIds 对超管
|
||||
// 返回 null(不限制),挂错了条件就等于只挡住了普通管理员,旁路照旧。
|
||||
// 返回 null(不限制),挂错了条件就等于只挡住了管理员,旁路照旧。
|
||||
// 这里是重新赋值 visibleMenus,绝不能改 menus——它是 toItemVos 的层级/父节点查找表。
|
||||
if (grantableOnly) {
|
||||
visibleMenus = visibleMenus.stream()
|
||||
@@ -707,7 +707,7 @@ public class PermissionMenuService {
|
||||
* 镜像 V84 惯例(已获「店铺数据任务管理」菜单的用户自动获得初始数据查看授权):
|
||||
* admin 分区授权更新后,若**有效授权**包含店铺数据相关菜单(任务管理/重复检查,
|
||||
* 含经一级分组「店铺管理」展开覆盖的情形),自动补上内部数据权限
|
||||
* admin_shop_data_crawl_task_data,避免普通管理员已勾了菜单仍提示
|
||||
* admin_shop_data_crawl_task_data,避免管理员已勾了菜单仍提示
|
||||
* “无权查看店铺数据任务”。
|
||||
* 只增不删:数据授权的回收仍走超管专用的「数据范围授权」UI。
|
||||
*/
|
||||
@@ -744,7 +744,7 @@ public class PermissionMenuService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除普通管理员直接创建的员工中,超出该管理员当前有效权限范围的授权。
|
||||
* 删除管理员直接创建的员工中,超出该管理员当前有效权限范围的授权。
|
||||
* 只清理越权项,保留员工合法持有的其他授权。超级管理员无此限制。
|
||||
*
|
||||
* <p>有效集按目标的<b>完整</b>直接授权(读库,含 admin/app 全类型)计算:
|
||||
@@ -945,7 +945,7 @@ public class PermissionMenuService {
|
||||
throw new BusinessException(403, "需要管理员权限");
|
||||
}
|
||||
if ("company_super_admin".equals(normalizeRole(operator.getRole()))) {
|
||||
// 公司超管:本公司管理员/普通用户都可授;同公司的公司超管与站点超管碰不得
|
||||
// 公司超管:本公司管理员/普通账号都可授;同公司的公司超管与站点超管碰不得
|
||||
String targetRole = normalizeRole(target.getRole());
|
||||
if ("company_super_admin".equals(targetRole) || "super_admin".equals(targetRole)) {
|
||||
throw new BusinessException(403, "只有超级管理员可以修改公司超级管理员");
|
||||
@@ -960,14 +960,14 @@ public class PermissionMenuService {
|
||||
&& operator.getId() != null
|
||||
&& operator.getId().equals(target.getCreatedById());
|
||||
if (!ownedNormal) {
|
||||
throw new BusinessException(403, "普通管理员只能管理自己创建的普通账号");
|
||||
throw new BusinessException(403, "管理员只能管理自己创建的普通账号");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Throws 403 when a non-super admin **新增** grants outside their own effective set.
|
||||
*
|
||||
* <p>目标用户已持有的直接授权不参与校验:那是既有事实(通常由超管分配),普通管理员
|
||||
* <p>目标用户已持有的直接授权不参与校验:那是既有事实(通常由超管分配),管理员
|
||||
* 编辑该用户时整树提交会把它原样带回,若一并判为越权,整笔事务会回滚——连建号、改密
|
||||
* 都做不成(生产 2026-09-16 现象:勾到一个越权项,创建用户与保存权限双双失败)。
|
||||
* 只放行「保留已有」不放行「新增」,因此不构成提权。
|
||||
@@ -989,7 +989,7 @@ public class PermissionMenuService {
|
||||
.filter(id -> !effective.contains(id))
|
||||
.collect(Collectors.toCollection(LinkedHashSet::new));
|
||||
if (!denied.isEmpty()) {
|
||||
throw new BusinessException(403, "普通管理员只能分配自己已有的菜单权限");
|
||||
throw new BusinessException(403, "管理员只能分配自己已有的菜单权限");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1042,7 +1042,7 @@ public class PermissionMenuService {
|
||||
}
|
||||
String role = normalizeRole(user.getRole());
|
||||
if (!role.isEmpty()) {
|
||||
// company_super_admin 也是授权链上的一级主管(可给本公司的管理员/普通用户授权)
|
||||
// company_super_admin 也是授权链上的一级主管(可给本公司的管理员/普通账号授权)
|
||||
return "super_admin".equals(role) || "admin".equals(role) || "company_super_admin".equals(role);
|
||||
}
|
||||
return Integer.valueOf(1).equals(user.getIsAdmin());
|
||||
|
||||
+3
-3
@@ -117,7 +117,7 @@ public class ShopManageController {
|
||||
}
|
||||
|
||||
@GetMapping("/groups")
|
||||
@Operation(summary = "查询分组列表", description = "普通管理员返回当前可访问的分组,超级管理员返回全部;"
|
||||
@Operation(summary = "查询分组列表", description = "管理员返回当前可访问的分组,超级管理员返回全部;"
|
||||
+ "company_id 只收窄可见集、不放大,跨公司查看仅超管")
|
||||
public ApiResponse<java.util.List<ShopManageGroupItemVo>> listGroups(
|
||||
HttpServletRequest request,
|
||||
@@ -143,7 +143,7 @@ public class ShopManageController {
|
||||
}
|
||||
|
||||
@PutMapping("/groups/{id}")
|
||||
@Operation(summary = "更新分组", description = "普通管理员只能修改自己可访问的分组")
|
||||
@Operation(summary = "更新分组", description = "管理员只能修改自己可访问的分组")
|
||||
public ApiResponse<ShopManageGroupItemVo> updateGroup(
|
||||
HttpServletRequest request,
|
||||
@Parameter(description = "主键 ID", required = true) @PathVariable Long id,
|
||||
@@ -154,7 +154,7 @@ public class ShopManageController {
|
||||
}
|
||||
|
||||
@DeleteMapping("/groups/{id}")
|
||||
@Operation(summary = "删除分组", description = "普通管理员只能删除自己可访问的分组")
|
||||
@Operation(summary = "删除分组", description = "管理员只能删除自己可访问的分组")
|
||||
public ApiResponse<Void> deleteGroup(
|
||||
HttpServletRequest request,
|
||||
@Parameter(description = "主键 ID", required = true) @PathVariable Long id) {
|
||||
|
||||
+1
-1
@@ -245,7 +245,7 @@ public class ShopManageGroupService {
|
||||
}
|
||||
Long normalizedOperatorId = normalizePositiveId(operatorId, "操作人不能为空");
|
||||
if (!normalizedOperatorId.equals(leaderId)) {
|
||||
throw new BusinessException("普通管理员只能创建自己作为组长的分组");
|
||||
throw new BusinessException("管理员只能创建自己作为组长的分组");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -99,7 +99,7 @@ public class ExpiredAccountTaskStopService {
|
||||
|
||||
/**
|
||||
* 过期账号 → 需要连带停任务的成员集合。与登录侧级联判定同口径:
|
||||
* 公司超管过期圈全公司;管理员过期圈名下子账户 + 所带分组的成员表成员;普通用户只有自己。
|
||||
* 公司超管过期圈全公司;管理员过期圈名下子账户 + 所带分组的成员表成员;普通账号只有自己。
|
||||
*/
|
||||
private Set<Long> resolveAffectedUserIds(List<AdminUserEntity> boundary) {
|
||||
LinkedHashSet<Long> affected = new LinkedHashSet<>();
|
||||
|
||||
+5
-5
@@ -25,8 +25,8 @@ import static org.mockito.Mockito.when;
|
||||
|
||||
/**
|
||||
* 到期级联判定(V146)口径钉:
|
||||
* super_admin 永不适用;公司超管到期 → 全公司跟随;管理员到期 → 创建人链上的普通用户跟随;
|
||||
* 普通用户同时受自身/创建人/组长/公司超管四条约束取最早;库里不改值,全部现算。
|
||||
* super_admin 永不适用;公司超管到期 → 全公司跟随;管理员到期 → 创建人链上的普通账号跟随;
|
||||
* 普通账号同时受自身/创建人/组长/公司超管四条约束取最早;库里不改值,全部现算。
|
||||
*/
|
||||
class AccountExpiryServiceTest {
|
||||
|
||||
@@ -76,7 +76,7 @@ class AccountExpiryServiceTest {
|
||||
csa.setExpiresAt(companyExpiry);
|
||||
when(adminUserMapper.selectList(any())).thenReturn(List.of(csa));
|
||||
|
||||
// 普通用户(自身无到期)被公司超管的到期拉进去
|
||||
// 普通账号(自身无到期)被公司超管的到期拉进去
|
||||
assertThat(service.effectiveExpiresAt(entity(3L, "normal", null, 1L, null))).isEqualTo(companyExpiry);
|
||||
// 管理员同样被拉进去
|
||||
assertThat(service.effectiveExpiresAt(entity(2L, "admin", null, 1L, null))).isEqualTo(companyExpiry);
|
||||
@@ -106,7 +106,7 @@ class AccountExpiryServiceTest {
|
||||
assertThat(service.effectiveExpiresAt(entity(3L, "normal", null, 1L, own))).isEqualTo(company);
|
||||
}
|
||||
|
||||
// ---------- 组级联:管理员到期 → 名下/组内普通用户 ----------
|
||||
// ---------- 组级联:管理员到期 → 名下/组内普通账号 ----------
|
||||
|
||||
@Test
|
||||
void expiredCreatorAdminCascadesToNormalUser() {
|
||||
@@ -135,7 +135,7 @@ class AccountExpiryServiceTest {
|
||||
|
||||
@Test
|
||||
void normalUserIsNotCascadedByNormalCreator() {
|
||||
// 创建人自己是普通用户(历史脏数据):不构成组级约束
|
||||
// 创建人自己是普通账号(历史脏数据):不构成组级约束
|
||||
AdminUserEntity creator = new AdminUserEntity();
|
||||
creator.setId(8L);
|
||||
creator.setRole("normal");
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ import static org.mockito.Mockito.when;
|
||||
|
||||
/**
|
||||
* 桌面端通知可见范围回归:接收者只能来自 JWT 解析出的本人,
|
||||
* 且一律按 audience=user 读写 —— 普通用户只能看到自己的通知,读不到后台管理员通知。
|
||||
* 且一律按 audience=user 读写 —— 非后台账号只能看到自己的通知,读不到后台管理员通知。
|
||||
*/
|
||||
class NotificationControllerTest {
|
||||
|
||||
|
||||
+1
-1
@@ -61,7 +61,7 @@ class Task142Test {
|
||||
|
||||
@Test
|
||||
void test_task_142_define_menu_typeadmin_dependency_failure_returns_actionable_message() {
|
||||
// 保留 admin 域;普通用户经有效权限输入再过滤,Controller 不复算授权。
|
||||
// 保留 admin 域;普通账号经有效权限输入再过滤,Controller 不复算授权。
|
||||
assertEquals("admin", AdminMenuTreeBuilder.filterByMenuType(List.of(item(1L, "a", "admin")), "admin").get(0).getMenuType());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user