fix 管理员看不到订单
Some checks failed
Build and Push Backend / docker (push) Failing after 6s

This commit is contained in:
irving
2025-10-31 23:59:52 -04:00
parent b6f89045ab
commit fb2bd510b1
2 changed files with 64 additions and 2 deletions

View File

@@ -0,0 +1,53 @@
package com.starry.common.enums;
import java.util.Locale;
import java.util.Objects;
import java.util.Set;
/**
* 租户后台角色枚举,集中维护角色标识,避免散落的魔法字符串。
*/
public enum TenantRoleEnum {
/**
* 管理员(运营)角色,拥有全量数据视图。
*/
OPERATOR("operator"),
/**
* 组长角色,只能查看所在小组的数据。
*/
LEADER("leader"),
/**
* 客服角色。
*/
WAITER("waiter");
private final String roleKey;
TenantRoleEnum(String roleKey) {
this.roleKey = roleKey.toLowerCase(Locale.ROOT);
}
public String getRoleKey() {
return roleKey;
}
/**
* 判断角色集合中是否包含目标角色。
*
* @param roles 当前角色集合
* @param targetRole 目标角色
* @return true 表示包含
*/
public static boolean contains(Set<String> roles, TenantRoleEnum targetRole) {
if (roles == null || targetRole == null) {
return false;
}
return roles.stream()
.filter(Objects::nonNull)
.map(role -> role.toLowerCase(Locale.ROOT))
.anyMatch(role -> role.equals(targetRole.getRoleKey()));
}
}