mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-23 23:19:19 +08:00
feat: owner 权限码改为返回公司已分配权限而非 company:* 通配
This commit is contained in:
+6
-1
@@ -54,6 +54,10 @@ public class AuthController {
|
||||
return ApiResponse.success("切换公司成功", loginVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前用户可操作的权限码(供前端按钮显隐)。
|
||||
* super → [*];owner → 公司已分配权限;member → 岗位权限。
|
||||
*/
|
||||
@GetMapping("/codes")
|
||||
public ApiResponse<List<String>> getAccessCodes() {
|
||||
try {
|
||||
@@ -66,7 +70,8 @@ public class AuthController {
|
||||
if (isSuper) {
|
||||
permissions = List.of("*");
|
||||
} else if ("owner".equalsIgnoreCase(companyRole)) {
|
||||
permissions = List.of("company:*");
|
||||
// 与 PermissionAspect 一致:owner 仅拥有平台分配给公司的权限,不再返回 company:* 通配
|
||||
permissions = permissionCheckService.getCompanyAssignedPermissionCodes(companyId);
|
||||
} else {
|
||||
permissions = permissionCheckService.getPositionPermissions(positionId, companyId);
|
||||
}
|
||||
|
||||
+8
@@ -33,6 +33,14 @@ public interface PermissionCheckService {
|
||||
*/
|
||||
java.util.List<String> getPositionPermissions(Long positionId, Long companyId);
|
||||
|
||||
/**
|
||||
* 获取平台已分配给公司的权限码(供 owner 的 /auth/codes 与按钮显隐对齐)
|
||||
*
|
||||
* @param companyId 公司ID
|
||||
* @return 权限码列表
|
||||
*/
|
||||
java.util.List<String> getCompanyAssignedPermissionCodes(Long companyId);
|
||||
|
||||
/**
|
||||
* 根据是否超管检查是否有权限
|
||||
*
|
||||
|
||||
+14
@@ -92,6 +92,20 @@ public class PermissionCheckServiceImpl implements PermissionCheckService {
|
||||
}
|
||||
}
|
||||
|
||||
/** 公司已分配权限码,与 PermissionAspect 对 owner 的校验数据源一致 */
|
||||
@Override
|
||||
public List<String> getCompanyAssignedPermissionCodes(Long companyId) {
|
||||
if (companyId == null) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
try {
|
||||
return companyPermissionService.getCompanyPermissionCodes(companyId);
|
||||
} catch (Exception e) {
|
||||
log.error("获取公司权限码异常 companyId={}", companyId, e);
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据是否超管检查是否有权限
|
||||
* @param isSuper 是否超级管理员
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/** 与 GET /auth/codes 返回的全局通配一致 */
|
||||
/** 超管通配(GET /auth/codes 对 super 返回 [*]) */
|
||||
export const PERMISSION_WILDCARD_ALL = '*';
|
||||
/** 历史公司通配;owner 已改为返回公司实际权限码,保留兼容旧会话缓存 */
|
||||
export const PERMISSION_WILDCARD_COMPANY = 'company:*';
|
||||
|
||||
export type PermissionMatchMode = 'all' | 'any';
|
||||
|
||||
Reference in New Issue
Block a user