|
@@ -1,5 +1,6 @@
|
|
|
package com.citu.module.menduner.reward.service;
|
|
|
|
|
|
+import com.citu.module.menduner.reward.controller.base.common.TreeRespVO;
|
|
|
import com.citu.module.menduner.reward.controller.base.event.EventTrackPointRespVO;
|
|
|
import com.citu.module.menduner.reward.controller.base.event.EventTrackUrlRespVO;
|
|
|
import com.citu.module.menduner.reward.convert.PointRuleConfigConvert;
|
|
@@ -8,12 +9,18 @@ import com.citu.module.menduner.reward.core.PointRuleFact;
|
|
|
import com.citu.module.menduner.reward.dal.dataobject.pointruleconfig.PointRuleConfigDO;
|
|
|
import com.citu.module.menduner.reward.rule.DynamicPointRule;
|
|
|
import com.citu.module.menduner.reward.rule.DynamicRuleAction;
|
|
|
+import com.citu.module.menduner.system.api.url.MendunerSystemUrlApi;
|
|
|
+import com.citu.module.menduner.system.api.url.UrlInfoRespVO;
|
|
|
import org.jeasy.rules.api.Facts;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Collections;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
import static com.citu.module.menduner.reward.enums.EasyRulesConstants.*;
|
|
|
|
|
@@ -30,6 +37,9 @@ public class EventTrackServiceImpl implements EventTrackService {
|
|
|
@Resource
|
|
|
private PointRuleConfigService ruleConfigService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private MendunerSystemUrlApi mendunerSystemUrlApi;
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
public List<EventTrackUrlRespVO> getEventTrackList() {
|
|
@@ -37,7 +47,6 @@ public class EventTrackServiceImpl implements EventTrackService {
|
|
|
return PointRuleConfigConvert.INSTANCE.convertList(list);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
@Override
|
|
|
public EventTrackPointRespVO click(Long id) {
|
|
|
PointRuleConfigDO config = ruleConfigService.get(id);
|
|
@@ -82,4 +91,43 @@ public class EventTrackServiceImpl implements EventTrackService {
|
|
|
|
|
|
return null;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<Object> getUrlList() {
|
|
|
+ List<UrlInfoRespVO> list = mendunerSystemUrlApi.list().getCheckedData();
|
|
|
+ return Collections.singletonList(convertUrlInfoListToTree(list));
|
|
|
+ }
|
|
|
+
|
|
|
+ public static List<TreeRespVO<List<TreeRespVO<List<UrlInfoRespVO>>>>> convertUrlInfoListToTree(List<UrlInfoRespVO> urlInfoList) {
|
|
|
+ // 首先按client分组,然后在每个client分组内部按module分组
|
|
|
+ Map<String, Map<String, List<UrlInfoRespVO>>> groupedByClientAndModule = urlInfoList.stream()
|
|
|
+ .collect(Collectors.groupingBy(
|
|
|
+ UrlInfoRespVO::getClient, // 先按client分组
|
|
|
+ Collectors.groupingBy(UrlInfoRespVO::getModule) // 再按module分组
|
|
|
+ ));
|
|
|
+
|
|
|
+ List<TreeRespVO<List<TreeRespVO<List<UrlInfoRespVO>>>>> tree = new ArrayList<>();
|
|
|
+ for (Map.Entry<String, Map<String, List<UrlInfoRespVO>>> clientEntry : groupedByClientAndModule.entrySet()) {
|
|
|
+ // 创建client节点
|
|
|
+ String clientName = clientEntry.getKey();
|
|
|
+ List<TreeRespVO<List<UrlInfoRespVO>>> modules = new ArrayList<>();
|
|
|
+
|
|
|
+ for (Map.Entry<String, List<UrlInfoRespVO>> moduleEntry : clientEntry.getValue().entrySet()) {
|
|
|
+ // 创建module节点
|
|
|
+ String moduleName = moduleEntry.getKey();
|
|
|
+ List<UrlInfoRespVO> urls = moduleEntry.getValue();
|
|
|
+ TreeRespVO<List<UrlInfoRespVO>> moduleTree = new TreeRespVO<>(moduleName, urls);
|
|
|
+
|
|
|
+ // 将module节点添加到client的children列表中
|
|
|
+ modules.add(moduleTree);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 创建client的TreeRespVO并添加到最终的树形列表中
|
|
|
+ TreeRespVO<List<TreeRespVO<List<UrlInfoRespVO>>>> clientTree = new TreeRespVO<>(clientName, modules);
|
|
|
+ tree.add(clientTree);
|
|
|
+ }
|
|
|
+
|
|
|
+ return tree;
|
|
|
+ }
|
|
|
+
|
|
|
}
|