BPM:新增流程分类表,替代现有的 `bpm_category` 数据字典
parent
d5e28d4c57
commit
ed83b912e4
@ -0,0 +1,86 @@
|
|||||||
|
package cn.iocoder.yudao.module.bpm.controller.admin.definition;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
|
import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.category.BpmCategoryPageReqVO;
|
||||||
|
import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.category.BpmCategoryRespVO;
|
||||||
|
import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.category.BpmCategorySaveReqVO;
|
||||||
|
import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmCategoryDO;
|
||||||
|
import cn.iocoder.yudao.module.bpm.service.definition.BpmCategoryService;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
||||||
|
|
||||||
|
@Tag(name = "管理后台 - BPM 流程分类")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/bpm/category")
|
||||||
|
@Validated
|
||||||
|
public class BpmCategoryController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private BpmCategoryService categoryService;
|
||||||
|
|
||||||
|
@PostMapping("/create")
|
||||||
|
@Operation(summary = "创建流程分类")
|
||||||
|
@PreAuthorize("@ss.hasPermission('bpm:category:create')")
|
||||||
|
public CommonResult<Long> createCategory(@Valid @RequestBody BpmCategorySaveReqVO createReqVO) {
|
||||||
|
return success(categoryService.createCategory(createReqVO));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/update")
|
||||||
|
@Operation(summary = "更新流程分类")
|
||||||
|
@PreAuthorize("@ss.hasPermission('bpm:category:update')")
|
||||||
|
public CommonResult<Boolean> updateCategory(@Valid @RequestBody BpmCategorySaveReqVO updateReqVO) {
|
||||||
|
categoryService.updateCategory(updateReqVO);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/delete")
|
||||||
|
@Operation(summary = "删除流程分类")
|
||||||
|
@Parameter(name = "id", description = "编号", required = true)
|
||||||
|
@PreAuthorize("@ss.hasPermission('bpm:category:delete')")
|
||||||
|
public CommonResult<Boolean> deleteCategory(@RequestParam("id") Long id) {
|
||||||
|
categoryService.deleteCategory(id);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/get")
|
||||||
|
@Operation(summary = "获得流程分类")
|
||||||
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||||
|
@PreAuthorize("@ss.hasPermission('bpm:category:query')")
|
||||||
|
public CommonResult<BpmCategoryRespVO> getCategory(@RequestParam("id") Long id) {
|
||||||
|
BpmCategoryDO category = categoryService.getCategory(id);
|
||||||
|
return success(BeanUtils.toBean(category, BpmCategoryRespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/page")
|
||||||
|
@Operation(summary = "获得流程分类分页")
|
||||||
|
@PreAuthorize("@ss.hasPermission('bpm:category:query')")
|
||||||
|
public CommonResult<PageResult<BpmCategoryRespVO>> getCategoryPage(@Valid BpmCategoryPageReqVO pageReqVO) {
|
||||||
|
PageResult<BpmCategoryDO> pageResult = categoryService.getCategoryPage(pageReqVO);
|
||||||
|
return success(BeanUtils.toBean(pageResult, BpmCategoryRespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/simple-list")
|
||||||
|
@Operation(summary = "获取流程分类的精简信息列表", description = "只包含被开启的分类,主要用于前端的下拉选项")
|
||||||
|
public CommonResult<List<BpmCategoryRespVO>> getCategorySimpleList() {
|
||||||
|
List<BpmCategoryDO> list = categoryService.getCategoryListByStatus(CommonStatusEnum.ENABLE.getStatus());
|
||||||
|
list.sort(Comparator.comparingInt(BpmCategoryDO::getSort));
|
||||||
|
return success(convertList(list, category -> new BpmCategoryRespVO().setId(category.getId())
|
||||||
|
.setName(category.getName()).setCode(category.getCode())));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,36 @@
|
|||||||
|
package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.category;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
|
import cn.iocoder.yudao.framework.common.validation.InEnum;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.ToString;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - BPM 流程分类分页 Request VO")
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
public class BpmCategoryPageReqVO extends PageParam {
|
||||||
|
|
||||||
|
@Schema(description = "分类名", example = "王五")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@Schema(description = "分类标志", example = "OA")
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
@Schema(description = "分类状态", example = "1")
|
||||||
|
@InEnum(CommonStatusEnum.class)
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
@Schema(description = "创建时间")
|
||||||
|
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||||
|
private LocalDateTime[] createTime;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,33 @@
|
|||||||
|
package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.category;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - BPM 流程分类 Response VO")
|
||||||
|
@Data
|
||||||
|
public class BpmCategoryRespVO {
|
||||||
|
|
||||||
|
@Schema(description = "分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3167")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "分类名", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@Schema(description = "分类标志", requiredMode = Schema.RequiredMode.REQUIRED, example = "OA")
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
@Schema(description = "分类描述", requiredMode = Schema.RequiredMode.REQUIRED, example = "你猜")
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
@Schema(description = "分类状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
@Schema(description = "分类排序", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
private Integer sort;
|
||||||
|
|
||||||
|
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,34 @@
|
|||||||
|
package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.category;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||||
|
import cn.iocoder.yudao.framework.common.validation.InEnum;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import jakarta.validation.constraints.NotEmpty;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - BPM 流程分类新增/修改 Request VO")
|
||||||
|
@Data
|
||||||
|
public class BpmCategorySaveReqVO {
|
||||||
|
|
||||||
|
@Schema(description = "分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3167")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "分类名", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
|
||||||
|
@NotEmpty(message = "分类名不能为空")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@Schema(description = "分类标志", requiredMode = Schema.RequiredMode.REQUIRED, example = "OA")
|
||||||
|
@NotEmpty(message = "分类标志不能为空")
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
@Schema(description = "分类状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||||
|
@NotNull(message = "分类状态不能为空")
|
||||||
|
@InEnum(CommonStatusEnum.class)
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
@Schema(description = "分类排序", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@NotNull(message = "分类排序不能为空")
|
||||||
|
private Integer sort;
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,48 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model;
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.ToString;
|
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
@Schema(description = "管理后台 - 流程模型的分页的每一项 Response VO")
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@ToString(callSuper = true)
|
|
||||||
public class BpmModelPageItemRespVO extends BpmModelBaseVO {
|
|
||||||
|
|
||||||
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
|
||||||
private String id;
|
|
||||||
|
|
||||||
@Schema(description = "表单名字", example = "请假表单")
|
|
||||||
private String formName;
|
|
||||||
|
|
||||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
|
||||||
private LocalDateTime createTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 最新部署的流程定义
|
|
||||||
*/
|
|
||||||
private ProcessDefinition processDefinition;
|
|
||||||
|
|
||||||
@Schema(description = "流程定义")
|
|
||||||
@Data
|
|
||||||
public static class ProcessDefinition {
|
|
||||||
|
|
||||||
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
|
||||||
private String id;
|
|
||||||
|
|
||||||
@Schema(description = "版本", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
|
||||||
private Integer version;
|
|
||||||
|
|
||||||
@Schema(description = "部署时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
|
||||||
private LocalDateTime deploymentTime;
|
|
||||||
|
|
||||||
@Schema(description = "中断状态-参见 SuspensionState 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
|
||||||
private Integer suspensionState;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,25 +1,56 @@
|
|||||||
package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model;
|
package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmProcessDefinitionRespVO;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.ToString;
|
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
@Schema(description = "管理后台 - 流程模型的创建 Request VO")
|
@Schema(description = "管理后台 - 流程模型 Response VO")
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
public class BpmModelRespVO {
|
||||||
@ToString(callSuper = true)
|
|
||||||
public class BpmModelRespVO extends BpmModelBaseVO {
|
|
||||||
|
|
||||||
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||||
private String id;
|
private String id;
|
||||||
|
|
||||||
@Schema(description = "BPMN XML", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "流程标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "process_yudao")
|
||||||
private String bpmnXml;
|
private String key;
|
||||||
|
|
||||||
|
@Schema(description = "流程名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@Schema(description = "流程描述", example = "我是描述")
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
@Schema(description = "流程分类编码", example = "1")
|
||||||
|
private String category;
|
||||||
|
@Schema(description = "流程分类名字", example = "请假")
|
||||||
|
private String categoryName;
|
||||||
|
|
||||||
|
@Schema(description = "表单类型-参见 bpm_model_form_type 数据字典", example = "1")
|
||||||
|
private Integer formType;
|
||||||
|
|
||||||
|
@Schema(description = "表单编号-在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空", example = "1024")
|
||||||
|
private Long formId;
|
||||||
|
@Schema(description = "表单名字", example = "请假表单")
|
||||||
|
private String formName;
|
||||||
|
|
||||||
|
@Schema(description = "自定义表单的提交路径,使用 Vue 的路由地址-在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空",
|
||||||
|
example = "/bpm/oa/leave/create")
|
||||||
|
private String formCustomCreatePath;
|
||||||
|
@Schema(description = "自定义表单的查看路径,使用 Vue 的路由地址-在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空",
|
||||||
|
example = "/bpm/oa/leave/view")
|
||||||
|
private String formCustomViewPath;
|
||||||
|
|
||||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
private LocalDateTime createTime;
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
@Schema(description = "BPMN XML", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
private String bpmnXml;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 最新部署的流程定义
|
||||||
|
*/
|
||||||
|
private BpmProcessDefinitionRespVO processDefinition;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,18 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process;
|
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.ToString;
|
|
||||||
|
|
||||||
@Schema(description = "管理后台 - 流程定义列表 Request VO")
|
|
||||||
@Data
|
|
||||||
@ToString(callSuper = true)
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
public class BpmProcessDefinitionListReqVO extends PageParam {
|
|
||||||
|
|
||||||
@Schema(description = "中断状态-参见 SuspensionState 枚举", example = "1")
|
|
||||||
private Integer suspensionState;
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,22 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process;
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.ToString;
|
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
@Schema(description = "管理后台 - 流程定义的分页的每一项 Response VO")
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@ToString(callSuper = true)
|
|
||||||
public class BpmProcessDefinitionPageItemRespVO extends BpmProcessDefinitionRespVO {
|
|
||||||
|
|
||||||
@Schema(description = "表单名字", example = "请假表单")
|
|
||||||
private String formName;
|
|
||||||
|
|
||||||
@Schema(description = "部署时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
|
||||||
private LocalDateTime deploymentTime;
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -0,0 +1,53 @@
|
|||||||
|
package cn.iocoder.yudao.module.bpm.dal.dataobject.definition;
|
||||||
|
|
||||||
|
import lombok.*;
|
||||||
|
import java.util.*;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* BPM 流程分类 DO
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
@TableName("bpm_category")
|
||||||
|
@KeySequence("bpm_category_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class BpmCategoryDO extends BaseDO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分类编号
|
||||||
|
*/
|
||||||
|
@TableId
|
||||||
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 分类名
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
/**
|
||||||
|
* 分类标志
|
||||||
|
*/
|
||||||
|
private String code;
|
||||||
|
/**
|
||||||
|
* 分类描述
|
||||||
|
*/
|
||||||
|
private String description;
|
||||||
|
/**
|
||||||
|
* 分类状态
|
||||||
|
*
|
||||||
|
* 枚举 {@link TODO common_status 对应的类}
|
||||||
|
*/
|
||||||
|
private Integer status;
|
||||||
|
/**
|
||||||
|
* 分类排序
|
||||||
|
*/
|
||||||
|
private Integer sort;
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package cn.iocoder.yudao.module.bpm.dal.dataobject.cc;
|
package cn.iocoder.yudao.module.bpm.dal.dataobject.task;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
@ -0,0 +1,46 @@
|
|||||||
|
package cn.iocoder.yudao.module.bpm.dal.mysql.category;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
|
import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.category.BpmCategoryPageReqVO;
|
||||||
|
import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmCategoryDO;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* BPM 流程分类 Mapper
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface BpmCategoryMapper extends BaseMapperX<BpmCategoryDO> {
|
||||||
|
|
||||||
|
default PageResult<BpmCategoryDO> selectPage(BpmCategoryPageReqVO reqVO) {
|
||||||
|
return selectPage(reqVO, new LambdaQueryWrapperX<BpmCategoryDO>()
|
||||||
|
.likeIfPresent(BpmCategoryDO::getName, reqVO.getName())
|
||||||
|
.eqIfPresent(BpmCategoryDO::getCode, reqVO.getCode())
|
||||||
|
.eqIfPresent(BpmCategoryDO::getStatus, reqVO.getStatus())
|
||||||
|
.betweenIfPresent(BpmCategoryDO::getCreateTime, reqVO.getCreateTime())
|
||||||
|
.orderByAsc(BpmCategoryDO::getSort));
|
||||||
|
}
|
||||||
|
|
||||||
|
default BpmCategoryDO selectByName(String name) {
|
||||||
|
return selectOne(BpmCategoryDO::getName, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
default BpmCategoryDO selectByCode(String code) {
|
||||||
|
return selectOne(BpmCategoryDO::getCode, code);
|
||||||
|
}
|
||||||
|
|
||||||
|
default List<BpmCategoryDO> selectListByCode(Collection<String> codes) {
|
||||||
|
return selectList(BpmCategoryDO::getCode, codes);
|
||||||
|
}
|
||||||
|
|
||||||
|
default List<BpmCategoryDO> selectListByStatus(Integer status) {
|
||||||
|
return selectList(BpmCategoryDO::getStatus, status);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,22 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.bpm.dal.mysql.definition;
|
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
|
||||||
import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessDefinitionExtDO;
|
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Mapper
|
|
||||||
public interface BpmProcessDefinitionExtMapper extends BaseMapperX<BpmProcessDefinitionExtDO> {
|
|
||||||
|
|
||||||
default List<BpmProcessDefinitionExtDO> selectListByProcessDefinitionIds(Collection<String> processDefinitionIds) {
|
|
||||||
return selectList("process_definition_id", processDefinitionIds);
|
|
||||||
}
|
|
||||||
|
|
||||||
default BpmProcessDefinitionExtDO selectByProcessDefinitionId(String processDefinitionId) {
|
|
||||||
return selectOne("process_definition_id", processDefinitionId);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -0,0 +1,21 @@
|
|||||||
|
package cn.iocoder.yudao.module.bpm.dal.mysql.definition;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessDefinitionInfoDO;
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface BpmProcessDefinitionInfoMapper extends BaseMapperX<BpmProcessDefinitionInfoDO> {
|
||||||
|
|
||||||
|
default List<BpmProcessDefinitionInfoDO> selectListByProcessDefinitionIds(Collection<String> processDefinitionIds) {
|
||||||
|
return selectList(BpmProcessDefinitionInfoDO::getProcessDefinitionId, processDefinitionIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
default BpmProcessDefinitionInfoDO selectByProcessDefinitionId(String processDefinitionId) {
|
||||||
|
return selectOne(BpmProcessDefinitionInfoDO::getProcessDefinitionId, processDefinitionId);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,10 +1,10 @@
|
|||||||
package cn.iocoder.yudao.module.bpm.dal.mysql.cc;
|
package cn.iocoder.yudao.module.bpm.dal.mysql.task;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceCopyPageReqVO;
|
import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceCopyPageReqVO;
|
||||||
import cn.iocoder.yudao.module.bpm.dal.dataobject.cc.BpmProcessInstanceCopyDO;
|
import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmProcessInstanceCopyDO;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
@ -0,0 +1,113 @@
|
|||||||
|
package cn.iocoder.yudao.module.bpm.service.definition;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.util.ObjUtil;
|
||||||
|
import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.category.BpmCategoryPageReqVO;
|
||||||
|
import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.category.BpmCategorySaveReqVO;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmCategoryDO;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.bpm.dal.mysql.category.BpmCategoryMapper;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
|
import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* BPM 流程分类 Service 实现类
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Validated
|
||||||
|
public class BpmCategoryServiceImpl implements BpmCategoryService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private BpmCategoryMapper bpmCategoryMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long createCategory(BpmCategorySaveReqVO createReqVO) {
|
||||||
|
// 校验唯一
|
||||||
|
validateCategoryNameUnique(createReqVO);
|
||||||
|
validateCategoryCodeUnique(createReqVO);
|
||||||
|
// 插入
|
||||||
|
BpmCategoryDO category = BeanUtils.toBean(createReqVO, BpmCategoryDO.class);
|
||||||
|
bpmCategoryMapper.insert(category);
|
||||||
|
return category.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateCategory(BpmCategorySaveReqVO updateReqVO) {
|
||||||
|
// 校验存在
|
||||||
|
validateCategoryExists(updateReqVO.getId());
|
||||||
|
validateCategoryNameUnique(updateReqVO);
|
||||||
|
validateCategoryCodeUnique(updateReqVO);
|
||||||
|
// 更新
|
||||||
|
BpmCategoryDO updateObj = BeanUtils.toBean(updateReqVO, BpmCategoryDO.class);
|
||||||
|
bpmCategoryMapper.updateById(updateObj);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void validateCategoryNameUnique(BpmCategorySaveReqVO updateReqVO) {
|
||||||
|
BpmCategoryDO category = bpmCategoryMapper.selectByName(updateReqVO.getName());
|
||||||
|
if (category == null
|
||||||
|
|| ObjUtil.equal(category.getId(), updateReqVO.getId())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
throw exception(CATEGORY_NAME_DUPLICATE, updateReqVO.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void validateCategoryCodeUnique(BpmCategorySaveReqVO updateReqVO) {
|
||||||
|
BpmCategoryDO category = bpmCategoryMapper.selectByCode(updateReqVO.getCode());
|
||||||
|
if (category == null
|
||||||
|
|| ObjUtil.equal(category.getId(), updateReqVO.getId())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
throw exception(CATEGORY_CODE_DUPLICATE, updateReqVO.getCode());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteCategory(Long id) {
|
||||||
|
// 校验存在
|
||||||
|
validateCategoryExists(id);
|
||||||
|
// 删除
|
||||||
|
bpmCategoryMapper.deleteById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void validateCategoryExists(Long id) {
|
||||||
|
if (bpmCategoryMapper.selectById(id) == null) {
|
||||||
|
throw exception(CATEGORY_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BpmCategoryDO getCategory(Long id) {
|
||||||
|
return bpmCategoryMapper.selectById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResult<BpmCategoryDO> getCategoryPage(BpmCategoryPageReqVO pageReqVO) {
|
||||||
|
return bpmCategoryMapper.selectPage(pageReqVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<BpmCategoryDO> getCategoryListByCode(Collection<String> codes) {
|
||||||
|
if (CollUtil.isEmpty(codes)) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
return bpmCategoryMapper.selectListByCode(codes);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<BpmCategoryDO> getCategoryListByStatus(Integer status) {
|
||||||
|
return bpmCategoryMapper.selectListByStatus(status);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
File diff suppressed because one or more lines are too long
@ -0,0 +1,137 @@
|
|||||||
|
package cn.iocoder.yudao.module.bpm.service.category;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.category.BpmCategoryPageReqVO;
|
||||||
|
import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.category.BpmCategorySaveReqVO;
|
||||||
|
import cn.iocoder.yudao.module.bpm.service.definition.BpmCategoryServiceImpl;
|
||||||
|
import org.junit.jupiter.api.Disabled;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmCategoryDO;
|
||||||
|
import cn.iocoder.yudao.module.bpm.dal.mysql.category.BpmCategoryMapper;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.Import;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.*;
|
||||||
|
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*;
|
||||||
|
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*;
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*;
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*;
|
||||||
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link BpmCategoryServiceImpl} 的单元测试类
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
@Import(BpmCategoryServiceImpl.class)
|
||||||
|
public class BpmCategoryServiceImplTest extends BaseDbUnitTest {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private BpmCategoryServiceImpl categoryService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private BpmCategoryMapper categoryMapper;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCreateCategory_success() {
|
||||||
|
// 准备参数
|
||||||
|
BpmCategorySaveReqVO createReqVO = randomPojo(BpmCategorySaveReqVO.class).setId(null);
|
||||||
|
|
||||||
|
// 调用
|
||||||
|
Long categoryId = categoryService.createCategory(createReqVO);
|
||||||
|
// 断言
|
||||||
|
assertNotNull(categoryId);
|
||||||
|
// 校验记录的属性是否正确
|
||||||
|
BpmCategoryDO category = categoryMapper.selectById(categoryId);
|
||||||
|
assertPojoEquals(createReqVO, category, "id");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUpdateCategory_success() {
|
||||||
|
// mock 数据
|
||||||
|
BpmCategoryDO dbCategory = randomPojo(BpmCategoryDO.class);
|
||||||
|
categoryMapper.insert(dbCategory);// @Sql: 先插入出一条存在的数据
|
||||||
|
// 准备参数
|
||||||
|
BpmCategorySaveReqVO updateReqVO = randomPojo(BpmCategorySaveReqVO.class, o -> {
|
||||||
|
o.setId(dbCategory.getId()); // 设置更新的 ID
|
||||||
|
});
|
||||||
|
|
||||||
|
// 调用
|
||||||
|
categoryService.updateCategory(updateReqVO);
|
||||||
|
// 校验是否更新正确
|
||||||
|
BpmCategoryDO category = categoryMapper.selectById(updateReqVO.getId()); // 获取最新的
|
||||||
|
assertPojoEquals(updateReqVO, category);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUpdateCategory_notExists() {
|
||||||
|
// 准备参数
|
||||||
|
BpmCategorySaveReqVO updateReqVO = randomPojo(BpmCategorySaveReqVO.class);
|
||||||
|
|
||||||
|
// 调用, 并断言异常
|
||||||
|
assertServiceException(() -> categoryService.updateCategory(updateReqVO), CATEGORY_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDeleteCategory_success() {
|
||||||
|
// mock 数据
|
||||||
|
BpmCategoryDO dbCategory = randomPojo(BpmCategoryDO.class);
|
||||||
|
categoryMapper.insert(dbCategory);// @Sql: 先插入出一条存在的数据
|
||||||
|
// 准备参数
|
||||||
|
Long id = dbCategory.getId();
|
||||||
|
|
||||||
|
// 调用
|
||||||
|
categoryService.deleteCategory(id);
|
||||||
|
// 校验数据不存在了
|
||||||
|
assertNull(categoryMapper.selectById(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDeleteCategory_notExists() {
|
||||||
|
// 准备参数
|
||||||
|
Long id = randomLongId();
|
||||||
|
|
||||||
|
// 调用, 并断言异常
|
||||||
|
assertServiceException(() -> categoryService.deleteCategory(id), CATEGORY_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
||||||
|
public void testGetCategoryPage() {
|
||||||
|
// mock 数据
|
||||||
|
BpmCategoryDO dbCategory = randomPojo(BpmCategoryDO.class, o -> { // 等会查询到
|
||||||
|
o.setName(null);
|
||||||
|
o.setCode(null);
|
||||||
|
o.setStatus(null);
|
||||||
|
o.setCreateTime(null);
|
||||||
|
});
|
||||||
|
categoryMapper.insert(dbCategory);
|
||||||
|
// 测试 name 不匹配
|
||||||
|
categoryMapper.insert(cloneIgnoreId(dbCategory, o -> o.setName(null)));
|
||||||
|
// 测试 code 不匹配
|
||||||
|
categoryMapper.insert(cloneIgnoreId(dbCategory, o -> o.setCode(null)));
|
||||||
|
// 测试 status 不匹配
|
||||||
|
categoryMapper.insert(cloneIgnoreId(dbCategory, o -> o.setStatus(null)));
|
||||||
|
// 测试 createTime 不匹配
|
||||||
|
categoryMapper.insert(cloneIgnoreId(dbCategory, o -> o.setCreateTime(null)));
|
||||||
|
// 准备参数
|
||||||
|
BpmCategoryPageReqVO reqVO = new BpmCategoryPageReqVO();
|
||||||
|
reqVO.setName(null);
|
||||||
|
reqVO.setCode(null);
|
||||||
|
reqVO.setStatus(null);
|
||||||
|
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
|
||||||
|
|
||||||
|
// 调用
|
||||||
|
PageResult<BpmCategoryDO> pageResult = categoryService.getCategoryPage(reqVO);
|
||||||
|
// 断言
|
||||||
|
assertEquals(1, pageResult.getTotal());
|
||||||
|
assertEquals(1, pageResult.getList().size());
|
||||||
|
assertPojoEquals(dbCategory, pageResult.getList().get(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue