提交 8feb4cbb authored 作者: mry's avatar mry

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

上级 14a00b93
......@@ -14,7 +14,9 @@ import org.matrix.database.vo.CommonResultObj;
import org.matrix.database.vo.MoveAction;
import org.matrix.exception.GlobalException;
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.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
......@@ -51,7 +53,9 @@ public class MoveController {
@GetMapping
@Cacheable(cacheNames = "moveNames", key = "#p0", condition = "#p0 != null ", unless = "#result.statusCodeValue != 200")
@Cacheable(cacheNames = "moveNames",
key = "#p0", condition = "#p0 != null ",
unless = "#result.statusCodeValue != 200")
public ResponseEntity<CommonResultObj<String>> findNameById(@RequestParam Integer moveId) {
String name = ofNullable(moveService.getById(moveId))
.orElseThrow(() -> new GlobalException(String.format("没有找到id = %d 的move对象名称", moveId)))
......@@ -70,10 +74,14 @@ public class MoveController {
*/
@ApiOperation(value = "分页查询行为")
@GetMapping("/{projectId}")
@Cacheable(cacheNames = "movePageName",
key = "#pageNum + '_' + #pageSize + #projectId",
condition = "#pageNum != null && #pageSize != null",
unless = "#result.statusCodeValue != 200")
public ResponseEntity<CommonResultObj<Page<Move>>> findPageConnects(
@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<Move> results = Optional.ofNullable(moveService.page(Page.of(pageNum, pageSize)
, Wrappers.lambdaQuery(Move.class).eq(Move::getProjectId, projectId)
......@@ -91,6 +99,10 @@ public class MoveController {
*/
@ApiOperation(value = "根据行为id查,行为以及,行为下的动作")
@GetMapping("/move/{moveId}")
@Cacheable(cacheNames = "moveName",
key = "#moveId",
condition = "#p0 != null",
unless = "#result.statusCodeValue != 200")
public ResponseEntity<CommonResultObj<MoveAction>> findByIdMoveAction(@PathVariable Long moveId) {
Move byId = moveService.getById(moveId);
if (byId == null) {
......@@ -113,6 +125,10 @@ public class MoveController {
*/
@ApiOperation(value = "添加行为和动作")
@PostMapping
@Caching(
put = {@CachePut(cacheNames = "moveName",key = "result.body.data.move.id",
condition = "#p0 != null",unless = "#result.statusCodeValue != 200")}
)
public ResponseEntity<CommonResultObj<MoveAction>> insertMoveAction(@RequestBody MoveAction moveAction) {
Boolean moveBoolean = Optional.of(moveService.save(moveAction.getMove()))
.orElseThrow(GlobalException::new);
......
......@@ -90,7 +90,10 @@ public class TestCaseController {
*/
@GetMapping("/testCase/{testCaseId}")
@ApiOperation(value = "根据用例id查,用例以及,用例下的数据组")
@Cacheable(cacheNames = "caseCache", key = "#testCaseId", condition = "#p0 !=null", unless = "#result.statusCodeValue != 200")
@Cacheable(cacheNames = "caseCache",
key = "#testCaseId",
condition = "#p0 !=null",
unless = "#result.statusCodeValue != 200")
public ResponseEntity<CommonResultObj<TestCaseData>> findByIdTestCaseData(@PathVariable Long testCaseId) {
TestCase byId = testCaseService.getById(testCaseId);
if (byId == null) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论