新增ios白名单

This commit is contained in:
tianfeng 2026-03-21 18:16:02 +08:00
parent c77d450b21
commit b2619e1327

View File

@ -6,7 +6,10 @@ import com.red.circle.common.business.dto.cmd.AppExtCommand;
import com.red.circle.other.app.convertor.sys.SysConfigAppConvertor;
import com.red.circle.other.app.dto.clientobject.sys.GameListConfigCO;
import com.red.circle.other.app.dto.cmd.game.GameListQryCmd;
import com.red.circle.other.domain.gateway.user.UserProfileGateway;
import com.red.circle.other.domain.gateway.user.ability.UserRegionGateway;
import com.red.circle.other.domain.model.user.UserProfile;
import com.red.circle.other.infra.database.cache.service.other.EnumConfigCacheService;
import com.red.circle.other.infra.database.cache.service.other.GameListCacheService;
import com.red.circle.other.infra.database.rds.service.live.RoomMemberService;
import com.red.circle.other.infra.database.rds.service.sys.GameListConfigService;
@ -15,14 +18,17 @@ import com.red.circle.other.infra.database.rds.service.user.device.LatestMobileD
import com.red.circle.other.infra.database.rds.entity.user.user.LatestMobileDevice;
import com.red.circle.other.infra.utils.IpCountryUtils;
import com.red.circle.other.inner.enums.live.RoomUserRolesEnum;
import com.red.circle.other.inner.model.dto.sys.EnumConfigDTO;
import com.red.circle.tool.core.collection.CollectionUtils;
import com.red.circle.tool.core.json.JacksonUtils;
import com.red.circle.tool.core.text.StringUtils;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@ -39,7 +45,10 @@ import org.springframework.stereotype.Component;
public class GameListConfigQryExe {
private static final String COMMON = "COMMON";
private static final String IOS_GAME_USER_WHITE_LIST = "IOS_GAME_USER_WHITE_LIST";
private final UserRegionGateway userRegionGateway;
private final UserProfileGateway userProfileGateway;
private final EnumConfigCacheService enumConfigCacheService;
private final SysConfigAppConvertor sysConfigAppConvertor;
private final GameListCacheService gameListCacheService;
private final RoomMemberService roomMemberService;
@ -93,6 +102,27 @@ public class GameListConfigQryExe {
return configs;
}
/**
* 判断用户是否在 ios游戏用户白名单 .
* 枚举配置code=IOS_GAME_USER_WHITE_LISTval 为逗号分隔的短用户IDaccount 8826602,8826603
*/
private boolean isIosGameWhiteListUser(Long userId) {
if (userId == null) {
return false;
}
EnumConfigDTO configDTO = enumConfigCacheService.getByCode(IOS_GAME_USER_WHITE_LIST, "LIKEI");
String whiteConfig = Optional.ofNullable(configDTO).map(EnumConfigDTO::getVal).orElse(null);
if (StringUtils.isBlank(whiteConfig)) {
return false;
}
UserProfile userProfile = userProfileGateway.getByUserId(userId);
if (userProfile == null) {
return false;
}
List<String> whiteIds = Arrays.asList(whiteConfig.split(","));
return whiteIds.contains(userProfile.getAccount());
}
// 解析 游戏 URL 参数
private Map<String, String> parseUrlParams(String url) {
Map<String, String> params = new HashMap<>();
@ -142,6 +172,10 @@ public class GameListConfigQryExe {
.filter(config -> Objects.equals(config.getClientOrigin(), "IOS") || Objects
.equals(config.getClientOrigin(), COMMON))
.toList();
// ios游戏用户白名单白名单用户不过滤否则只返回 CASUAL 分类
if (isIosGameWhiteListUser(cmd.requiredReqUserId())) {
return iosConfigs;
}
return iosConfigs.stream()
.filter(config -> Objects.equals(config.getCategory(), "CASUAL"))
.toList();