Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
I
inspect
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
912协同工作系统
项目监控管理工具
inspect
Commits
7d917ebe
提交
7d917ebe
authored
3月 12, 2020
作者:
孙洁清
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' of git.yfzx.zjtys.com.cn:912-system/monitor/inspect
上级
a0d2c57f
03071369
显示空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
66 行增加
和
40 行删除
+66
-40
RuleController.java
...main/java/com/zjty/inspect/controller/RuleController.java
+5
-7
RuleDao.java
src/main/java/com/zjty/inspect/dao/RuleDao.java
+2
-0
Page.java
src/main/java/com/zjty/inspect/entity/Page.java
+4
-0
Inspector.java
src/main/java/com/zjty/inspect/inspect/Inspector.java
+1
-8
RuleService.java
src/main/java/com/zjty/inspect/service/RuleService.java
+4
-6
RuleServiceImpl.java
...n/java/com/zjty/inspect/service/impl/RuleServiceImpl.java
+50
-19
没有找到文件。
src/main/java/com/zjty/inspect/controller/RuleController.java
浏览文件 @
7d917ebe
package
com
.
zjty
.
inspect
.
controller
;
package
com
.
zjty
.
inspect
.
controller
;
import
com.zjty.inspect.entity.Page
;
import
com.zjty.inspect.entity.PageResult
;
import
com.zjty.inspect.entity.PageResult
;
import
com.zjty.inspect.entity.Rule
;
import
com.zjty.inspect.entity.Rule
;
import
com.zjty.inspect.entity.RuleQo
;
import
com.zjty.inspect.entity.RuleQo
;
...
@@ -9,7 +10,6 @@ import io.swagger.annotations.ApiImplicitParam;
...
@@ -9,7 +10,6 @@ import io.swagger.annotations.ApiImplicitParam;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Page
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
...
@@ -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
);
}
}
...
@@ -103,7 +101,7 @@ public class RuleController {
...
@@ -103,7 +101,7 @@ public class RuleController {
})
})
@RequestMapping
(
value
=
"/search/{page}/{size}"
,
method
=
RequestMethod
.
POST
)
@RequestMapping
(
value
=
"/search/{page}/{size}"
,
method
=
RequestMethod
.
POST
)
public
ResponseEntity
findSearch
(
@RequestBody
Map
searchMap
,
@PathVariable
int
page
,
@PathVariable
int
size
){
public
ResponseEntity
findSearch
(
@RequestBody
Map
searchMap
,
@PathVariable
int
page
,
@PathVariable
int
size
){
Page
<
Rule
>
pageList
=
ruleService
.
findSearch
(
searchMap
,
page
,
size
);
Page
<
Rule
Qo
>
search
=
ruleService
.
findSearch
(
searchMap
,
page
,
size
);
return
ResponseEntity
.
ok
(
new
PageResult
<
Rule
>(
pageList
.
getTotalElements
(),
pageList
.
getContent
())
);
return
ResponseEntity
.
ok
(
search
);
}
}
}
}
src/main/java/com/zjty/inspect/dao/RuleDao.java
浏览文件 @
7d917ebe
...
@@ -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
);
}
}
src/main/java/com/zjty/inspect/entity/Page.java
浏览文件 @
7d917ebe
...
@@ -38,4 +38,8 @@ public class Page<T> {
...
@@ -38,4 +38,8 @@ public class Page<T> {
public
List
<
T
>
getObjects
()
{
public
List
<
T
>
getObjects
()
{
return
objects
;
return
objects
;
}
}
public
void
setObjects
(
List
<
T
>
objects
)
{
this
.
objects
=
objects
;
}
}
}
src/main/java/com/zjty/inspect/inspect/Inspector.java
浏览文件 @
7d917ebe
...
@@ -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
);
...
...
src/main/java/com/zjty/inspect/service/RuleService.java
浏览文件 @
7d917ebe
package
com
.
zjty
.
inspect
.
service
;
package
com
.
zjty
.
inspect
.
service
;
import
com.zjty.inspect.entity.
Rul
e
;
import
com.zjty.inspect.entity.
Pag
e
;
import
com.zjty.inspect.entity.RuleQo
;
import
com.zjty.inspect.entity.RuleQo
;
import
com.zjty.inspect.entity.RuleVo
;
import
org.springframework.data.domain.Page
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -39,10 +37,10 @@ public interface RuleService {
...
@@ -39,10 +37,10 @@ public interface RuleService {
* 查询所有规则
* 查询所有规则
* @return 规则
* @return 规则
*/
*/
List
<
Rule
>
findAll
();
List
<
Rule
Qo
>
findAll
();
List
<
Rule
>
findByName
(
String
name
);
List
<
Rule
Qo
>
findByName
(
String
name
);
Page
<
Rule
>
findSearch
(
Map
searchMap
,
int
page
,
int
size
);
Page
<
Rule
Qo
>
findSearch
(
Map
searchMap
,
int
page
,
int
size
);
void
test
();
void
test
();
}
}
src/main/java/com/zjty/inspect/service/impl/RuleServiceImpl.java
浏览文件 @
7d917ebe
package
com
.
zjty
.
inspect
.
service
.
impl
;
package
com
.
zjty
.
inspect
.
service
.
impl
;
import
com.zjty.inspect.dao.TechnologyDao
;
import
com.zjty.inspect.dao.RuleDao
;
import
com.zjty.inspect.dao.RuleDao
;
import
com.zjty.inspect.entity.ExcelDataVo
;
import
com.zjty.inspect.entity.ExcelDataVo
;
import
com.zjty.inspect.entity.Technology
;
import
com.zjty.inspect.entity.Rule
;
import
com.zjty.inspect.entity.Rule
;
import
com.zjty.inspect.entity.RuleQo
;
import
com.zjty.inspect.entity.RuleQo
;
import
com.zjty.inspect.service.RuleService
;
import
com.zjty.inspect.service.RuleService
;
...
@@ -99,10 +97,17 @@ public class RuleServiceImpl implements RuleService {
...
@@ -99,10 +97,17 @@ public class RuleServiceImpl implements RuleService {
* @return
* @return
*/
*/
@Override
@Override
public
Page
<
Rule
>
findSearch
(
Map
whereMap
,
int
page
,
int
size
)
{
public
com
.
zjty
.
inspect
.
entity
.
Page
<
RuleQo
>
findSearch
(
Map
whereMap
,
int
page
,
int
size
)
{
Specification
<
Rule
>
specification
=
createSpecification
(
whereMap
);
Specification
<
Rule
>
specification
=
createSpecification
(
whereMap
);
PageRequest
pageRequest
=
PageRequest
.
of
(
page
-
1
,
size
);
PageRequest
pageRequest
=
PageRequest
.
of
(
page
-
1
,
size
);
return
ruleDao
.
findAll
(
specification
,
pageRequest
);
Page
<
Rule
>
all
=
ruleDao
.
findAll
(
specification
,
pageRequest
);
List
<
RuleQo
>
ruleQos
=
data2RuleQo
(
all
.
getContent
());
com
.
zjty
.
inspect
.
entity
.
Page
<
RuleQo
>
myPage
=
new
com
.
zjty
.
inspect
.
entity
.
Page
<>();
myPage
.
setTotalPage
(
all
.
getTotalPages
());
myPage
.
setTotalElement
((
int
)
all
.
getTotalElements
());
myPage
.
setObjects
(
ruleQos
);
return
myPage
;
}
}
/**
/**
...
@@ -133,18 +138,11 @@ public class RuleServiceImpl implements RuleService {
...
@@ -133,18 +138,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
...
@@ -160,20 +158,53 @@ public class RuleServiceImpl implements RuleService {
...
@@ -160,20 +158,53 @@ public class RuleServiceImpl implements RuleService {
/**
/**
* 查询所有规则
* 查询所有规则
* 规则唯一 关键字+后缀+技术id
* target:xx,suffix:js:tech:gjfgj
* target:xx,suffix:html:tech:gjfgj
* target:xx,suffix:css:tech:gjfgj
*
*
* target:xx,suffix:html,css,js:tech:gjfgj
* @return RuleVoList
* @return RuleVoList
*/
*/
@Override
@Override
public
List
<
Rule
>
findAll
()
{
public
List
<
RuleQo
>
findAll
()
{
return
ruleDao
.
findAll
();
List
<
Rule
>
rules
=
ruleDao
.
findAll
();
List
<
RuleQo
>
ruleQos
=
data2RuleQo
(
rules
);
return
ruleQos
;
}
}
@Override
@Override
public
List
<
Rule
>
findByName
(
String
name
)
{
public
List
<
Rule
Qo
>
findByName
(
String
name
)
{
List
<
Rule
>
rules
=
ruleDao
.
findAllByTargetLike
(
"%"
+
name
+
"%"
);
List
<
Rule
>
rules
=
ruleDao
.
findAllByTargetLike
(
"%"
+
name
+
"%"
);
if
(
rules
!=
null
&&
rules
.
size
()
>
0
)
{
if
(
rules
!=
null
&&
rules
.
size
()
>
0
)
{
return
rules
;
return
data2RuleQo
(
rules
)
;
}
}
return
null
;
return
null
;
}
}
private
List
<
RuleQo
>
data2RuleQo
(
List
<
Rule
>
rules
){
HashMap
<
String
,
RuleQo
>
hashMap
=
new
HashMap
<>();
for
(
Rule
rule
:
rules
)
{
if
(!
hashMap
.
containsKey
(
rule
.
getTarget
()+
rule
.
getTechnologyId
())){
RuleQo
ruleQo
=
new
RuleQo
();
ruleQo
.
setId
(
rule
.
getId
());
ruleQo
.
setTarget
(
rule
.
getTarget
());
ruleQo
.
setTechnologyId
(
rule
.
getTechnologyId
());
ruleQo
.
setTechnologyName
(
rule
.
getTechnologyName
());
ArrayList
<
String
>
suffix
=
new
ArrayList
<>();
suffix
.
add
(
rule
.
getSuffix
());
ruleQo
.
setSuffix
(
suffix
);
hashMap
.
put
(
rule
.
getTarget
()+
rule
.
getTechnologyId
(),
ruleQo
);
}
else
{
RuleQo
ruleQo
=
hashMap
.
get
(
rule
.
getTarget
()
+
rule
.
getTechnologyId
());
ruleQo
.
getSuffix
().
add
(
rule
.
getSuffix
());
if
(
ruleQo
.
getSuffix
().
size
()>
1
){
System
.
out
.
println
(
rule
.
getTarget
()+
rule
.
getTechnologyId
());
System
.
out
.
println
(
ruleQo
.
getSuffix
());
}
}
}
return
new
ArrayList
<>(
hashMap
.
values
());
}
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论