From 9b507f06c4a7ff9ad39d25b45bb11982bc814e5d Mon Sep 17 00:00:00 2001 From: gssong <1742057357@qq.com> Date: 星期日, 02 六月 2024 10:19:18 +0800 Subject: [PATCH] update 增加通用接口 降低耦合 --- ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/TestLeaveServiceImpl.java | 37 ++++++++++++++++--------------------- 1 files changed, 16 insertions(+), 21 deletions(-) diff --git a/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/TestLeaveServiceImpl.java b/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/TestLeaveServiceImpl.java index 276cafe..abb6473 100644 --- a/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/TestLeaveServiceImpl.java +++ b/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/TestLeaveServiceImpl.java @@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import lombok.RequiredArgsConstructor; +import org.dromara.common.core.service.WorkflowService; import org.dromara.common.core.utils.MapstructUtils; import org.dromara.common.core.utils.StreamUtils; import org.dromara.common.core.utils.StringUtils; @@ -15,9 +16,7 @@ import org.dromara.workflow.domain.bo.TestLeaveBo; import org.dromara.workflow.domain.vo.TestLeaveVo; import org.dromara.workflow.mapper.TestLeaveMapper; -import org.dromara.workflow.service.IActProcessInstanceService; import org.dromara.workflow.service.ITestLeaveService; -import org.dromara.workflow.utils.WorkflowUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -35,7 +34,7 @@ public class TestLeaveServiceImpl implements ITestLeaveService { private final TestLeaveMapper baseMapper; - private final IActProcessInstanceService iActProcessInstanceService; + private final WorkflowService workflowService; /** * 鏌ヨ璇峰亣 @@ -43,7 +42,7 @@ @Override public TestLeaveVo queryById(Long id) { TestLeaveVo testLeaveVo = baseMapper.selectVoById(id); - WorkflowUtils.setProcessInstanceVo(testLeaveVo,String.valueOf(id)); + workflowService.setBusinessInstanceDTO(testLeaveVo, String.valueOf(id)); return testLeaveVo; } @@ -58,7 +57,7 @@ List<TestLeaveVo> rows = build.getRows(); if (CollUtil.isNotEmpty(rows)) { List<String> ids = StreamUtils.toList(rows, e -> String.valueOf(e.getId())); - WorkflowUtils.setProcessInstanceListVo(rows, ids, "id"); + workflowService.setBusinessInstanceListDTO(rows, ids, "id"); } return build; } @@ -75,8 +74,8 @@ private LambdaQueryWrapper<TestLeave> buildQueryWrapper(TestLeaveBo bo) { LambdaQueryWrapper<TestLeave> lqw = Wrappers.lambdaQuery(); lqw.eq(StringUtils.isNotBlank(bo.getLeaveType()), TestLeave::getLeaveType, bo.getLeaveType()); - lqw.ge(bo.getStartLeaveDays() != null,TestLeave::getLeaveDays, bo.getStartLeaveDays()); - lqw.le(bo.getEndLeaveDays() != null,TestLeave::getLeaveDays, bo.getEndLeaveDays()); + lqw.ge(bo.getStartLeaveDays() != null, TestLeave::getLeaveDays, bo.getStartLeaveDays()); + lqw.le(bo.getEndLeaveDays() != null, TestLeave::getLeaveDays, bo.getEndLeaveDays()); lqw.orderByDesc(BaseEntity::getCreateTime); return lqw; } @@ -85,31 +84,27 @@ * 鏂板璇峰亣 */ @Override - public TestLeave insertByBo(TestLeaveBo bo) { + public TestLeaveVo insertByBo(TestLeaveBo bo) { TestLeave add = MapstructUtils.convert(bo, TestLeave.class); - validEntityBeforeSave(add); boolean flag = baseMapper.insert(add) > 0; if (flag) { bo.setId(add.getId()); } - return add; + TestLeaveVo testLeaveVo = MapstructUtils.convert(add, TestLeaveVo.class); + workflowService.setBusinessInstanceDTO(testLeaveVo, String.valueOf(add.getId())); + return testLeaveVo; } /** * 淇敼璇峰亣 */ @Override - public TestLeave updateByBo(TestLeaveBo bo) { + public TestLeaveVo updateByBo(TestLeaveBo bo) { TestLeave update = MapstructUtils.convert(bo, TestLeave.class); - validEntityBeforeSave(update); - return baseMapper.updateById(update) > 0 ? update : null; - } - - /** - * 淇濆瓨鍓嶇殑鏁版嵁鏍¢獙 - */ - private void validEntityBeforeSave(TestLeave entity) { - //TODO 鍋氫竴浜涙暟鎹牎楠�,濡傚敮涓�绾︽潫 + baseMapper.updateById(update); + TestLeaveVo testLeaveVo = MapstructUtils.convert(update, TestLeaveVo.class); + workflowService.setBusinessInstanceDTO(testLeaveVo, String.valueOf(update.getId())); + return testLeaveVo; } /** @@ -119,7 +114,7 @@ @Transactional(rollbackFor = Exception.class) public Boolean deleteWithValidByIds(Collection<Long> ids) { List<String> idList = StreamUtils.toList(ids, String::valueOf); - iActProcessInstanceService.deleteRunAndHisInstanceByBusinessKeys(idList); + workflowService.deleteRunAndHisInstance(idList); return baseMapper.deleteBatchIds(ids) > 0; } } -- Gitblit v1.9.3