From ed8fc5f674544d3af63c6f68093ffc038385c493 Mon Sep 17 00:00:00 2001 From: dongyukun <1208714201@qq.com> Date: 星期一, 16 十二月 2024 09:30:04 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- iailab-module-bpm/iailab-module-bpm-biz/src/main/java/com/iailab/module/bpm/service/definition/BpmCategoryServiceImpl.java | 23 +++++++++++++++++++++-- 1 files changed, 21 insertions(+), 2 deletions(-) diff --git a/iailab-module-bpm/iailab-module-bpm-biz/src/main/java/com/iailab/module/bpm/service/definition/BpmCategoryServiceImpl.java b/iailab-module-bpm/iailab-module-bpm-biz/src/main/java/com/iailab/module/bpm/service/definition/BpmCategoryServiceImpl.java index f020701..2ba5bf6 100644 --- a/iailab-module-bpm/iailab-module-bpm-biz/src/main/java/com/iailab/module/bpm/service/definition/BpmCategoryServiceImpl.java +++ b/iailab-module-bpm/iailab-module-bpm-biz/src/main/java/com/iailab/module/bpm/service/definition/BpmCategoryServiceImpl.java @@ -9,12 +9,15 @@ import com.iailab.module.bpm.dal.dataobject.definition.BpmCategoryDO; import com.iailab.module.bpm.dal.mysql.category.BpmCategoryMapper; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.annotation.Validated; import javax.annotation.Resource; import java.util.Collection; import java.util.Collections; import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.IntStream; import static com.iailab.framework.common.exception.util.ServiceExceptionUtil.exception; import static com.iailab.module.bpm.enums.ErrorCodeConstants.*; @@ -56,7 +59,7 @@ private void validateCategoryNameUnique(BpmCategorySaveReqVO updateReqVO) { BpmCategoryDO category = bpmCategoryMapper.selectByName(updateReqVO.getName()); if (category == null - || ObjUtil.equal(category.getId(), updateReqVO.getId())) { + || ObjUtil.equal(category.getId(), updateReqVO.getId())) { return; } throw exception(CATEGORY_NAME_DUPLICATE, updateReqVO.getName()); @@ -65,7 +68,7 @@ private void validateCategoryCodeUnique(BpmCategorySaveReqVO updateReqVO) { BpmCategoryDO category = bpmCategoryMapper.selectByCode(updateReqVO.getCode()); if (category == null - || ObjUtil.equal(category.getId(), updateReqVO.getId())) { + || ObjUtil.equal(category.getId(), updateReqVO.getId())) { return; } throw exception(CATEGORY_CODE_DUPLICATE, updateReqVO.getCode()); @@ -108,4 +111,20 @@ return bpmCategoryMapper.selectListByStatus(status); } + @Override + @Transactional(rollbackFor = Exception.class) + public void updateCategorySortBatch(List<Long> ids) { + // 校验分类都存在 + List<BpmCategoryDO> categories = bpmCategoryMapper.selectBatchIds(ids); + if (categories.size() != ids.size()) { + throw exception(CATEGORY_NOT_EXISTS); + } + + // 批量更新排序 + List<BpmCategoryDO> updateList = IntStream.range(0, ids.size()) + .mapToObj(index -> new BpmCategoryDO().setId(ids.get(index)).setSort(index)) + .collect(Collectors.toList()); + bpmCategoryMapper.updateBatch(updateList); + } + } \ No newline at end of file -- Gitblit v1.9.3