BPM:增加流程表达式的管理
This commit is contained in:
parent
6d44bf0d7a
commit
727faac8d8
@ -72,4 +72,7 @@ public interface ErrorCodeConstants {
|
||||
ErrorCode PROCESS_LISTENER_CLASS_IMPLEMENTS_ERROR = new ErrorCode(1_009_013_002, "流程监听器类({})没有实现接口({})");
|
||||
ErrorCode PROCESS_LISTENER_EXPRESSION_INVALID = new ErrorCode(1_009_013_003, "流程监听器表达式({})不合法");
|
||||
|
||||
// ========== BPM 流程表达式 1-009-014-000 ==========
|
||||
ErrorCode PROCESS_EXPRESSION_NOT_EXISTS = new ErrorCode(1_009_014_000, "流程表达式不存在");
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,73 @@
|
||||
package cn.iocoder.yudao.module.bpm.controller.admin.definition;
|
||||
|
||||
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.expression.BpmProcessExpressionPageReqVO;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.expression.BpmProcessExpressionRespVO;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.expression.BpmProcessExpressionSaveReqVO;
|
||||
import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessExpressionDO;
|
||||
import cn.iocoder.yudao.module.bpm.service.definition.BpmProcessExpressionService;
|
||||
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 static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@Tag(name = "管理后台 - BPM 流程表达式")
|
||||
@RestController
|
||||
@RequestMapping("/bpm/process-expression")
|
||||
@Validated
|
||||
public class BpmProcessExpressionController {
|
||||
|
||||
@Resource
|
||||
private BpmProcessExpressionService processExpressionService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建流程表达式")
|
||||
@PreAuthorize("@ss.hasPermission('bpm:process-expression:create')")
|
||||
public CommonResult<Long> createProcessExpression(@Valid @RequestBody BpmProcessExpressionSaveReqVO createReqVO) {
|
||||
return success(processExpressionService.createProcessExpression(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新流程表达式")
|
||||
@PreAuthorize("@ss.hasPermission('bpm:process-expression:update')")
|
||||
public CommonResult<Boolean> updateProcessExpression(@Valid @RequestBody BpmProcessExpressionSaveReqVO updateReqVO) {
|
||||
processExpressionService.updateProcessExpression(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除流程表达式")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('bpm:process-expression:delete')")
|
||||
public CommonResult<Boolean> deleteProcessExpression(@RequestParam("id") Long id) {
|
||||
processExpressionService.deleteProcessExpression(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得流程表达式")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('bpm:process-expression:query')")
|
||||
public CommonResult<BpmProcessExpressionRespVO> getProcessExpression(@RequestParam("id") Long id) {
|
||||
BpmProcessExpressionDO processExpression = processExpressionService.getProcessExpression(id);
|
||||
return success(BeanUtils.toBean(processExpression, BpmProcessExpressionRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得流程表达式分页")
|
||||
@PreAuthorize("@ss.hasPermission('bpm:process-expression:query')")
|
||||
public CommonResult<PageResult<BpmProcessExpressionRespVO>> getProcessExpressionPage(
|
||||
@Valid BpmProcessExpressionPageReqVO pageReqVO) {
|
||||
PageResult<BpmProcessExpressionDO> pageResult = processExpressionService.getProcessExpressionPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, BpmProcessExpressionRespVO.class));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.expression;
|
||||
|
||||
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 BpmProcessExpressionPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "表达式名字", example = "李四")
|
||||
private String name;
|
||||
|
||||
@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,30 @@
|
||||
package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.expression;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - BPM 流程表达式 Response VO")
|
||||
@Data
|
||||
public class BpmProcessExpressionRespVO {
|
||||
|
||||
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3870")
|
||||
@ExcelProperty("编号")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "表达式名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四")
|
||||
@ExcelProperty("表达式名字")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "表达式状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "表达式", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private String expression;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.expression;
|
||||
|
||||
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 BpmProcessExpressionSaveReqVO {
|
||||
|
||||
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3870")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "表达式名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四")
|
||||
@NotEmpty(message = "表达式名字不能为空")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "表达式状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotNull(message = "表达式状态不能为空")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "表达式", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotEmpty(message = "表达式不能为空")
|
||||
private String expression;
|
||||
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
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_process_expression")
|
||||
@KeySequence("bpm_process_expression_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class BpmProcessExpressionDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 编号
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 表达式名字
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 表达式状态
|
||||
*
|
||||
* 枚举 {@link TODO common_status 对应的类}
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 表达式
|
||||
*/
|
||||
private String expression;
|
||||
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package cn.iocoder.yudao.module.bpm.dal.mysql.definition;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.expression.BpmProcessExpressionPageReqVO;
|
||||
import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessExpressionDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* BPM 流程表达式 Mapper
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface BpmProcessExpressionMapper extends BaseMapperX<BpmProcessExpressionDO> {
|
||||
|
||||
default PageResult<BpmProcessExpressionDO> selectPage(BpmProcessExpressionPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<BpmProcessExpressionDO>()
|
||||
.likeIfPresent(BpmProcessExpressionDO::getName, reqVO.getName())
|
||||
.eqIfPresent(BpmProcessExpressionDO::getStatus, reqVO.getStatus())
|
||||
.betweenIfPresent(BpmProcessExpressionDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(BpmProcessExpressionDO::getId));
|
||||
}
|
||||
|
||||
}
|
@ -34,7 +34,7 @@ public class BpmTaskAssignLeaderExpression {
|
||||
@Resource
|
||||
private BpmProcessInstanceService processInstanceService;
|
||||
|
||||
protected Set<Long> calculateUsers(DelegateExecution execution, int level) {
|
||||
public Set<Long> calculateUsers(DelegateExecution execution, int level) {
|
||||
Assert.isTrue(level > 0, "level 必须大于 0");
|
||||
// 获得发起人
|
||||
ProcessInstance processInstance = processInstanceService.getProcessInstance(execution.getProcessInstanceId());
|
||||
|
@ -4,7 +4,6 @@ import cn.iocoder.yudao.framework.common.util.collection.SetUtils;
|
||||
import cn.iocoder.yudao.framework.common.util.number.NumberUtils;
|
||||
import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.flowable.engine.delegate.DelegateExecution;
|
||||
import org.flowable.engine.runtime.ProcessInstance;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@ -21,7 +20,7 @@ public class BpmTaskAssignStartUserExpression {
|
||||
@Resource
|
||||
private BpmProcessInstanceService processInstanceService;
|
||||
|
||||
public Set<Long> calculateUsers(DelegateExecution execution) {
|
||||
public Set<Long> calculateUsers(org.flowable.engine.impl.persistence.entity.ExecutionEntityImpl execution) {
|
||||
ProcessInstance processInstance = processInstanceService.getProcessInstance(execution.getProcessInstanceId());
|
||||
Long startUserId = NumberUtils.parseLong(processInstance.getStartUserId());
|
||||
return SetUtils.asSet(startUserId);
|
||||
|
@ -0,0 +1,54 @@
|
||||
package cn.iocoder.yudao.module.bpm.service.definition;
|
||||
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.expression.BpmProcessExpressionPageReqVO;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.expression.BpmProcessExpressionSaveReqVO;
|
||||
import jakarta.validation.*;
|
||||
import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessExpressionDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
|
||||
/**
|
||||
* BPM 流程表达式 Service 接口
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
public interface BpmProcessExpressionService {
|
||||
|
||||
/**
|
||||
* 创建流程表达式
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createProcessExpression(@Valid BpmProcessExpressionSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新流程表达式
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateProcessExpression(@Valid BpmProcessExpressionSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除流程表达式
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteProcessExpression(Long id);
|
||||
|
||||
/**
|
||||
* 获得流程表达式
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 流程表达式
|
||||
*/
|
||||
BpmProcessExpressionDO getProcessExpression(Long id);
|
||||
|
||||
/**
|
||||
* 获得流程表达式分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 流程表达式分页
|
||||
*/
|
||||
PageResult<BpmProcessExpressionDO> getProcessExpressionPage(BpmProcessExpressionPageReqVO pageReqVO);
|
||||
|
||||
}
|
@ -0,0 +1,72 @@
|
||||
package cn.iocoder.yudao.module.bpm.service.definition;
|
||||
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.expression.BpmProcessExpressionPageReqVO;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.expression.BpmProcessExpressionSaveReqVO;
|
||||
import org.springframework.stereotype.Service;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessExpressionDO;
|
||||
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.definition.BpmProcessExpressionMapper;
|
||||
|
||||
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 BpmProcessExpressionServiceImpl implements BpmProcessExpressionService {
|
||||
|
||||
@Resource
|
||||
private BpmProcessExpressionMapper processExpressionMapper;
|
||||
|
||||
@Override
|
||||
public Long createProcessExpression(BpmProcessExpressionSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
BpmProcessExpressionDO processExpression = BeanUtils.toBean(createReqVO, BpmProcessExpressionDO.class);
|
||||
processExpressionMapper.insert(processExpression);
|
||||
// 返回
|
||||
return processExpression.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateProcessExpression(BpmProcessExpressionSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateProcessExpressionExists(updateReqVO.getId());
|
||||
// 更新
|
||||
BpmProcessExpressionDO updateObj = BeanUtils.toBean(updateReqVO, BpmProcessExpressionDO.class);
|
||||
processExpressionMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteProcessExpression(Long id) {
|
||||
// 校验存在
|
||||
validateProcessExpressionExists(id);
|
||||
// 删除
|
||||
processExpressionMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateProcessExpressionExists(Long id) {
|
||||
if (processExpressionMapper.selectById(id) == null) {
|
||||
throw exception(PROCESS_EXPRESSION_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BpmProcessExpressionDO getProcessExpression(Long id) {
|
||||
return processExpressionMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<BpmProcessExpressionDO> getProcessExpressionPage(BpmProcessExpressionPageReqVO pageReqVO) {
|
||||
return processExpressionMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user