zhaohaipeng 2 часов назад
Родитель
Сommit
b610c0ff09

+ 1 - 0
recommend-feature-produce/src/main/java/com/tzld/piaoquan/recommend/feature/produce/model/DTSConfig.java

@@ -26,6 +26,7 @@ public class DTSConfig implements Serializable {
     public static class Redis implements Serializable {
         private String prefix;
         private List<String> key;
+        private List<String> value;
         private long expire;
     }
 

+ 9 - 1
recommend-feature-produce/src/main/java/com/tzld/piaoquan/recommend/feature/produce/service/RedisService.java

@@ -3,7 +3,6 @@ package com.tzld.piaoquan.recommend.feature.produce.service;
 import com.tzld.piaoquan.recommend.feature.produce.model.DTSConfig;
 import com.tzld.piaoquan.recommend.feature.produce.util.CompressionUtil;
 import com.tzld.piaoquan.recommend.feature.produce.util.JSONUtils;
-import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.collections.MapUtils;
 import org.apache.commons.lang3.RandomUtils;
@@ -46,6 +45,15 @@ public class RedisService implements Serializable {
         while (dataIte.hasNext()) {
             Map<String, String> record = dataIte.next();
             String redisKey = redisKey(record, config);
+
+            Map<String, String> valueMap = new HashMap<>();
+            if (CollectionUtils.isNotEmpty(config.getRedis().getValue())) {
+                for (String valueKey : config.getRedis().getValue()) {
+                    valueMap.put(valueKey, record.get(valueKey));
+                }
+                record = valueMap;
+            }
+
             String value = JSONUtils.toJson(record);
             if (RandomUtils.nextDouble() <= 0.001d) {
                 System.out.printf("redisKey: %s, value: %s%n", redisKey, value);