refactor(测试计划): 优化权限&取消模块下计划名称唯一限制

This commit is contained in:
WangXu10 2024-05-11 17:23:52 +08:00 committed by 刘瑞斌
parent 9aad091459
commit 1c1d52f45f
2 changed files with 3 additions and 17 deletions

View File

@ -63,7 +63,7 @@ public class TestPlanFunctionalCaseController {
@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());
@ -73,7 +73,7 @@ public class TestPlanFunctionalCaseController {
@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);
@ -81,7 +81,7 @@ public class TestPlanFunctionalCaseController {
@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);

View File

@ -39,20 +39,6 @@ public class TestPlanBaseUtilsService {
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());
}
}
}