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

@@ -10,18 +10,21 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.starry.admin.common.domain.LoginUser;
import com.starry.admin.modules.clerk.module.entity.PlayClerkUserInfoEntity;
import com.starry.admin.modules.clerk.module.enums.ClerkRoleStatus;
import com.starry.admin.modules.clerk.service.IPlayClerkUserInfoService;
import com.starry.admin.modules.personnel.mapper.PlayPersonnelGroupInfoMapper;
import com.starry.admin.modules.personnel.module.entity.PlayPersonnelGroupInfoEntity;
import com.starry.admin.modules.personnel.module.vo.PlayPersonnelGroupInfoQueryVo;
import com.starry.admin.modules.personnel.module.vo.PlayPersonnelGroupInfoReturnVo;
import com.starry.admin.modules.personnel.service.IPlayPersonnelGroupInfoService;
import com.starry.common.enums.TenantRoleEnum;
import com.starry.common.utils.IdUtils;
import com.starry.common.utils.StringUtils;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
@@ -130,7 +133,13 @@ public class PlayPersonnelGroupInfoServiceImpl
@Override
public List<String> getValidClerkIdList(LoginUser loginUser, String clerkNickName) {
List<String> idList;
PlayPersonnelGroupInfoEntity groupInfoEntity = this.selectByUserId(loginUser.getUserId());
Set<String> roleKeys = loginUser != null && loginUser.getRoles() != null ? loginUser.getRoles()
: Collections.emptySet();
boolean hasOperatorRole = TenantRoleEnum.contains(roleKeys, TenantRoleEnum.OPERATOR);
PlayPersonnelGroupInfoEntity groupInfoEntity = null;
if (!hasOperatorRole && loginUser != null) {
groupInfoEntity = this.selectByUserId(loginUser.getUserId());
}
if (Objects.nonNull(groupInfoEntity)) {
List<PlayClerkUserInfoEntity> list = clerkUserInfoService
.list(Wrappers.lambdaQuery(PlayClerkUserInfoEntity.class)
@@ -147,7 +156,7 @@ public class PlayPersonnelGroupInfoServiceImpl
// 返回所有的clerkId
idList = clerkUserInfoService
.list(Wrappers.lambdaQuery(PlayClerkUserInfoEntity.class).select(PlayClerkUserInfoEntity::getId)
.eq(PlayClerkUserInfoEntity::getClerkState, "1"))
.eq(PlayClerkUserInfoEntity::getClerkState, ClerkRoleStatus.CLERK.getCode()))
.stream().map(PlayClerkUserInfoEntity::getId).collect(Collectors.toList());
}

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()));
}
}