mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-24 01:59:20 +08:00
refactor(auth): 移除平台角色 admin,改为纯 user/super 两级
变更内容:
1. sys_user.role 枚举从 enum('user','admin','super') 改为 enum('user','super')
2. RoleAspect 移除 case "admin" 分支,公司拥有者通过检查 org_company_member.role=owner 获得公司管理员权限
3. PermissionAspect 同样添加 owner 检查逻辑
4. UserMenuServiceImpl 移除 case "admin" 分支
5. AccountServiceImpl/SuperAccountServiceImpl 移除 getRoleName 中的 admin 分支
This commit is contained in:
+21
-5
@@ -60,12 +60,28 @@ public class PermissionAspect {
|
||||
case "super":
|
||||
hasPermission = annotation.allowSuper();
|
||||
break;
|
||||
case "admin":
|
||||
hasPermission = annotation.allowCompany();
|
||||
break;
|
||||
case "user":
|
||||
hasPermission = annotation.allowUser() &&
|
||||
permissionCheckService.hasPermissionByPosition(positionId, annotation.value(), companyId);
|
||||
// 普通用户检查公司成员角色
|
||||
if (annotation.allowCompany()) {
|
||||
try {
|
||||
String memberRole = currentUserContext.getCurrentMemberRole();
|
||||
if ("owner".equals(memberRole)) {
|
||||
hasPermission = true;
|
||||
log.debug("权限验证 - 用户是公司拥有者,视为公司管理员");
|
||||
} else {
|
||||
hasPermission = annotation.allowUser() &&
|
||||
permissionCheckService.hasPermissionByPosition(positionId, annotation.value(), companyId);
|
||||
}
|
||||
} catch (BusinessException e) {
|
||||
// 无法获取公司成员角色,降为普通用户权限
|
||||
log.debug("无法获取公司成员角色: {}", e.getMessage());
|
||||
hasPermission = annotation.allowUser() &&
|
||||
permissionCheckService.hasPermissionByPosition(positionId, annotation.value(), companyId);
|
||||
}
|
||||
} else {
|
||||
hasPermission = annotation.allowUser() &&
|
||||
permissionCheckService.hasPermissionByPosition(positionId, annotation.value(), companyId);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new BusinessException("未知的用户角色: " + role);
|
||||
|
||||
@@ -55,9 +55,6 @@ public class RoleAspect {
|
||||
case "super":
|
||||
hasPermission = annotation.allowSuper();
|
||||
break;
|
||||
case "admin":
|
||||
hasPermission = annotation.allowCompany();
|
||||
break;
|
||||
case "user":
|
||||
// 普通用户检查公司成员角色,如果是 owner 则视为公司管理员
|
||||
if (annotation.allowCompany()) {
|
||||
|
||||
-1
@@ -428,7 +428,6 @@ public class AccountServiceImpl extends ServiceImpl<UserMapper, UserPO> implemen
|
||||
if (role == null) return "未知";
|
||||
return switch (role) {
|
||||
case "super" -> "超级管理员";
|
||||
case "admin" -> "公司管理员";
|
||||
case "user" -> "普通用户";
|
||||
default -> "未知";
|
||||
};
|
||||
|
||||
-1
@@ -445,7 +445,6 @@ public class SuperAccountServiceImpl extends ServiceImpl<UserMapper, UserPO> imp
|
||||
if (role == null) return "未知";
|
||||
return switch (role) {
|
||||
case "super" -> "超级管理员";
|
||||
case "admin" -> "公司管理员";
|
||||
case "user" -> "普通用户";
|
||||
default -> "未知";
|
||||
};
|
||||
|
||||
-9
@@ -79,15 +79,6 @@ public class UserMenuServiceImpl implements UserMenuService {
|
||||
// 超级管理员获取所有系统菜单,不需要公司上下文
|
||||
menus = menuService.getAllMenus();
|
||||
break;
|
||||
case "admin":
|
||||
// 公司管理员获取公司所有菜单
|
||||
Long companyId = currentUserContext.getCurrentCompanyId();
|
||||
if (companyId == null) {
|
||||
menus = List.of();
|
||||
} else {
|
||||
menus = companyMenuService.getCompanyMenusForRoute(companyId);
|
||||
}
|
||||
break;
|
||||
case "user":
|
||||
// 普通用户,根据公司成员角色判断
|
||||
Long companyIdForUser = currentUserContext.getCurrentCompanyId();
|
||||
|
||||
Reference in New Issue
Block a user