hubin 1 год назад
Родитель
Сommit
6690942732

+ 1 - 1
src/main/java/com/aizuda/boot/modules/flw/controller/ProcessController.java

@@ -103,7 +103,7 @@ public class ProcessController extends ApiController {
     @Operation(summary = "创建添加")
     @Permission("flw:process:create")
     @PostMapping("/create")
-    public Long create(@RequestBody FlwProcessDTO dto) {
+    public Long create(@Validated @RequestBody FlwProcessDTO dto) {
         return flwProcessService.saveDto(dto);
     }
 

+ 6 - 0
src/main/java/com/aizuda/boot/modules/flw/entity/dto/FlwProcessDTO.java

@@ -4,6 +4,8 @@ package com.aizuda.boot.modules.flw.entity.dto;
 import com.aizuda.boot.modules.flw.entity.FlwProcessSetting;
 import com.aizuda.bpm.engine.entity.FlwProcess;
 import io.swagger.v3.oas.annotations.media.Schema;
+import jakarta.validation.constraints.NotBlank;
+import jakarta.validation.constraints.NotNull;
 import lombok.Getter;
 import lombok.Setter;
 import org.apache.commons.lang3.StringUtils;
@@ -24,9 +26,11 @@ public class FlwProcessDTO {
     private Long processId;
 
     @Schema(description = "流程定义 key 唯一标识")
+    @NotBlank
     private String processKey;
 
     @Schema(description = "流程定义名称")
+    @NotBlank
     private String processName;
 
     @Schema(description = "流程定义名称")
@@ -39,6 +43,7 @@ public class FlwProcessDTO {
     private String remark;
 
     @Schema(description = "流程分类ID")
+    @NotNull
     private Long categoryId;
 
     @Schema(description = "使用范围 0,全员 1,指定人员(业务关联) 2,均不可提交")
@@ -48,6 +53,7 @@ public class FlwProcessDTO {
     private List<FlwProcessPermissionDTO> processPermissionList;
 
     @Schema(description = "流程模型定义JSON内容")
+    @NotBlank
     private String modelContent;
 
     @Schema(description = "流程定义表单")

+ 3 - 0
src/main/java/com/aizuda/boot/modules/flw/service/IFlwFormCategoryService.java

@@ -5,6 +5,7 @@ import com.aizuda.boot.modules.flw.entity.vo.FlwFormCategoryVO;
 import com.aizuda.service.service.IBaseService;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 
+import java.util.Collection;
 import java.util.List;
 
 /**
@@ -20,4 +21,6 @@ public interface IFlwFormCategoryService extends IBaseService<FlwFormCategory> {
     List<FlwFormCategoryVO> listTree(FlwFormCategory flwFormCategory);
 
     List<FlwFormCategory> listAll();
+
+    boolean removeByIds(List<Long> ids);
 }

+ 3 - 0
src/main/java/com/aizuda/boot/modules/flw/service/IFlwFormTemplateService.java

@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.aizuda.service.service.IBaseService;
 import com.aizuda.boot.modules.flw.entity.FlwFormTemplate;
 
+import java.util.List;
+
 /**
  * 流程表单模板 服务类
  *
@@ -16,4 +18,5 @@ public interface IFlwFormTemplateService extends IBaseService<FlwFormTemplate> {
 
     Page<FlwFormTemplate> pageSimple(Page<FlwFormTemplate> page, FlwFormTemplate flwFormTemplate);
 
+    boolean existByFormCategoryIds(List<Long> formCategoryIds);
 }

+ 9 - 4
src/main/java/com/aizuda/boot/modules/flw/service/impl/FlwFormCategoryServiceImpl.java

@@ -4,15 +4,16 @@ import com.aizuda.boot.modules.flw.entity.FlwFormCategory;
 import com.aizuda.boot.modules.flw.entity.vo.FlwFormCategoryVO;
 import com.aizuda.boot.modules.flw.mapper.FlwFormCategoryMapper;
 import com.aizuda.boot.modules.flw.service.IFlwFormCategoryService;
+import com.aizuda.boot.modules.flw.service.IFlwFormTemplateService;
 import com.aizuda.core.api.ApiAssert;
 import com.aizuda.service.service.BaseServiceImpl;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import lombok.AllArgsConstructor;
 import org.springframework.stereotype.Service;
 
-import java.util.Collection;
 import java.util.List;
 import java.util.Objects;
 
@@ -23,7 +24,9 @@ import java.util.Objects;
  * @since 2024-05-19
  */
 @Service
+@AllArgsConstructor
 public class FlwFormCategoryServiceImpl extends BaseServiceImpl<FlwFormCategoryMapper, FlwFormCategory> implements IFlwFormCategoryService {
+    private IFlwFormTemplateService formTemplateService;
 
     @Override
     public Page<FlwFormCategory> page(Page<FlwFormCategory> page, FlwFormCategory flwFormCategory) {
@@ -82,9 +85,11 @@ public class FlwFormCategoryServiceImpl extends BaseServiceImpl<FlwFormCategoryM
     }
 
     @Override
-    public boolean removeByIds(Collection<?> list) {
+    public boolean removeByIds(List<Long> ids) {
+        ApiAssert.fail(ids.stream().anyMatch(Objects::isNull), "不允许删除所有");
         this.checkExists(Wrappers.<FlwFormCategory>lambdaQuery().select(FlwFormCategory::getId)
-                .in(FlwFormCategory::getPid, list), "存在子类不允许删除");
-        return super.removeByIds(list);
+                .in(FlwFormCategory::getPid, ids), "存在子类不允许删除");
+        ApiAssert.fail(formTemplateService.existByFormCategoryIds(ids), "存在关联表单模板不允许删除");
+        return super.removeByIds(ids);
     }
 }

+ 7 - 0
src/main/java/com/aizuda/boot/modules/flw/service/impl/FlwFormTemplateServiceImpl.java

@@ -10,6 +10,8 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 /**
  * 流程表单模板 服务实现类
  *
@@ -43,4 +45,9 @@ public class FlwFormTemplateServiceImpl extends BaseServiceImpl<FlwFormTemplateM
         ApiAssert.fail(null == flwFormTemplate.getId(), "主键不存在无法更新");
         return super.updateById(flwFormTemplate);
     }
+
+    @Override
+    public boolean existByFormCategoryIds(List<Long> formCategoryIds) {
+        return lambdaQuery().in(FlwFormTemplate::getFormCategoryId, formCategoryIds).count() > 0;
+    }
 }