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

feat(web): 执行器部分加入了缓存

上级 22a40208
......@@ -8,6 +8,10 @@ import org.matrix.database.service.ITestJobService;
import org.matrix.database.vo.CommonResult;
import org.matrix.database.vo.CommonResultObj;
import org.matrix.database.vo.TestJobVo;
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.web.bind.annotation.*;
......@@ -43,22 +47,46 @@ public class TestJobController {
}
/**
* 分页查询所有测试任务信息
* 条件查询所有测试任务信息
*
* @param pageSize 每页多少条数据
* @param pageNum 当前第几页
* @param name 测试任务名称
* @return 分页查询的结果,测试任务信息
* @param pageSize 每页多少条数据
* @param pageNum 当前第几页
* @param projectId 项目id
* @return 条件查询的结果,测试任务信息
*/
@ApiOperation(value = "分页查询测试任务")
@ApiOperation(value = "条件查询测试任务")
@GetMapping("/page")
@Cacheable(cacheNames = "testJobPageCache",
key = "#pageSize + '_' + #pageNum + '_' + #projectId",
condition = "#pageSize != null && #pageNum != null",
unless = "#result.statusCodeValue != 200")
public ResponseEntity<CommonResultObj<IPage<TestJobVo>>> findPageTestTasks(
@RequestParam(defaultValue = "10") int pageSize,
@RequestParam(defaultValue = "1") int pageNum,
@RequestParam(required = true)Long projectId,
@RequestParam(required = false,defaultValue = "")String name
) {
IPage<TestJobVo> result = testJobService.pageTestJob(projectId,name, pageSize, pageNum);
@RequestParam Long projectId
) {
IPage<TestJobVo> result = testJobService.pageTestJob(projectId, "", pageSize, pageNum);
return CommonResult.success(result, "查询成功");
}
/**
* 条件查询所有测试任务信息
*
* @param pageSize 每页多少条数据
* @param pageNum 当前第几页
* @param projectId 项目id
* @param name 测试任务名称
* @return 条件查询的结果,测试任务信息
*/
@ApiOperation(value = "条件查询测试任务")
@GetMapping("/condition")
public ResponseEntity<CommonResultObj<IPage<TestJobVo>>> findConditionTestTasks(
@RequestParam(defaultValue = "10") int pageSize,
@RequestParam(defaultValue = "1") int pageNum,
@RequestParam Long projectId,
@RequestParam(required = false, defaultValue = "") String name
) {
IPage<TestJobVo> result = testJobService.pageTestJob(projectId, name, pageSize, pageNum);
return CommonResult.success(result, "查询成功");
}
......@@ -70,6 +98,12 @@ public class TestJobController {
*/
@ApiOperation(value = "添加测试任务")
@PostMapping
@Caching(
put = {@CachePut(cacheNames = "testJobPageCache", key = "#result.body.data.id",
condition = "#p0 != null", unless = "#result.statusCodeValue != 200")
},
evict = {@CacheEvict(cacheNames = "testJobPageCache", allEntries = true)}
)
public ResponseEntity<CommonResultObj<TestJob>> insertTestTask(@RequestBody TestJob testJob) {
return CommonResult.pred(testJobService::save, testJob
, "添加成功", "添加失败");
......@@ -83,6 +117,12 @@ public class TestJobController {
*/
@ApiOperation(value = "修改测试任务")
@PutMapping
@Caching(
put = {@CachePut(cacheNames = "testJobPageCache", key = "#result.body.data.id",
condition = "#p0 != null", unless = "#result.statusCodeValue != 200")
},
evict = {@CacheEvict(cacheNames = "testJobPageCache", allEntries = true)}
)
public ResponseEntity<CommonResultObj<TestJob>> updateTestTask(@RequestBody TestJob testJob) {
return CommonResult.pred(testJobService::updateById, testJob
, "修改成功", "修改失败");
......@@ -96,6 +136,7 @@ public class TestJobController {
*/
@ApiOperation(value = "根据主键id删除测试任务")
@DeleteMapping("/{id}")
@CacheEvict(cacheNames = "connectPageCache", allEntries = true, condition = "#p0 != null")
public ResponseEntity<CommonResultObj<Long>> deleteTestTask(@PathVariable Long id) {
return CommonResult.pred(testJobService::removeById, id
, "删除成功", "删除失败或id不存在");
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论