|
@@ -47,7 +47,7 @@ public class BlacklistContainer {
|
|
|
|
|
|
private static final Logger LOG = LoggerFactory.getLogger(BlacklistContainer.class);
|
|
|
|
|
|
- public static final String USER_TYPE_SUB_TYPE_CONNECTOR = ":";
|
|
|
+ public static final String CONNECTOR_STR = ":";
|
|
|
|
|
|
private static final int USER_REDIS_KEY_PARTITION_COUNT = 10;
|
|
|
|
|
@@ -236,7 +236,7 @@ public class BlacklistContainer {
|
|
|
}
|
|
|
|
|
|
|
|
|
- String userType = this.matchGeneralizationUserType(uid, cityCode, hotSceneType);
|
|
|
+ String userType = this.matchGeneralizationUserType(uid, cityCode, hotSceneType, appType);
|
|
|
if (StringUtils.isNotBlank(userType)) {
|
|
|
this.filterLogUpload(uid, cityCode, hotSceneType, clientIP, userType, "RegionAndHotSceneType", mid, usedScene, appType);
|
|
|
}
|
|
@@ -244,21 +244,45 @@ public class BlacklistContainer {
|
|
|
} catch (
|
|
|
Exception e) {
|
|
|
LOG.error("blacklist filter isSafeVideoByUid error: ", e);
|
|
|
+
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- private String matchGeneralizationUserType(String uid, String cityCode, Long hotSceneType) {
|
|
|
- if (StringUtils.isNotBlank(cityCode) && Objects.nonNull(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;
|
|
|
- }
|
|
|
- }
|
|
|
+ private String matchGeneralizationUserType(String uid, String cityCode, Long hotSceneType, Integer appType) {
|
|
|
+ // 参数为空,则跳过
|
|
|
+ if (StringUtils.isBlank(cityCode) && Objects.isNull(appType)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ // 配置为空,则跳过
|
|
|
+ if (MapUtils.isEmpty(generalizationUserConditionConfig)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 优先找,城市+appType的配置
|
|
|
+ if (StringUtils.isNotBlank(cityCode) && Objects.nonNull(appType)) {
|
|
|
+ GeneralizationUserConfig userConfig = generalizationUserConditionConfig.get(cityCode + CONNECTOR_STR + appType);
|
|
|
+ if (Objects.nonNull(userConfig) && userConfig.isExcludeHotSceneType(hotSceneType)) {
|
|
|
+ LOG.info("用户 {} 在泛化用户规则中命中: {}, 参数为: appType = {}, cityCode={}, hotSceneType={}", uid, userConfig.fullUserType, appType, cityCode, hotSceneType);
|
|
|
+ return userConfig.getFullUserType();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 其次找,appType的配置
|
|
|
+ if (Objects.nonNull(appType)) {
|
|
|
+ GeneralizationUserConfig userConfig = generalizationUserConditionConfig.get(appType.toString());
|
|
|
+ if (Objects.nonNull(userConfig) && userConfig.isExcludeHotSceneType(hotSceneType)) {
|
|
|
+ LOG.info("用户 {} 在泛化用户规则中命中: {}, 参数为: appType={}, hotSceneType={}", uid, userConfig.fullUserType, appType, hotSceneType);
|
|
|
+ return userConfig.getFullUserType();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 最后找,城市的配置
|
|
|
+ if (StringUtils.isNotBlank(cityCode)) {
|
|
|
+ GeneralizationUserConfig userConfig = generalizationUserConditionConfig.get(cityCode);
|
|
|
+ if (Objects.nonNull(userConfig) && userConfig.isExcludeHotSceneType(hotSceneType)) {
|
|
|
+ LOG.info("用户 {} 在泛化用户规则中命中: {}, 参数为: cityCode={}, hotSceneType={}", uid, userConfig.fullUserType, cityCode, hotSceneType);
|
|
|
+ return userConfig.getFullUserType();
|
|
|
}
|
|
|
}
|
|
|
return null;
|
|
@@ -301,24 +325,35 @@ public class BlacklistContainer {
|
|
|
}
|
|
|
|
|
|
// 查看单APP配置的
|
|
|
- if (Objects.nonNull(appType)) {
|
|
|
- TagFilterConfig tagFilterConfig = tagFilterConfigMap.get(userType + USER_TYPE_SUB_TYPE_CONNECTOR + appType);
|
|
|
+ if (StringUtils.isNotBlank(userType) && Objects.nonNull(appType)) {
|
|
|
+ TagFilterConfig tagFilterConfig = tagFilterConfigMap.get(userType + CONNECTOR_STR + appType);
|
|
|
if (Objects.nonNull(tagFilterConfig)) {
|
|
|
+ LOG.info("命中过滤标签配置: {}", userType + CONNECTOR_STR + appType);
|
|
|
return tagFilterConfig.getRecommendExcludeTag();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ if (Objects.nonNull(appType)) {
|
|
|
+ TagFilterConfig tagFilterConfig = tagFilterConfigMap.get(appType.toString());
|
|
|
+ if (Objects.nonNull(tagFilterConfig)) {
|
|
|
+ LOG.info("命中过滤标签配置: {}", appType);
|
|
|
+ return tagFilterConfig.getRecommendExcludeTag();
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- TagFilterConfig tagFilterConfig = tagFilterConfigMap.get(userType);
|
|
|
- if (Objects.isNull(tagFilterConfig)) {
|
|
|
- return Collections.emptySet();
|
|
|
+ if (StringUtils.isNotBlank(userType)) {
|
|
|
+ TagFilterConfig tagFilterConfig = tagFilterConfigMap.get(userType);
|
|
|
+ if (Objects.nonNull(tagFilterConfig)) {
|
|
|
+ LOG.info("命中过滤标签配置: {}", userType);
|
|
|
+ return tagFilterConfig.getRecommendExcludeTag();
|
|
|
+ }
|
|
|
}
|
|
|
- return tagFilterConfig.getRecommendExcludeTag();
|
|
|
+ return null;
|
|
|
}
|
|
|
|
|
|
private void filterLogUpload(String uid, String cityCode, Long hotSceneType, String clientIp, String fullUserType, String blacklistType, String mid, String usedScene, Integer appType) {
|
|
|
try {
|
|
|
- String[] split = fullUserType.split(USER_TYPE_SUB_TYPE_CONNECTOR);
|
|
|
+ String[] split = fullUserType.split(CONNECTOR_STR);
|
|
|
Map<String, String> logMap = new HashMap<>();
|
|
|
logMap.put("uid", StringUtils.isNotBlank(uid) ? uid : "");
|
|
|
logMap.put("mid", StringUtils.isNotBlank(mid) ? mid : "");
|
|
@@ -355,6 +390,12 @@ public class BlacklistContainer {
|
|
|
Set<Long> excludeHotSceneType;
|
|
|
String userType;
|
|
|
String userSubType;
|
|
|
+ String fullUserType;
|
|
|
+
|
|
|
+ public boolean isExcludeHotSceneType(Long hotSceneType) {
|
|
|
+ return CollectionUtils.isEmpty(excludeHotSceneType)
|
|
|
+ || !excludeHotSceneType.contains(hotSceneType);
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|