|
@@ -212,23 +212,28 @@ public class BlacklistContainer {
|
|
|
private String matchUserBlacklistTypeEnum(String uid, Long hotSceneType, String cityCode, String clientIP) {
|
|
|
try {
|
|
|
LOG.info("计算用户黑名单类型,判断参数: uid={}, hotSceneType={}, cityCode={}, clientIP={}", uid, hotSceneType, cityCode, clientIP);
|
|
|
- String key = this.calcUserRedisKey(uid);
|
|
|
- Map<String, String> uidBlacklistMap = blacklistCache.get(key);
|
|
|
- if (uidBlacklistMap.containsKey(uid)) {
|
|
|
- String userType = uidBlacklistMap.get(uid);
|
|
|
- this.filterLogUpload(uid, cityCode, hotSceneType, clientIP, userType, "UID");
|
|
|
- LOG.info("用户 {} 在UID黑名单中命中 {}", uid, userType);
|
|
|
- return userType;
|
|
|
+ if (StringUtils.isNotBlank(uid)) {
|
|
|
+ String key = this.calcUserRedisKey(uid);
|
|
|
+ Map<String, String> uidBlacklistMap = blacklistCache.get(key);
|
|
|
+ if (uidBlacklistMap.containsKey(uid)) {
|
|
|
+ String userType = uidBlacklistMap.get(uid);
|
|
|
+ this.filterLogUpload(uid, cityCode, hotSceneType, clientIP, userType, "UID");
|
|
|
+ LOG.info("用户 {} 在UID黑名单中命中 {}", uid, userType);
|
|
|
+ return userType;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- Map<String, String> ipBlacklistMap = blacklistCache.get(IP_VISIO_BLACKLIST_HASH_KEY);
|
|
|
- if (ipBlacklistMap.containsKey(clientIP)) {
|
|
|
- String userType = ipBlacklistMap.get(clientIP);
|
|
|
- this.filterLogUpload(uid, cityCode, hotSceneType, clientIP, userType, "IP");
|
|
|
- LOG.info("用户 {} 在IP黑名单中命中 {}, 参数为: clientIP为: {}", uid, userType, clientIP);
|
|
|
- return userType;
|
|
|
+ if (StringUtils.isNotBlank(clientIP)) {
|
|
|
+ Map<String, String> ipBlacklistMap = blacklistCache.get(IP_VISIO_BLACKLIST_HASH_KEY);
|
|
|
+ if (ipBlacklistMap.containsKey(clientIP)) {
|
|
|
+ String userType = ipBlacklistMap.get(clientIP);
|
|
|
+ this.filterLogUpload(uid, cityCode, hotSceneType, clientIP, userType, "IP");
|
|
|
+ LOG.info("用户 {} 在IP黑名单中命中 {}, 参数为: clientIP为: {}", uid, userType, clientIP);
|
|
|
+ return userType;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+
|
|
|
String userType = this.matchGeneralizationUserType(uid, cityCode, hotSceneType);
|
|
|
if (StringUtils.isNotBlank(userType)) {
|
|
|
this.filterLogUpload(uid, cityCode, hotSceneType, clientIP, userType, "RegionAndHotSceneType");
|
|
@@ -242,13 +247,15 @@ public class BlacklistContainer {
|
|
|
}
|
|
|
|
|
|
private String matchGeneralizationUserType(String uid, String cityCode, Long hotSceneType) {
|
|
|
- if (MapUtils.isNotEmpty(generalizationUserConditionConfig) && generalizationUserConditionConfig.containsKey(cityCode)) {
|
|
|
- GeneralizationUserConfig userConfig = generalizationUserConditionConfig.get(cityCode);
|
|
|
- if (CollectionUtils.isNotEmpty(userConfig.getExcludeHotSceneType())) {
|
|
|
- if (!userConfig.getExcludeHotSceneType().contains(hotSceneType)) {
|
|
|
- String userType = userConfig.getUserType() + USER_TYPE_SUB_TYPE_CONNECTOR + userConfig.getUserSubType();
|
|
|
- LOG.info("用户 {} 在泛化用户规则中命中: {}, 参数为: cityCode={}, hotSceneType={}", uid, userType, cityCode, hotSceneType);
|
|
|
- return userType;
|
|
|
+ if (StringUtils.isNotBlank(cityCode)) {
|
|
|
+ if (MapUtils.isNotEmpty(generalizationUserConditionConfig) && generalizationUserConditionConfig.containsKey(cityCode)) {
|
|
|
+ GeneralizationUserConfig userConfig = generalizationUserConditionConfig.get(cityCode);
|
|
|
+ if (CollectionUtils.isNotEmpty(userConfig.getExcludeHotSceneType())) {
|
|
|
+ if (!userConfig.getExcludeHotSceneType().contains(hotSceneType)) {
|
|
|
+ String userType = userConfig.getUserType() + USER_TYPE_SUB_TYPE_CONNECTOR + userConfig.getUserSubType();
|
|
|
+ LOG.info("用户 {} 在泛化用户规则中命中: {}, 参数为: cityCode={}, hotSceneType={}", uid, userType, cityCode, hotSceneType);
|
|
|
+ return userType;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|