发现页区域隔离增加土耳其
This commit is contained in:
parent
7c6c82959f
commit
865461657a
@ -62,9 +62,10 @@ public class RoomVoiceDiscoverQryExe {
|
||||
private static final String EMPTY_ROOM_CACHE_KEY = "empty_room_cache:*";
|
||||
|
||||
// 区域隔离常量 - 与ActiveVoiceRoomServiceImpl保持一致
|
||||
private static final Set<String> TR_REGIONS = Set.of("TR");
|
||||
private static final Set<String> SA_REGIONS = Set.of("BD","SA", "IN", "PK");
|
||||
private static final Set<String> AR_REGIONS = Set.of("AE", "AR", "BH", "DJ", "DZ", "EG", "EY", "ER", "IL", "IQ", "JO", "KM", "KW", "LB", "LY", "MA", "MR", "OM", "PS", "QA", "SD", "SO", "SS", "SY", "TD", "TN", "YE");
|
||||
private static final Set<String> OTHER_REGIONS = Set.of("OTHER", "PH", "ID", "TR", "GH", "IR", "AF", "NG", "DE", "MYS", "TM", "AZ", "NP");
|
||||
private static final Set<String> OTHER_REGIONS = Set.of("OTHER", "PH", "ID", "GH", "IR", "AF", "NG", "DE", "MYS", "TM", "AZ", "NP");
|
||||
|
||||
public List<RoomVoiceProfileCO> execute(AppExtCommand cmd) {
|
||||
String region = cmd.isAllRegion() ? "ALL" : userRegionGateway.getRegionCode(cmd.requiredReqUserId());
|
||||
@ -100,11 +101,6 @@ public class RoomVoiceDiscoverQryExe {
|
||||
log.info("activeVoiceRooms:{}", JSON.toJSONString(activeVoiceRooms));
|
||||
List<RoomVoiceProfileCO> roomList = roomVoiceProfileCommon.toListRoomVoiceProfileCO(activeVoiceRooms);
|
||||
|
||||
if (CollectionUtils.isEmpty(roomList)) {
|
||||
//roomList = getHomeData(cmd,latestMobileDeviceService.getLatestLanguage(cmd.requiredReqUserId()));
|
||||
roomList = roomVoiceProfileCommon.toListRoomVoiceProfileCO(
|
||||
activeVoiceRoomService.listDiscover(cmd.requireReqSysOrigin(), cmd.isAllRegion(), "ID", 50));
|
||||
}
|
||||
if (CollectionUtils.isEmpty(roomList)) {
|
||||
return CollectionUtils.newArrayList();
|
||||
}
|
||||
@ -240,43 +236,51 @@ public class RoomVoiceDiscoverQryExe {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 按照listDiscover的过滤规则过滤空房间
|
||||
*
|
||||
* @param emptyRooms 空房间列表
|
||||
* @param sysOrigin 系统来源
|
||||
* @param isAllRegion 是否显示所有区域
|
||||
* @param region 当前用户区域
|
||||
* @return 过滤后的空房间列表
|
||||
*/
|
||||
private List<ActiveVoiceRoom> filterEmptyRoomsByRegion(List<ActiveVoiceRoom> emptyRooms, String sysOrigin, boolean isAllRegion, String region) {
|
||||
List<String> excludeRegions = getRegions(region);
|
||||
List<String> includeRegions = getSpecialRegions(region);
|
||||
|
||||
return emptyRooms.stream()
|
||||
.filter(room -> Objects.equals(sysOrigin, room.getSysOrigin()))
|
||||
.filter(room -> {
|
||||
if (isAllRegion) {
|
||||
return true; // 如果是所有区域,不进行区域过滤
|
||||
}
|
||||
|
||||
String roomRegion = room.getRegion();
|
||||
|
||||
if (CollectionUtils.isNotEmpty(includeRegions)) {
|
||||
// 如果当前用户属于特殊区域组,只显示该区域组内的房间
|
||||
return includeRegions.contains(roomRegion);
|
||||
}
|
||||
|
||||
if (CollectionUtils.isNotEmpty(excludeRegions)) {
|
||||
// 如果当前用户不属于特殊区域组,排除所有特殊区域组的房间
|
||||
return !excludeRegions.contains(roomRegion);
|
||||
}
|
||||
|
||||
return true;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
.filter(room -> Objects.equals(sysOrigin, room.getSysOrigin()) &&
|
||||
(isAllRegion || shouldShowRoom(region, room.getRegion())))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 判断是否应该显示该房间
|
||||
*/
|
||||
private boolean shouldShowRoom(String userRegion, String roomRegion) {
|
||||
// 获取用户所属区域组
|
||||
Set<String> userRegionGroup = getRegionGroup(userRegion);
|
||||
Set<String> roomRegionGroup = getRegionGroup(roomRegion);
|
||||
|
||||
// 如果用户在特殊区域组,只显示同组房间
|
||||
if (userRegionGroup != null) {
|
||||
return userRegionGroup.contains(roomRegion);
|
||||
}
|
||||
|
||||
// 如果用户不在特殊区域组,排除所有特殊区域组房间
|
||||
return roomRegionGroup == null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取区域所属的特殊区域组(如果不属于任何特殊组则返回null)
|
||||
*/
|
||||
private Set<String> getRegionGroup(String region) {
|
||||
if (SA_REGIONS.contains(region)) {
|
||||
return SA_REGIONS;
|
||||
}
|
||||
if (AR_REGIONS.contains(region)) {
|
||||
return AR_REGIONS;
|
||||
}
|
||||
if (OTHER_REGIONS.contains(region)) {
|
||||
return OTHER_REGIONS;
|
||||
}
|
||||
if (TR_REGIONS.contains(region)) {
|
||||
return TR_REGIONS;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取需要排除的区域列表
|
||||
*/
|
||||
|
||||
@ -36,9 +36,20 @@ public class ActiveVoiceRoomServiceImpl implements ActiveVoiceRoomService {
|
||||
|
||||
private final MongoTemplate mongoTemplate;
|
||||
|
||||
private static final Set<String> TR_REGIONS = Set.of("TR");
|
||||
private static final Set<String> SA_REGIONS = Set.of("BD","SA", "IN", "PK");
|
||||
private static final Set<String> AR_REGIONS = Set.of("AE", "AR", "BH", "DJ", "DZ", "EG", "EY", "ER", "IL", "IQ", "JO", "KM", "KW", "LB", "LY", "MA", "MR", "OM", "PS", "QA", "SD", "SO", "SS", "SY", "TD", "TN", "YE");
|
||||
private static final Set<String> OTHER_REGIONS = Set.of("OTHER", "PH", "ID", "TR", "GH", "IR", "AF", "NG", "DE", "MYS", "TM", "AZ", "NP");
|
||||
private static final Set<String> OTHER_REGIONS = Set.of("OTHER", "PH", "ID", "GH", "IR", "AF", "NG", "DE", "MYS", "TM", "AZ", "NP");
|
||||
private static final Set<String> ALL_SPECIAL_REGIONS;
|
||||
|
||||
static {
|
||||
Set<String> temp = new HashSet<>();
|
||||
temp.addAll(SA_REGIONS);
|
||||
temp.addAll(AR_REGIONS);
|
||||
temp.addAll(TR_REGIONS);
|
||||
temp.addAll(OTHER_REGIONS);
|
||||
ALL_SPECIAL_REGIONS = Collections.unmodifiableSet(temp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveOrUpdate(ActiveVoiceRoom param) {
|
||||
@ -123,18 +134,19 @@ public class ActiveVoiceRoomServiceImpl implements ActiveVoiceRoomService {
|
||||
|
||||
@Override
|
||||
public List<ActiveVoiceRoom> listDiscover(String sysOrigin, boolean isAllRegion, String region, Integer limit) {
|
||||
|
||||
// 区域隔离
|
||||
List<String> regions = getRegions(region);
|
||||
List<String> specialRegions = getSpecialRegions(region);
|
||||
log.info("被隔离区域 regions:{}", JSON.toJSONString(regions));
|
||||
Set<String> userRegionGroup = getRegionGroup(region);
|
||||
Set<String> excludeRegions = userRegionGroup == null ? ALL_SPECIAL_REGIONS : getExcludeRegionsForGroup(userRegionGroup);
|
||||
|
||||
log.info("被隔离区域 regions:{}", JSON.toJSONString(excludeRegions));
|
||||
|
||||
// 构建聚合管道
|
||||
Criteria criteria = Criteria.where("sysOrigin").is(sysOrigin);
|
||||
if (CollectionUtils.isNotEmpty(specialRegions) && !isAllRegion) {
|
||||
criteria.and("region").in(specialRegions);
|
||||
if (userRegionGroup != null && !isAllRegion) {
|
||||
criteria.and("region").in(userRegionGroup);
|
||||
}
|
||||
if (CollectionUtils.isEmpty(specialRegions) && CollectionUtils.isNotEmpty(regions) && !isAllRegion) {
|
||||
criteria.and("region").nin(regions);
|
||||
if (userRegionGroup == null && !isAllRegion) {
|
||||
criteria.and("region").nin(excludeRegions);
|
||||
}
|
||||
Aggregation aggregation = Aggregation.newAggregation(
|
||||
// 1. 匹配国家(可选条件)
|
||||
@ -172,41 +184,48 @@ public class ActiveVoiceRoomServiceImpl implements ActiveVoiceRoomService {
|
||||
.getMappedResults();
|
||||
}
|
||||
|
||||
private List<String> getSpecialRegions(String region) {
|
||||
/**
|
||||
* 获取区域所属的特殊区域组(如果不属于任何特殊组则返回null)
|
||||
*/
|
||||
private Set<String> getRegionGroup(String region) {
|
||||
if (SA_REGIONS.contains(region)) {
|
||||
return new ArrayList<>(SA_REGIONS);
|
||||
return SA_REGIONS;
|
||||
}
|
||||
|
||||
if (AR_REGIONS.contains(region)) {
|
||||
return new ArrayList<>(AR_REGIONS);
|
||||
return AR_REGIONS;
|
||||
}
|
||||
|
||||
if (OTHER_REGIONS.contains(region)) {
|
||||
return new ArrayList<>(OTHER_REGIONS);
|
||||
return OTHER_REGIONS;
|
||||
}
|
||||
|
||||
return new ArrayList<>();
|
||||
if (TR_REGIONS.contains(region)) {
|
||||
return TR_REGIONS;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private List<String> getRegions(String region) {
|
||||
List<String> excludeRegions = new ArrayList<>();
|
||||
|
||||
if (SA_REGIONS.contains(region)) {
|
||||
excludeRegions.addAll(AR_REGIONS);
|
||||
excludeRegions.addAll(OTHER_REGIONS);
|
||||
} else if (AR_REGIONS.contains(region)) {
|
||||
excludeRegions.addAll(SA_REGIONS);
|
||||
excludeRegions.addAll(OTHER_REGIONS);
|
||||
} else if (OTHER_REGIONS.contains(region)) {
|
||||
excludeRegions.addAll(SA_REGIONS);
|
||||
excludeRegions.addAll(AR_REGIONS);
|
||||
} else {
|
||||
excludeRegions.addAll(SA_REGIONS);
|
||||
excludeRegions.addAll(AR_REGIONS);
|
||||
excludeRegions.addAll(OTHER_REGIONS);
|
||||
/**
|
||||
* 获取指定区域组需要排除的其他区域组
|
||||
*/
|
||||
private Set<String> getExcludeRegionsForGroup(Set<String> regionGroup) {
|
||||
Set<String> excludes = new HashSet<>();
|
||||
if (regionGroup == SA_REGIONS) {
|
||||
excludes.addAll(AR_REGIONS);
|
||||
excludes.addAll(OTHER_REGIONS);
|
||||
excludes.addAll(TR_REGIONS);
|
||||
} else if (regionGroup == AR_REGIONS) {
|
||||
excludes.addAll(SA_REGIONS);
|
||||
excludes.addAll(OTHER_REGIONS);
|
||||
excludes.addAll(TR_REGIONS);
|
||||
} else if (regionGroup == OTHER_REGIONS) {
|
||||
excludes.addAll(SA_REGIONS);
|
||||
excludes.addAll(AR_REGIONS);
|
||||
excludes.addAll(TR_REGIONS);
|
||||
} else if (regionGroup == TR_REGIONS) {
|
||||
excludes.addAll(SA_REGIONS);
|
||||
excludes.addAll(AR_REGIONS);
|
||||
excludes.addAll(OTHER_REGIONS);
|
||||
}
|
||||
|
||||
return excludeRegions;
|
||||
return excludes;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user