update 优化 流程分类新增修改

dev
疯狂的狮子Li 5 months ago
parent 38feed5469
commit b54bece04d

@ -100,5 +100,15 @@ public enum TaskStatusEnum {
return STATUS_DESC_MAP.getOrDefault(status, StrUtil.EMPTY);
}
/**
* 退
*
* @param status
* @return true 退
*/
public static boolean isPassOrBack(String status) {
return PASS.getStatus().equals(status) || BACK.getStatus().equals(status);
}
}

@ -66,7 +66,6 @@ public class FlwCategoryController extends BaseController {
@SaCheckPermission("workflow:category:query")
@GetMapping("/{categoryId}")
public R<FlowCategoryVo> getInfo(@NotNull(message = "主键不能为空") @PathVariable Long categoryId) {
flwCategoryService.checkCategoryDataScope(categoryId);
return R.ok(flwCategoryService.queryById(categoryId));
}
@ -93,7 +92,6 @@ public class FlwCategoryController extends BaseController {
@PutMapping()
public R<Void> edit(@Validated(EditGroup.class) @RequestBody FlowCategoryBo category) {
Long categoryId = category.getCategoryId();
flwCategoryService.checkCategoryDataScope(categoryId);
if (!flwCategoryService.checkCategoryNameUnique(category)) {
return R.fail("修改流程分类'" + category.getCategoryName() + "'失败,流程分类名称已存在");
} else if (category.getParentId().equals(categoryId)) {

@ -83,8 +83,7 @@ public class WorkflowGlobalListener implements GlobalListener {
String applyNodeCode = flwCommonService.applyNodeCode(definition.getId());
for (Task flowTask : nextTasks) {
// 如果办理或者退回并行存在需要指定办理人,则直接覆盖办理人
if (variable.containsKey(flowTask.getNodeCode()) && (TaskStatusEnum.PASS.getStatus().equals(flowParams.getHisStatus())
|| TaskStatusEnum.BACK.getStatus().equals(flowParams.getHisStatus()))) {
if (variable.containsKey(flowTask.getNodeCode()) && TaskStatusEnum.isPassOrBack(flowParams.getHisStatus())) {
String userIds = variable.get(flowTask.getNodeCode()).toString();
flowTask.setPermissionList(List.of(userIds.split(StringUtils.SEPARATOR)));
variable.remove(flowTask.getNodeCode());
@ -137,8 +136,7 @@ public class WorkflowGlobalListener implements GlobalListener {
return;
}
// 只有办理或者退回的时候才执行消息通知和抄送
if (!StringUtils.equalsAny(flowParams.getHisStatus(),
TaskStatusEnum.PASS.getStatus(), TaskStatusEnum.BACK.getStatus())) {
if (!TaskStatusEnum.isPassOrBack(flowParams.getHisStatus())) {
return;
}
if (ObjectUtil.isNull(variable)) {

@ -1,8 +1,6 @@
package org.dromara.workflow.mapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.dromara.common.mybatis.annotation.DataColumn;
import org.dromara.common.mybatis.annotation.DataPermission;
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
import org.dromara.common.mybatis.helper.DataBaseHelper;
import org.dromara.workflow.domain.FlowCategory;
@ -20,19 +18,6 @@ import java.util.stream.Stream;
*/
public interface FlwCategoryMapper extends BaseMapperPlus<FlowCategory, FlowCategoryVo> {
/**
* ID
*
* @param categoryId ID
* @return ID
*/
@DataPermission({
@DataColumn(key = "deptName", value = "createDept")
})
default long countCategoryById(Long categoryId) {
return this.selectCount(new LambdaQueryWrapper<FlowCategory>().eq(FlowCategory::getCategoryId, categoryId));
}
/**
* ID
*

@ -45,13 +45,6 @@ public interface IFlwCategoryService {
*/
List<Tree<String>> selectCategoryTreeList(FlowCategoryBo category);
/**
*
*
* @param categoryId ID
*/
void checkCategoryDataScope(Long categoryId);
/**
*
*

@ -23,6 +23,7 @@ import org.dromara.workflow.service.IFlwCategoryService;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
@ -111,24 +112,6 @@ public class FlwCategoryServiceImpl implements IFlwCategoryService {
);
}
/**
*
*
* @param categoryId ID
*/
@Override
public void checkCategoryDataScope(Long categoryId) {
if (ObjectUtil.isNull(categoryId)) {
return;
}
if (LoginHelper.isSuperAdmin()) {
return;
}
if (baseMapper.countCategoryById(categoryId) == 0) {
throw new ServiceException("没有权限访问流程分类数据!");
}
}
/**
*
*
@ -191,6 +174,9 @@ public class FlwCategoryServiceImpl implements IFlwCategoryService {
@Override
public int insertByBo(FlowCategoryBo bo) {
FlowCategory info = baseMapper.selectById(bo.getParentId());
if (ObjectUtil.isNull(info)) {
throw new ServiceException("父级流程分类不存在!");
}
FlowCategory category = MapstructUtils.convert(bo, FlowCategory.class);
category.setAncestors(info.getAncestors() + StringUtils.SEPARATOR + category.getParentId());
return baseMapper.insert(category);
@ -204,6 +190,7 @@ public class FlwCategoryServiceImpl implements IFlwCategoryService {
*/
@CacheEvict(cacheNames = FlowConstant.FLOW_CATEGORY_NAME, key = "#bo.categoryId")
@Override
@Transactional(rollbackFor = Exception.class)
public int updateByBo(FlowCategoryBo bo) {
FlowCategory category = MapstructUtils.convert(bo, FlowCategory.class);
FlowCategory oldCategory = baseMapper.selectById(category.getCategoryId());
@ -211,14 +198,14 @@ public class FlwCategoryServiceImpl implements IFlwCategoryService {
throw new ServiceException("流程分类不存在,无法修改");
}
if (!oldCategory.getParentId().equals(category.getParentId())) {
// 如果是新父流程分类 则校验是否具有新父流程分类权限 避免越权
this.checkCategoryDataScope(category.getParentId());
FlowCategory newParentCategory = baseMapper.selectById(category.getParentId());
if (ObjectUtil.isNotNull(newParentCategory)) {
String newAncestors = newParentCategory.getAncestors() + StringUtils.SEPARATOR + newParentCategory.getCategoryId();
String oldAncestors = oldCategory.getAncestors();
category.setAncestors(newAncestors);
updateCategoryChildren(category.getCategoryId(), newAncestors, oldAncestors);
} else {
throw new ServiceException("父级流程分类不存在!");
}
} else {
category.setAncestors(oldCategory.getAncestors());

Loading…
Cancel
Save