Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
I
inspect
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
912协同工作系统
项目监控管理工具
inspect
Commits
012417c5
提交
012417c5
authored
3月 04, 2020
作者:
马晨俊
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' of git.yfzx.zjtys.com.cn:912-system/monitor/inspect
上级
d463d87e
b21920ec
隐藏空白字符变更
内嵌
并排
正在显示
12 个修改的文件
包含
207 行增加
和
6 行删除
+207
-6
pom.xml
pom.xml
+4
-1
RuleController.java
...main/java/com/zjty/inspect/controller/RuleController.java
+27
-2
TechnologyController.java
...ava/com/zjty/inspect/controller/TechnologyController.java
+24
-0
RuleDao.java
src/main/java/com/zjty/inspect/dao/RuleDao.java
+2
-1
TechnologyDao.java
src/main/java/com/zjty/inspect/dao/TechnologyDao.java
+2
-1
PageResult.java
src/main/java/com/zjty/inspect/entity/PageResult.java
+31
-0
Technology.java
src/main/java/com/zjty/inspect/entity/Technology.java
+3
-1
RuleService.java
src/main/java/com/zjty/inspect/service/RuleService.java
+4
-0
TechnologyService.java
...main/java/com/zjty/inspect/service/TechnologyService.java
+4
-0
ReportServiceImpl.java
...java/com/zjty/inspect/service/impl/ReportServiceImpl.java
+28
-0
RuleServiceImpl.java
...n/java/com/zjty/inspect/service/impl/RuleServiceImpl.java
+42
-0
TechnologyServiceImpl.java
.../com/zjty/inspect/service/impl/TechnologyServiceImpl.java
+36
-0
没有找到文件。
pom.xml
浏览文件 @
012417c5
...
...
@@ -37,7 +37,10 @@
<artifactId>
springfox-swagger-ui
</artifactId>
<version>
${swagger.version}
</version>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-freemarker
</artifactId>
</dependency>
<dependency>
<groupId>
org.eclipse.jgit
</groupId>
<artifactId>
org.eclipse.jgit
</artifactId>
...
...
src/main/java/com/zjty/inspect/controller/RuleController.java
浏览文件 @
012417c5
package
com
.
zjty
.
inspect
.
controller
;
import
com.zjty.inspect.entity.PageResult
;
import
com.zjty.inspect.entity.Rule
;
import
com.zjty.inspect.entity.RuleQo
;
import
com.zjty.inspect.service.RuleService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Page
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.Map
;
/**
* 规则库设置
* @author Mcj
...
...
@@ -60,8 +67,7 @@ public class RuleController {
@ApiOperation
(
"根据name查询规则"
)
@GetMapping
(
value
=
"/{name}"
)
public
ResponseEntity
getName
(
@PathVariable
String
name
)
{
ruleService
.
findByName
(
name
);
return
ResponseEntity
.
ok
(
200
);
return
ResponseEntity
.
ok
(
ruleService
.
findByName
(
name
));
}
/**
* 查询所有规则
...
...
@@ -72,4 +78,23 @@ public class RuleController {
public
ResponseEntity
getRules
(){
return
ResponseEntity
.
ok
(
ruleService
.
findAll
());
}
/**
* 分页+多条件查询
* @param searchMap 查询条件封装
* @param page 页码
* @param size 页大小
* @return 分页结果
*/
@ApiOperation
(
"分页查询页面列表"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"page"
,
value
=
"页码"
,
required
=
true
,
paramType
=
"path"
,
dataType
=
"int"
),
@ApiImplicitParam
(
name
=
"size"
,
value
=
"每页记录数"
,
required
=
true
,
paramType
=
"path"
,
dataType
=
"int"
)
})
@RequestMapping
(
value
=
"/search/{page}/{size}"
,
method
=
RequestMethod
.
POST
)
public
ResponseEntity
findSearch
(
@RequestBody
Map
searchMap
,
@PathVariable
int
page
,
@PathVariable
int
size
){
Page
<
Rule
>
pageList
=
ruleService
.
findSearch
(
searchMap
,
page
,
size
);
return
ResponseEntity
.
ok
(
new
PageResult
<
Rule
>(
pageList
.
getTotalElements
(),
pageList
.
getContent
())
);
}
}
src/main/java/com/zjty/inspect/controller/TechnologyController.java
浏览文件 @
012417c5
package
com
.
zjty
.
inspect
.
controller
;
import
com.zjty.inspect.entity.PageResult
;
import
com.zjty.inspect.entity.Rule
;
import
com.zjty.inspect.entity.Technology
;
import
com.zjty.inspect.entity.TechnologyQo
;
import
com.zjty.inspect.service.TechnologyService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Page
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.Map
;
/**
* 适配技术
* @author Mcj
...
...
@@ -71,4 +78,21 @@ public class TechnologyController {
technologyService
.
update
(
technology
);
return
ResponseEntity
.
ok
(
200
);
}
/**
* 分页+多条件查询
* @param searchMap 查询条件封装
* @param page 页码
* @param size 页大小
* @return 分页结果
*/
@ApiOperation
(
"分页查询页面列表"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"page"
,
value
=
"页码"
,
required
=
true
,
paramType
=
"path"
,
dataType
=
"int"
),
@ApiImplicitParam
(
name
=
"size"
,
value
=
"每页记录数"
,
required
=
true
,
paramType
=
"path"
,
dataType
=
"int"
)
})
@RequestMapping
(
value
=
"/search/{page}/{size}"
,
method
=
RequestMethod
.
POST
)
public
ResponseEntity
findSearch
(
@RequestBody
Map
searchMap
,
@PathVariable
int
page
,
@PathVariable
int
size
){
Page
<
Technology
>
pageList
=
technologyService
.
findSearch
(
searchMap
,
page
,
size
);
return
ResponseEntity
.
ok
(
new
PageResult
<
Technology
>(
pageList
.
getTotalElements
(),
pageList
.
getContent
())
);
}
}
src/main/java/com/zjty/inspect/dao/RuleDao.java
浏览文件 @
012417c5
...
...
@@ -3,10 +3,11 @@ package com.zjty.inspect.dao;
import
com.zjty.inspect.entity.Rule
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.JpaSpecificationExecutor
;
import
java.util.List
;
public
interface
RuleDao
extends
JpaRepository
<
Rule
,
String
>
{
public
interface
RuleDao
extends
JpaRepository
<
Rule
,
String
>
,
JpaSpecificationExecutor
<
Rule
>
{
/**
* 根据目标关键字查询规则
* @param target 目标关键字
...
...
src/main/java/com/zjty/inspect/dao/TechnologyDao.java
浏览文件 @
012417c5
...
...
@@ -2,11 +2,12 @@ package com.zjty.inspect.dao;
import
com.zjty.inspect.entity.Technology
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.JpaSpecificationExecutor
;
import
org.springframework.data.jpa.repository.Query
;
import
java.util.List
;
public
interface
TechnologyDao
extends
JpaRepository
<
Technology
,
String
>
{
public
interface
TechnologyDao
extends
JpaRepository
<
Technology
,
String
>
,
JpaSpecificationExecutor
<
Technology
>
{
/**
* 根据名称查询适配技术
...
...
src/main/java/com/zjty/inspect/entity/PageResult.java
0 → 100644
浏览文件 @
012417c5
package
com
.
zjty
.
inspect
.
entity
;
import
java.util.List
;
public
class
PageResult
<
T
>
{
private
Long
total
;
private
List
<
T
>
rows
;
public
PageResult
(
Long
total
,
List
<
T
>
rows
)
{
super
();
this
.
total
=
total
;
this
.
rows
=
rows
;
}
public
Long
getTotal
()
{
return
total
;
}
public
void
setTotal
(
Long
total
)
{
this
.
total
=
total
;
}
public
List
<
T
>
getRows
()
{
return
rows
;
}
public
void
setRows
(
List
<
T
>
rows
)
{
this
.
rows
=
rows
;
}
}
src/main/java/com/zjty/inspect/entity/Technology.java
浏览文件 @
012417c5
...
...
@@ -47,8 +47,10 @@ public class Technology {
/**
* 技术类型
* 1:前端技术
* 2:后端技术
*/
private
String
backOrFront
;
private
Integer
backOrFront
=
2
;
/**
* 数据创建时间
*/
...
...
src/main/java/com/zjty/inspect/service/RuleService.java
浏览文件 @
012417c5
...
...
@@ -3,8 +3,10 @@ package com.zjty.inspect.service;
import
com.zjty.inspect.entity.Rule
;
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.Map
;
/**
* 规则接口
...
...
@@ -40,4 +42,6 @@ public interface RuleService {
List
<
Rule
>
findAll
();
List
<
Rule
>
findByName
(
String
name
);
Page
<
Rule
>
findSearch
(
Map
searchMap
,
int
page
,
int
size
);
}
src/main/java/com/zjty/inspect/service/TechnologyService.java
浏览文件 @
012417c5
...
...
@@ -2,8 +2,10 @@ package com.zjty.inspect.service;
import
com.zjty.inspect.entity.Technology
;
import
com.zjty.inspect.entity.TechnologyQo
;
import
org.springframework.data.domain.Page
;
import
java.util.List
;
import
java.util.Map
;
/**
* 关键技术
...
...
@@ -26,4 +28,6 @@ public interface TechnologyService {
public
List
<
Technology
>
findAllTechnology
(
String
name
);
void
update
(
Technology
technology
);
Page
<
Technology
>
findSearch
(
Map
searchMap
,
int
page
,
int
size
);
}
src/main/java/com/zjty/inspect/service/impl/ReportServiceImpl.java
浏览文件 @
012417c5
...
...
@@ -4,9 +4,15 @@ import com.zjty.inspect.dao.TechnologyDao;
import
com.zjty.inspect.entity.*
;
import
com.zjty.inspect.service.ReportService
;
import
com.zjty.inspect.utils.RedisUtil
;
import
freemarker.cache.StringTemplateLoader
;
import
freemarker.template.Configuration
;
import
freemarker.template.Template
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.ui.freemarker.FreeMarkerTemplateUtils
;
import
java.util.Map
;
/**
* @author Mcj
...
...
@@ -26,4 +32,26 @@ public class ReportServiceImpl implements ReportService {
return
new
ReportVo
();
}
//执行静态化
private
String
generateHtml
(
String
templateContent
,
Map
model
){
//创建配置对象
Configuration
configuration
=
new
Configuration
(
Configuration
.
getVersion
());
//创建模板加载器
StringTemplateLoader
stringTemplateLoader
=
new
StringTemplateLoader
();
stringTemplateLoader
.
putTemplate
(
"template"
,
templateContent
);
//向configuration配置模板加载器
configuration
.
setTemplateLoader
(
stringTemplateLoader
);
//获取模板
try
{
Template
template
=
configuration
.
getTemplate
(
"template"
);
//调用api进行静态化
String
content
=
FreeMarkerTemplateUtils
.
processTemplateIntoString
(
template
,
model
);
return
content
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
null
;
}
}
src/main/java/com/zjty/inspect/service/impl/RuleServiceImpl.java
浏览文件 @
012417c5
...
...
@@ -8,11 +8,20 @@ import com.zjty.inspect.entity.RuleQo;
import
com.zjty.inspect.service.RuleService
;
import
com.zjty.inspect.utils.UUIDUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.data.jpa.domain.Specification
;
import
org.springframework.data.jpa.repository.Modifying
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.persistence.criteria.CriteriaBuilder
;
import
javax.persistence.criteria.CriteriaQuery
;
import
javax.persistence.criteria.Predicate
;
import
javax.persistence.criteria.Root
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
/**
* 规则库
...
...
@@ -44,6 +53,39 @@ public class RuleServiceImpl implements RuleService {
rule
.
setId
(
UUIDUtil
.
getUUID
());
ruleDao
.
save
(
rule
);
}
/**
* 条件查询+分页
* @param whereMap
* @param page
* @param size
* @return
*/
public
Page
<
Rule
>
findSearch
(
Map
whereMap
,
int
page
,
int
size
)
{
Specification
<
Rule
>
specification
=
createSpecification
(
whereMap
);
PageRequest
pageRequest
=
PageRequest
.
of
(
page
-
1
,
size
);
return
ruleDao
.
findAll
(
specification
,
pageRequest
);
}
/**
* 动态条件构建
* @param searchMap
* @return
*/
private
Specification
<
Rule
>
createSpecification
(
Map
searchMap
)
{
return
new
Specification
<
Rule
>()
{
@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"
)+
"%"
));
}
return
cb
.
and
(
predicateList
.
toArray
(
new
Predicate
[
predicateList
.
size
()]));
}
};
}
@Override
public
void
upRule
(
RuleQo
ruleQo
)
{
...
...
src/main/java/com/zjty/inspect/service/impl/TechnologyServiceImpl.java
浏览文件 @
012417c5
...
...
@@ -6,11 +6,19 @@ import com.zjty.inspect.entity.Technology;
import
com.zjty.inspect.service.TechnologyService
;
import
com.zjty.inspect.utils.UUIDUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.data.jpa.domain.Specification
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.persistence.criteria.CriteriaBuilder
;
import
javax.persistence.criteria.CriteriaQuery
;
import
javax.persistence.criteria.Predicate
;
import
javax.persistence.criteria.Root
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
/**
* 适配技术
...
...
@@ -85,4 +93,32 @@ public class TechnologyServiceImpl implements TechnologyService {
public
void
update
(
Technology
technology
)
{
technologyDao
.
save
(
technology
);
}
@Override
public
Page
<
Technology
>
findSearch
(
Map
whereMap
,
int
page
,
int
size
)
{
Specification
<
Technology
>
specification
=
createSpecification
(
whereMap
);
PageRequest
pageRequest
=
PageRequest
.
of
(
page
-
1
,
size
);
return
technologyDao
.
findAll
(
specification
,
pageRequest
);
}
/**
* 动态条件构建
* @param searchMap
* @return
*/
private
Specification
<
Technology
>
createSpecification
(
Map
searchMap
)
{
return
new
Specification
<
Technology
>()
{
@Override
public
Predicate
toPredicate
(
Root
<
Technology
>
root
,
CriteriaQuery
<?>
query
,
CriteriaBuilder
cb
)
{
List
<
Predicate
>
predicateList
=
new
ArrayList
<
Predicate
>();
if
(
searchMap
.
get
(
"technologyName"
)!=
null
&&
!
""
.
equals
(
searchMap
.
get
(
"technologyName"
))){
predicateList
.
add
(
cb
.
like
(
root
.
get
(
"technologyName"
).
as
(
String
.
class
),
"%"
+(
String
)
searchMap
.
get
(
"technologyName"
)+
"%"
));
}
return
cb
.
and
(
predicateList
.
toArray
(
new
Predicate
[
predicateList
.
size
()]));
}
};
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论