1.修改单词拼写错误
This commit is contained in:
parent
0a8964d69a
commit
bb12a1fe76
|
@ -9,7 +9,7 @@ import cn.hutool.json.JSONUtil;
|
|||
import com.example.liteflow.mysql.entity.BaseDataEntity;
|
||||
import com.example.liteflow.mysql.entity.BaseNodeEntity;
|
||||
import com.example.liteflow.mysql.model.BaseCenter;
|
||||
import com.example.liteflow.mysql.model.role.Role;
|
||||
import com.example.liteflow.mysql.model.rule.Rule;
|
||||
import com.example.liteflow.mysql.service.BaseDataService;
|
||||
import com.example.liteflow.mysql.service.BaseNodeService;
|
||||
import com.example.liteflow.mysql.util.ConditionParser;
|
||||
|
@ -52,8 +52,8 @@ public class CenterCmp extends NodeIfComponent {
|
|||
String nodeRole = baseNodeEntity.getNodeRole();
|
||||
String templateId = baseNodeEntity.getTemplateId();
|
||||
log.info("nodeRole = {}", nodeRole);
|
||||
List<Role> roles = JSONUtil.toList(JSONUtil.parseArray(nodeRole), Role.class);
|
||||
List<Map<String, Object>> collect = roles.stream().map(RoleUtil::parseRole).collect(Collectors.toList());
|
||||
List<Rule> rules = JSONUtil.toList(JSONUtil.parseArray(nodeRole), Rule.class);
|
||||
List<Map<String, Object>> collect = rules.stream().map(RoleUtil::parseRole).collect(Collectors.toList());
|
||||
String droolStr = JSONUtil.toJsonStr(collect);
|
||||
|
||||
// 替换规则中的关键字
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.example.liteflow.mysql.model.node;
|
||||
|
||||
import com.example.liteflow.mysql.model.OutputFrom;
|
||||
import com.example.liteflow.mysql.model.role.Role;
|
||||
import com.example.liteflow.mysql.model.rule.Rule;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -35,7 +35,7 @@ public class CreateNodeFrom {
|
|||
/**
|
||||
* 规则
|
||||
*/
|
||||
private List<Role> roles;
|
||||
private List<Rule> rules;
|
||||
/**
|
||||
* 节点对应输出节点id
|
||||
*/
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.example.liteflow.mysql.model.node;
|
||||
|
||||
import com.example.liteflow.mysql.model.OutputFrom;
|
||||
import com.example.liteflow.mysql.model.role.Role;
|
||||
import com.example.liteflow.mysql.model.rule.Rule;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -20,7 +20,7 @@ public class UpdateNodeFrom {
|
|||
/**
|
||||
* 规则
|
||||
*/
|
||||
private List<Role> roles;
|
||||
private List<Rule> rules;
|
||||
/**
|
||||
* 内容
|
||||
*/
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package com.example.liteflow.mysql.model.role;
|
||||
package com.example.liteflow.mysql.model.rule;
|
||||
|
||||
import lombok.Data;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.example.liteflow.mysql.model.role;
|
||||
package com.example.liteflow.mysql.model.rule;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
|
@ -9,7 +9,7 @@ import java.util.List;
|
|||
* @date: 2022年12月07日 16:04
|
||||
*/
|
||||
@Data
|
||||
public class Role {
|
||||
public class Rule {
|
||||
// 逻辑运算符"$or"
|
||||
private String logicOperators;
|
||||
// 条件运算符:"$eq"
|
||||
|
@ -18,6 +18,6 @@ public class Role {
|
|||
private String matchingValue;
|
||||
// 匹配内容
|
||||
private String matchingContent;
|
||||
private List<Role> children;
|
||||
private List<Rule> children;
|
||||
private List<Match> matches;
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package com.example.liteflow.mysql.model.role;
|
||||
package com.example.liteflow.mysql.model.rule;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
|
@ -9,7 +9,7 @@ import java.util.List;
|
|||
* @date: 2022年12月07日 10:41
|
||||
*/
|
||||
@Data
|
||||
public class RoleForm {
|
||||
public class RuleForm {
|
||||
private String roleName;
|
||||
private List<Role> roles;
|
||||
private List<Rule> rules;
|
||||
}
|
|
@ -18,7 +18,7 @@ import com.example.liteflow.mysql.model.OutputFrom;
|
|||
import com.example.liteflow.mysql.model.node.BaseNodeVO;
|
||||
import com.example.liteflow.mysql.model.node.CreateNodeFrom;
|
||||
import com.example.liteflow.mysql.model.node.UpdateNodeFrom;
|
||||
import com.example.liteflow.mysql.model.role.Role;
|
||||
import com.example.liteflow.mysql.model.rule.Rule;
|
||||
import com.example.liteflow.mysql.service.BaseNodeService;
|
||||
import com.example.liteflow.mysql.service.BaseTemplateService;
|
||||
import com.yomahub.liteflow.flow.FlowBus;
|
||||
|
@ -58,10 +58,10 @@ public class BaseNodeServiceImpl extends ServiceImpl<BaseNodeMapper, BaseNodeEnt
|
|||
}
|
||||
BaseNodeEntity baseNodeEntity = BeanUtil.toBean(createNodeFrom, BaseNodeEntity.class);
|
||||
baseNodeEntity.setNodeClass(nodeEnum.getNodeClass());
|
||||
List<Role> roles = createNodeFrom.getRoles();
|
||||
List<Rule> rules = createNodeFrom.getRules();
|
||||
OutputFrom content = createNodeFrom.getContent();
|
||||
if (CollUtil.isNotEmpty(roles) && NodeEnum.IfNode.getName().equals(nodeType)) {
|
||||
baseNodeEntity.setNodeRole(JSONUtil.toJsonStr(roles));
|
||||
if (CollUtil.isNotEmpty(rules) && NodeEnum.IfNode.getName().equals(nodeType)) {
|
||||
baseNodeEntity.setNodeRole(JSONUtil.toJsonStr(rules));
|
||||
} else if (ObjectUtil.isNotNull(content) && NodeEnum.CommonNode.getName().equals(nodeType)) {
|
||||
baseNodeEntity.setNodeContent(JSONUtil.toJsonStr(content));
|
||||
} else {
|
||||
|
@ -77,8 +77,8 @@ public class BaseNodeServiceImpl extends ServiceImpl<BaseNodeMapper, BaseNodeEnt
|
|||
String id = updateNodeFrom.getId();
|
||||
String nodeContentId = updateNodeFrom.getNodeContentId();
|
||||
Integer enableMark = updateNodeFrom.getEnableMark();
|
||||
List<Role> roles = updateNodeFrom.getRoles();
|
||||
String roleStr = ObjectUtil.isNotNull(roles) ? JSONUtil.toJsonStr(roles) : "";
|
||||
List<Rule> rules = updateNodeFrom.getRules();
|
||||
String roleStr = ObjectUtil.isNotNull(rules) ? JSONUtil.toJsonStr(rules) : "";
|
||||
OutputFrom content = updateNodeFrom.getContent();
|
||||
String contentStr = ObjectUtil.isNotNull(content) ? JSONUtil.toJsonStr(content) : "";
|
||||
LambdaUpdateWrapper<BaseNodeEntity> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package com.example.liteflow.mysql.util;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.example.liteflow.mysql.model.role.Match;
|
||||
import com.example.liteflow.mysql.model.role.Role;
|
||||
import com.example.liteflow.mysql.model.rule.Match;
|
||||
import com.example.liteflow.mysql.model.rule.Rule;
|
||||
import org.assertj.core.util.Lists;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
@ -15,13 +15,13 @@ import java.util.stream.Collectors;
|
|||
* @date: 2022年12月08日 15:37
|
||||
*/
|
||||
public class RoleUtil {
|
||||
public static Map<String, Object> parseRole(Role role) {
|
||||
List<Match> matchList = role.getMatches();
|
||||
List<Role> roleChildren = role.getChildren();
|
||||
String logicOperators = role.getLogicOperators();
|
||||
if (CollUtil.isNotEmpty(roleChildren)) {
|
||||
List<Map<String,Object>> collect = roleChildren.stream().map(child -> {
|
||||
List<Role> sunList = child.getChildren();
|
||||
public static Map<String, Object> parseRole(Rule rule) {
|
||||
List<Match> matchList = rule.getMatches();
|
||||
List<Rule> ruleChildren = rule.getChildren();
|
||||
String logicOperators = rule.getLogicOperators();
|
||||
if (CollUtil.isNotEmpty(ruleChildren)) {
|
||||
List<Map<String,Object>> collect = ruleChildren.stream().map(child -> {
|
||||
List<Rule> sunList = child.getChildren();
|
||||
if (CollUtil.isNotEmpty(sunList)) {
|
||||
List<Map<String, Object>> sunCollect = sunList.stream().map(RoleUtil::parseRole).collect(Collectors.toList());
|
||||
String childLogicOperators = child.getLogicOperators();
|
||||
|
@ -62,9 +62,9 @@ public class RoleUtil {
|
|||
childMap.put(logicOperators, list);
|
||||
return childMap;
|
||||
} else {
|
||||
String matchingValue = role.getMatchingValue();
|
||||
String matchingContent = role.getMatchingContent();
|
||||
String conditionalOperators = role.getConditionalOperators();
|
||||
String matchingValue = rule.getMatchingValue();
|
||||
String matchingContent = rule.getMatchingContent();
|
||||
String conditionalOperators = rule.getConditionalOperators();
|
||||
List<String> itemList = Lists.newArrayList(matchingValue, matchingContent);
|
||||
Map<String, Object> itemMap = new HashMap<>();
|
||||
itemMap.put(conditionalOperators, itemList);
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
"nodeName": "costCenter01Cmp",
|
||||
"nodeType": "IfNode",
|
||||
"nodeContentId": "2480deadc736b40435a2b6930851aaa5",
|
||||
"roles": [
|
||||
"rules": [
|
||||
{
|
||||
"logicOperators": "$or",
|
||||
"children": [
|
||||
|
@ -70,7 +70,7 @@
|
|||
"nodeName": "costCenter02Cmp",
|
||||
"nodeType": "IfNode",
|
||||
"nodeContentId": "0264efebbfb4c7cb5e4cb81092e1bce4",
|
||||
"roles": [
|
||||
"rules": [
|
||||
{
|
||||
"logicOperators": "$or",
|
||||
"children": [
|
||||
|
@ -140,7 +140,7 @@
|
|||
"nodeName": "profitCenter01Cmp",
|
||||
"nodeType": "IfNode",
|
||||
"nodeContentId": "1a1df8cbdc9983fa03b3060049293b87",
|
||||
"roles": [
|
||||
"rules": [
|
||||
{
|
||||
"logicOperators": "$or",
|
||||
"children": [
|
||||
|
@ -196,7 +196,7 @@
|
|||
"nodeName": "profitCenter02Cmp",
|
||||
"nodeType": "IfNode",
|
||||
"nodeContentId": "f050bd67f23cd0152f17d4f82d29b8a4",
|
||||
"roles": [
|
||||
"rules": [
|
||||
{
|
||||
"logicOperators": "$or",
|
||||
"children": [
|
||||
|
|
|
@ -4,16 +4,12 @@ import cn.hutool.json.JSONUtil;
|
|||
import com.example.liteflow.mysql.enums.MathOperatorEnum;
|
||||
import com.example.liteflow.mysql.enums.NodeEnum;
|
||||
import com.example.liteflow.mysql.model.node.CreateNodeFrom;
|
||||
import com.example.liteflow.mysql.model.role.Match;
|
||||
import com.example.liteflow.mysql.model.role.Role;
|
||||
import com.example.liteflow.mysql.model.role.RoleForm;
|
||||
import com.yomahub.liteflow.flow.FlowBus;
|
||||
import com.yomahub.liteflow.flow.element.Node;
|
||||
import com.example.liteflow.mysql.model.rule.Match;
|
||||
import com.example.liteflow.mysql.model.rule.Rule;
|
||||
import com.example.liteflow.mysql.model.rule.RuleForm;
|
||||
import org.assertj.core.util.Lists;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
@ -30,13 +26,13 @@ public class MyTest {
|
|||
|
||||
@Test
|
||||
public void test01() {
|
||||
List<Role> roles = new ArrayList<>();
|
||||
Role role = new Role();
|
||||
role.setLogicOperators(MathOperatorEnum.or.getOperator());
|
||||
List<Rule> rules = new ArrayList<>();
|
||||
Rule rule = new Rule();
|
||||
rule.setLogicOperators(MathOperatorEnum.or.getOperator());
|
||||
|
||||
List<Role> children = new ArrayList<>();
|
||||
Role childRole = new Role();
|
||||
childRole.setLogicOperators(MathOperatorEnum.and.getOperator());
|
||||
List<Rule> children = new ArrayList<>();
|
||||
Rule childRule = new Rule();
|
||||
childRule.setLogicOperators(MathOperatorEnum.and.getOperator());
|
||||
|
||||
List<Match> matches = new ArrayList<>();
|
||||
Match match = new Match();
|
||||
|
@ -50,31 +46,31 @@ public class MyTest {
|
|||
match.setMatchingContent("1");
|
||||
matches.add(match);
|
||||
|
||||
childRole.setMatches(matches);
|
||||
children.add(childRole);
|
||||
role.setChildren(children);
|
||||
roles.add(role);
|
||||
System.out.println(JSONUtil.toJsonStr(roles));
|
||||
childRule.setMatches(matches);
|
||||
children.add(childRule);
|
||||
rule.setChildren(children);
|
||||
rules.add(rule);
|
||||
System.out.println(JSONUtil.toJsonStr(rules));
|
||||
|
||||
List<? extends Map<String, ?>> collect = roles.stream().map(this::parseRole).collect(Collectors.toList());
|
||||
List<? extends Map<String, ?>> collect = rules.stream().map(this::parseRole).collect(Collectors.toList());
|
||||
System.out.println(JSONUtil.toJsonStr(collect));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test02() {
|
||||
List<Role> roles = new ArrayList<>();
|
||||
Role role = new Role();
|
||||
role.setLogicOperators(MathOperatorEnum.or.getOperator());
|
||||
List<Rule> rules = new ArrayList<>();
|
||||
Rule rule = new Rule();
|
||||
rule.setLogicOperators(MathOperatorEnum.or.getOperator());
|
||||
|
||||
Role child = new Role();
|
||||
Rule child = new Rule();
|
||||
child.setLogicOperators(MathOperatorEnum.or.getOperator());
|
||||
|
||||
Role sun = new Role();
|
||||
Rule sun = new Rule();
|
||||
sun.setLogicOperators(MathOperatorEnum.or.getOperator());
|
||||
|
||||
|
||||
List<Role> sunList = new ArrayList<>();
|
||||
List<Rule> sunList = new ArrayList<>();
|
||||
|
||||
List<Match> matches = new ArrayList<>();
|
||||
Match match = new Match();
|
||||
|
@ -92,12 +88,12 @@ public class MyTest {
|
|||
sunList.add(sun);
|
||||
child.setChildren(sunList);
|
||||
|
||||
List<Role> children = Lists.newArrayList(child);
|
||||
role.setChildren(children);
|
||||
roles.add(role);
|
||||
System.out.println(JSONUtil.toJsonStr(roles));
|
||||
List<Rule> children = Lists.newArrayList(child);
|
||||
rule.setChildren(children);
|
||||
rules.add(rule);
|
||||
System.out.println(JSONUtil.toJsonStr(rules));
|
||||
|
||||
List<? extends Map<String, ?>> collect = roles.stream().map(this::parseRole).collect(Collectors.toList());
|
||||
List<? extends Map<String, ?>> collect = rules.stream().map(this::parseRole).collect(Collectors.toList());
|
||||
System.out.println(JSONUtil.toJsonStr(collect));
|
||||
|
||||
}
|
||||
|
@ -105,8 +101,8 @@ public class MyTest {
|
|||
@Test
|
||||
public void test3() {
|
||||
|
||||
Role role = new Role();
|
||||
role.setLogicOperators(MathOperatorEnum.or.getOperator());
|
||||
Rule rule = new Rule();
|
||||
rule.setLogicOperators(MathOperatorEnum.or.getOperator());
|
||||
|
||||
List<Match> matches = new ArrayList<>();
|
||||
Match match = new Match();
|
||||
|
@ -115,17 +111,17 @@ public class MyTest {
|
|||
match.setMatchingContent("1");
|
||||
matches.add(match);
|
||||
|
||||
role.setMatches(matches);
|
||||
List<Role> roles = Lists.newArrayList(role);
|
||||
System.out.println(JSONUtil.toJsonStr(roles));
|
||||
List<? extends Map<String, ?>> collect = roles.stream().map(this::parseRole).collect(Collectors.toList());
|
||||
rule.setMatches(matches);
|
||||
List<Rule> rules = Lists.newArrayList(rule);
|
||||
System.out.println(JSONUtil.toJsonStr(rules));
|
||||
List<? extends Map<String, ?>> collect = rules.stream().map(this::parseRole).collect(Collectors.toList());
|
||||
System.out.println(JSONUtil.toJsonStr(collect));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test4() {
|
||||
Role role = new Role();
|
||||
role.setLogicOperators(MathOperatorEnum.or.getOperator());
|
||||
Rule rule = new Rule();
|
||||
rule.setLogicOperators(MathOperatorEnum.or.getOperator());
|
||||
|
||||
List<Match> matches = new ArrayList<>();
|
||||
Match match = new Match();
|
||||
|
@ -140,34 +136,34 @@ public class MyTest {
|
|||
match.setMatchingContent("2");
|
||||
matches.add(match);
|
||||
|
||||
role.setMatches(matches);
|
||||
List<Role> roles = Lists.newArrayList(role);
|
||||
System.out.println(JSONUtil.toJsonStr(roles));
|
||||
List<? extends Map<String, ?>> collect = roles.stream().map(this::parseRole).collect(Collectors.toList());
|
||||
rule.setMatches(matches);
|
||||
List<Rule> rules = Lists.newArrayList(rule);
|
||||
System.out.println(JSONUtil.toJsonStr(rules));
|
||||
List<? extends Map<String, ?>> collect = rules.stream().map(this::parseRole).collect(Collectors.toList());
|
||||
System.out.println(JSONUtil.toJsonStr(collect));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test5() {
|
||||
Role role = new Role();
|
||||
role.setLogicOperators(MathOperatorEnum.or.getOperator());
|
||||
Rule rule = new Rule();
|
||||
rule.setLogicOperators(MathOperatorEnum.or.getOperator());
|
||||
|
||||
role.setConditionalOperators(MathOperatorEnum.eq.getOperator());
|
||||
role.setMatchingValue("1");
|
||||
role.setMatchingContent("1");
|
||||
rule.setConditionalOperators(MathOperatorEnum.eq.getOperator());
|
||||
rule.setMatchingValue("1");
|
||||
rule.setMatchingContent("1");
|
||||
|
||||
List<Role> roles = Lists.newArrayList(role);
|
||||
System.out.println(JSONUtil.toJsonStr(roles));
|
||||
List<? extends Map<String, ?>> collect = roles.stream().map(this::parseRole).collect(Collectors.toList());
|
||||
List<Rule> rules = Lists.newArrayList(rule);
|
||||
System.out.println(JSONUtil.toJsonStr(rules));
|
||||
List<? extends Map<String, ?>> collect = rules.stream().map(this::parseRole).collect(Collectors.toList());
|
||||
System.out.println(JSONUtil.toJsonStr(collect));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test6() {
|
||||
Role role = new Role();
|
||||
role.setLogicOperators(MathOperatorEnum.or.getOperator());
|
||||
Rule rule = new Rule();
|
||||
rule.setLogicOperators(MathOperatorEnum.or.getOperator());
|
||||
|
||||
Role child = new Role();
|
||||
Rule child = new Rule();
|
||||
child.setLogicOperators(MathOperatorEnum.and.getOperator());
|
||||
List<Match> matches = new ArrayList<>();
|
||||
Match match = new Match();
|
||||
|
@ -183,13 +179,13 @@ public class MyTest {
|
|||
matches.add(match);
|
||||
|
||||
child.setMatches(matches);
|
||||
List<Role> children = Lists.newArrayList(child);
|
||||
role.setChildren(children);
|
||||
List<Rule> children = Lists.newArrayList(child);
|
||||
rule.setChildren(children);
|
||||
|
||||
Role role2 = new Role();
|
||||
role2.setLogicOperators(MathOperatorEnum.or.getOperator());
|
||||
Rule rule2 = new Rule();
|
||||
rule2.setLogicOperators(MathOperatorEnum.or.getOperator());
|
||||
|
||||
Role child2 = new Role();
|
||||
Rule child2 = new Rule();
|
||||
child2.setLogicOperators(MathOperatorEnum.and.getOperator());
|
||||
List<Match> matches2 = new ArrayList<>();
|
||||
Match match2 = new Match();
|
||||
|
@ -205,22 +201,22 @@ public class MyTest {
|
|||
matches2.add(match2);
|
||||
|
||||
child2.setMatches(matches2);
|
||||
List<Role> children2 = Lists.newArrayList(child2);
|
||||
role2.setChildren(children2);
|
||||
List<Rule> children2 = Lists.newArrayList(child2);
|
||||
rule2.setChildren(children2);
|
||||
|
||||
List<Role> roles = Lists.newArrayList(role, role2);
|
||||
System.out.println(JSONUtil.toJsonStr(roles));
|
||||
List<? extends Map<String, ?>> collect = roles.stream().map(this::parseRole).collect(Collectors.toList());
|
||||
List<Rule> rules = Lists.newArrayList(rule, rule2);
|
||||
System.out.println(JSONUtil.toJsonStr(rules));
|
||||
List<? extends Map<String, ?>> collect = rules.stream().map(this::parseRole).collect(Collectors.toList());
|
||||
System.out.println(JSONUtil.toJsonStr(collect));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void test7() {
|
||||
Role role = new Role();
|
||||
role.setLogicOperators(MathOperatorEnum.or.getOperator());
|
||||
Rule rule = new Rule();
|
||||
rule.setLogicOperators(MathOperatorEnum.or.getOperator());
|
||||
|
||||
Role child = new Role();
|
||||
Rule child = new Rule();
|
||||
child.setLogicOperators(MathOperatorEnum.and.getOperator());
|
||||
List<Match> matches = new ArrayList<>();
|
||||
Match match = new Match();
|
||||
|
@ -248,13 +244,13 @@ public class MyTest {
|
|||
matches.add(match);
|
||||
|
||||
child.setMatches(matches);
|
||||
List<Role> children = Lists.newArrayList(child);
|
||||
role.setChildren(children);
|
||||
List<Rule> children = Lists.newArrayList(child);
|
||||
rule.setChildren(children);
|
||||
|
||||
List<Role> roles = Lists.newArrayList(role);
|
||||
RoleForm roleForm = new RoleForm();
|
||||
roleForm.setRoles(roles);
|
||||
roleForm.setRoleName("costCenter01Cmp");
|
||||
List<Rule> rules = Lists.newArrayList(rule);
|
||||
RuleForm ruleForm = new RuleForm();
|
||||
ruleForm.setRules(rules);
|
||||
ruleForm.setRoleName("costCenter01Cmp");
|
||||
// baseRoleService.createRole(roleForm);
|
||||
// System.out.println(JSONUtil.toJsonStr(roles));
|
||||
// List<? extends Map<String, ?>> collect = roles.stream().map(this::parseRole).collect(Collectors.toList());
|
||||
|
@ -263,13 +259,13 @@ public class MyTest {
|
|||
|
||||
@Test
|
||||
public void test8() {
|
||||
Role role = new Role();
|
||||
role.setLogicOperators(MathOperatorEnum.or.getOperator());
|
||||
Rule rule = new Rule();
|
||||
rule.setLogicOperators(MathOperatorEnum.or.getOperator());
|
||||
|
||||
Role child = new Role();
|
||||
Rule child = new Rule();
|
||||
child.setLogicOperators(MathOperatorEnum.or.getOperator());
|
||||
|
||||
Role sun = new Role();
|
||||
Rule sun = new Rule();
|
||||
sun.setLogicOperators(MathOperatorEnum.and.getOperator());
|
||||
List<Match> matches = new ArrayList<>();
|
||||
Match match = new Match();
|
||||
|
@ -285,10 +281,10 @@ public class MyTest {
|
|||
matches.add(match);
|
||||
|
||||
sun.setMatches(matches);
|
||||
List<Role> sunList = Lists.newArrayList(sun);
|
||||
List<Rule> sunList = Lists.newArrayList(sun);
|
||||
child.setChildren(sunList);
|
||||
List<Role> children = Lists.newArrayList(child);
|
||||
role.setChildren(children);
|
||||
List<Rule> children = Lists.newArrayList(child);
|
||||
rule.setChildren(children);
|
||||
|
||||
|
||||
List<Match> matches2 = new ArrayList<>();
|
||||
|
@ -297,26 +293,26 @@ public class MyTest {
|
|||
match2.setMatchingValue("businessType");
|
||||
match2.setMatchingContent("businessTypeList");
|
||||
matches2.add(match2);
|
||||
Role role2 = new Role();
|
||||
role2.setLogicOperators(MathOperatorEnum.or.getOperator());
|
||||
role2.setMatches(matches2);
|
||||
Rule rule2 = new Rule();
|
||||
rule2.setLogicOperators(MathOperatorEnum.or.getOperator());
|
||||
rule2.setMatches(matches2);
|
||||
|
||||
List<Role> roles = Lists.newArrayList(role, role2);
|
||||
RoleForm roleForm = new RoleForm();
|
||||
roleForm.setRoles(roles);
|
||||
roleForm.setRoleName("costCenter02Cmp");
|
||||
List<Rule> rules = Lists.newArrayList(rule, rule2);
|
||||
RuleForm ruleForm = new RuleForm();
|
||||
ruleForm.setRules(rules);
|
||||
ruleForm.setRoleName("costCenter02Cmp");
|
||||
// baseRoleService.createRole(roleForm);
|
||||
System.out.println(JSONUtil.toJsonStr(roles));
|
||||
List<? extends Map<String, ?>> collect = roles.stream().map(this::parseRole).collect(Collectors.toList());
|
||||
System.out.println(JSONUtil.toJsonStr(rules));
|
||||
List<? extends Map<String, ?>> collect = rules.stream().map(this::parseRole).collect(Collectors.toList());
|
||||
System.out.println(JSONUtil.toJsonStr(collect));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test09() {
|
||||
Role role = new Role();
|
||||
role.setLogicOperators(MathOperatorEnum.or.getOperator());
|
||||
Rule rule = new Rule();
|
||||
rule.setLogicOperators(MathOperatorEnum.or.getOperator());
|
||||
|
||||
Role child = new Role();
|
||||
Rule child = new Rule();
|
||||
child.setLogicOperators(MathOperatorEnum.and.getOperator());
|
||||
|
||||
List<Match> matches = new ArrayList<>();
|
||||
|
@ -339,12 +335,12 @@ public class MyTest {
|
|||
matches.add(match);
|
||||
|
||||
child.setMatches(matches);
|
||||
List<Role> children = Lists.newArrayList(child);
|
||||
role.setChildren(children);
|
||||
List<Rule> children = Lists.newArrayList(child);
|
||||
rule.setChildren(children);
|
||||
|
||||
Role role2 = new Role();
|
||||
role2.setLogicOperators(MathOperatorEnum.or.getOperator());
|
||||
Role child2 = new Role();
|
||||
Rule rule2 = new Rule();
|
||||
rule2.setLogicOperators(MathOperatorEnum.or.getOperator());
|
||||
Rule child2 = new Rule();
|
||||
child2.setLogicOperators(MathOperatorEnum.and.getOperator());
|
||||
List<Match> matches2 = new ArrayList<>();
|
||||
Match match2 = new Match();
|
||||
|
@ -359,25 +355,25 @@ public class MyTest {
|
|||
match2.setMatchingContent("businessTypeList");
|
||||
matches2.add(match2);
|
||||
child2.setMatches(matches2);
|
||||
List<Role> children2 = Lists.newArrayList(child2);
|
||||
role2.setChildren(children2);
|
||||
List<Rule> children2 = Lists.newArrayList(child2);
|
||||
rule2.setChildren(children2);
|
||||
|
||||
List<Role> roles = Lists.newArrayList(role, role2);
|
||||
RoleForm roleForm = new RoleForm();
|
||||
roleForm.setRoles(roles);
|
||||
roleForm.setRoleName("profitCenter01Cmp");
|
||||
List<Rule> rules = Lists.newArrayList(rule, rule2);
|
||||
RuleForm ruleForm = new RuleForm();
|
||||
ruleForm.setRules(rules);
|
||||
ruleForm.setRoleName("profitCenter01Cmp");
|
||||
// baseRoleService.createRole(roleForm);
|
||||
System.out.println(JSONUtil.toJsonStr(roles));
|
||||
List<? extends Map<String, ?>> collect = roles.stream().map(this::parseRole).collect(Collectors.toList());
|
||||
System.out.println(JSONUtil.toJsonStr(rules));
|
||||
List<? extends Map<String, ?>> collect = rules.stream().map(this::parseRole).collect(Collectors.toList());
|
||||
System.out.println(JSONUtil.toJsonStr(collect));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test10() {
|
||||
Role role = new Role();
|
||||
role.setLogicOperators(MathOperatorEnum.or.getOperator());
|
||||
Rule rule = new Rule();
|
||||
rule.setLogicOperators(MathOperatorEnum.or.getOperator());
|
||||
|
||||
Role child = new Role();
|
||||
Rule child = new Rule();
|
||||
child.setLogicOperators(MathOperatorEnum.and.getOperator());
|
||||
|
||||
List<Match> matches = new ArrayList<>();
|
||||
|
@ -394,12 +390,12 @@ public class MyTest {
|
|||
matches.add(match);
|
||||
|
||||
child.setMatches(matches);
|
||||
List<Role> children = Lists.newArrayList(child);
|
||||
role.setChildren(children);
|
||||
List<Rule> children = Lists.newArrayList(child);
|
||||
rule.setChildren(children);
|
||||
|
||||
Role role2 = new Role();
|
||||
role2.setLogicOperators(MathOperatorEnum.or.getOperator());
|
||||
Role child2 = new Role();
|
||||
Rule rule2 = new Rule();
|
||||
rule2.setLogicOperators(MathOperatorEnum.or.getOperator());
|
||||
Rule child2 = new Rule();
|
||||
child2.setLogicOperators(MathOperatorEnum.and.getOperator());
|
||||
List<Match> matches2 = new ArrayList<>();
|
||||
Match match2 = new Match();
|
||||
|
@ -414,25 +410,25 @@ public class MyTest {
|
|||
match2.setMatchingContent("businessTypeList");
|
||||
matches2.add(match2);
|
||||
child2.setMatches(matches2);
|
||||
List<Role> children2 = Lists.newArrayList(child2);
|
||||
role2.setChildren(children2);
|
||||
List<Rule> children2 = Lists.newArrayList(child2);
|
||||
rule2.setChildren(children2);
|
||||
|
||||
List<Role> roles = Lists.newArrayList(role, role2);
|
||||
RoleForm roleForm = new RoleForm();
|
||||
roleForm.setRoles(roles);
|
||||
roleForm.setRoleName("profitCenter02Cmp");
|
||||
List<Rule> rules = Lists.newArrayList(rule, rule2);
|
||||
RuleForm ruleForm = new RuleForm();
|
||||
ruleForm.setRules(rules);
|
||||
ruleForm.setRoleName("profitCenter02Cmp");
|
||||
// baseRoleService.createRole(roleForm);
|
||||
System.out.println(JSONUtil.toJsonStr(roles));
|
||||
List<? extends Map<String, ?>> collect = roles.stream().map(this::parseRole).collect(Collectors.toList());
|
||||
System.out.println(JSONUtil.toJsonStr(rules));
|
||||
List<? extends Map<String, ?>> collect = rules.stream().map(this::parseRole).collect(Collectors.toList());
|
||||
System.out.println(JSONUtil.toJsonStr(collect));
|
||||
}
|
||||
private Map<String, Object> parseRole(Role role) {
|
||||
List<Match> matchList = role.getMatches();
|
||||
List<Role> roleChildren = role.getChildren();
|
||||
String logicOperators = role.getLogicOperators();
|
||||
if (CollUtil.isNotEmpty(roleChildren)) {
|
||||
List<Map<String,Object>> collect = roleChildren.stream().map(child -> {
|
||||
List<Role> sunList = child.getChildren();
|
||||
private Map<String, Object> parseRole(Rule rule) {
|
||||
List<Match> matchList = rule.getMatches();
|
||||
List<Rule> ruleChildren = rule.getChildren();
|
||||
String logicOperators = rule.getLogicOperators();
|
||||
if (CollUtil.isNotEmpty(ruleChildren)) {
|
||||
List<Map<String,Object>> collect = ruleChildren.stream().map(child -> {
|
||||
List<Rule> sunList = child.getChildren();
|
||||
if (CollUtil.isNotEmpty(sunList)) {
|
||||
List<Map<String, Object>> sunCollect = sunList.stream().map(this::parseRole).collect(Collectors.toList());
|
||||
String childLogicOperators = child.getLogicOperators();
|
||||
|
@ -473,9 +469,9 @@ public class MyTest {
|
|||
childMap.put(logicOperators, list);
|
||||
return childMap;
|
||||
} else {
|
||||
String matchingValue = role.getMatchingValue();
|
||||
String matchingContent = role.getMatchingContent();
|
||||
String conditionalOperators = role.getConditionalOperators();
|
||||
String matchingValue = rule.getMatchingValue();
|
||||
String matchingContent = rule.getMatchingContent();
|
||||
String conditionalOperators = rule.getConditionalOperators();
|
||||
List<String> itemList = Lists.newArrayList(matchingValue, matchingContent);
|
||||
Map<String, Object> itemMap = new HashMap<>();
|
||||
itemMap.put(conditionalOperators, itemList);
|
||||
|
@ -503,5 +499,8 @@ public class MyTest {
|
|||
createNodeFrom.setNodeName("costCenter01Cmp");
|
||||
createNodeFrom.setNodeType(NodeEnum.IfNode.getName());
|
||||
System.out.println(JSONUtil.toJsonStr(createNodeFrom));
|
||||
|
||||
String str = "2";
|
||||
System.out.println(str.equals(null));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue