getUserByRoleEnumAndAreaId
This commit is contained in:
@@ -103,8 +103,8 @@ public class RedisConstantUtil {
|
||||
return active + "_" + RedisConstant.USER_WANT_AREA_CACHE + eid + ":" + userId;
|
||||
}
|
||||
|
||||
public String getInvestmentManagerKey(Long wantShopAreaId) {
|
||||
return active + "_" + RedisConstant.INVESTMENT_MANAGER_CACHE + eid + ":" + wantShopAreaId;
|
||||
public String getInvestmentManagerKey(Long wantShopAreaId, Long roleId) {
|
||||
return active + "_" + RedisConstant.INVESTMENT_MANAGER_CACHE + eid + ":" + wantShopAreaId + ":" + roleId ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -77,14 +77,11 @@ public class UserAuthMappingServiceImpl implements UserAuthMappingService {
|
||||
if(Objects.isNull(userRoleEnum) || Objects.isNull(wantShopAreaId)){
|
||||
return null;
|
||||
}
|
||||
String suitableUserId = null;
|
||||
String investmentManagerKey = redisConstantUtil.getInvestmentManagerKey(wantShopAreaId);
|
||||
if(UserRoleEnum.INVESTMENT_MANAGER.equals(userRoleEnum)){
|
||||
suitableUserId = redisUtilPool.rpopStr(investmentManagerKey);
|
||||
if(StringUtils.isNotBlank(suitableUserId)){
|
||||
EnterpriseUserDO userDO = enterpriseUserDAO.getUserInfoById(suitableUserId);
|
||||
return userDO;
|
||||
}
|
||||
String investmentManagerKey = redisConstantUtil.getInvestmentManagerKey(wantShopAreaId, userRoleEnum.getCode());
|
||||
String suitableUserId = redisUtilPool.rpopStr(investmentManagerKey);
|
||||
if(StringUtils.isNotBlank(suitableUserId)){
|
||||
EnterpriseUserDO userDO = enterpriseUserDAO.getUserInfoById(suitableUserId);
|
||||
return userDO;
|
||||
}
|
||||
Long warRegionId = regionAreaConfigDao.getByWantShopAreaId(wantShopAreaId);
|
||||
if(warRegionId == null){
|
||||
@@ -104,16 +101,11 @@ public class UserAuthMappingServiceImpl implements UserAuthMappingService {
|
||||
if(CollectionUtils.isEmpty(authWarRegionUserIdList)){
|
||||
return fillDefaultUser(userRoleEnum);
|
||||
}
|
||||
if(UserRoleEnum.INVESTMENT_MANAGER.equals(userRoleEnum)){
|
||||
// 按工号排序后放入redis
|
||||
authWarRegionUserIdList = authWarRegionUserIdList.stream()
|
||||
.sorted((a, b) -> b.compareTo(a))
|
||||
.collect(Collectors.toList());
|
||||
redisUtilPool.listPushTail(investmentManagerKey, authWarRegionUserIdList.toArray(new String[authWarRegionUserIdList.size()]));
|
||||
suitableUserId = redisUtilPool.rpopStr(investmentManagerKey);
|
||||
}else {
|
||||
suitableUserId = authWarRegionUserIdList.get(0);
|
||||
}
|
||||
authWarRegionUserIdList = authWarRegionUserIdList.stream()
|
||||
.sorted((a, b) -> b.compareTo(a))
|
||||
.collect(Collectors.toList());
|
||||
redisUtilPool.listPushTail(investmentManagerKey, authWarRegionUserIdList.toArray(new String[authWarRegionUserIdList.size()]));
|
||||
suitableUserId = redisUtilPool.rpopStr(investmentManagerKey);
|
||||
EnterpriseUserDO userDO = enterpriseUserDAO.getUserInfoById(suitableUserId);
|
||||
return userDO;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user