Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
kt-keystone
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Matrix
kt-keystone
Commits
c5013cbb
提交
c5013cbb
authored
3月 22, 2022
作者:
mry
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(web): 添加了数据库所有缓存
上级
5485056e
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
22 行增加
和
0 行删除
+22
-0
ConnectController.java
...ava/org/matrix/autotest/controller/ConnectController.java
+22
-0
没有找到文件。
kt-web/src/main/java/org/matrix/autotest/controller/ConnectController.java
浏览文件 @
c5013cbb
...
...
@@ -11,6 +11,10 @@ import org.matrix.database.entity.Connect;
import
org.matrix.database.service.IConnectService
;
import
org.matrix.database.vo.CommonResult
;
import
org.matrix.database.vo.CommonResultObj
;
import
org.springframework.cache.annotation.CacheEvict
;
import
org.springframework.cache.annotation.CachePut
;
import
org.springframework.cache.annotation.Cacheable
;
import
org.springframework.cache.annotation.Caching
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.util.StringUtils
;
import
org.springframework.web.bind.annotation.*
;
...
...
@@ -75,6 +79,10 @@ public class ConnectController {
*/
@ApiOperation
(
value
=
"分页查询数据库信息"
)
@GetMapping
@Cacheable
(
cacheNames
=
"connectPageCache"
,
key
=
"#pageSize + '_' + #pageNum + '_' + #projectId"
,
condition
=
"#pageNum != null && #pageSize != null"
,
unless
=
"#result.statusCodeValue != 200"
)
public
ResponseEntity
<
CommonResultObj
<
Page
<
Connect
>>>
findPageConnects
(
@RequestParam
(
defaultValue
=
"10"
)
int
pageSize
,
@RequestParam
(
defaultValue
=
"1"
)
int
pageNum
,
...
...
@@ -95,6 +103,12 @@ public class ConnectController {
*/
@ApiOperation
(
value
=
"添加连接池"
)
@PostMapping
@Caching
(
put
=
{
@CachePut
(
cacheNames
=
"connectPageCache"
,
key
=
"#result.body.data.id"
,
condition
=
"#p0 != null"
,
unless
=
"#result.statusCodeValue != 200"
)
},
evict
=
{
@CacheEvict
(
cacheNames
=
"connectPageCache"
,
allEntries
=
true
)}
)
public
ResponseEntity
<
CommonResultObj
<
Connect
>>
insertConnect
(
@RequestBody
Connect
connect
)
{
return
CommonResult
.
pred
(
connectService:
:
save
,
connect
,
"添加成功"
,
"添加失败"
);
...
...
@@ -108,6 +122,13 @@ public class ConnectController {
*/
@ApiOperation
(
value
=
"修改连接池"
)
@PutMapping
@Caching
(
put
=
{
@CachePut
(
cacheNames
=
"connectPageCache"
,
key
=
"#result.body.data.id"
,
condition
=
"#p0 != null"
,
unless
=
"#result.statusCodeValue != 200"
)
},
evict
=
{
@CacheEvict
(
cacheNames
=
"connectPageCache"
,
key
=
"#p0.id"
,
condition
=
"#p0 != null"
)}
)
public
ResponseEntity
<
CommonResultObj
<
Connect
>>
updateConnect
(
@RequestBody
Connect
connect
)
{
return
CommonResult
.
pred
(
connectService:
:
updateById
,
connect
,
"修改成功"
,
"修改失败"
);
...
...
@@ -121,6 +142,7 @@ public class ConnectController {
*/
@ApiOperation
(
value
=
"根据主键id删除连接池"
)
@DeleteMapping
(
"/{id}"
)
@CacheEvict
(
cacheNames
=
"connectPageCache"
,
allEntries
=
true
,
condition
=
"#p0 != null"
)
public
ResponseEntity
<
CommonResultObj
<
Long
>>
deleteConnect
(
@PathVariable
Long
id
)
{
return
CommonResult
.
pred
(
connectService:
:
removeById
,
id
,
"删除成功"
,
"删除失败或id不存在"
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论