mirror of
https://gitee.com/fit2cloud-feizhiyun/MeterSphere.git
synced 2024-12-02 03:58:33 +08:00
fix(测试计划): 测试计划用例批量操作没有日志
--bug=1048219 --user=陈建星 【测试计划】测试计划-功能用例详情页批量修改执行人,没有日志记录 https://www.tapd.cn/55049933/s/1599739
This commit is contained in:
parent
a137e5f581
commit
b96a33622b
@ -136,4 +136,6 @@ test_plan.status.completed=已完成
|
||||
test_plan.status.success=成功
|
||||
test_plan.status.error=失败
|
||||
test_plan.status.prepared=未开始
|
||||
test_plan.status.underway=进行中
|
||||
test_plan.status.underway=进行中
|
||||
|
||||
test_plan.update.executor=修改执行人
|
||||
|
@ -140,4 +140,6 @@ test_plan.status.completed=Completed
|
||||
test_plan.status.success=Success
|
||||
test_plan.status.error=Error
|
||||
test_plan.status.prepared=Prepared
|
||||
test_plan.status.underway=Underway
|
||||
test_plan.status.underway=Underway
|
||||
|
||||
test_plan.update.executor=Modify the executor
|
||||
|
@ -140,4 +140,6 @@ test_plan.status.completed=已完成
|
||||
test_plan.status.success=成功
|
||||
test_plan.status.error=失败
|
||||
test_plan.status.prepared=未开始
|
||||
test_plan.status.underway=进行中
|
||||
test_plan.status.underway=进行中
|
||||
|
||||
test_plan.update.executor=修改执行人
|
||||
|
@ -139,4 +139,6 @@ test_plan.status.completed=已完成
|
||||
test_plan.status.success=成功
|
||||
test_plan.status.error=失敗
|
||||
test_plan.status.prepared=未開始
|
||||
test_plan.status.underway=進行中
|
||||
test_plan.status.underway=進行中
|
||||
|
||||
test_plan.update.executor=修改執行人
|
||||
|
@ -63,6 +63,8 @@ public class TestPlanApiCaseController {
|
||||
private BugService bugService;
|
||||
@Resource
|
||||
private BugLogService bugLogService;
|
||||
@Resource
|
||||
private TestPlanApiCaseLogService testPlanApiCaseLogService;
|
||||
|
||||
@PostMapping(value = "/sort")
|
||||
@Operation(summary = "测试计划功能用例-功能用例拖拽排序")
|
||||
@ -129,9 +131,9 @@ public class TestPlanApiCaseController {
|
||||
@Operation(summary = "测试计划-计划详情-接口用例列表-批量更新执行人")
|
||||
@RequiresPermissions(PermissionConstants.TEST_PLAN_READ_UPDATE)
|
||||
@CheckOwner(resourceId = "#request.getTestPlanId()", resourceType = "test_plan")
|
||||
@Log(type = OperationLogType.UPDATE, expression = "#msClass.batchUpdateExecutor(#request)", msClass = TestPlanApiCaseLogService.class)
|
||||
public void batchUpdateExecutor(@Validated @RequestBody TestPlanApiCaseUpdateRequest request) {
|
||||
testPlanApiCaseService.batchUpdateExecutor(request);
|
||||
testPlanApiCaseLogService.batchUpdateExecutor(request);
|
||||
}
|
||||
|
||||
@GetMapping("/run/{id}")
|
||||
@ -179,9 +181,9 @@ public class TestPlanApiCaseController {
|
||||
@Operation(summary = "测试计划-计划详情-接口用例-批量移动")
|
||||
@RequiresPermissions(PermissionConstants.TEST_PLAN_READ_UPDATE)
|
||||
@CheckOwner(resourceId = "#request.getTestPlanId()", resourceType = "test_plan")
|
||||
@Log(type = OperationLogType.UPDATE, expression = "#msClass.batchMove(#request)", msClass = TestPlanApiCaseLogService.class)
|
||||
public void batchMove(@Validated @RequestBody TestPlanApiCaseBatchMoveRequest request) {
|
||||
testPlanApiCaseService.batchMove(request);
|
||||
testPlanApiCaseLogService.batchMove(request, SessionUtils.getUserId());
|
||||
}
|
||||
|
||||
@PostMapping("/associate/bug/page")
|
||||
|
@ -60,6 +60,8 @@ public class TestPlanApiScenarioController {
|
||||
private BugService bugService;
|
||||
@Resource
|
||||
private BugLogService bugLogService;
|
||||
@Resource
|
||||
private TestPlanApiScenarioLogService testPlanApiScenarioLogService;
|
||||
|
||||
@PostMapping("/page")
|
||||
@Operation(summary = "测试计划-已关联场景用例列表分页查询")
|
||||
@ -129,9 +131,9 @@ public class TestPlanApiScenarioController {
|
||||
@Operation(summary = "测试计划-计划详情-场景用例列表-批量更新执行人")
|
||||
@RequiresPermissions(PermissionConstants.TEST_PLAN_READ_UPDATE)
|
||||
@CheckOwner(resourceId = "#request.getTestPlanId()", resourceType = "test_plan")
|
||||
@Log(type = OperationLogType.UPDATE, expression = "#msClass.batchUpdateExecutor(#request)", msClass = TestPlanApiScenarioLogService.class)
|
||||
public void batchUpdateExecutor(@Validated @RequestBody TestPlanApiScenarioUpdateRequest request) {
|
||||
testPlanApiScenarioService.batchUpdateExecutor(request);
|
||||
testPlanApiScenarioLogService.batchUpdateExecutor(request);
|
||||
}
|
||||
|
||||
@GetMapping("/report/get/{id}")
|
||||
@ -164,9 +166,9 @@ public class TestPlanApiScenarioController {
|
||||
@Operation(summary = "测试计划-计划详情-场景用例-批量移动")
|
||||
@RequiresPermissions(PermissionConstants.TEST_PLAN_READ_UPDATE)
|
||||
@CheckOwner(resourceId = "#request.getTestPlanId()", resourceType = "test_plan")
|
||||
@Log(type = OperationLogType.UPDATE, expression = "#msClass.batchMove(#request)", msClass = TestPlanApiScenarioLogService.class)
|
||||
public void batchMove(@Validated @RequestBody BaseBatchMoveRequest request) {
|
||||
testPlanApiScenarioService.batchMove(request);
|
||||
testPlanApiScenarioLogService.batchMove(request, SessionUtils.getUserId());
|
||||
}
|
||||
|
||||
@PostMapping("/associate/bug/page")
|
||||
|
@ -55,6 +55,8 @@ public class TestPlanFunctionalCaseController {
|
||||
@Resource
|
||||
private TestPlanFunctionalCaseService testPlanFunctionalCaseService;
|
||||
@Resource
|
||||
private TestPlanCaseLogService testPlanCaseLogService;
|
||||
@Resource
|
||||
private BugService bugService;
|
||||
@Resource
|
||||
private BugLogService bugLogService;
|
||||
@ -74,7 +76,6 @@ public class TestPlanFunctionalCaseController {
|
||||
public Pager<List<TestPlanCasePageResponse>> page(@Validated @RequestBody TestPlanCaseRequest request) {
|
||||
Page<Object> page = PageHelper.startPage(request.getCurrent(), request.getPageSize(),
|
||||
StringUtils.isNotBlank(request.getSortString("id", "functional_case")) ? request.getSortString("id", "functional_case") : "test_plan_functional_case.pos desc");
|
||||
|
||||
return PageUtils.setPageInfo(page, testPlanFunctionalCaseService.getFunctionalCasePage(request, false, SessionUtils.getCurrentProjectId()));
|
||||
}
|
||||
|
||||
@ -173,9 +174,9 @@ public class TestPlanFunctionalCaseController {
|
||||
@Operation(summary = "测试计划-计划详情-功能用例-批量更新执行人")
|
||||
@RequiresPermissions(PermissionConstants.TEST_PLAN_READ_UPDATE)
|
||||
@CheckOwner(resourceId = "#request.getTestPlanId()", resourceType = "test_plan")
|
||||
@Log(type = OperationLogType.UPDATE, expression = "#msClass.batchUpdateExecutor(#request)", msClass = TestPlanCaseLogService.class)
|
||||
public void batchUpdateExecutor(@Validated @RequestBody TestPlanCaseUpdateRequest request) {
|
||||
testPlanFunctionalCaseService.batchUpdateExecutor(request);
|
||||
testPlanCaseLogService.batchUpdateExecutor(request);
|
||||
}
|
||||
|
||||
@GetMapping("/detail/{id}")
|
||||
@ -207,9 +208,9 @@ public class TestPlanFunctionalCaseController {
|
||||
@Operation(summary = "测试计划-计划详情-功能用例-批量移动")
|
||||
@RequiresPermissions(PermissionConstants.TEST_PLAN_READ_UPDATE)
|
||||
@CheckOwner(resourceId = "#request.getTestPlanId()", resourceType = "test_plan")
|
||||
@Log(type = OperationLogType.UPDATE, expression = "#msClass.batchMove(#request)", msClass = TestPlanCaseLogService.class)
|
||||
public void batchMove(@Validated @RequestBody BaseBatchMoveRequest request) {
|
||||
testPlanFunctionalCaseService.batchMove(request);
|
||||
testPlanCaseLogService.batchMove(request, SessionUtils.getUserId());
|
||||
}
|
||||
|
||||
|
||||
|
@ -3,17 +3,23 @@ package io.metersphere.plan.service;
|
||||
import io.metersphere.api.domain.ApiTestCase;
|
||||
import io.metersphere.api.domain.ApiTestCaseExample;
|
||||
import io.metersphere.api.mapper.ApiTestCaseMapper;
|
||||
import io.metersphere.plan.domain.TestPlan;
|
||||
import io.metersphere.plan.domain.TestPlanApiCase;
|
||||
import io.metersphere.plan.domain.TestPlanApiCaseExample;
|
||||
import io.metersphere.plan.dto.request.TestPlanApiCaseBatchMoveRequest;
|
||||
import io.metersphere.plan.dto.request.TestPlanApiCaseUpdateRequest;
|
||||
import io.metersphere.plan.mapper.TestPlanApiCaseMapper;
|
||||
import io.metersphere.plan.mapper.TestPlanMapper;
|
||||
import io.metersphere.project.domain.Project;
|
||||
import io.metersphere.project.mapper.ProjectMapper;
|
||||
import io.metersphere.sdk.constants.HttpMethodConstants;
|
||||
import io.metersphere.sdk.util.JSON;
|
||||
import io.metersphere.sdk.util.LogUtils;
|
||||
import io.metersphere.sdk.util.Translator;
|
||||
import io.metersphere.system.log.constants.OperationLogModule;
|
||||
import io.metersphere.system.log.constants.OperationLogType;
|
||||
import io.metersphere.system.log.dto.LogDTO;
|
||||
import io.metersphere.system.log.service.OperationLogService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -34,69 +40,89 @@ public class TestPlanApiCaseLogService {
|
||||
private TestPlanApiCaseMapper testPlanApiCaseMapper;
|
||||
@Resource
|
||||
private ApiTestCaseMapper apiTestCaseMapper;
|
||||
@Resource
|
||||
private TestPlanMapper testPlanMapper;
|
||||
@Resource
|
||||
private ProjectMapper projectMapper;
|
||||
@Resource
|
||||
private OperationLogService operationLogService;
|
||||
|
||||
public void batchUpdateExecutor(TestPlanApiCaseUpdateRequest request) {
|
||||
List<String> ids = testPlanApiCaseService.doSelectIds(request);
|
||||
if (CollectionUtils.isNotEmpty(ids)) {
|
||||
TestPlanApiCaseExample example = new TestPlanApiCaseExample();
|
||||
example.createCriteria().andIdIn(ids);
|
||||
List<TestPlanApiCase> planCaseList = testPlanApiCaseMapper.selectByExample(example);
|
||||
Map<String, String> userMap = planCaseList.stream().collect(Collectors.toMap(TestPlanApiCase::getId, TestPlanApiCase::getExecuteUser));
|
||||
Map<String, String> idsMap = planCaseList.stream().collect(Collectors.toMap(TestPlanApiCase::getId, TestPlanApiCase::getApiCaseId));
|
||||
List<String> caseIds = planCaseList.stream().map(TestPlanApiCase::getApiCaseId).collect(Collectors.toList());
|
||||
ApiTestCaseExample caseExample = new ApiTestCaseExample();
|
||||
caseExample.createCriteria().andIdIn(caseIds);
|
||||
List<ApiTestCase> functionalCases = apiTestCaseMapper.selectByExample(caseExample);
|
||||
Map<String, String> caseMap = functionalCases.stream().collect(Collectors.toMap(ApiTestCase::getId, ApiTestCase::getName));
|
||||
List<LogDTO> dtoList = new ArrayList<>();
|
||||
idsMap.forEach((k, v) -> {
|
||||
LogDTO dto = new LogDTO(
|
||||
null,
|
||||
null,
|
||||
k,
|
||||
null,
|
||||
OperationLogType.UPDATE.name(),
|
||||
OperationLogModule.TEST_PLAN,
|
||||
caseMap.get(v));
|
||||
dto.setPath("/test-plan/api/case/batch/update/executor");
|
||||
dto.setMethod(HttpMethodConstants.POST.name());
|
||||
dto.setOriginalValue(JSON.toJSONBytes(userMap.get(k)));
|
||||
dto.setModifiedValue(JSON.toJSONBytes(request.getUserId()));
|
||||
dtoList.add(dto);
|
||||
});
|
||||
try {
|
||||
List<String> ids = testPlanApiCaseService.doSelectIds(request);
|
||||
if (CollectionUtils.isNotEmpty(ids)) {
|
||||
TestPlan testPlan = testPlanMapper.selectByPrimaryKey(request.getTestPlanId());
|
||||
Project project = projectMapper.selectByPrimaryKey(testPlan.getProjectId());
|
||||
TestPlanApiCaseExample example = new TestPlanApiCaseExample();
|
||||
example.createCriteria().andIdIn(ids);
|
||||
List<TestPlanApiCase> planCaseList = testPlanApiCaseMapper.selectByExample(example);
|
||||
Map<String, String> userMap = planCaseList.stream().collect(Collectors.toMap(TestPlanApiCase::getId, TestPlanApiCase::getExecuteUser));
|
||||
Map<String, String> idsMap = planCaseList.stream().collect(Collectors.toMap(TestPlanApiCase::getId, TestPlanApiCase::getApiCaseId));
|
||||
List<String> caseIds = planCaseList.stream().map(TestPlanApiCase::getApiCaseId).collect(Collectors.toList());
|
||||
ApiTestCaseExample caseExample = new ApiTestCaseExample();
|
||||
caseExample.createCriteria().andIdIn(caseIds);
|
||||
List<ApiTestCase> functionalCases = apiTestCaseMapper.selectByExample(caseExample);
|
||||
Map<String, String> caseMap = functionalCases.stream().collect(Collectors.toMap(ApiTestCase::getId, ApiTestCase::getName));
|
||||
List<LogDTO> dtoList = new ArrayList<>();
|
||||
idsMap.forEach((k, v) -> {
|
||||
LogDTO dto = new LogDTO(
|
||||
project.getId(),
|
||||
project.getOrganizationId(),
|
||||
k,
|
||||
request.getUserId(),
|
||||
OperationLogType.UPDATE.name(),
|
||||
OperationLogModule.TEST_PLAN,
|
||||
Translator.get("test_plan.update.executor") + ":" + caseMap.get(v));
|
||||
dto.setPath("/test-plan/api/case/batch/update/executor");
|
||||
dto.setMethod(HttpMethodConstants.POST.name());
|
||||
dto.setOriginalValue(JSON.toJSONBytes(userMap.get(k)));
|
||||
dto.setModifiedValue(JSON.toJSONBytes(request.getUserId()));
|
||||
dtoList.add(dto);
|
||||
});
|
||||
operationLogService.batchAdd(dtoList);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogUtils.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void batchMove(TestPlanApiCaseBatchMoveRequest request) {
|
||||
List<String> ids = testPlanApiCaseService.doSelectIds(request);
|
||||
if (CollectionUtils.isNotEmpty(ids)) {
|
||||
TestPlanApiCaseExample example = new TestPlanApiCaseExample();
|
||||
example.createCriteria().andIdIn(ids);
|
||||
List<TestPlanApiCase> caseList = testPlanApiCaseMapper.selectByExample(example);
|
||||
List<String> apiCaseIds = caseList.stream().map(TestPlanApiCase::getApiCaseId).collect(Collectors.toList());
|
||||
ApiTestCaseExample caseExample = new ApiTestCaseExample();
|
||||
caseExample.createCriteria().andIdIn(apiCaseIds);
|
||||
List<ApiTestCase> apiTestCases = apiTestCaseMapper.selectByExample(caseExample);
|
||||
Map<String, String> caseMap = apiTestCases.stream().collect(Collectors.toMap(ApiTestCase::getId, ApiTestCase::getName));
|
||||
List<LogDTO> dtoList = new ArrayList<>();
|
||||
caseList.forEach(item -> {
|
||||
LogDTO dto = new LogDTO(
|
||||
null,
|
||||
null,
|
||||
item.getApiCaseId(),
|
||||
null,
|
||||
OperationLogType.UPDATE.name(),
|
||||
OperationLogModule.TEST_PLAN,
|
||||
Translator.get("move") + ":" + caseMap.get(item.getApiCaseId()));
|
||||
dto.setPath("/test-plan/api/case/batch/move");
|
||||
dto.setMethod(HttpMethodConstants.POST.name());
|
||||
dto.setOriginalValue(JSON.toJSONBytes(item));
|
||||
TestPlanApiCase testPlanApiCase = new TestPlanApiCase();
|
||||
testPlanApiCase.setId(item.getId());
|
||||
testPlanApiCase.setTestPlanCollectionId(request.getTargetCollectionId());
|
||||
dto.setModifiedValue(JSON.toJSONBytes(testPlanApiCase));
|
||||
dtoList.add(dto);
|
||||
});
|
||||
public void batchMove(TestPlanApiCaseBatchMoveRequest request, String userId) {
|
||||
try {
|
||||
List<String> ids = testPlanApiCaseService.doSelectIds(request);
|
||||
if (CollectionUtils.isNotEmpty(ids)) {
|
||||
TestPlan testPlan = testPlanMapper.selectByPrimaryKey(request.getTestPlanId());
|
||||
Project project = projectMapper.selectByPrimaryKey(testPlan.getProjectId());
|
||||
TestPlanApiCaseExample example = new TestPlanApiCaseExample();
|
||||
example.createCriteria().andIdIn(ids);
|
||||
List<TestPlanApiCase> caseList = testPlanApiCaseMapper.selectByExample(example);
|
||||
List<String> apiCaseIds = caseList.stream().map(TestPlanApiCase::getApiCaseId).collect(Collectors.toList());
|
||||
ApiTestCaseExample caseExample = new ApiTestCaseExample();
|
||||
caseExample.createCriteria().andIdIn(apiCaseIds);
|
||||
List<ApiTestCase> apiTestCases = apiTestCaseMapper.selectByExample(caseExample);
|
||||
Map<String, String> caseMap = apiTestCases.stream().collect(Collectors.toMap(ApiTestCase::getId, ApiTestCase::getName));
|
||||
List<LogDTO> dtoList = new ArrayList<>();
|
||||
caseList.forEach(item -> {
|
||||
LogDTO dto = new LogDTO(
|
||||
project.getId(),
|
||||
project.getOrganizationId(),
|
||||
item.getApiCaseId(),
|
||||
userId,
|
||||
OperationLogType.UPDATE.name(),
|
||||
OperationLogModule.TEST_PLAN,
|
||||
Translator.get("move") + ":" + caseMap.get(item.getApiCaseId()));
|
||||
dto.setPath("/test-plan/api/case/batch/move");
|
||||
dto.setMethod(HttpMethodConstants.POST.name());
|
||||
dto.setOriginalValue(JSON.toJSONBytes(item));
|
||||
TestPlanApiCase testPlanApiCase = new TestPlanApiCase();
|
||||
testPlanApiCase.setId(item.getId());
|
||||
testPlanApiCase.setTestPlanCollectionId(request.getTargetCollectionId());
|
||||
dto.setModifiedValue(JSON.toJSONBytes(testPlanApiCase));
|
||||
dtoList.add(dto);
|
||||
});
|
||||
operationLogService.batchAdd(dtoList);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogUtils.error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,17 +3,23 @@ package io.metersphere.plan.service;
|
||||
import io.metersphere.api.domain.ApiScenario;
|
||||
import io.metersphere.api.domain.ApiScenarioExample;
|
||||
import io.metersphere.api.mapper.ApiScenarioMapper;
|
||||
import io.metersphere.plan.domain.TestPlan;
|
||||
import io.metersphere.plan.domain.TestPlanApiScenario;
|
||||
import io.metersphere.plan.domain.TestPlanApiScenarioExample;
|
||||
import io.metersphere.plan.dto.request.BaseBatchMoveRequest;
|
||||
import io.metersphere.plan.dto.request.TestPlanApiScenarioUpdateRequest;
|
||||
import io.metersphere.plan.mapper.TestPlanApiScenarioMapper;
|
||||
import io.metersphere.plan.mapper.TestPlanMapper;
|
||||
import io.metersphere.project.domain.Project;
|
||||
import io.metersphere.project.mapper.ProjectMapper;
|
||||
import io.metersphere.sdk.constants.HttpMethodConstants;
|
||||
import io.metersphere.sdk.util.JSON;
|
||||
import io.metersphere.sdk.util.LogUtils;
|
||||
import io.metersphere.sdk.util.Translator;
|
||||
import io.metersphere.system.log.constants.OperationLogModule;
|
||||
import io.metersphere.system.log.constants.OperationLogType;
|
||||
import io.metersphere.system.log.dto.LogDTO;
|
||||
import io.metersphere.system.log.service.OperationLogService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -34,70 +40,89 @@ public class TestPlanApiScenarioLogService {
|
||||
private TestPlanApiScenarioMapper testPlanApiScenarioMapper;
|
||||
@Resource
|
||||
private ApiScenarioMapper apiScenarioMapper;
|
||||
@Resource
|
||||
private TestPlanMapper testPlanMapper;
|
||||
@Resource
|
||||
private ProjectMapper projectMapper;
|
||||
@Resource
|
||||
private OperationLogService operationLogService;
|
||||
|
||||
|
||||
public void batchUpdateExecutor(TestPlanApiScenarioUpdateRequest request) {
|
||||
List<String> ids = testPlanApiScenarioService.doSelectIds(request);
|
||||
if (CollectionUtils.isNotEmpty(ids)) {
|
||||
TestPlanApiScenarioExample example = new TestPlanApiScenarioExample();
|
||||
example.createCriteria().andIdIn(ids);
|
||||
List<TestPlanApiScenario> planApiScenarioList = testPlanApiScenarioMapper.selectByExample(example);
|
||||
Map<String, String> userMap = planApiScenarioList.stream().collect(Collectors.toMap(TestPlanApiScenario::getId, TestPlanApiScenario::getExecuteUser));
|
||||
Map<String, String> idsMap = planApiScenarioList.stream().collect(Collectors.toMap(TestPlanApiScenario::getId, TestPlanApiScenario::getApiScenarioId));
|
||||
List<String> scenarioIds = planApiScenarioList.stream().map(TestPlanApiScenario::getApiScenarioId).collect(Collectors.toList());
|
||||
ApiScenarioExample scenarioExample = new ApiScenarioExample();
|
||||
scenarioExample.createCriteria().andIdIn(scenarioIds);
|
||||
List<ApiScenario> apiScenarios = apiScenarioMapper.selectByExample(scenarioExample);
|
||||
Map<String, String> caseMap = apiScenarios.stream().collect(Collectors.toMap(ApiScenario::getId, ApiScenario::getName));
|
||||
List<LogDTO> dtoList = new ArrayList<>();
|
||||
idsMap.forEach((k, v) -> {
|
||||
LogDTO dto = new LogDTO(
|
||||
null,
|
||||
null,
|
||||
k,
|
||||
null,
|
||||
OperationLogType.UPDATE.name(),
|
||||
OperationLogModule.TEST_PLAN,
|
||||
caseMap.get(v));
|
||||
dto.setPath("/test-plan/api/scenario/batch/update/executor");
|
||||
dto.setMethod(HttpMethodConstants.POST.name());
|
||||
dto.setOriginalValue(JSON.toJSONBytes(userMap.get(k)));
|
||||
dto.setModifiedValue(JSON.toJSONBytes(request.getUserId()));
|
||||
dtoList.add(dto);
|
||||
});
|
||||
try {
|
||||
List<String> ids = testPlanApiScenarioService.doSelectIds(request);
|
||||
if (CollectionUtils.isNotEmpty(ids)) {
|
||||
TestPlan testPlan = testPlanMapper.selectByPrimaryKey(request.getTestPlanId());
|
||||
Project project = projectMapper.selectByPrimaryKey(testPlan.getProjectId());
|
||||
TestPlanApiScenarioExample example = new TestPlanApiScenarioExample();
|
||||
example.createCriteria().andIdIn(ids);
|
||||
List<TestPlanApiScenario> planApiScenarioList = testPlanApiScenarioMapper.selectByExample(example);
|
||||
Map<String, String> userMap = planApiScenarioList.stream().collect(Collectors.toMap(TestPlanApiScenario::getId, TestPlanApiScenario::getExecuteUser));
|
||||
Map<String, String> idsMap = planApiScenarioList.stream().collect(Collectors.toMap(TestPlanApiScenario::getId, TestPlanApiScenario::getApiScenarioId));
|
||||
List<String> scenarioIds = planApiScenarioList.stream().map(TestPlanApiScenario::getApiScenarioId).collect(Collectors.toList());
|
||||
ApiScenarioExample scenarioExample = new ApiScenarioExample();
|
||||
scenarioExample.createCriteria().andIdIn(scenarioIds);
|
||||
List<ApiScenario> apiScenarios = apiScenarioMapper.selectByExample(scenarioExample);
|
||||
Map<String, String> caseMap = apiScenarios.stream().collect(Collectors.toMap(ApiScenario::getId, ApiScenario::getName));
|
||||
List<LogDTO> dtoList = new ArrayList<>();
|
||||
idsMap.forEach((k, v) -> {
|
||||
LogDTO dto = new LogDTO(
|
||||
project.getId(),
|
||||
project.getOrganizationId(),
|
||||
k,
|
||||
request.getUserId(),
|
||||
OperationLogType.UPDATE.name(),
|
||||
OperationLogModule.TEST_PLAN,
|
||||
Translator.get("test_plan.update.executor") + ":" + caseMap.get(v));
|
||||
dto.setPath("/test-plan/api/scenario/batch/update/executor");
|
||||
dto.setMethod(HttpMethodConstants.POST.name());
|
||||
dto.setOriginalValue(JSON.toJSONBytes(userMap.get(k)));
|
||||
dto.setModifiedValue(JSON.toJSONBytes(request.getUserId()));
|
||||
dtoList.add(dto);
|
||||
});
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogUtils.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void batchMove(BaseBatchMoveRequest request) {
|
||||
List<String> ids = testPlanApiScenarioService.doSelectIds(request);
|
||||
if (CollectionUtils.isNotEmpty(ids)) {
|
||||
TestPlanApiScenarioExample example = new TestPlanApiScenarioExample();
|
||||
example.createCriteria().andIdIn(ids);
|
||||
List<TestPlanApiScenario> caseList = testPlanApiScenarioMapper.selectByExample(example);
|
||||
List<String> apiScenarioIds = caseList.stream().map(TestPlanApiScenario::getApiScenarioId).collect(Collectors.toList());
|
||||
ApiScenarioExample scenarioExample = new ApiScenarioExample();
|
||||
scenarioExample.createCriteria().andIdIn(apiScenarioIds);
|
||||
List<ApiScenario> apiScenarios = apiScenarioMapper.selectByExample(scenarioExample);
|
||||
Map<String, String> caseMap = apiScenarios.stream().collect(Collectors.toMap(ApiScenario::getId, ApiScenario::getName));
|
||||
List<LogDTO> dtoList = new ArrayList<>();
|
||||
caseList.forEach(item -> {
|
||||
LogDTO dto = new LogDTO(
|
||||
null,
|
||||
null,
|
||||
item.getApiScenarioId(),
|
||||
null,
|
||||
OperationLogType.UPDATE.name(),
|
||||
OperationLogModule.TEST_PLAN,
|
||||
Translator.get("move") + ":" + caseMap.get(item.getApiScenarioId()));
|
||||
dto.setPath("/test-plan/api/scenario/batch/move");
|
||||
dto.setMethod(HttpMethodConstants.POST.name());
|
||||
dto.setOriginalValue(JSON.toJSONBytes(item));
|
||||
TestPlanApiScenario testPlanApiScenario = new TestPlanApiScenario();
|
||||
testPlanApiScenario.setId(item.getId());
|
||||
testPlanApiScenario.setTestPlanCollectionId(request.getTargetCollectionId());
|
||||
dto.setModifiedValue(JSON.toJSONBytes(testPlanApiScenario));
|
||||
dtoList.add(dto);
|
||||
});
|
||||
|
||||
public void batchMove(BaseBatchMoveRequest request, String userId) {
|
||||
try {
|
||||
List<String> ids = testPlanApiScenarioService.doSelectIds(request);
|
||||
if (CollectionUtils.isNotEmpty(ids)) {
|
||||
TestPlan testPlan = testPlanMapper.selectByPrimaryKey(request.getTestPlanId());
|
||||
Project project = projectMapper.selectByPrimaryKey(testPlan.getProjectId());
|
||||
TestPlanApiScenarioExample example = new TestPlanApiScenarioExample();
|
||||
example.createCriteria().andIdIn(ids);
|
||||
List<TestPlanApiScenario> caseList = testPlanApiScenarioMapper.selectByExample(example);
|
||||
List<String> apiScenarioIds = caseList.stream().map(TestPlanApiScenario::getApiScenarioId).collect(Collectors.toList());
|
||||
ApiScenarioExample scenarioExample = new ApiScenarioExample();
|
||||
scenarioExample.createCriteria().andIdIn(apiScenarioIds);
|
||||
List<ApiScenario> apiScenarios = apiScenarioMapper.selectByExample(scenarioExample);
|
||||
Map<String, String> caseMap = apiScenarios.stream().collect(Collectors.toMap(ApiScenario::getId, ApiScenario::getName));
|
||||
List<LogDTO> dtoList = new ArrayList<>();
|
||||
caseList.forEach(item -> {
|
||||
LogDTO dto = new LogDTO(
|
||||
project.getId(),
|
||||
project.getOrganizationId(),
|
||||
item.getApiScenarioId(),
|
||||
userId,
|
||||
OperationLogType.UPDATE.name(),
|
||||
OperationLogModule.TEST_PLAN,
|
||||
Translator.get("move") + ":" + caseMap.get(item.getApiScenarioId()));
|
||||
dto.setPath("/test-plan/api/scenario/batch/move");
|
||||
dto.setMethod(HttpMethodConstants.POST.name());
|
||||
dto.setOriginalValue(JSON.toJSONBytes(item));
|
||||
TestPlanApiScenario testPlanApiScenario = new TestPlanApiScenario();
|
||||
testPlanApiScenario.setId(item.getId());
|
||||
testPlanApiScenario.setTestPlanCollectionId(request.getTargetCollectionId());
|
||||
dto.setModifiedValue(JSON.toJSONBytes(testPlanApiScenario));
|
||||
dtoList.add(dto);
|
||||
});
|
||||
operationLogService.batchAdd(dtoList);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogUtils.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,17 +3,23 @@ package io.metersphere.plan.service;
|
||||
import io.metersphere.functional.domain.FunctionalCase;
|
||||
import io.metersphere.functional.domain.FunctionalCaseExample;
|
||||
import io.metersphere.functional.mapper.FunctionalCaseMapper;
|
||||
import io.metersphere.plan.domain.TestPlan;
|
||||
import io.metersphere.plan.domain.TestPlanFunctionalCase;
|
||||
import io.metersphere.plan.domain.TestPlanFunctionalCaseExample;
|
||||
import io.metersphere.plan.dto.request.BaseBatchMoveRequest;
|
||||
import io.metersphere.plan.dto.request.TestPlanCaseUpdateRequest;
|
||||
import io.metersphere.plan.mapper.TestPlanFunctionalCaseMapper;
|
||||
import io.metersphere.plan.mapper.TestPlanMapper;
|
||||
import io.metersphere.project.domain.Project;
|
||||
import io.metersphere.project.mapper.ProjectMapper;
|
||||
import io.metersphere.sdk.constants.HttpMethodConstants;
|
||||
import io.metersphere.sdk.util.JSON;
|
||||
import io.metersphere.sdk.util.LogUtils;
|
||||
import io.metersphere.sdk.util.Translator;
|
||||
import io.metersphere.system.log.constants.OperationLogModule;
|
||||
import io.metersphere.system.log.constants.OperationLogType;
|
||||
import io.metersphere.system.log.dto.LogDTO;
|
||||
import io.metersphere.system.log.service.OperationLogService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -34,70 +40,90 @@ public class TestPlanCaseLogService {
|
||||
private TestPlanFunctionalCaseMapper testPlanFunctionalCaseMapper;
|
||||
@Resource
|
||||
private FunctionalCaseMapper functionalCaseMapper;
|
||||
@Resource
|
||||
private OperationLogService operationLogService;
|
||||
@Resource
|
||||
private ProjectMapper projectMapper;
|
||||
@Resource
|
||||
private TestPlanMapper testPlanMapper;
|
||||
|
||||
public void batchUpdateExecutor(TestPlanCaseUpdateRequest request) {
|
||||
List<String> ids = testPlanFunctionalCaseService.doSelectIds(request);
|
||||
if (CollectionUtils.isNotEmpty(ids)) {
|
||||
TestPlanFunctionalCaseExample example = new TestPlanFunctionalCaseExample();
|
||||
example.createCriteria().andIdIn(ids);
|
||||
List<TestPlanFunctionalCase> planCaseList = testPlanFunctionalCaseMapper.selectByExample(example);
|
||||
Map<String, String> userMap = planCaseList.stream().collect(Collectors.toMap(TestPlanFunctionalCase::getId, TestPlanFunctionalCase::getExecuteUser));
|
||||
Map<String, String> idsMap = planCaseList.stream().collect(Collectors.toMap(TestPlanFunctionalCase::getId, TestPlanFunctionalCase::getFunctionalCaseId));
|
||||
List<String> caseIds = planCaseList.stream().map(TestPlanFunctionalCase::getFunctionalCaseId).collect(Collectors.toList());
|
||||
FunctionalCaseExample caseExample = new FunctionalCaseExample();
|
||||
caseExample.createCriteria().andIdIn(caseIds);
|
||||
List<FunctionalCase> functionalCases = functionalCaseMapper.selectByExample(caseExample);
|
||||
Map<String, String> caseMap = functionalCases.stream().collect(Collectors.toMap(FunctionalCase::getId, FunctionalCase::getName));
|
||||
List<LogDTO> dtoList = new ArrayList<>();
|
||||
idsMap.forEach((k, v) -> {
|
||||
LogDTO dto = new LogDTO(
|
||||
null,
|
||||
null,
|
||||
k,
|
||||
null,
|
||||
OperationLogType.UPDATE.name(),
|
||||
OperationLogModule.TEST_PLAN,
|
||||
caseMap.get(v));
|
||||
dto.setPath("/test-plan/functional/case/batch/update/executor");
|
||||
dto.setMethod(HttpMethodConstants.POST.name());
|
||||
dto.setOriginalValue(JSON.toJSONBytes(userMap.get(k)));
|
||||
dto.setModifiedValue(JSON.toJSONBytes(request.getUserId()));
|
||||
dtoList.add(dto);
|
||||
});
|
||||
try {
|
||||
List<String> ids = testPlanFunctionalCaseService.doSelectIds(request);
|
||||
if (CollectionUtils.isNotEmpty(ids)) {
|
||||
TestPlan testPlan = testPlanMapper.selectByPrimaryKey(request.getTestPlanId());
|
||||
Project project = projectMapper.selectByPrimaryKey(testPlan.getProjectId());
|
||||
TestPlanFunctionalCaseExample example = new TestPlanFunctionalCaseExample();
|
||||
example.createCriteria().andIdIn(ids);
|
||||
List<TestPlanFunctionalCase> planCaseList = testPlanFunctionalCaseMapper.selectByExample(example);
|
||||
Map<String, String> userMap = planCaseList.stream().collect(Collectors.toMap(TestPlanFunctionalCase::getId, TestPlanFunctionalCase::getExecuteUser));
|
||||
Map<String, String> idsMap = planCaseList.stream().collect(Collectors.toMap(TestPlanFunctionalCase::getId, TestPlanFunctionalCase::getFunctionalCaseId));
|
||||
List<String> caseIds = planCaseList.stream().map(TestPlanFunctionalCase::getFunctionalCaseId).collect(Collectors.toList());
|
||||
FunctionalCaseExample caseExample = new FunctionalCaseExample();
|
||||
caseExample.createCriteria().andIdIn(caseIds);
|
||||
List<FunctionalCase> functionalCases = functionalCaseMapper.selectByExample(caseExample);
|
||||
Map<String, String> caseMap = functionalCases.stream().collect(Collectors.toMap(FunctionalCase::getId, FunctionalCase::getName));
|
||||
List<LogDTO> dtoList = new ArrayList<>();
|
||||
idsMap.forEach((k, v) -> {
|
||||
LogDTO dto = new LogDTO(
|
||||
project.getId(),
|
||||
project.getOrganizationId(),
|
||||
k,
|
||||
request.getUserId(),
|
||||
OperationLogType.UPDATE.name(),
|
||||
OperationLogModule.TEST_PLAN,
|
||||
Translator.get("test_plan.update.executor") + ":" + caseMap.get(v));
|
||||
dto.setPath("/test-plan/functional/case/batch/update/executor");
|
||||
dto.setMethod(HttpMethodConstants.POST.name());
|
||||
dto.setOriginalValue(JSON.toJSONBytes(userMap.get(k)));
|
||||
dto.setModifiedValue(JSON.toJSONBytes(request.getUserId()));
|
||||
dtoList.add(dto);
|
||||
});
|
||||
operationLogService.batchAdd(dtoList);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogUtils.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void batchMove(BaseBatchMoveRequest request) {
|
||||
List<String> ids = testPlanFunctionalCaseService.doSelectIds(request);
|
||||
if (CollectionUtils.isNotEmpty(ids)) {
|
||||
TestPlanFunctionalCaseExample example = new TestPlanFunctionalCaseExample();
|
||||
example.createCriteria().andIdIn(ids);
|
||||
List<TestPlanFunctionalCase> caseList = testPlanFunctionalCaseMapper.selectByExample(example);
|
||||
List<String> functionalCaseIds = caseList.stream().map(TestPlanFunctionalCase::getFunctionalCaseId).collect(Collectors.toList());
|
||||
FunctionalCaseExample caseExample = new FunctionalCaseExample();
|
||||
caseExample.createCriteria().andIdIn(functionalCaseIds);
|
||||
List<FunctionalCase> functionalCases = functionalCaseMapper.selectByExample(caseExample);
|
||||
Map<String, String> caseMap = functionalCases.stream().collect(Collectors.toMap(FunctionalCase::getId, FunctionalCase::getName));
|
||||
List<LogDTO> dtoList = new ArrayList<>();
|
||||
caseList.forEach(item -> {
|
||||
LogDTO dto = new LogDTO(
|
||||
null,
|
||||
null,
|
||||
item.getFunctionalCaseId(),
|
||||
null,
|
||||
OperationLogType.UPDATE.name(),
|
||||
OperationLogModule.TEST_PLAN,
|
||||
Translator.get("move") + ":" + caseMap.get(item.getFunctionalCaseId()));
|
||||
dto.setPath("/test-plan/functional/case/batch/move");
|
||||
dto.setMethod(HttpMethodConstants.POST.name());
|
||||
dto.setOriginalValue(JSON.toJSONBytes(item));
|
||||
TestPlanFunctionalCase testPlanFunctionalCase = new TestPlanFunctionalCase();
|
||||
testPlanFunctionalCase.setId(item.getId());
|
||||
testPlanFunctionalCase.setTestPlanCollectionId(request.getTargetCollectionId());
|
||||
dto.setModifiedValue(JSON.toJSONBytes(testPlanFunctionalCase));
|
||||
dtoList.add(dto);
|
||||
});
|
||||
public void batchMove(BaseBatchMoveRequest request, String userId) {
|
||||
try {
|
||||
List<String> ids = testPlanFunctionalCaseService.doSelectIds(request);
|
||||
if (CollectionUtils.isNotEmpty(ids)) {
|
||||
TestPlan testPlan = testPlanMapper.selectByPrimaryKey(request.getTestPlanId());
|
||||
Project project = projectMapper.selectByPrimaryKey(testPlan.getProjectId());
|
||||
TestPlanFunctionalCaseExample example = new TestPlanFunctionalCaseExample();
|
||||
example.createCriteria().andIdIn(ids);
|
||||
List<TestPlanFunctionalCase> caseList = testPlanFunctionalCaseMapper.selectByExample(example);
|
||||
List<String> functionalCaseIds = caseList.stream().map(TestPlanFunctionalCase::getFunctionalCaseId).collect(Collectors.toList());
|
||||
FunctionalCaseExample caseExample = new FunctionalCaseExample();
|
||||
caseExample.createCriteria().andIdIn(functionalCaseIds);
|
||||
List<FunctionalCase> functionalCases = functionalCaseMapper.selectByExample(caseExample);
|
||||
Map<String, String> caseMap = functionalCases.stream().collect(Collectors.toMap(FunctionalCase::getId, FunctionalCase::getName));
|
||||
List<LogDTO> dtoList = new ArrayList<>();
|
||||
caseList.forEach(item -> {
|
||||
LogDTO dto = new LogDTO(
|
||||
project.getId(),
|
||||
project.getOrganizationId(),
|
||||
item.getFunctionalCaseId(),
|
||||
userId,
|
||||
OperationLogType.UPDATE.name(),
|
||||
OperationLogModule.TEST_PLAN,
|
||||
Translator.get("move") + ":" + caseMap.get(item.getFunctionalCaseId()));
|
||||
dto.setPath("/test-plan/functional/case/batch/move");
|
||||
dto.setMethod(HttpMethodConstants.POST.name());
|
||||
dto.setOriginalValue(JSON.toJSONBytes(item));
|
||||
TestPlanFunctionalCase testPlanFunctionalCase = new TestPlanFunctionalCase();
|
||||
testPlanFunctionalCase.setId(item.getId());
|
||||
testPlanFunctionalCase.setTestPlanCollectionId(request.getTargetCollectionId());
|
||||
dto.setModifiedValue(JSON.toJSONBytes(testPlanFunctionalCase));
|
||||
dtoList.add(dto);
|
||||
});
|
||||
operationLogService.batchAdd(dtoList);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogUtils.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user