refactor: mapstruct函数统一风格: convert,convertList,convertToXxx,convertListToXxxxList

This commit is contained in:
dhb52 2024-05-10 12:56:38 +08:00
parent e7cf4e109c
commit 087e77ef2d
6 changed files with 10 additions and 10 deletions

View File

@ -31,7 +31,7 @@ public interface JobBatchResponseVOConverter {
}) })
JobBatchResponseVO convert(JobBatchResponseDO jobBatchResponseDO); JobBatchResponseVO convert(JobBatchResponseDO jobBatchResponseDO);
List<JobBatchResponseVO> convertListToJobBatchResponseList(List<JobTaskBatch> jobTaskBatchList); List<JobBatchResponseVO> convertListToJobBatchList(List<JobTaskBatch> jobTaskBatchList);
@Mappings({ @Mappings({
@Mapping(target = "executionAt", expression = "java(JobBatchResponseVOConverter.toLocalDateTime(jobTaskBatch.getExecutionAt()))") @Mapping(target = "executionAt", expression = "java(JobBatchResponseVOConverter.toLocalDateTime(jobTaskBatch.getExecutionAt()))")

View File

@ -25,7 +25,7 @@ public interface NotifyRecipientConverter {
NotifyRecipient convert(NotifyRecipientRequestVO requestVO); NotifyRecipient convert(NotifyRecipientRequestVO requestVO);
List<CommonLabelValueResponseVO> convertListToCommonLabelValueResponseList(List<NotifyRecipient> notifyRecipients); List<CommonLabelValueResponseVO> convertListToCommonLabelValueList(List<NotifyRecipient> notifyRecipients);
@Mappings({ @Mappings({
@Mapping(target = "label", source = "recipientName"), @Mapping(target = "label", source = "recipientName"),

View File

@ -48,14 +48,14 @@ public interface WorkflowConverter {
}) })
WorkflowDetailResponseVO.NodeInfo convert(WorkflowNode workflowNode); WorkflowDetailResponseVO.NodeInfo convert(WorkflowNode workflowNode);
List<WorkflowResponseVO> convertListToWorkflowResponseList(List<Workflow> workflowList); List<WorkflowResponseVO> convertListToWorkflowList(List<Workflow> workflowList);
@Mappings({ @Mappings({
@Mapping(target = "nextTriggerAt", expression = "java(WorkflowConverter.toLocalDateTime(workflow.getNextTriggerAt()))") @Mapping(target = "nextTriggerAt", expression = "java(WorkflowConverter.toLocalDateTime(workflow.getNextTriggerAt()))")
}) })
WorkflowResponseVO convertToWorkflowResponseVO(Workflow workflow); WorkflowResponseVO convertToWorkflow(Workflow workflow);
List<WorkflowBatchResponseVO> convertListToWorkflowBatchResponseList(List<WorkflowBatchResponseDO> workflowBatchResponseList); List<WorkflowBatchResponseVO> convertListToWorkflowBatchList(List<WorkflowBatchResponseDO> workflowBatchResponseList);
@Mappings({ @Mappings({
@Mapping(source = "workflowTaskBatch.groupName", target = "groupName"), @Mapping(source = "workflowTaskBatch.groupName", target = "groupName"),

View File

@ -65,7 +65,7 @@ public class NotifyRecipientServiceImpl implements NotifyRecipientService {
List<NotifyRecipient> notifyRecipients = notifyRecipientMapper.selectList( List<NotifyRecipient> notifyRecipients = notifyRecipientMapper.selectList(
new LambdaQueryWrapper<NotifyRecipient>() new LambdaQueryWrapper<NotifyRecipient>()
.select(NotifyRecipient::getRecipientName, NotifyRecipient::getId)); .select(NotifyRecipient::getRecipientName, NotifyRecipient::getId));
return NotifyRecipientConverter.INSTANCE.convertListToCommonLabelValueResponseList(notifyRecipients); return NotifyRecipientConverter.INSTANCE.convertListToCommonLabelValueList(notifyRecipients);
} }
@Override @Override

View File

@ -83,7 +83,7 @@ public class WorkflowBatchServiceImpl implements WorkflowBatchService {
List<WorkflowBatchResponseDO> batchResponseDOList = workflowTaskBatchMapper.selectWorkflowBatchPageList(pageDTO, wrapper); List<WorkflowBatchResponseDO> batchResponseDOList = workflowTaskBatchMapper.selectWorkflowBatchPageList(pageDTO, wrapper);
List<WorkflowBatchResponseVO> batchResponseVOList = List<WorkflowBatchResponseVO> batchResponseVOList =
WorkflowConverter.INSTANCE.convertListToWorkflowBatchResponseList(batchResponseDOList); WorkflowConverter.INSTANCE.convertListToWorkflowBatchList(batchResponseDOList);
return new PageResult<>(pageDTO, batchResponseVOList); return new PageResult<>(pageDTO, batchResponseVOList);
} }
@ -138,7 +138,7 @@ public class WorkflowBatchServiceImpl implements WorkflowBatchService {
jobTaskBatchList = jobTaskBatchList.stream() jobTaskBatchList = jobTaskBatchList.stream()
.sorted(Comparator.comparingInt(JobTaskBatch::getTaskBatchStatus)) .sorted(Comparator.comparingInt(JobTaskBatch::getTaskBatchStatus))
.collect(Collectors.toList()); .collect(Collectors.toList());
nodeInfo.setJobBatchList(JobBatchResponseVOConverter.INSTANCE.convertListToJobBatchResponseList(jobTaskBatchList)); nodeInfo.setJobBatchList(JobBatchResponseVOConverter.INSTANCE.convertListToJobBatchList(jobTaskBatchList));
// 取第最新的一条状态 // 取第最新的一条状态
JobTaskBatch jobTaskBatch = jobTaskBatchList.get(0); JobTaskBatch jobTaskBatch = jobTaskBatchList.get(0);

View File

@ -215,7 +215,7 @@ public class WorkflowServiceImpl implements WorkflowService {
.eq(Objects.nonNull(queryVO.getWorkflowStatus()), Workflow::getWorkflowStatus, queryVO.getWorkflowStatus()) .eq(Objects.nonNull(queryVO.getWorkflowStatus()), Workflow::getWorkflowStatus, queryVO.getWorkflowStatus())
.orderByDesc(Workflow::getId)); .orderByDesc(Workflow::getId));
List<WorkflowResponseVO> jobResponseList = WorkflowConverter.INSTANCE.convertListToWorkflowResponseList(page.getRecords()); List<WorkflowResponseVO> jobResponseList = WorkflowConverter.INSTANCE.convertListToWorkflowList(page.getRecords());
return new PageResult<>(pageDTO, jobResponseList); return new PageResult<>(pageDTO, jobResponseList);
} }
@ -320,7 +320,7 @@ public class WorkflowServiceImpl implements WorkflowService {
.eq(Workflow::getDeleted, StatusEnum.NO.getStatus()) .eq(Workflow::getDeleted, StatusEnum.NO.getStatus())
.orderByAsc(Workflow::getId)); .orderByAsc(Workflow::getId));
return WorkflowConverter.INSTANCE.convertListToWorkflowResponseList(selectPage.getRecords()); return WorkflowConverter.INSTANCE.convertListToWorkflowList(selectPage.getRecords());
} }
@Override @Override