refactor(测试计划): 优化测试计划保存日志代码

This commit is contained in:
WangXu10 2024-05-28 14:05:00 +08:00 committed by Craftsman
parent dd2e1943da
commit 201bed2eb2
3 changed files with 8 additions and 9 deletions

View File

@ -179,7 +179,7 @@ public class TestPlanController {
public void association(@Validated @RequestBody TestPlanAssociationRequest request) {
testPlanManagementService.checkModuleIsOpen(request.getTestPlanId(), TestPlanResourceConfig.CHECK_TYPE_TEST_PLAN, Collections.singletonList(TestPlanResourceConfig.CONFIG_TEST_PLAN_FUNCTIONAL_CASE));
testPlanService.checkTestPlanNotArchived(request.getTestPlanId());
testPlanService.association(request);
testPlanService.association(request, SessionUtils.getUserId());
testPlanService.refreshTestPlanStatus(request.getTestPlanId());
}

View File

@ -16,7 +16,6 @@ import io.metersphere.sdk.util.Translator;
import io.metersphere.system.domain.TestPlanModuleExample;
import io.metersphere.system.dto.LogInsertModule;
import io.metersphere.system.mapper.TestPlanModuleMapper;
import io.metersphere.system.utils.SessionUtils;
import jakarta.annotation.Resource;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
@ -80,9 +79,9 @@ public class TestPlanBaseUtilsService {
* @param request
* @return
*/
public void association(TestPlanAssociationRequest request) {
public void association(TestPlanAssociationRequest request, String operator) {
TestPlan testPlan = testPlanMapper.selectByPrimaryKey(request.getTestPlanId());
handleAssociateCase(request, testPlan);
handleAssociateCase(request, operator, testPlan);
}
@ -92,9 +91,9 @@ public class TestPlanBaseUtilsService {
* @param request
* @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())
}
@ -104,11 +103,11 @@ public class TestPlanBaseUtilsService {
*
* @param functionalSelectIds
*/
private void handleFunctionalCase(List<String> functionalSelectIds, TestPlan testPlan) {
private void handleFunctionalCase(List<String> functionalSelectIds, String operator, TestPlan testPlan) {
if (CollectionUtils.isNotEmpty(functionalSelectIds)) {
TestPlanResourceAssociationParam associationParam = new TestPlanResourceAssociationParam(functionalSelectIds, testPlan.getProjectId(), testPlan.getId(), testPlan.getNum(), testPlan.getCreateUser());
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())));
}
}
}

View File

@ -128,7 +128,7 @@ public class TestPlanService extends TestPlanBaseUtilsService {
testPlanConfig.setTestPlanning(createOrCopyRequest.isTestPlanning());
if (StringUtils.isBlank(id)) {
handleAssociateCase(createOrCopyRequest.getBaseAssociateCaseRequest(), createTestPlan);
handleAssociateCase(createOrCopyRequest.getBaseAssociateCaseRequest(), operator, createTestPlan);
} else {
//复制
handleCopy(createTestPlan, id);