refactor(测试计划): 优化测试计划保存日志代码
This commit is contained in:
parent
dd2e1943da
commit
201bed2eb2
|
@ -179,7 +179,7 @@ public class TestPlanController {
|
||||||
public void association(@Validated @RequestBody TestPlanAssociationRequest request) {
|
public void association(@Validated @RequestBody TestPlanAssociationRequest request) {
|
||||||
testPlanManagementService.checkModuleIsOpen(request.getTestPlanId(), TestPlanResourceConfig.CHECK_TYPE_TEST_PLAN, Collections.singletonList(TestPlanResourceConfig.CONFIG_TEST_PLAN_FUNCTIONAL_CASE));
|
testPlanManagementService.checkModuleIsOpen(request.getTestPlanId(), TestPlanResourceConfig.CHECK_TYPE_TEST_PLAN, Collections.singletonList(TestPlanResourceConfig.CONFIG_TEST_PLAN_FUNCTIONAL_CASE));
|
||||||
testPlanService.checkTestPlanNotArchived(request.getTestPlanId());
|
testPlanService.checkTestPlanNotArchived(request.getTestPlanId());
|
||||||
testPlanService.association(request);
|
testPlanService.association(request, SessionUtils.getUserId());
|
||||||
testPlanService.refreshTestPlanStatus(request.getTestPlanId());
|
testPlanService.refreshTestPlanStatus(request.getTestPlanId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,6 @@ import io.metersphere.sdk.util.Translator;
|
||||||
import io.metersphere.system.domain.TestPlanModuleExample;
|
import io.metersphere.system.domain.TestPlanModuleExample;
|
||||||
import io.metersphere.system.dto.LogInsertModule;
|
import io.metersphere.system.dto.LogInsertModule;
|
||||||
import io.metersphere.system.mapper.TestPlanModuleMapper;
|
import io.metersphere.system.mapper.TestPlanModuleMapper;
|
||||||
import io.metersphere.system.utils.SessionUtils;
|
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
@ -80,9 +79,9 @@ public class TestPlanBaseUtilsService {
|
||||||
* @param request
|
* @param request
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public void association(TestPlanAssociationRequest request) {
|
public void association(TestPlanAssociationRequest request, String operator) {
|
||||||
TestPlan testPlan = testPlanMapper.selectByPrimaryKey(request.getTestPlanId());
|
TestPlan testPlan = testPlanMapper.selectByPrimaryKey(request.getTestPlanId());
|
||||||
handleAssociateCase(request, testPlan);
|
handleAssociateCase(request, operator, testPlan);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -92,9 +91,9 @@ public class TestPlanBaseUtilsService {
|
||||||
* @param request
|
* @param request
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public void handleAssociateCase(BaseAssociateCaseRequest request, TestPlan testPlan) {
|
public void handleAssociateCase(BaseAssociateCaseRequest request, String operator, TestPlan testPlan) {
|
||||||
//关联的功能用例
|
//关联的功能用例
|
||||||
handleFunctionalCase(request.getFunctionalSelectIds(), testPlan);
|
handleFunctionalCase(request.getFunctionalSelectIds(), operator, testPlan);
|
||||||
//TODO 关联接口用例/接口场景用例 handleApi(request.getApiSelectIds(),request.getApiCaseSelectIds())
|
//TODO 关联接口用例/接口场景用例 handleApi(request.getApiSelectIds(),request.getApiCaseSelectIds())
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -104,11 +103,11 @@ public class TestPlanBaseUtilsService {
|
||||||
*
|
*
|
||||||
* @param functionalSelectIds
|
* @param functionalSelectIds
|
||||||
*/
|
*/
|
||||||
private void handleFunctionalCase(List<String> functionalSelectIds, TestPlan testPlan) {
|
private void handleFunctionalCase(List<String> functionalSelectIds, String operator, TestPlan testPlan) {
|
||||||
if (CollectionUtils.isNotEmpty(functionalSelectIds)) {
|
if (CollectionUtils.isNotEmpty(functionalSelectIds)) {
|
||||||
TestPlanResourceAssociationParam associationParam = new TestPlanResourceAssociationParam(functionalSelectIds, testPlan.getProjectId(), testPlan.getId(), testPlan.getNum(), testPlan.getCreateUser());
|
TestPlanResourceAssociationParam associationParam = new TestPlanResourceAssociationParam(functionalSelectIds, testPlan.getProjectId(), testPlan.getId(), testPlan.getNum(), testPlan.getCreateUser());
|
||||||
testPlanCaseService.saveTestPlanResource(associationParam);
|
testPlanCaseService.saveTestPlanResource(associationParam);
|
||||||
testPlanResourceLogService.saveAddLog(testPlan, new ResourceLogInsertModule(TestPlanResourceConstants.RESOURCE_FUNCTIONAL_CASE, new LogInsertModule(SessionUtils.getUserId(), "/test-plan/association", HttpMethodConstants.POST.name())));
|
testPlanResourceLogService.saveAddLog(testPlan, new ResourceLogInsertModule(TestPlanResourceConstants.RESOURCE_FUNCTIONAL_CASE, new LogInsertModule(operator, "/test-plan/association", HttpMethodConstants.POST.name())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,7 +128,7 @@ public class TestPlanService extends TestPlanBaseUtilsService {
|
||||||
testPlanConfig.setTestPlanning(createOrCopyRequest.isTestPlanning());
|
testPlanConfig.setTestPlanning(createOrCopyRequest.isTestPlanning());
|
||||||
|
|
||||||
if (StringUtils.isBlank(id)) {
|
if (StringUtils.isBlank(id)) {
|
||||||
handleAssociateCase(createOrCopyRequest.getBaseAssociateCaseRequest(), createTestPlan);
|
handleAssociateCase(createOrCopyRequest.getBaseAssociateCaseRequest(), operator, createTestPlan);
|
||||||
} else {
|
} else {
|
||||||
//复制
|
//复制
|
||||||
handleCopy(createTestPlan, id);
|
handleCopy(createTestPlan, id);
|
||||||
|
|
Loading…
Reference in New Issue