一单n制等功能,接入随手拍之前我先提交一版本
This commit is contained in:
@@ -43,6 +43,26 @@ export function resolveUserIdentityRoleKey(userInfo) {
|
||||
return normalizeRoleKey(identity?.roleKey);
|
||||
}
|
||||
|
||||
/** 从 userInfo 中读取组织实体类型:0/1=政府,2/3=企业及企业下部门 */
|
||||
export function resolveOrganizationEntityType(userInfo) {
|
||||
if (!userInfo) return null;
|
||||
const identity = normalizeUserIdentity(userInfo.userIdentity);
|
||||
const currentIdentity = getCurrentIdentityFromStorage();
|
||||
const merged = identity || currentIdentity;
|
||||
if (merged?.organizationEntityType == null || merged?.organizationEntityType === '') return null;
|
||||
const entityType = Number(merged.organizationEntityType);
|
||||
return Number.isNaN(entityType) ? null : entityType;
|
||||
}
|
||||
|
||||
const MANAGER_ROLE_KEYS = ['admin', 'manage'];
|
||||
|
||||
/** 是否为政府类型组织的管理员(organizationEntityType=0/1 且 roleKey 为 admin/manage) */
|
||||
export function isGovernmentEntityAdmin(userInfo) {
|
||||
const entityType = resolveOrganizationEntityType(userInfo);
|
||||
if (entityType !== 0 && entityType !== 1) return false;
|
||||
return MANAGER_ROLE_KEYS.includes(resolveUserIdentityRoleKey(userInfo));
|
||||
}
|
||||
|
||||
/** 解析用于权限判断的角色标识,优先当前身份 roleKey */
|
||||
export function resolveUserRoleKey(userInfo) {
|
||||
if (!userInfo) return '';
|
||||
|
||||
Reference in New Issue
Block a user