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

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

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