提交 4629d5b3 authored 作者: 马晨俊's avatar 马晨俊

mcj:更新规则的修改

上级 11111ae4
...@@ -43,13 +43,11 @@ public class RuleController { ...@@ -43,13 +43,11 @@ public class RuleController {
/** /**
* 修改规则 * 修改规则
* @param ruleQo 规则封装 * @param ruleQo 规则封装
* @param id id
* @return * @return
*/ */
@PostMapping(value = "/{id}") @PostMapping(value = "/update")
@ApiOperation("修改规则") @ApiOperation("修改规则")
public ResponseEntity update(@RequestBody RuleQo ruleQo,@PathVariable String id){ public ResponseEntity update(@RequestBody RuleQo ruleQo){
ruleQo.setId(id);
ruleService.upRule(ruleQo); ruleService.upRule(ruleQo);
return ResponseEntity.ok(200); return ResponseEntity.ok(200);
} }
......
...@@ -36,4 +36,6 @@ public interface RuleDao extends JpaRepository<Rule,String>,JpaSpecificationExec ...@@ -36,4 +36,6 @@ public interface RuleDao extends JpaRepository<Rule,String>,JpaSpecificationExec
* @return * @return
*/ */
List<Rule> findAllByTechnologyIdIn(List<String> ids); List<Rule> findAllByTechnologyIdIn(List<String> ids);
List<Rule> findAllByTechnologyIdEqualsAndTargetEquals(String techId,String target);
} }
...@@ -199,9 +199,7 @@ public class Inspector { ...@@ -199,9 +199,7 @@ public class Inspector {
Files.walkFileTree(Paths.get(inspectParameter.getSourceAddress()), new FileVisitor<Path>() { Files.walkFileTree(Paths.get(inspectParameter.getSourceAddress()), new FileVisitor<Path>() {
@Override @Override
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException { public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
//这里是对于路径(文件夹)的过滤,在这里读不到文件如果能判断,可以返回FileVisitResult.SKIP_SUBTREE 不访问子目录
//if(dir.getFileName().startsWith("."))return FileVisitResult.SKIP_SUBTREE;
//if (dir.endsWith(".git"))return FileVisitResult.SKIP_SUBTREE;
return FileVisitResult.CONTINUE; return FileVisitResult.CONTINUE;
} }
...@@ -274,7 +272,6 @@ public class Inspector { ...@@ -274,7 +272,6 @@ public class Inspector {
ruleSuffixFilePathMap.get(entry.getValue()).add(file); ruleSuffixFilePathMap.get(entry.getValue()).add(file);
} }
} }
//检查到普通jar包
return FileVisitResult.CONTINUE; return FileVisitResult.CONTINUE;
} }
...@@ -316,7 +313,6 @@ public class Inspector { ...@@ -316,7 +313,6 @@ public class Inspector {
public ReportVo analysis() { public ReportVo analysis() {
DependencyVo dependencyVo = new DependencyVo(); DependencyVo dependencyVo = new DependencyVo();
setReportLanguageAndFrame(); setReportLanguageAndFrame();
//查询所有规则 //查询所有规则
ruleTransform(report.getRecastMethod()); ruleTransform(report.getRecastMethod());
//解析配置文件集合 //解析配置文件集合
...@@ -375,9 +371,6 @@ public class Inspector { ...@@ -375,9 +371,6 @@ public class Inspector {
if (path1.toAbsolutePath().toString().endsWith("jar") || path1.toAbsolutePath().toString().endsWith("class")) { if (path1.toAbsolutePath().toString().endsWith("jar") || path1.toAbsolutePath().toString().endsWith("class")) {
continue; continue;
} }
if(path1.getFileName().toString().equals("js")){
System.out.println("d");
}
valiWarn(rules, path1, path1.getFileName().toString(), 0); valiWarn(rules, path1, path1.getFileName().toString(), 0);
//将文件的每一行都与规则匹配 //将文件的每一行都与规则匹配
List<String> strings = Files.readAllLines(path1); List<String> strings = Files.readAllLines(path1);
......
...@@ -23,6 +23,7 @@ import javax.persistence.criteria.CriteriaQuery; ...@@ -23,6 +23,7 @@ import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate; import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root; import javax.persistence.criteria.Root;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
/** /**
* 规则库 * 规则库
...@@ -130,18 +131,11 @@ public class RuleServiceImpl implements RuleService { ...@@ -130,18 +131,11 @@ public class RuleServiceImpl implements RuleService {
@Override @Override
public void upRule(RuleQo ruleQo) { public void upRule(RuleQo ruleQo) {
List<String> suffixes = ruleQo.getSuffix(); List<Rule> rules = ruleDao.findAllByTechnologyIdEqualsAndTargetEquals(ruleQo.getTechnologyId(), ruleQo.getTarget());
for (String suffix : suffixes) { for (Rule rule : rules) {
Rule rule1 = ruleDao.findByTargetAndSuffixEqualsAndTechnologyIdEquals(ruleQo.getTarget(), suffix,ruleQo.getTechnologyId()); ruleDao.deleteById(rule.getId());
if (rule1 != null) {
return;
}
rule1.setTarget(ruleQo.getTarget());
rule1.setSuffix(suffix);
rule1.setTechnologyId(ruleQo.getTechnologyId());
rule1.setTechnologyName(ruleQo.getTechnologyName());
ruleDao.save(rule1);
} }
addRule(ruleQo);
} }
@Override @Override
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论