use of io.choerodon.core.oauth.CustomUserDetails in project test-manager-service by open-hand.
the class TestCycleCaseAttachmentRelServiceImpl method snycByCase.
@Override
public void snycByCase(TestCycleCaseDTO testCycleCaseDTO, TestCaseDTO testCaseDTO) {
CustomUserDetails userDetails = DetailsHelper.getUserDetails();
testCycleCaseDTO.setLastUpdatedBy(userDetails.getUserId());
testCycleCaseDTO.setCreatedBy(userDetails.getUserId());
testCycleCaseAttachmentRelMapper.batchDeleteByLinkIdsAndType(Arrays.asList(testCycleCaseDTO.getExecuteId()), TestAttachmentCode.ATTACHMENT_CYCLE_CASE);
List<TestCaseAttachmentDTO> attachmentDTOS = testAttachmentMapper.listByCaseIds(Arrays.asList(testCaseDTO.getCaseId()));
Map<Long, List<TestCaseAttachmentDTO>> attachMap = attachmentDTOS.stream().collect(Collectors.groupingBy(TestCaseAttachmentDTO::getCaseId));
batchInsert(Arrays.asList(testCycleCaseDTO), attachMap);
}
use of io.choerodon.core.oauth.CustomUserDetails in project test-manager-service by open-hand.
the class TestPriorityServiceImpl method delete.
@Override
public void delete(Long organizationId, TestPriorityDTO testPriorityDTO) {
Long priorityId = testPriorityDTO.getId();
Long changePriorityId = testPriorityDTO.getChangePriorityId();
if (priorityId.equals(changePriorityId)) {
throw new CommonException(DELETE_ILLEGAL);
}
checkLastPriority(organizationId, priorityId);
TestPriorityDTO priority = testPriorityMapper.selectByPrimaryKey(priorityId);
Long count = checkDelete(organizationId, priorityId);
List<ProjectDTO> projectVOS = baseFeignClient.listProjectsByOrgId(organizationId).getBody();
List<Long> projectIds = projectVOS.stream().map(ProjectDTO::getId).collect(Collectors.toList());
// 执行优先级转换
if (!count.equals(0L)) {
if (changePriorityId == null) {
throw new CommonException(DELETE_ILLEGAL);
}
CustomUserDetails customUserDetails = DetailsHelper.getUserDetails();
this.batchChangeIssuePriority(organizationId, priorityId, changePriorityId, customUserDetails.getUserId(), projectIds);
}
int isDelete = testPriorityMapper.deleteByPrimaryKey(priorityId);
if (isDelete != 1) {
throw new CommonException("error.priority.delete");
}
if (priority.getDefaultFlag()) {
updateOtherDefault(organizationId);
}
}
use of io.choerodon.core.oauth.CustomUserDetails in project test-manager-service by open-hand.
the class TestCycleCaseServiceImpl method cloneCycleCase.
@Override
public void cloneCycleCase(Map<Long, Long> cycleMapping, List<Long> cycIds) {
Long defaultStatusId = testStatusService.getDefaultStatusId(TestStatusType.STATUS_TYPE_CASE);
Integer count = testCycleCaseMapper.countByCycleIds(cycIds);
int ceil = (int) Math.ceil(count / AVG_NUM == 0 ? 0 : count / AVG_NUM);
for (int page = 0; page < ceil; page++) {
Page<TestCycleCaseDTO> testCyclePageInfo = PageHelper.doPageAndSort(new PageRequest(page, 500), () -> testCycleCaseMapper.listByCycleIds(cycIds));
if (CollectionUtils.isEmpty(testCyclePageInfo.getContent())) {
return;
}
List<TestCycleCaseDTO> testCycleCaseDTOS = testCyclePageInfo.getContent();
CustomUserDetails userDetails = DetailsHelper.getUserDetails();
List<Long> olderExecuteIds = new ArrayList<>();
testCycleCaseDTOS.forEach(v -> {
olderExecuteIds.add(v.getExecuteId());
v.setLastExecuteId(v.getExecuteId());
v.setCycleId(cycleMapping.get(v.getCycleId()));
v.setCreatedBy(userDetails.getUserId());
v.setLastUpdatedBy(userDetails.getUserId());
v.setExecuteId(null);
v.setExecutionStatus(defaultStatusId);
});
bathcInsert(testCycleCaseDTOS);
Map<Long, Long> caseIdMap = new HashMap<>();
testCycleCaseDTOS.forEach(v -> caseIdMap.put(v.getLastExecuteId(), v.getExecuteId()));
// 复制步骤
testCycleCaseStepService.cloneStep(caseIdMap, olderExecuteIds);
// 复制附件
testCycleCaseAttachmentRelService.cloneAttach(caseIdMap, olderExecuteIds, "CYCLE_CASE");
}
}
use of io.choerodon.core.oauth.CustomUserDetails in project test-manager-service by open-hand.
the class TestCycleCaseStepServiceImpl method cloneStep.
@Override
public void cloneStep(Map<Long, Long> caseIdMap, List<Long> olderExecuteIds) {
CustomUserDetails userDetails = DetailsHelper.getUserDetails();
Long defaultStatusId = testStatusService.getDefaultStatusId(TestStatusType.STATUS_TYPE_CASE_STEP);
int count = testCycleCaseStepMapper.countByExecuteIds(olderExecuteIds);
int ceil = (int) Math.ceil(count / AVG_NUM == 0 ? 0 : count / AVG_NUM);
for (int page = 0; page < ceil; page++) {
Page<TestCycleCaseStepDTO> stepDTOPageInfo = PageHelper.doPageAndSort(new PageRequest(page, (int) AVG_NUM), () -> testCycleCaseStepMapper.listByexecuteIds(olderExecuteIds));
List<TestCycleCaseStepDTO> list = stepDTOPageInfo.getContent();
if (CollectionUtils.isEmpty(list)) {
return;
}
List<Long> stepIds = new ArrayList<>();
list.forEach(v -> {
v.setExecuteId(caseIdMap.get(v.getExecuteId()));
v.setExecuteStepId(null);
v.setCreatedBy(userDetails.getUserId());
v.setLastUpdatedBy(userDetails.getUserId());
v.setCaseId(v.getExecuteStepId());
v.setStepStatus(defaultStatusId);
stepIds.add(v.getExecuteStepId());
});
testCycleCaseStepMapper.batchInsertTestCycleCaseSteps(list);
Map<Long, Long> valueMapping = new HashMap<>();
list.forEach(v -> valueMapping.put(v.getCaseId(), v.getExecuteStepId()));
// 克隆步骤关联的附件
testCycleCaseAttachmentRelService.cloneAttach(valueMapping, stepIds, "CASE_STEP");
// 克隆步骤的缺陷
testCycleCaseDefectRelService.cloneDefect(valueMapping, stepIds, "CASE_STEP");
}
}
use of io.choerodon.core.oauth.CustomUserDetails in project test-manager-service by open-hand.
the class DataMigrationServiceImpl method migrateAttachment.
private void migrateAttachment() {
List<TestCaseAttachmentDTO> attachmentDTOS = dataFixFeignClient.migrateAttachment().getBody();
CustomUserDetails userDetails = DetailsHelper.getUserDetails();
if (!CollectionUtils.isEmpty(attachmentDTOS)) {
for (TestCaseAttachmentDTO testCaseAttachmentDTO : attachmentDTOS) {
if (testCaseAttachmentDTO != null) {
logger.info("==========>>>>>>>>SET Test Case Attachment caseId:{} <<<<<<<<=======", testCaseAttachmentDTO.getCaseId());
testCaseAttachmentDTO.setUrl("/agile-service/" + testCaseAttachmentDTO.getUrl());
testCaseAttachmentDTO.setCreatedBy(userDetails.getUserId());
testCaseAttachmentDTO.setLastUpdatedBy(userDetails.getUserId());
}
}
testAttachmentMapper.batchInsert(attachmentDTOS);
}
logger.info("===========attachment=============> copy successed");
}
Aggregations