|
@@ -1,5 +1,7 @@
|
|
|
package com.citu.module.menduner.reward.service.event;
|
|
|
|
|
|
+import com.citu.framework.security.core.LoginUser;
|
|
|
+import com.citu.module.menduner.common.util.LoginUserContext;
|
|
|
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;
|
|
@@ -41,6 +43,38 @@ public class EventTrackServiceImpl implements EventTrackService {
|
|
|
@Resource
|
|
|
private MendunerSystemUrlApi mendunerSystemUrlApi;
|
|
|
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public List<EventTrackUrlRespVO> getEventTrackList() {
|
|
|
List<PointRuleConfigDO> list = ruleConfigService.getList();
|
|
@@ -55,16 +89,17 @@ public class EventTrackServiceImpl implements EventTrackService {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- // redis 解析出当前操作用户的参数
|
|
|
-
|
|
|
- List<String> triggerKeyList = EasyRulesEngine.extractUniqueKeys(config.getConstraintRule());
|
|
|
+ // 解析出当前规则的参数
|
|
|
+ List<String> triggerKeyList = EasyRulesEngine.extractUniqueKeys(config.getTriggerRule());
|
|
|
|
|
|
// 读取对应数据
|
|
|
// 赋值到 context
|
|
|
|
|
|
+ // 用户信息
|
|
|
+ LoginUser loginUser = LoginUserContext.get2();
|
|
|
|
|
|
|
|
|
- PointRule pointRule= new PointRule();
|
|
|
+ PointRule pointRule = new PointRule();
|
|
|
// 基本信息
|
|
|
pointRule.setRuleId(String.valueOf(config.getId()));
|
|
|
pointRule.setRuleName(config.getUrl());
|
|
@@ -74,9 +109,9 @@ public class EventTrackServiceImpl implements EventTrackService {
|
|
|
|
|
|
// 构造参数
|
|
|
pointRule.setTriggerRule(EasyRulesEngine.buildWhenExpression(config.getTriggerRule()));
|
|
|
- pointRule.setLimitRule(EasyRulesEngine.buildThenExpression());
|
|
|
+ pointRule.setConstraintRule(EasyRulesEngine.buildThenExpression());
|
|
|
pointRule.setTriggerContext(null);
|
|
|
- pointRule.setLimitContext(null);
|
|
|
+ pointRule.setConstraintContext(null);
|
|
|
pointRule.setOperation(config.getOperation());
|
|
|
pointRule.setPoint(config.getPoint());
|
|
|
|
|
@@ -95,8 +130,8 @@ public class EventTrackServiceImpl implements EventTrackService {
|
|
|
|
|
|
// 调用
|
|
|
EasyRulesEngine.match(RuleMatch.builder()
|
|
|
- .facts(context)
|
|
|
- .ruleBase(pointRule)
|
|
|
+ .facts(context)
|
|
|
+ .ruleBase(pointRule)
|
|
|
.build());
|
|
|
|
|
|
return null;
|
|
@@ -108,36 +143,4 @@ public class EventTrackServiceImpl implements EventTrackService {
|
|
|
return 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;
|
|
|
- }
|
|
|
-
|
|
|
}
|