Files
YschcmsService/src/main/java/com/yunhai/cms/config/CmsAuthProperties.java
T
2026-09-07 09:09:39 +08:00

31 lines
1.2 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package com.yunhai.cms.config;
import com.yunhai.platform.utils.model.BoaUser;
import org.springframework.stereotype.Component;
/**
* CMS 权限判定(对齐 UserBase GroupAuthzService#isSuperAdmin 与 UserTypeEnum 平台约定)。
*
* <p>超管规则:{@code BoaUser.type == 1}(UserTypeEnum.SUPER_ADMIN,系统种子账号),
* 或 {@code BoaUser.id == 100000}(基石超级管理员账号,同 UserBase 内部判定)。
* type 随认证链路经 BoaUserLoader 从 UserBase 换出,无需任何注入配置。
* 学校管理员(type=2,持 ADMIN 角色)与学校领导不特判,统一走
* {@code currentRole.schId → site.schId} 校级规则(方案 §7.2 规则②)。</p>
*/
@Component
public class CmsAuthProperties {
/** UserBase 基石超级管理员账号 id(DicUtil.SUPER_ADMIN_ID,平台约定常量) */
private static final int PLATFORM_ROOT_USER_ID = 100000;
public boolean isSuperAdmin(BoaUser user) {
if (user == null) {
return false;
}
if (user.getType() != null && user.getType() == 1) {
return true;
}
return user.getId() != null && user.getId() == PLATFORM_ROOT_USER_ID;
}
}