You've already forked FrameTour-BE
feat(wechat): 支持微信订阅消息模板渲染嵌套数据结构
- 实现renderValue方法支持递归渲染Map类型的值 - 添加对非字符串类型值的直接返回处理 - 在任务服务中根据分组配置动态设置视频结果页面变量 - 为分组启用场景添加travelVideoCenter页面配置 - 为非分组场景保留videoSynthesis页面配置
This commit is contained in:
@@ -244,12 +244,31 @@ public class WechatSubscribeNotifyTriggerService {
|
|||||||
if (StringUtils.isBlank(key)) {
|
if (StringUtils.isBlank(key)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
String rawValue = entry.getValue() != null ? entry.getValue().toString() : "";
|
dataParam.put(key, renderValue(entry.getValue(), variables));
|
||||||
dataParam.put(key, render(rawValue, variables));
|
|
||||||
}
|
}
|
||||||
return dataParam;
|
return dataParam;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
private static Object renderValue(Object value, Map<String, Object> variables) {
|
||||||
|
if (value == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
if (value instanceof String) {
|
||||||
|
return render((String) value, variables);
|
||||||
|
}
|
||||||
|
if (value instanceof Map) {
|
||||||
|
Map<String, Object> mapValue = (Map<String, Object>) value;
|
||||||
|
Map<String, Object> result = new HashMap<>();
|
||||||
|
for (Map.Entry<String, Object> entry : mapValue.entrySet()) {
|
||||||
|
result.put(entry.getKey(), renderValue(entry.getValue(), variables));
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
// 其他类型(数字、布尔等)直接返回
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
private static String renderOrDefault(String template, Map<String, Object> variables, String defaultValue) {
|
private static String renderOrDefault(String template, Map<String, Object> variables, String defaultValue) {
|
||||||
if (StringUtils.isBlank(template)) {
|
if (StringUtils.isBlank(template)) {
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
|
|||||||
@@ -641,6 +641,12 @@ public class TaskTaskServiceImpl implements TaskService {
|
|||||||
variables.put("scenicName", scenic.getName());
|
variables.put("scenicName", scenic.getName());
|
||||||
variables.put("faceId", item.getFaceId());
|
variables.put("faceId", item.getFaceId());
|
||||||
variables.put("videoId", item.getVideoId());
|
variables.put("videoId", item.getVideoId());
|
||||||
|
ScenicConfigManager configManager = scenicRepository.getScenicConfigManager(item.getScenicId());
|
||||||
|
if (configManager.getBoolean("grouping_enable", false)) {
|
||||||
|
variables.put("videoResultPage", "travelVideoCenter");
|
||||||
|
} else {
|
||||||
|
variables.put("videoResultPage", "videoSynthesis");
|
||||||
|
}
|
||||||
variables.put("videoDeviceCount", videoTaskRepository.getTaskDeviceNum(taskId));
|
variables.put("videoDeviceCount", videoTaskRepository.getTaskDeviceNum(taskId));
|
||||||
variables.put("videoLensCount", videoTaskRepository.getTaskLensNum(taskId));
|
variables.put("videoLensCount", videoTaskRepository.getTaskLensNum(taskId));
|
||||||
variables.put("videoShotTime", DateUtil.format(videoTaskRepository.getTaskShotDate(taskId), "yyyy-MM-dd HH:mm"));
|
variables.put("videoShotTime", DateUtil.format(videoTaskRepository.getTaskShotDate(taskId), "yyyy-MM-dd HH:mm"));
|
||||||
|
|||||||
Reference in New Issue
Block a user