重构评论
This commit is contained in:
@@ -83,7 +83,7 @@ public class JDUtil {
|
|||||||
private static final String ACCESS_TOKEN = "";
|
private static final String ACCESS_TOKEN = "";
|
||||||
private static final Logger logger = LoggerFactory.getLogger(JDUtil.class);
|
private static final Logger logger = LoggerFactory.getLogger(JDUtil.class);
|
||||||
private static final String INTERACTION_STATE_PREFIX = "interaction_state:";
|
private static final String INTERACTION_STATE_PREFIX = "interaction_state:";
|
||||||
private static final String PRODUCT_TYPE_MAP_PREFIX = "product_type_map" ;
|
private static final String PRODUCT_TYPE_MAP_PREFIX = "product_type_map";
|
||||||
private static HashMap<String, String> productTypeMap = new HashMap<>();
|
private static HashMap<String, String> productTypeMap = new HashMap<>();
|
||||||
private static final String COMMENT_TEMPLATES_DS = "我需要为我的商品模拟一些商品评论。你协助我生成3条评价内容,京东商品评价的风格,每条评价100字即可,不需要太浮夸,也不要太像ai生成,尽量模拟真实客户评价,不要提到以旧换新和国家补贴。我会为你提供其他真实用户的评论:";
|
private static final String COMMENT_TEMPLATES_DS = "我需要为我的商品模拟一些商品评论。你协助我生成3条评价内容,京东商品评价的风格,每条评价100字即可,不需要太浮夸,也不要太像ai生成,尽量模拟真实客户评价,不要提到以旧换新和国家补贴。我会为你提供其他真实用户的评论:";
|
||||||
private static final long TIMEOUT_MINUTES = 2;
|
private static final long TIMEOUT_MINUTES = 2;
|
||||||
@@ -1651,7 +1651,7 @@ public class JDUtil {
|
|||||||
state.setCurrentField("commentTypeSelection");
|
state.setCurrentField("commentTypeSelection");
|
||||||
// 提示用户选择评论类型
|
// 提示用户选择评论类型
|
||||||
getProductTypeMap();
|
getProductTypeMap();
|
||||||
if (productTypeMap == null){
|
if (productTypeMap == null) {
|
||||||
wxUtil.sendTextMessage(fromWxid, "productTypeMap 为空 ", 1, fromWxid, false);
|
wxUtil.sendTextMessage(fromWxid, "productTypeMap 为空 ", 1, fromWxid, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1679,10 +1679,19 @@ public class JDUtil {
|
|||||||
|
|
||||||
//getProductTypeMap 从redis中获取PRODUCT_TYPE_MAP_PREFIX
|
//getProductTypeMap 从redis中获取PRODUCT_TYPE_MAP_PREFIX
|
||||||
public void getProductTypeMap() {
|
public void getProductTypeMap() {
|
||||||
String json = redisTemplate.opsForValue().get(PRODUCT_TYPE_MAP_PREFIX);
|
Map<Object, Object> rawMap = redisTemplate.opsForHash().entries(PRODUCT_TYPE_MAP_PREFIX);
|
||||||
productTypeMap = JSON.parseObject(json, new TypeReference<Map<String, String>>() {
|
|
||||||
});
|
if (rawMap != null && !rawMap.isEmpty()) {
|
||||||
|
productTypeMap.clear();
|
||||||
|
for (Map.Entry<Object, Object> entry : rawMap.entrySet()) {
|
||||||
|
productTypeMap.put(entry.getKey().toString(), entry.getValue().toString());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logger.warn("Redis 中未找到键为 {} 的 Hash 数据", PRODUCT_TYPE_MAP_PREFIX);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理生成评论流程中的用户交互
|
* 处理生成评论流程中的用户交互
|
||||||
*/
|
*/
|
||||||
@@ -1695,7 +1704,7 @@ public class JDUtil {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
getProductTypeMap();
|
getProductTypeMap();
|
||||||
if (productTypeMap == null){
|
if (productTypeMap == null) {
|
||||||
wxUtil.sendTextMessage(fromWxid, "productTypeMap 为空 ", 1, fromWxid, false);
|
wxUtil.sendTextMessage(fromWxid, "productTypeMap 为空 ", 1, fromWxid, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1723,7 +1732,7 @@ public class JDUtil {
|
|||||||
|
|
||||||
// 获取产品ID
|
// 获取产品ID
|
||||||
getProductTypeMap();
|
getProductTypeMap();
|
||||||
if (productTypeMap == null){
|
if (productTypeMap == null) {
|
||||||
wxUtil.sendTextMessage(fromWxid, "productTypeMap 为空 ", 1, fromWxid, false);
|
wxUtil.sendTextMessage(fromWxid, "productTypeMap 为空 ", 1, fromWxid, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user