Skip to content

Commit

Permalink
refactor(测试计划): 优化权限&取消模块下计划名称唯一限制
Browse files Browse the repository at this point in the history
  • Loading branch information
WangXu10 authored and liuruibin committed May 11, 2024
1 parent 9aad091 commit 1c1d52f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 17 deletions.
Expand Up @@ -63,7 +63,7 @@ public TestPlanResourceSortResponse sortNode(@Validated @RequestBody ResourceSor

@PostMapping("/page")
@Operation(summary = "测试计划-已关联功能用例分页查询")
@RequiresPermissions(PermissionConstants.FUNCTIONAL_CASE_READ)
@RequiresPermissions(PermissionConstants.TEST_PLAN_READ)
@CheckOwner(resourceId = "#request.getTestPlanId()", resourceType = "test_plan")
public Pager<List<TestPlanCasePageResponse>> page(@Validated @RequestBody TestPlanCaseRequest request) {
Page<Object> page = PageHelper.startPage(request.getCurrent(), request.getPageSize());
Expand All @@ -73,15 +73,15 @@ public Pager<List<TestPlanCasePageResponse>> page(@Validated @RequestBody TestPl

@GetMapping("/tree/{testPlanId}")
@Operation(summary = "测试计划-已关联功能用例列表模块树")
@RequiresPermissions(PermissionConstants.CASE_REVIEW_READ)
@RequiresPermissions(PermissionConstants.TEST_PLAN_READ)
@CheckOwner(resourceId = "#testPlanId", resourceType = "test_plan")
public List<BaseTreeNode> getTree(@PathVariable String testPlanId) {
return testPlanFunctionalCaseService.getTree(testPlanId);
}

@PostMapping("/module/count")
@Operation(summary = "测试计划-已关联功能用例模块数量")
@RequiresPermissions(PermissionConstants.CASE_REVIEW_READ)
@RequiresPermissions(PermissionConstants.TEST_PLAN_READ)
@CheckOwner(resourceId = "#request.getTestPlanId()", resourceType = "test_plan")
public Map<String, Long> moduleCount(@Validated @RequestBody TestPlanCaseRequest request) {
return testPlanFunctionalCaseService.moduleCount(request);
Expand Down
Expand Up @@ -39,20 +39,6 @@ public void validateTestPlan(TestPlan testPlan) {
TestPlan group = testPlanMapper.selectByPrimaryKey(testPlan.getGroupId());
testPlan.setModuleId(group.getModuleId());
}
TestPlanExample example = new TestPlanExample();
if (StringUtils.isBlank(testPlan.getId())) {
//新建 校验
example.createCriteria().andNameEqualTo(testPlan.getName()).andProjectIdEqualTo(testPlan.getProjectId()).andModuleIdEqualTo(testPlan.getModuleId());
if (testPlanMapper.countByExample(example) > 0) {
throw new MSException(Translator.get("test_plan.name.exist") + ":" + testPlan.getName());
}
} else {
//更新 校验
example.createCriteria().andNameEqualTo(testPlan.getName()).andProjectIdEqualTo(testPlan.getProjectId()).andIdNotEqualTo(testPlan.getId()).andModuleIdEqualTo(testPlan.getModuleId());
if (testPlanMapper.countByExample(example) > 0) {
throw new MSException(Translator.get("test_plan.name.exist") + ":" + testPlan.getName());
}
}
}


Expand Down

0 comments on commit 1c1d52f

Please sign in to comment.