提交 0bdc9fc8 authored 作者: 马晨俊's avatar 马晨俊

mcj:规则类中加上技术名称

上级 012417c5
......@@ -29,7 +29,10 @@ public class Rule {
@Id
@Column(length = 48)
private String id;
/**
* 建议
*/
private String technologyName;
/**
* 目标关键字
*/
......
......@@ -13,16 +13,24 @@ import java.util.List;
public class RuleVo {
private String id;
/**
* 目标关键字
*/
private String target;
/**
* 匹配的文件后缀
*/
private String suffix;
/**
* 建议
*/
private String technologyId;
/**
* 建议
*/
private String technologyName;
}
......@@ -500,6 +500,7 @@ public class Inspector {
warn.setRuleId(rule.getId());
warn.setRule(rule.getTarget());
warn.setTechnologyId(rule.getTechnologyId());
warn.setTechnologyName(technologyHashMap.get(rule.getTechnologyId()).getTechnologyName());
if (technologyHashMap.get(rule.getTechnologyId()).getSupport() == 2) {
warns.add(warn);
//设置a=0代表当前依赖有问题
......
......@@ -25,6 +25,7 @@ import java.util.Map;
/**
* 规则库
*
* @author Mcj
* @date 2020-02-26 15:05
*/
......@@ -41,6 +42,7 @@ public class RuleServiceImpl implements RuleService {
/**
* 新增规则
*
* @param ruleQo 规则封装类
*/
@Override
......@@ -53,20 +55,25 @@ public class RuleServiceImpl implements RuleService {
rule.setId(UUIDUtil.getUUID());
ruleDao.save(rule);
}
/**
* 条件查询+分页
* @param whereMap
* @param page
* @param size
* @return
*/
/**
* 条件查询+分页
*
* @param whereMap
* @param page
* @param size
* @return
*/
@Override
public Page<Rule> findSearch(Map whereMap, int page, int size) {
Specification<Rule> specification = createSpecification(whereMap);
PageRequest pageRequest = PageRequest.of(page-1, size);
PageRequest pageRequest = PageRequest.of(page - 1, size);
return ruleDao.findAll(specification, pageRequest);
}
/**
* 动态条件构建
*
* @param searchMap
* @return
*/
......@@ -77,10 +84,10 @@ public class RuleServiceImpl implements RuleService {
@Override
public Predicate toPredicate(Root<Rule> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
List<Predicate> predicateList = new ArrayList<Predicate>();
if(searchMap.get("target")!=null && !"".equals(searchMap.get("target"))){
predicateList.add(cb.like(root.get("target").as(String.class),"%"+(String)searchMap.get("target")+"%"));
if (searchMap.get("target") != null && !"".equals(searchMap.get("target"))) {
predicateList.add(cb.like(root.get("target").as(String.class), "%" + (String) searchMap.get("target") + "%"));
}
return cb.and( predicateList.toArray(new Predicate[predicateList.size()]));
return cb.and(predicateList.toArray(new Predicate[predicateList.size()]));
}
};
......@@ -110,6 +117,7 @@ public class RuleServiceImpl implements RuleService {
/**
* 查询所有规则
*
* @return RuleVoList
*/
@Override
......@@ -120,7 +128,7 @@ public class RuleServiceImpl implements RuleService {
@Override
public List<Rule> findByName(String name) {
List<Rule> rules = ruleDao.findAllByTargetLike("%" + name + "%");
if(rules!=null&&rules.size()>0){
if (rules != null && rules.size() > 0) {
return rules;
}
return null;
......
......@@ -153,6 +153,7 @@ public class task implements CommandLineRunner {
coefficientMode11.setBelowCoefficient(-0.05);
coefficientMode11.setMediumCoefficient(0D);
coefficientMode11.setTopCoefficient(0.05);
CoefficientModel coefficientMode12 = new CoefficientModel();
coefficientMode12.setScale(3);
coefficientMode12.setId(UUIDUtil.getUUID());
......@@ -162,6 +163,37 @@ public class task implements CommandLineRunner {
coefficientMode12.setBelowCoefficient(-0.05);
coefficientMode12.setMediumCoefficient(0D);
coefficientMode12.setTopCoefficient(0.05);
CoefficientModel coefficientMode13 = new CoefficientModel();
coefficientMode13.setScale(1);
coefficientMode13.setId(UUIDUtil.getUUID());
coefficientMode13.setName("数据库表");
coefficientMode13.setMin(10);
coefficientMode13.setMax(100);
coefficientMode13.setBelowCoefficient(-0.05);
coefficientMode13.setMediumCoefficient(0D);
coefficientMode13.setTopCoefficient(0.05);
CoefficientModel coefficientMode14 = new CoefficientModel();
coefficientMode14.setScale(2);
coefficientMode14.setId(UUIDUtil.getUUID());
coefficientMode14.setName("数据库表");
coefficientMode14.setMin(10);
coefficientMode14.setMax(100);
coefficientMode14.setBelowCoefficient(-0.05);
coefficientMode14.setMediumCoefficient(0D);
coefficientMode14.setTopCoefficient(0.05);
CoefficientModel coefficientMode15 = new CoefficientModel();
coefficientMode15.setScale(3);
coefficientMode15.setId(UUIDUtil.getUUID());
coefficientMode15.setName("数据库表");
coefficientMode15.setMin(10);
coefficientMode15.setMax(100);
coefficientMode15.setBelowCoefficient(-0.05);
coefficientMode15.setMediumCoefficient(0D);
coefficientMode15.setTopCoefficient(0.05);
coefficientModels.add(coefficientMode6);
coefficientModels.add(coefficientMode5);
coefficientModels.add(coefficientMode4);
......@@ -174,6 +206,9 @@ public class task implements CommandLineRunner {
coefficientModels.add(coefficientMode10);
coefficientModels.add(coefficientMode11);
coefficientModels.add(coefficientMode12);
coefficientModels.add(coefficientMode13);
coefficientModels.add(coefficientMode14);
coefficientModels.add(coefficientMode15);
coefficientModelDao.saveAll(coefficientModels);
Technology JavaTechnology = new Technology();
......
......@@ -18,7 +18,7 @@ logging.file.path=./log/master.log
# spring-data-jpa \u76F8\u5173\u914D\u7F6E
# \u6307jpa\u5BF9\u8868\u751F\u6210\u7684\u7B56\u7565
spring.jpa.hibernate.ddl-auto=create
spring.jpa.hibernate.ddl-auto=update
# \u662F\u5426\u663E\u793Asql\u8BED\u53E5
spring.jpa.show-sql=false
# \u683C\u5F0F\u5316sql
......
......@@ -18,7 +18,7 @@ logging.file.path=./log/master.log
# spring-data-jpa \u76F8\u5173\u914D\u7F6E
# \u6307jpa\u5BF9\u8868\u751F\u6210\u7684\u7B56\u7565
spring.jpa.hibernate.ddl-auto=create
spring.jpa.hibernate.ddl-auto=update
# \u662F\u5426\u663E\u793Asql\u8BED\u53E5
spring.jpa.show-sql=false
# \u683C\u5F0F\u5316sql
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论