提交 c7ddc57c authored 作者: mry's avatar mry

feat(web): 添加了行为动作中部分缓存

上级 8feb4cbb
......@@ -75,7 +75,7 @@ public class MoveController {
@ApiOperation(value = "分页查询行为")
@GetMapping("/{projectId}")
@Cacheable(cacheNames = "movePageName",
key = "#pageNum + '_' + #pageSize + #projectId",
key = "#pageNum + '_' + #pageSize + '_' + #projectId",
condition = "#pageNum != null && #pageSize != null",
unless = "#result.statusCodeValue != 200")
public ResponseEntity<CommonResultObj<Page<Move>>> findPageConnects(
......@@ -126,9 +126,9 @@ public class MoveController {
@ApiOperation(value = "添加行为和动作")
@PostMapping
@Caching(
put = {@CachePut(cacheNames = "moveName",key = "result.body.data.move.id",
condition = "#p0 != null",unless = "#result.statusCodeValue != 200")}
)
put = {@CachePut(cacheNames = "moveName", key = "result.body.data.move.id",
condition = "#p0 != null", unless = "#result.statusCodeValue != 200")},
evict = {@CacheEvict(cacheNames = "movePageName", allEntries = true)})
public ResponseEntity<CommonResultObj<MoveAction>> insertMoveAction(@RequestBody MoveAction moveAction) {
Boolean moveBoolean = Optional.of(moveService.save(moveAction.getMove()))
.orElseThrow(GlobalException::new);
......@@ -153,10 +153,15 @@ public class MoveController {
* @param moveAction 行为以及行为下的动作
* @return {@link MoveAction}
*/
@CacheEvict(cacheNames = "moveNames", key = "#p0.move.id")
@ApiOperation(value = "修改行为以及动作")
@PutMapping
@Transactional(rollbackFor = Exception.class)
@Caching(
put = {@CachePut(cacheNames = "moveNames", key = "#result.body.data.move.id",
condition = "#p0 != null", unless = "#result.statusCodeValue != 200")},
evict = {
@CacheEvict(cacheNames = "movePageName", allEntries = true, condition = "#p0 != null "),
@CacheEvict(cacheNames = "moveNames", key = "#p0.move.id", condition = "#p0 != null ")})
public ResponseEntity<CommonResultObj<MoveAction>> updateMoveAction(@RequestBody MoveAction moveAction) {
Boolean update = Optional.of(moveService.updateById(moveAction.getMove()))
.orElseThrow(GlobalException::new);
......@@ -184,6 +189,9 @@ public class MoveController {
@ApiOperation(value = "删除行为和动作")
@DeleteMapping("/{moveId}")
@Transactional(rollbackFor = Exception.class)
@Caching(evict = {
@CacheEvict(cacheNames = "movePageName", allEntries = true, condition = "#p0 != null"),
@CacheEvict(cacheNames = "moveNames", key = "#moveId", condition = "#p0!= null")})
public ResponseEntity<CommonResultObj<MoveAction>> deleteMoveAction(@PathVariable Long moveId) {
Boolean moveBoolean = Optional.of(moveService.removeById(moveId))
.orElseThrow(() -> new GlobalException(String.format("没有查到指定的行为,你提供的行为id是%d", moveId)));
......
......@@ -70,7 +70,7 @@ public class TestCaseController {
public ResponseEntity<CommonResultObj<Page<TestCase>>> findPageTestCase(
@RequestParam(defaultValue = "10") int pageSize,
@RequestParam(defaultValue = "1") int pageNum,
@RequestParam(required = false,defaultValue = "")String name,
@RequestParam(required = false, defaultValue = "") String name,
@PathVariable Long projectId) {
Page<TestCase> results = Optional.ofNullable(testCaseService.page(Page.of(pageNum, pageSize)
......@@ -91,8 +91,7 @@ public class TestCaseController {
@GetMapping("/testCase/{testCaseId}")
@ApiOperation(value = "根据用例id查,用例以及,用例下的数据组")
@Cacheable(cacheNames = "caseCache",
key = "#testCaseId",
condition = "#p0 !=null",
key = "#testCaseId", condition = "#p0 !=null",
unless = "#result.statusCodeValue != 200")
public ResponseEntity<CommonResultObj<TestCaseData>> findByIdTestCaseData(@PathVariable Long testCaseId) {
TestCase byId = testCaseService.getById(testCaseId);
......@@ -151,7 +150,7 @@ public class TestCaseController {
@Transactional(rollbackFor = Exception.class)
@Caching(
put = {@CachePut(cacheNames = "caseCache", key = "#result.body.data.testCase.id",
condition = "#p0 !=null", unless = "#result.statusCodeValue != 200")
condition = "#p0 !=null", unless = "#result.statusCodeValue != 200"),
},
evict = {
@CacheEvict(cacheNames = "casePageCache", allEntries = true, condition = "#p0 != null "),
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论