多模块重构 8:bom 模块,尝试公用部分逻辑

This commit is contained in:
YunaiV 2022-02-01 20:33:03 +08:00
parent fe1271a6f7
commit f39bfdab89
102 changed files with 945 additions and 424 deletions

View File

@ -42,28 +42,13 @@
<artifactId>yudao-module-pay-impl</artifactId>
<version>${revision}</version>
</dependency>
<!-- 默认引入bpm-activiti. 可以替换为bpm-flowable -->
<!-- 默认引入 bpm-activiti 实现,可以替换为 bpm-flowable 实现-->
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-module-bpm-activiti</artifactId>
<artifactId>yudao-module-bpm-impl-activiti</artifactId>
<version>${revision}</version>
</dependency>
<!-- 业务组件 -->
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-spring-boot-starter-biz-dict</artifactId>
</dependency>
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-spring-boot-starter-biz-tenant</artifactId>
</dependency>
<!-- spring boot 配置所需依赖 -->
<dependency>
<groupId>org.springframework.boot</groupId>
@ -88,12 +73,6 @@
<artifactId>spring-boot-admin-starter-server</artifactId> <!-- 实现 Spring Boot Admin Server 服务端 -->
</dependency>
<!-- 三方云服务相关 -->
<dependency>
<groupId>com.xkcoding.justauth</groupId>
<artifactId>justauth-spring-boot-starter</artifactId>
</dependency>
</dependencies>
<build>

View File

@ -58,7 +58,8 @@ yudao:
app-api:
prefix: /app-api
controller: '**.controller.app.**'
admin-ui:
url: http://dashboard.yudao.iocoder.cn # Admin 管理后台 UI 的地址
swagger:
title: 管理后台
description: 提供管理员管理的所有功能
@ -78,8 +79,6 @@ yudao:
- cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants
tenant: # 多租户相关配置项
tables: # 配置需要开启多租户的表;如果实体已经继承 TenantBaseDO 类,则无需重复配置
url: ## TODO 芋艿:迁移到 web 配置项下,
admin-ui: http://dashboard.yudao.iocoder.cn # Admin 管理后台 UI 的地址
sms-code: # 短信验证码相关的配置项
expire-times: 10m
send-frequency: 1m

View File

@ -19,6 +19,9 @@ public class WebProperties {
@NotNull(message = "Admin API 不能为空")
private Api adminApi;
@NotNull(message = "Admin UI 不能为空")
private Ui adminUi;
@Data
@Valid
public static class Api {
@ -45,4 +48,15 @@ public class WebProperties {
}
@Data
@Valid
public static class Ui {
/**
* 访问地址
*/
private String url;
}
}

View File

@ -1,6 +1,7 @@
1. 类名可以去掉 Bpm 前缀哈
2. 后续接口我们分成 admin 管理后天app 用户前端;所以 controller 包下,需要有 admin 和 app 两个子包。可见 https://gitee.com/zhijiantianya/ruoyi-vue-pro/tree/feature/multi-module/yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/controller
3. yudao-module-xxx-api 是暴露接口给外部模块,所以可以把 yudao-module-bpm-core-service-api 改成 yudao-module-bpm-api。大概率用不了暴露 BpmUserGroupServiceApi 哈。
4. yudao-module-bpm-core-service-impl 模块,要不改成 yudao-module-bpm-base本质上是提供给 yudao-module-bpm-flowable-impl 和 yudao-module-bpm-activiti-impl 继承的。这样的话,我们在 yudao-module-bpm-base
3. yudao-module-bpm-core-service-impl 模块,要不改成 yudao-module-bpm-base本质上是提供给 yudao-module-bpm-flowable-impl 和 yudao-module-bpm-activiti-impl 继承的。这样的话,我们在 yudao-module-bpm-base
* 定义一些可被继承的类,例如说 ModelAbstractService
* 定义一些无需被继承的类,例如说 UserGroupService、UserGroupController 等等;

View File

@ -55,5 +55,10 @@ public interface ErrorCodeConstants {
// ========== 动态表单模块 1-009-010-000 ==========
ErrorCode FORM_NOT_EXISTS = new ErrorCode(1009010000, "动态表单不存在");
ErrorCode FORM_FIELD_REPEAT = new ErrorCode(1009010000, "表单项({}) 和 ({}) 使用了相同的字段名({})");
// ========== 用户组模块 1-009-011-000 ==========
ErrorCode USER_GROUP_NOT_EXISTS = new ErrorCode(1009011000, "用户组不存在");
ErrorCode USER_GROUP_IS_DISABLE = new ErrorCode(1009011001, "名字为【{}】的用户组已被禁用");
}

View File

@ -21,6 +21,17 @@
<artifactId>yudao-module-bpm-api</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-module-system-api</artifactId>
<version>${revision}</version>
</dependency>
<!-- 业务组件 -->
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-spring-boot-starter-biz-operatelog</artifactId>
</dependency>
<!-- Web 相关 -->
<dependency>

View File

@ -1,6 +1,5 @@
package cn.iocoder.yudao.module.bpm.controller.definition.vo.form;
import com.sun.istack.internal.NotNull;
import lombok.*;
import io.swagger.annotations.*;
import javax.validation.constraints.*;

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo;
package cn.iocoder.yudao.module.bpm.controller.oa.vo;
import lombok.*;
import java.util.*;

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo;
package cn.iocoder.yudao.module.bpm.controller.oa.vo;
import io.swagger.annotations.ApiModel;
import lombok.Data;

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo;
package cn.iocoder.yudao.module.bpm.controller.oa.vo;
import lombok.*;
import java.util.*;

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo;
package cn.iocoder.yudao.module.bpm.controller.oa.vo;
import lombok.*;
import io.swagger.annotations.*;

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.activity;
package cn.iocoder.yudao.module.bpm.controller.task.vo.activity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.instance;
package cn.iocoder.yudao.module.bpm.controller.task.vo.instance;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.instance;
package cn.iocoder.yudao.module.bpm.controller.task.vo.instance;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.instance;
package cn.iocoder.yudao.module.bpm.controller.task.vo.instance;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import io.swagger.annotations.ApiModel;

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.instance;
package cn.iocoder.yudao.module.bpm.controller.task.vo.instance;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.instance;
package cn.iocoder.yudao.module.bpm.controller.task.vo.instance;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.task;
package cn.iocoder.yudao.module.bpm.controller.task.vo.task;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.task;
package cn.iocoder.yudao.module.bpm.controller.task.vo.task;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.task;
package cn.iocoder.yudao.module.bpm.controller.task.vo.task;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import io.swagger.annotations.ApiModel;

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.task;
package cn.iocoder.yudao.module.bpm.controller.task.vo.task;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.task;
package cn.iocoder.yudao.module.bpm.controller.task.vo.task;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
@ -6,8 +6,6 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import java.util.List;
@ApiModel("流程任务的 Response VO")
@Data
@EqualsAndHashCode(callSuper = true)

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.task;
package cn.iocoder.yudao.module.bpm.controller.task.vo.task;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.task;
package cn.iocoder.yudao.module.bpm.controller.task.vo.task;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import io.swagger.annotations.ApiModel;

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.task;
package cn.iocoder.yudao.module.bpm.controller.task.vo.task;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

View File

@ -5,7 +5,6 @@ import cn.iocoder.yudao.module.bpm.controller.definition.vo.form.BpmFormRespVO;
import cn.iocoder.yudao.module.bpm.controller.definition.vo.form.BpmFormSimpleRespVO;
import cn.iocoder.yudao.module.bpm.controller.definition.vo.form.BpmFormUpdateReqVO;
import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO;
import cn.iocoder.yudao.module.bpm.api.form.dto.BpmFormDTO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
@ -28,10 +27,6 @@ public interface BpmFormConvert {
BpmFormRespVO convert(BpmFormDO bean);
BpmFormDTO convert1(BpmFormDO bean);
List<BpmFormDTO> convertList(List<BpmFormDO> list);
List<BpmFormSimpleRespVO> convertList2(List<BpmFormDO> list);
PageResult<BpmFormRespVO> convertPage(PageResult<BpmFormDO> page);

View File

@ -6,7 +6,6 @@ import cn.iocoder.yudao.module.bpm.controller.definition.vo.group.BpmUserGroupCr
import cn.iocoder.yudao.module.bpm.controller.definition.vo.group.BpmUserGroupRespVO;
import cn.iocoder.yudao.module.bpm.controller.definition.vo.group.BpmUserGroupUpdateReqVO;
import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmUserGroupDO;
import cn.iocoder.yudao.module.bpm.api.group.dto.BpmUserGroupDTO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import org.mapstruct.Mapper;
@ -36,5 +35,4 @@ public interface BpmUserGroupConvert {
@Named("convertList2")
List<BpmUserGroupRespVO> convertList2(List<BpmUserGroupDO> list);
List<BpmUserGroupDTO> convertList3(List<BpmUserGroupDO> list);
}

View File

@ -0,0 +1,16 @@
package cn.iocoder.yudao.module.bpm.convert.message;
import cn.iocoder.yudao.module.system.api.sms.dto.send.SmsSendSingleToUserReqDTO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import java.util.Map;
@Mapper
public interface BpmMessageConvert {
BpmMessageConvert INSTANCE = Mappers.getMapper(BpmMessageConvert.class);
SmsSendSingleToUserReqDTO convert(Long userId, String templateCode, Map<String, Object> templateParams);
}

View File

@ -0,0 +1 @@
package cn.iocoder.yudao.module.bpm.convert.oa;

View File

@ -0,0 +1 @@
package cn.iocoder.yudao.module.bpm.convert.task;

View File

@ -1,15 +1,12 @@
package cn.iocoder.yudao.module.bpm.dal.dataobject.definition;
import cn.iocoder.yudao.adminserver.modules.bpm.enums.definition.BpmModelFormTypeEnum;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO;
import cn.iocoder.yudao.module.bpm.enums.definition.BpmModelFormTypeEnum;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import lombok.*;
import org.activiti.engine.repository.Model;
import org.activiti.engine.repository.ProcessDefinition;
import java.util.List;
@ -36,13 +33,13 @@ public class BpmProcessDefinitionExtDO extends BaseDO {
/**
* 流程定义的编号
*
* 关联 {@link ProcessDefinition#getId()}
* 关联 ProcessDefinition id 属性
*/
private String processDefinitionId;
/**
* 流程模型的编号
*
* 关联 {@link Model#getId()}
* 关联 Model id 属性
*/
private String modelId;
/**

View File

@ -1,16 +1,13 @@
package cn.iocoder.yudao.module.bpm.dal.dataobject.definition;
import cn.iocoder.yudao.adminserver.modules.bpm.enums.definition.BpmTaskRuleScriptEnum;
import cn.iocoder.yudao.adminserver.modules.bpm.enums.definition.BpmTaskAssignRuleTypeEnum;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import cn.iocoder.yudao.framework.mybatis.core.type.JsonLongSetTypeHandler;
import cn.iocoder.yudao.module.bpm.enums.definition.BpmTaskAssignRuleTypeEnum;
import cn.iocoder.yudao.module.bpm.enums.definition.BpmTaskRuleScriptEnum;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.*;
import org.activiti.engine.repository.Model;
import org.activiti.engine.repository.ProcessDefinition;
import org.activiti.engine.task.Task;
import java.util.Set;
@ -46,19 +43,19 @@ public class BpmTaskAssignRuleDO extends BaseDO {
/**
* 流程模型编号
*
* 关联 {@link Model#getId()}
* 关联 Model id 属性
*/
private String modelId;
/**
* 流程定义编号
*
* 关联 {@link ProcessDefinition#getId()}
* 关联 ProcessDefinition id 属性
*/
private String processDefinitionId;
/**
* 流程任务的定义 Key
*
* 关联 {@link Task#getTaskDefinitionKey()}
* 关联 Task taskDefinitionKey 属性
*/
private String taskDefinitionKey;

View File

@ -1,11 +1,10 @@
package cn.iocoder.yudao.module.bpm.dal.dataobject.oa;
import cn.iocoder.yudao.module.system.dal.dataobject.user.SysUserDO;
import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceResultEnum;
import lombok.*;
import java.util.*;
import com.baomidou.mybatisplus.annotation.*;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import org.activiti.engine.runtime.ProcessInstance;
/**
* OA 请假申请 DO
@ -32,7 +31,7 @@ public class BpmOALeaveDO extends BaseDO {
/**
* 申请人的用户编号
*
* 关联 {@link SysUserDO#getId()}
* 关联 AdminUserDO id 属性
*/
private Long userId;
/**
@ -59,7 +58,7 @@ public class BpmOALeaveDO extends BaseDO {
/**
* 请假的结果
*
* 枚举 {@link cn.iocoder.yudao.adminserver.modules.bpm.enums.task.BpmProcessInstanceResultEnum}
* 枚举 {@link BpmProcessInstanceResultEnum}
* 考虑到简单所以直接复用了 BpmProcessInstanceResultEnum 枚举也可以自己定义一个枚举哈
*/
private Integer result;
@ -67,7 +66,7 @@ public class BpmOALeaveDO extends BaseDO {
/**
* 对应的流程编号
*
* 关联 {@link ProcessInstance#getId()}
* 关联 ProcessInstance id 属性
*/
private String processInstanceId;

View File

@ -1,8 +1,8 @@
package cn.iocoder.yudao.module.bpm.dal.dataobject.task;
import cn.iocoder.yudao.adminserver.modules.bpm.enums.task.BpmProcessInstanceResultEnum;
import cn.iocoder.yudao.adminserver.modules.bpm.enums.task.BpmProcessInstanceStatusEnum;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceResultEnum;
import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceStatusEnum;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
@ -10,16 +10,13 @@ import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.activiti.engine.history.HistoricProcessInstance;
import org.activiti.engine.repository.ProcessDefinition;
import org.activiti.engine.runtime.ProcessInstance;
import java.util.Date;
import java.util.Map;
/**
* Bpm 流程实例的拓展表
* 主要解决 Activiti {@link ProcessInstance} {@link HistoricProcessInstance} 不支持拓展字段所以新建拓展表
* 主要解决 Activiti ProcessInstance HistoricProcessInstance 不支持拓展字段所以新建拓展表
*
* @author 芋道源码
*/
@ -27,9 +24,6 @@ import java.util.Map;
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
//@Builder
//@NoArgsConstructor
//@AllArgsConstructor
public class BpmProcessInstanceExtDO extends BaseDO {
/**
@ -40,31 +34,31 @@ public class BpmProcessInstanceExtDO extends BaseDO {
/**
* 发起流程的用户编号
*
* 冗余 {@link HistoricProcessInstance#getStartUserId()}
* 冗余 HistoricProcessInstance startUserId 属性
*/
private Long startUserId;
/**
* 流程实例的名字
*
* 冗余 {@link ProcessInstance#getName()} 为了筛选
* 冗余 ProcessInstance name 属性用于筛选
*/
private String name;
/**
* 流程实例的编号
*
* 关联 {@link ProcessInstance#getId()}
* 关联 ProcessInstance id 属性
*/
private String processInstanceId;
/**
* 流程定义的编号
*
* 关联 {@link ProcessDefinition#getId()}
* 关联 ProcessDefinition id 属性
*/
private String processDefinitionId;
/**
* 流程分类
*
* 冗余 {@link ProcessDefinition#getCategory()}
* 冗余 ProcessDefinition category 属性
* 数据字典 bpm_model_category
*/
private String category;
@ -83,7 +77,7 @@ public class BpmProcessInstanceExtDO extends BaseDO {
/**
* 结束时间
*
* 冗余 {@link HistoricProcessInstance#getEndTime()}
* 冗余 HistoricProcessInstance endTime 属性
*/
private Date endTime;

View File

@ -1,21 +1,17 @@
package cn.iocoder.yudao.module.bpm.dal.dataobject.task;
import cn.iocoder.yudao.adminserver.modules.bpm.enums.task.BpmProcessInstanceResultEnum;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceResultEnum;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.activiti.engine.history.HistoricTaskInstance;
import org.activiti.engine.repository.ProcessDefinition;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Task;
import java.util.Date;
/**
* Bpm 流程任务的拓展表
* 主要解决 Activiti {@link Task} {@link HistoricTaskInstance} 不支持拓展字段所以新建拓展表
* 主要解决 Activiti Task HistoricTaskInstance 不支持拓展字段所以新建拓展表
*
* @author 芋道源码
*/
@ -23,27 +19,24 @@ import java.util.Date;
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
//@Builder
//@NoArgsConstructor
//@AllArgsConstructor
public class BpmTaskExtDO extends BaseDO {
/**
* 任务的审批人
*
* 冗余 {@link Task#getAssignee()}
* 冗余 Task assignee 属性
*/
private Long assigneeUserId;
/**
* 任务的名字
*
* 冗余 {@link Task#getName()} 为了筛选
* 冗余 Task name 属性为了筛选
*/
private String name;
/**
* 任务的编号
*
* 关联 {@link Task#getId()}
* 关联 Task id 属性
*/
private String taskId;
// /**
@ -65,20 +58,20 @@ public class BpmTaskExtDO extends BaseDO {
/**
* 任务的结束时间
*
* 冗余 {@link HistoricTaskInstance#getEndTime()}
* 冗余 HistoricTaskInstance endTime 属性
*/
private Date endTime;
/**
* 流程实例的编号
*
* 关联 {@link ProcessInstance#getId()}
* 关联 ProcessInstance id 属性
*/
private String processInstanceId;
/**
* 流程定义的编号
*
* 关联 {@link ProcessDefinition#getId()}
* 关联 ProcessDefinition id 属性
*/
private String processDefinitionId;

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.adminserver.modules.bpm.dal.mysql.definition;
package cn.iocoder.yudao.module.bpm.dal.mysql.definition;
import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessDefinitionExtDO;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.adminserver.modules.bpm.dal.mysql.definition;
package cn.iocoder.yudao.module.bpm.dal.mysql.definition;
import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmTaskAssignRuleDO;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;

View File

@ -1,6 +1,6 @@
package cn.iocoder.yudao.adminserver.modules.bpm.dal.mysql.oa;
package cn.iocoder.yudao.module.bpm.dal.mysql.oa;
import cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo.BpmOALeavePageReqVO;
import cn.iocoder.yudao.module.bpm.controller.oa.vo.BpmOALeavePageReqVO;
import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOALeaveDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;

View File

@ -1,6 +1,6 @@
package cn.iocoder.yudao.adminserver.modules.bpm.dal.mysql.task;
package cn.iocoder.yudao.module.bpm.dal.mysql.task;
import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.instance.BpmProcessInstanceMyPageReqVO;
import cn.iocoder.yudao.module.bpm.controller.task.vo.instance.BpmProcessInstanceMyPageReqVO;
import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmProcessInstanceExtDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.adminserver.modules.bpm.dal.mysql.task;
package cn.iocoder.yudao.module.bpm.dal.mysql.task;
import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmTaskExtDO;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;

View File

@ -1,6 +1,5 @@
package cn.iocoder.yudao.module.bpm.enums.message;
import cn.iocoder.yudao.module.system.dal.dataobject.sms.SysSmsTemplateDO;
import lombok.AllArgsConstructor;
import lombok.Getter;
@ -20,9 +19,8 @@ public enum BpmMessageEnum {
/**
* 短信模板的标识
*
* 关联 {@link SysSmsTemplateDO#getCode()}
* 关联 SmsTemplateDO code 属性
*/
private final String smsCode;
private final String smsTemplateCode;
}

View File

@ -46,6 +46,14 @@ public interface BpmUserGroupService {
*/
BpmUserGroupDO getUserGroup(Long id);
/**
* 获得用户组列表
*
* @param ids 编号
* @return 用户组列表
*/
List<BpmUserGroupDO> getUserGroupList(Collection<Long> ids);
/**
* 获得指定状态的用户组列表
*
@ -70,4 +78,5 @@ public interface BpmUserGroupService {
* @param ids 用户组编号数组
*/
void validUserGroups(Set<Long> ids);
}

View File

@ -15,12 +15,13 @@ import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.USER_GROUP_NOT_EXISTS;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.*;
/**
* 用户组 Service 实现类
@ -71,6 +72,11 @@ public class BpmUserGroupServiceImpl implements BpmUserGroupService {
return userGroupMapper.selectById(id);
}
@Override
public List<BpmUserGroupDO> getUserGroupList(Collection<Long> ids) {
return userGroupMapper.selectBatchIds(ids);
}
@Override
public List<BpmUserGroupDO> getUserGroupListByStatus(Integer status) {

View File

@ -1,13 +1,13 @@
package cn.iocoder.yudao.module.bpm.service.message;
import cn.iocoder.yudao.adminserver.modules.bpm.enums.message.BpmMessageEnum;
import cn.iocoder.yudao.module.bpm.service.message.BpmMessageService;
import cn.iocoder.yudao.framework.web.config.WebProperties;
import cn.iocoder.yudao.module.bpm.convert.message.BpmMessageConvert;
import cn.iocoder.yudao.module.bpm.enums.message.BpmMessageEnum;
import cn.iocoder.yudao.module.bpm.service.message.dto.BpmMessageSendWhenProcessInstanceApproveReqDTO;
import cn.iocoder.yudao.module.bpm.service.message.dto.BpmMessageSendWhenProcessInstanceRejectReqDTO;
import cn.iocoder.yudao.module.bpm.service.message.dto.BpmMessageSendWhenTaskCreatedReqDTO;
import cn.iocoder.yudao.module.system.service.sms.SysSmsCoreService;
import cn.iocoder.yudao.module.system.api.sms.SmsSendApi;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
@ -26,18 +26,18 @@ import java.util.Map;
public class BpmMessageServiceImpl implements BpmMessageService {
@Resource
private SysSmsCoreService smsCoreService;
private SmsSendApi smsSendApi;
@Value("${yudao.url.admin-ui}")
private String adminUiUrl;
@Resource
private WebProperties webProperties;
@Override
public void sendMessageWhenProcessInstanceApprove(BpmMessageSendWhenProcessInstanceApproveReqDTO reqDTO) {
Map<String, Object> templateParams = new HashMap<>();
templateParams.put("processInstanceName", reqDTO.getProcessInstanceName());
templateParams.put("detailUrl", getProcessInstanceDetailUrl(reqDTO.getProcessInstanceId()));
smsCoreService.sendSingleSmsToAdmin(null, reqDTO.getStartUserId(),
BpmMessageEnum.PROCESS_INSTANCE_APPROVE.getSmsCode(), templateParams);
smsSendApi.sendSingleSmsToAdmin(BpmMessageConvert.INSTANCE.convert(reqDTO.getStartUserId(),
BpmMessageEnum.PROCESS_INSTANCE_APPROVE.getSmsTemplateCode(), templateParams));
}
@Override
@ -46,8 +46,8 @@ public class BpmMessageServiceImpl implements BpmMessageService {
templateParams.put("processInstanceName", reqDTO.getProcessInstanceName());
templateParams.put("comment", reqDTO.getComment());
templateParams.put("detailUrl", getProcessInstanceDetailUrl(reqDTO.getProcessInstanceId()));
smsCoreService.sendSingleSmsToAdmin(null, reqDTO.getStartUserId(),
BpmMessageEnum.PROCESS_INSTANCE_REJECT.getSmsCode(), templateParams);
smsSendApi.sendSingleSmsToAdmin(BpmMessageConvert.INSTANCE.convert(reqDTO.getStartUserId(),
BpmMessageEnum.PROCESS_INSTANCE_REJECT.getSmsTemplateCode(), templateParams));
}
@Override
@ -57,12 +57,12 @@ public class BpmMessageServiceImpl implements BpmMessageService {
templateParams.put("taskName", reqDTO.getTaskName());
templateParams.put("startUserNickname", reqDTO.getStartUserNickname());
templateParams.put("detailUrl", getProcessInstanceDetailUrl(reqDTO.getProcessInstanceId()));
smsCoreService.sendSingleSmsToAdmin(null, reqDTO.getAssigneeUserId(),
BpmMessageEnum.TASK_ASSIGNED.getSmsCode(), templateParams);
smsSendApi.sendSingleSmsToAdmin(BpmMessageConvert.INSTANCE.convert(reqDTO.getStartUserId(),
BpmMessageEnum.TASK_ASSIGNED.getSmsTemplateCode(), templateParams));
}
private String getProcessInstanceDetailUrl(String taskId) {
return adminUiUrl + "bpm/process-instance/detail?id=" + taskId;
return webProperties.getAdminUi().getUrl() + "/bpm/process-instance/detail?id=" + taskId;
}
}

View File

@ -22,7 +22,7 @@ public class BpmMessageSendWhenTaskCreatedReqDTO {
@NotEmpty(message = "流程实例的名字不能为空")
private String processInstanceName;
@NotEmpty(message = "发起人的用户编号")
private String startUserId;
private Long startUserId;
@NotEmpty(message = "发起人的昵称")
private String startUserNickname;

View File

@ -0,0 +1 @@
package cn.iocoder.yudao.module.bpm.service.task;

View File

@ -1,6 +1,5 @@
package cn.iocoder.yudao.adminserver.modules.bpm.controller.definition;
import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.model.*;
import cn.iocoder.yudao.adminserver.modules.bpm.convert.definition.BpmModelConvert;
import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmModelService;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;

View File

@ -1,8 +1,8 @@
package cn.iocoder.yudao.adminserver.modules.bpm.controller.oa;
import cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo.BpmOALeaveCreateReqVO;
import cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo.BpmOALeavePageReqVO;
import cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo.BpmOALeaveRespVO;
import cn.iocoder.yudao.module.bpm.controller.oa.vo.BpmOALeaveCreateReqVO;
import cn.iocoder.yudao.module.bpm.controller.oa.vo.BpmOALeavePageReqVO;
import cn.iocoder.yudao.module.bpm.controller.oa.vo.BpmOALeaveRespVO;
import cn.iocoder.yudao.adminserver.modules.bpm.convert.oa.BpmOALeaveConvert;
import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOALeaveDO;
import cn.iocoder.yudao.adminserver.modules.bpm.service.oa.BpmOALeaveService;

View File

@ -1,7 +1,7 @@
package cn.iocoder.yudao.adminserver.modules.bpm.controller.task;
import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.activity.BpmActivityRespVO;
import cn.iocoder.yudao.module.bpm.controller.task.vo.activity.BpmActivityRespVO;
import cn.iocoder.yudao.adminserver.modules.bpm.service.task.BpmActivityService;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils;

View File

@ -1,9 +1,9 @@
package cn.iocoder.yudao.adminserver.modules.bpm.controller.task;
import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.instance.*;
import cn.iocoder.yudao.adminserver.modules.bpm.service.task.BpmProcessInstanceService;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.bpm.controller.task.vo.instance.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
@ -25,7 +25,7 @@ public class BpmProcessInstanceController {
@Resource
private BpmProcessInstanceService processInstanceService;
@PostMapping("/create")
@ApiOperation("新建流程实例")
@PreAuthorize("@ss.hasPermission('bpm:process-instance:query')")

View File

@ -1,10 +1,9 @@
package cn.iocoder.yudao.adminserver.modules.bpm.controller.task;
import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.task.*;
import cn.iocoder.yudao.adminserver.modules.bpm.service.task.BpmTaskService;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils;
import cn.iocoder.yudao.module.bpm.controller.task.vo.task.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
@ -13,9 +12,7 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;
import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

View File

@ -1,13 +1,12 @@
package cn.iocoder.yudao.adminserver.modules.bpm.convert.definition;
import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.model.*;
import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.dto.BpmModelMetaInfoRespDTO;
import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.dto.BpmProcessDefinitionCreateReqDTO;
import cn.iocoder.yudao.module.bpm.api.form.dto.BpmFormDTO;
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
import cn.iocoder.yudao.module.bpm.controller.definition.vo.model.*;
import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO;
import org.activiti.engine.impl.persistence.entity.SuspensionState;
import org.activiti.engine.repository.Deployment;
import org.activiti.engine.repository.Model;
@ -31,19 +30,19 @@ public interface BpmModelConvert {
BpmModelConvert INSTANCE = Mappers.getMapper(BpmModelConvert.class);
default List<BpmModelPageItemRespVO> convertList(List<Model> list, Map<Long, BpmFormDTO> formMap,
default List<BpmModelPageItemRespVO> convertList(List<Model> list, Map<Long, BpmFormDO> formMap,
Map<String, Deployment> deploymentMap,
Map<String, ProcessDefinition> processDefinitionMap) {
return CollectionUtils.convertList(list, model -> {
BpmModelMetaInfoRespDTO metaInfo = JsonUtils.parseObject(model.getMetaInfo(), BpmModelMetaInfoRespDTO.class);
BpmFormDTO form = metaInfo != null ? formMap.get(metaInfo.getFormId()) : null;
BpmFormDO form = metaInfo != null ? formMap.get(metaInfo.getFormId()) : null;
Deployment deployment = model.getDeploymentId() != null ? deploymentMap.get(model.getDeploymentId()) : null;
ProcessDefinition processDefinition = model.getDeploymentId() != null ? processDefinitionMap.get(model.getDeploymentId()) : null;
return convert(model, form, deployment, processDefinition);
});
}
default BpmModelPageItemRespVO convert(Model model, BpmFormDTO form, Deployment deployment, ProcessDefinition processDefinition) {
default BpmModelPageItemRespVO convert(Model model, BpmFormDO form, Deployment deployment, ProcessDefinition processDefinition) {
BpmModelPageItemRespVO modelRespVO = new BpmModelPageItemRespVO();
modelRespVO.setId(model.getId());
modelRespVO.setCreateTime(model.getCreateTime());
@ -84,7 +83,7 @@ public interface BpmModelConvert {
void copyTo(BpmModelMetaInfoRespDTO from, @MappingTarget BpmModelBaseVO to);
default BpmProcessDefinitionCreateReqDTO convert2(Model model, BpmFormDTO form) {
default BpmProcessDefinitionCreateReqDTO convert2(Model model, BpmFormDO form) {
BpmProcessDefinitionCreateReqDTO createReqDTO = new BpmProcessDefinitionCreateReqDTO();
createReqDTO.setModelId(model.getId());
createReqDTO.setName(model.getName());

View File

@ -2,9 +2,9 @@ package cn.iocoder.yudao.adminserver.modules.bpm.convert.definition;
import cn.iocoder.yudao.module.bpm.controller.definition.vo.process.BpmProcessDefinitionPageItemRespVO;
import cn.iocoder.yudao.module.bpm.controller.definition.vo.process.BpmProcessDefinitionRespVO;
import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO;
import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessDefinitionExtDO;
import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.dto.BpmProcessDefinitionCreateReqDTO;
import cn.iocoder.yudao.module.bpm.api.form.dto.BpmFormDTO;
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
import org.activiti.engine.impl.persistence.entity.SuspensionState;
import org.activiti.engine.repository.Deployment;
@ -29,17 +29,17 @@ public interface BpmProcessDefinitionConvert {
BpmProcessDefinitionConvert INSTANCE = Mappers.getMapper(BpmProcessDefinitionConvert.class);
default List<BpmProcessDefinitionPageItemRespVO> convertList(List<ProcessDefinition> list, Map<String, Deployment> deploymentMap,
Map<String, BpmProcessDefinitionExtDO> processDefinitionDOMap, Map<Long, BpmFormDTO> formMap) {
Map<String, BpmProcessDefinitionExtDO> processDefinitionDOMap, Map<Long, BpmFormDO> formMap) {
return CollectionUtils.convertList(list, definition -> {
Deployment deployment = definition.getDeploymentId() != null ? deploymentMap.get(definition.getDeploymentId()) : null;
BpmProcessDefinitionExtDO definitionDO = processDefinitionDOMap.get(definition.getId());
BpmFormDTO form = definitionDO != null ? formMap.get(definitionDO.getFormId()) : null;
BpmFormDO form = definitionDO != null ? formMap.get(definitionDO.getFormId()) : null;
return convert(definition, deployment, definitionDO, form);
});
}
default BpmProcessDefinitionPageItemRespVO convert(ProcessDefinition bean, Deployment deployment,
BpmProcessDefinitionExtDO processDefinitionExtDO, BpmFormDTO form) {
BpmProcessDefinitionExtDO processDefinitionExtDO, BpmFormDO form) {
BpmProcessDefinitionPageItemRespVO respVO = convert(bean);
respVO.setSuspensionState(bean.isSuspended() ? SuspensionState.SUSPENDED.getStateCode() : SuspensionState.ACTIVE.getStateCode());
if (deployment != null) {

View File

@ -3,7 +3,7 @@ package cn.iocoder.yudao.adminserver.modules.bpm.convert.message;
import cn.iocoder.yudao.module.bpm.service.message.dto.BpmMessageSendWhenProcessInstanceApproveReqDTO;
import cn.iocoder.yudao.module.bpm.service.message.dto.BpmMessageSendWhenProcessInstanceRejectReqDTO;
import cn.iocoder.yudao.module.bpm.service.message.dto.BpmMessageSendWhenTaskCreatedReqDTO;
import cn.iocoder.yudao.module.system.dal.dataobject.user.SysUserDO;
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
import org.activiti.api.task.model.Task;
import org.activiti.engine.runtime.ProcessInstance;
import org.mapstruct.Mapper;
@ -17,7 +17,7 @@ public interface BpmMessageConvert {
BpmMessageConvert INSTANCE = Mappers.getMapper(BpmMessageConvert.class);
default BpmMessageSendWhenTaskCreatedReqDTO convert(ProcessInstance processInstance, SysUserDO startUser, Task task) {
default BpmMessageSendWhenTaskCreatedReqDTO convert(ProcessInstance processInstance, AdminUserRespDTO startUser, Task task) {
BpmMessageSendWhenTaskCreatedReqDTO reqDTO = new BpmMessageSendWhenTaskCreatedReqDTO();
copyTo(processInstance, reqDTO);
copyTo(startUser, reqDTO);
@ -30,7 +30,7 @@ public interface BpmMessageConvert {
@Mapping(source = "id", target = "startUserId"),
@Mapping(source = "nickname", target = "startUserNickname")
})
void copyTo(SysUserDO from, @MappingTarget BpmMessageSendWhenTaskCreatedReqDTO to);
void copyTo(AdminUserRespDTO from, @MappingTarget BpmMessageSendWhenTaskCreatedReqDTO to);
@Mappings({
@Mapping(source = "id", target = "taskId"),
@Mapping(source = "name", target = "taskName"),

View File

@ -1,7 +1,7 @@
package cn.iocoder.yudao.adminserver.modules.bpm.convert.oa;
import cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo.BpmOALeaveCreateReqVO;
import cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo.BpmOALeaveRespVO;
import cn.iocoder.yudao.module.bpm.controller.oa.vo.BpmOALeaveCreateReqVO;
import cn.iocoder.yudao.module.bpm.controller.oa.vo.BpmOALeaveRespVO;
import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOALeaveDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import org.mapstruct.Mapper;

View File

@ -1,6 +1,6 @@
package cn.iocoder.yudao.adminserver.modules.bpm.convert.task;
import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.activity.BpmActivityRespVO;
import cn.iocoder.yudao.module.bpm.controller.task.vo.activity.BpmActivityRespVO;
import org.activiti.engine.history.HistoricActivityInstance;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

View File

@ -1,12 +1,12 @@
package cn.iocoder.yudao.adminserver.modules.bpm.convert.task;
import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.instance.BpmProcessInstancePageItemRespVO;
import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.instance.BpmProcessInstanceRespVO;
import cn.iocoder.yudao.module.bpm.controller.task.vo.instance.BpmProcessInstancePageItemRespVO;
import cn.iocoder.yudao.module.bpm.controller.task.vo.instance.BpmProcessInstanceRespVO;
import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessDefinitionExtDO;
import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmProcessInstanceExtDO;
import cn.iocoder.yudao.adminserver.modules.bpm.framework.activiti.core.event.BpmProcessInstanceResultEvent;
import cn.iocoder.yudao.module.system.dal.dataobject.dept.SysDeptDO;
import cn.iocoder.yudao.module.system.dal.dataobject.user.SysUserDO;
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import org.activiti.engine.history.HistoricProcessInstance;
import org.activiti.engine.repository.ProcessDefinition;
@ -71,7 +71,7 @@ public interface BpmProcessInstanceConvert {
default BpmProcessInstanceRespVO convert2(HistoricProcessInstance processInstance, BpmProcessInstanceExtDO processInstanceExt,
ProcessDefinition processDefinition, BpmProcessDefinitionExtDO processDefinitionExt,
String bpmnXml, SysUserDO startUser, SysDeptDO dept) {
String bpmnXml, AdminUserRespDTO startUser, DeptRespDTO dept) {
BpmProcessInstanceRespVO respVO = convert2(processInstance);
copyTo(processInstanceExt, respVO);
// definition
@ -94,7 +94,7 @@ public interface BpmProcessInstanceConvert {
BpmProcessInstanceRespVO.ProcessDefinition convert2(ProcessDefinition bean);
@Mapping(source = "from.id", target = "to.id", ignore = true)
void copyTo(BpmProcessDefinitionExtDO from, @MappingTarget BpmProcessInstanceRespVO.ProcessDefinition to);
BpmProcessInstanceRespVO.User convert2(SysUserDO bean);
BpmProcessInstanceRespVO.User convert2(AdminUserRespDTO bean);
default BpmProcessInstanceResultEvent convert(Object source, ProcessInstance instance, Integer result) {
BpmProcessInstanceResultEvent event = new BpmProcessInstanceResultEvent(source);

View File

@ -1,11 +1,11 @@
package cn.iocoder.yudao.adminserver.modules.bpm.convert.task;
import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.task.BpmTaskDonePageItemRespVO;
import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.task.BpmTaskRespVO;
import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.task.BpmTaskTodoPageItemRespVO;
import cn.iocoder.yudao.module.bpm.controller.task.vo.task.BpmTaskDonePageItemRespVO;
import cn.iocoder.yudao.module.bpm.controller.task.vo.task.BpmTaskRespVO;
import cn.iocoder.yudao.module.bpm.controller.task.vo.task.BpmTaskTodoPageItemRespVO;
import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmTaskExtDO;
import cn.iocoder.yudao.module.system.dal.dataobject.dept.SysDeptDO;
import cn.iocoder.yudao.module.system.dal.dataobject.user.SysUserDO;
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
import cn.iocoder.yudao.framework.common.util.number.NumberUtils;
import org.activiti.engine.history.HistoricProcessInstance;
@ -30,12 +30,12 @@ public interface BpmTaskConvert {
BpmTaskConvert INSTANCE = Mappers.getMapper(BpmTaskConvert.class);
default List<BpmTaskTodoPageItemRespVO> convertList1(List<Task> tasks, Map<String, ProcessInstance> processInstanceMap,
Map<Long, SysUserDO> userMap) {
Map<Long, AdminUserRespDTO> userMap) {
return CollectionUtils.convertList(tasks, task -> {
BpmTaskTodoPageItemRespVO respVO = convert1(task);
ProcessInstance processInstance = processInstanceMap.get(task.getProcessInstanceId());
if (processInstance != null) {
SysUserDO startUser = userMap.get(NumberUtils.parseLong(processInstance.getStartUserId()));
AdminUserRespDTO startUser = userMap.get(NumberUtils.parseLong(processInstance.getStartUserId()));
respVO.setProcessInstance(convert(processInstance, startUser));
}
return respVO;
@ -53,14 +53,14 @@ public interface BpmTaskConvert {
default List<BpmTaskDonePageItemRespVO> convertList2(List<HistoricTaskInstance> tasks, Map<String, BpmTaskExtDO> bpmTaskExtDOMap,
Map<String, HistoricProcessInstance> historicProcessInstanceMap,
Map<Long, SysUserDO> userMap) {
Map<Long, AdminUserRespDTO> userMap) {
return CollectionUtils.convertList(tasks, task -> {
BpmTaskDonePageItemRespVO respVO = convert2(task);
BpmTaskExtDO taskExtDO = bpmTaskExtDOMap.get(task.getId());
copyTo(taskExtDO, respVO);
HistoricProcessInstance processInstance = historicProcessInstanceMap.get(task.getProcessInstanceId());
if (processInstance != null) {
SysUserDO startUser = userMap.get(NumberUtils.parseLong(processInstance.getStartUserId()));
AdminUserRespDTO startUser = userMap.get(NumberUtils.parseLong(processInstance.getStartUserId()));
respVO.setProcessInstance(convert(processInstance, startUser));
}
return respVO;
@ -77,20 +77,20 @@ public interface BpmTaskConvert {
BpmTaskExtDO convert(org.activiti.api.task.model.Task bean);
default List<BpmTaskRespVO> convertList3(List<HistoricTaskInstance> tasks, Map<String, BpmTaskExtDO> bpmTaskExtDOMap,
HistoricProcessInstance processInstance, Map<Long, SysUserDO> userMap,
Map<Long, SysDeptDO> deptMap) {
HistoricProcessInstance processInstance, Map<Long, AdminUserRespDTO> userMap,
Map<Long, DeptRespDTO> deptMap) {
return CollectionUtils.convertList(tasks, task -> {
BpmTaskRespVO respVO = convert3(task);
BpmTaskExtDO taskExtDO = bpmTaskExtDOMap.get(task.getId());
copyTo(taskExtDO, respVO);
if (processInstance != null) {
SysUserDO startUser = userMap.get(NumberUtils.parseLong(processInstance.getStartUserId()));
AdminUserRespDTO startUser = userMap.get(NumberUtils.parseLong(processInstance.getStartUserId()));
respVO.setProcessInstance(convert(processInstance, startUser));
}
SysUserDO assignUser = userMap.get(NumberUtils.parseLong(task.getAssignee()));
AdminUserRespDTO assignUser = userMap.get(NumberUtils.parseLong(task.getAssignee()));
if (assignUser != null) {
respVO.setAssigneeUser(convert3(assignUser));
SysDeptDO dept = deptMap.get(assignUser.getDeptId());
DeptRespDTO dept = deptMap.get(assignUser.getDeptId());
if (dept != null) {
respVO.getAssigneeUser().setDeptName(dept.getName());
}
@ -101,7 +101,7 @@ public interface BpmTaskConvert {
@Mapping(source = "taskDefinitionKey", target = "definitionKey")
BpmTaskRespVO convert3(HistoricTaskInstance bean);
BpmTaskRespVO.User convert3(SysUserDO bean);
BpmTaskRespVO.User convert3(AdminUserRespDTO bean);
void copyTo(BpmTaskExtDO from, @MappingTarget BpmTaskDonePageItemRespVO to);
@ -112,7 +112,7 @@ public interface BpmTaskConvert {
@Mapping(source = "processInstance.processDefinitionId", target = "processDefinitionId"),
@Mapping(source = "startUser.nickname", target = "startUserNickname")
})
BpmTaskTodoPageItemRespVO.ProcessInstance convert(ProcessInstance processInstance, SysUserDO startUser);
BpmTaskTodoPageItemRespVO.ProcessInstance convert(ProcessInstance processInstance, AdminUserRespDTO startUser);
@Mappings({
@Mapping(source = "processInstance.id", target = "id"),
@ -121,6 +121,6 @@ public interface BpmTaskConvert {
@Mapping(source = "processInstance.processDefinitionId", target = "processDefinitionId"),
@Mapping(source = "startUser.nickname", target = "startUserNickname")
})
BpmTaskTodoPageItemRespVO.ProcessInstance convert(HistoricProcessInstance processInstance, SysUserDO startUser);
BpmTaskTodoPageItemRespVO.ProcessInstance convert(HistoricProcessInstance processInstance, AdminUserRespDTO startUser);
}

View File

@ -6,13 +6,10 @@ import cn.iocoder.yudao.adminserver.modules.bpm.framework.activiti.core.event.Bp
import cn.iocoder.yudao.adminserver.modules.bpm.framework.activiti.core.identity.EmptyUserGroupManager;
import cn.iocoder.yudao.adminserver.modules.bpm.framework.activiti.core.listener.BpmTackActivitiEventListener;
import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmTaskAssignRuleService;
import cn.iocoder.yudao.module.bpm.api.group.BpmUserGroupServiceApi;
import cn.iocoder.yudao.module.system.service.dept.SysDeptCoreService;
import cn.iocoder.yudao.module.system.service.permission.SysPermissionCoreService;
import cn.iocoder.yudao.module.system.service.user.SysUserCoreService;
import cn.iocoder.yudao.coreservice.modules.system.service.dept.SysDeptCoreService;
import cn.iocoder.yudao.coreservice.modules.system.service.permission.SysPermissionCoreService;
import cn.iocoder.yudao.coreservice.modules.system.service.user.SysUserCoreService;
import cn.iocoder.yudao.module.bpm.service.definition.BpmUserGroupService;
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
import cn.iocoder.yudao.module.system.api.permission.PermissionApi;
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
import org.activiti.api.runtime.shared.identity.UserGroupManager;
import org.activiti.spring.boot.ProcessEngineConfigurationConfigurer;
import org.springframework.context.ApplicationEventPublisher;
@ -67,17 +64,17 @@ public class BpmActivitiConfiguration {
@Bean
public BpmActivityBehaviorFactory bpmActivityBehaviorFactory(BpmTaskAssignRuleService taskRuleService,
SysPermissionCoreService permissionCoreService,
SysDeptCoreService deptCoreService,
BpmUserGroupServiceApi userGroupServiceApi,
SysUserCoreService userCoreService,
BpmUserGroupService userGroupService,
PermissionApi permissionApi,
DeptApi deptApi,
AdminUserApi adminUserApi,
List<BpmTaskAssignScript> scripts) {
BpmActivityBehaviorFactory bpmActivityBehaviorFactory = new BpmActivityBehaviorFactory();
bpmActivityBehaviorFactory.setBpmTaskRuleService(taskRuleService);
bpmActivityBehaviorFactory.setPermissionCoreService(permissionCoreService);
bpmActivityBehaviorFactory.setDeptCoreService(deptCoreService);
bpmActivityBehaviorFactory.setUserGroupServiceApi(userGroupServiceApi);
bpmActivityBehaviorFactory.setUserCoreService(userCoreService);
bpmActivityBehaviorFactory.setUserGroupService(userGroupService);
bpmActivityBehaviorFactory.setAdminUserApi(adminUserApi);
bpmActivityBehaviorFactory.setPermissionApi(permissionApi);
bpmActivityBehaviorFactory.setDeptApi(deptApi);
bpmActivityBehaviorFactory.setScripts(scripts);
return bpmActivityBehaviorFactory;
}

View File

@ -2,10 +2,10 @@ package cn.iocoder.yudao.adminserver.modules.bpm.framework.activiti.core.behavio
import cn.iocoder.yudao.adminserver.modules.bpm.framework.activiti.core.behavior.script.BpmTaskAssignScript;
import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmTaskAssignRuleService;
import cn.iocoder.yudao.module.bpm.api.group.BpmUserGroupServiceApi;
import cn.iocoder.yudao.module.system.service.dept.SysDeptCoreService;
import cn.iocoder.yudao.module.system.service.permission.SysPermissionCoreService;
import cn.iocoder.yudao.module.system.service.user.SysUserCoreService;
import cn.iocoder.yudao.module.bpm.service.definition.BpmUserGroupService;
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
import cn.iocoder.yudao.module.system.api.permission.PermissionApi;
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.Setter;
@ -30,13 +30,15 @@ public class BpmActivityBehaviorFactory extends DefaultActivityBehaviorFactory {
@Setter
private BpmTaskAssignRuleService bpmTaskRuleService;
@Setter
private SysPermissionCoreService permissionCoreService;
private BpmUserGroupService userGroupService;
@Setter
private SysDeptCoreService deptCoreService;
private PermissionApi permissionApi;
@Setter
private BpmUserGroupServiceApi userGroupServiceApi;
private DeptApi deptApi;
@Setter
private SysUserCoreService userCoreService;
private AdminUserApi adminUserApi;
@Setter
private List<BpmTaskAssignScript> scripts;
@ -44,10 +46,10 @@ public class BpmActivityBehaviorFactory extends DefaultActivityBehaviorFactory {
public UserTaskActivityBehavior createUserTaskActivityBehavior(UserTask userTask) {
BpmUserTaskActivitiBehavior userTaskActivityBehavior = new BpmUserTaskActivitiBehavior(userTask);
userTaskActivityBehavior.setBpmTaskRuleService(bpmTaskRuleService);
userTaskActivityBehavior.setPermissionCoreService(permissionCoreService);
userTaskActivityBehavior.setDeptCoreService(deptCoreService);
userTaskActivityBehavior.setUserGroupServiceApi(userGroupServiceApi);
userTaskActivityBehavior.setSysUserCoreService(userCoreService);
userTaskActivityBehavior.setPermissionApi(permissionApi);
userTaskActivityBehavior.setDeptApi(deptApi);
userTaskActivityBehavior.setUserGroupService(userGroupService);
userTaskActivityBehavior.setAdminUserApi(adminUserApi);
userTaskActivityBehavior.setScripts(scripts);
return userTaskActivityBehavior;
}

View File

@ -3,18 +3,18 @@ package cn.iocoder.yudao.adminserver.modules.bpm.framework.activiti.core.behavio
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmTaskAssignRuleDO;
import cn.iocoder.yudao.module.bpm.enums.definition.BpmTaskAssignRuleTypeEnum;
import cn.iocoder.yudao.adminserver.modules.bpm.framework.activiti.core.behavior.script.BpmTaskAssignScript;
import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmTaskAssignRuleService;
import cn.iocoder.yudao.module.bpm.api.group.BpmUserGroupServiceApi;
import cn.iocoder.yudao.module.bpm.api.group.dto.BpmUserGroupDTO;
import cn.iocoder.yudao.module.system.dal.dataobject.dept.SysDeptDO;
import cn.iocoder.yudao.module.system.dal.dataobject.user.SysUserDO;
import cn.iocoder.yudao.module.system.service.dept.SysDeptCoreService;
import cn.iocoder.yudao.module.system.service.permission.SysPermissionCoreService;
import cn.iocoder.yudao.module.system.service.user.SysUserCoreService;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmTaskAssignRuleDO;
import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmUserGroupDO;
import cn.iocoder.yudao.module.bpm.enums.definition.BpmTaskAssignRuleTypeEnum;
import cn.iocoder.yudao.module.bpm.service.definition.BpmUserGroupService;
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
import cn.iocoder.yudao.module.system.api.permission.PermissionApi;
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
import com.google.common.annotations.VisibleForTesting;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
@ -28,12 +28,12 @@ import org.activiti.engine.impl.persistence.entity.TaskEntityManager;
import java.util.*;
import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.TASK_ASSIGN_SCRIPT_NOT_EXISTS;
import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.TASK_CREATE_FAIL_NO_CANDIDATE_USER;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString;
import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.TASK_ASSIGN_SCRIPT_NOT_EXISTS;
import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.TASK_CREATE_FAIL_NO_CANDIDATE_USER;
/**
* 自定义的流程任务的 assignee 负责人的分配
@ -48,14 +48,17 @@ public class BpmUserTaskActivitiBehavior extends UserTaskActivityBehavior {
@Setter
private BpmTaskAssignRuleService bpmTaskRuleService;
@Setter
private SysPermissionCoreService permissionCoreService;
private BpmUserGroupService userGroupService;
@Setter
private SysDeptCoreService deptCoreService;
private DeptApi deptApi;
@Setter
private BpmUserGroupServiceApi userGroupServiceApi;
private AdminUserApi adminUserApi;
@Setter
private SysUserCoreService sysUserCoreService;
private PermissionApi permissionApi;
/**
* 任务分配脚本
*/
@ -133,22 +136,22 @@ public class BpmUserTaskActivitiBehavior extends UserTaskActivityBehavior {
}
private Set<Long> calculateTaskCandidateUsersByRole(TaskEntity task, BpmTaskAssignRuleDO rule) {
return permissionCoreService.getUserRoleIdListByRoleIds(rule.getOptions());
return permissionApi.getUserRoleIdListByRoleIds(rule.getOptions());
}
private Set<Long> calculateTaskCandidateUsersByDeptMember(TaskEntity task, BpmTaskAssignRuleDO rule) {
List<SysUserDO> users = sysUserCoreService.getUsersByDeptIds(rule.getOptions());
return convertSet(users, SysUserDO::getId);
List<AdminUserRespDTO> users = adminUserApi.getUsersByDeptIds(rule.getOptions());
return convertSet(users, AdminUserRespDTO::getId);
}
private Set<Long> calculateTaskCandidateUsersByDeptLeader(TaskEntity task, BpmTaskAssignRuleDO rule) {
List<SysDeptDO> depts = deptCoreService.getDepts(rule.getOptions());
return convertSet(depts, SysDeptDO::getLeaderUserId);
List<DeptRespDTO> depts = deptApi.getDepts(rule.getOptions());
return convertSet(depts, DeptRespDTO::getLeaderUserId);
}
private Set<Long> calculateTaskCandidateUsersByPost(TaskEntity task, BpmTaskAssignRuleDO rule) {
List<SysUserDO> users = sysUserCoreService.getUsersByPostIds(rule.getOptions());
return convertSet(users, SysUserDO::getId);
List<AdminUserRespDTO> users = adminUserApi.getUsersByPostIds(rule.getOptions());
return convertSet(users, AdminUserRespDTO::getId);
}
private Set<Long> calculateTaskCandidateUsersByUser(TaskEntity task, BpmTaskAssignRuleDO rule) {
@ -156,9 +159,9 @@ public class BpmUserTaskActivitiBehavior extends UserTaskActivityBehavior {
}
private Set<Long> calculateTaskCandidateUsersByUserGroup(TaskEntity task, BpmTaskAssignRuleDO rule) {
List<BpmUserGroupDTO> userGroups = userGroupServiceApi.getUserGroupList(rule.getOptions());
List<BpmUserGroupDO> userGroups = userGroupService.getUserGroupList(rule.getOptions());
Set<Long> userIds = new HashSet<>();
userGroups.forEach(bpmUserGroupDO -> userIds.addAll(bpmUserGroupDO.getMemberUserIds()));
userGroups.forEach(group -> userIds.addAll(group.getMemberUserIds()));
return userIds;
}
@ -183,9 +186,9 @@ public class BpmUserTaskActivitiBehavior extends UserTaskActivityBehavior {
if (CollUtil.isEmpty(assigneeUserIds)) {
return;
}
Map<Long, SysUserDO> userMap = sysUserCoreService.getUserMap(assigneeUserIds);
Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(assigneeUserIds);
assigneeUserIds.removeIf(id -> {
SysUserDO user = userMap.get(id);
AdminUserRespDTO user = userMap.get(id);
return user == null || !CommonStatusEnum.ENABLE.getStatus().equals(user.getStatus());
});
}

View File

@ -2,16 +2,17 @@ package cn.iocoder.yudao.adminserver.modules.bpm.framework.activiti.core.behavio
import cn.iocoder.yudao.adminserver.modules.bpm.framework.activiti.core.behavior.script.BpmTaskAssignScript;
import cn.iocoder.yudao.module.system.dal.dataobject.dept.SysDeptDO;
import cn.iocoder.yudao.module.system.dal.dataobject.user.SysUserDO;
import cn.iocoder.yudao.module.system.service.dept.SysDeptCoreService;
import cn.iocoder.yudao.module.system.service.user.SysUserCoreService;
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
import org.activiti.engine.impl.persistence.entity.TaskEntity;
import org.springframework.util.Assert;
import javax.annotation.Resource;
import java.util.Set;
import static cn.iocoder.yudao.framework.common.util.collection.SetUtils.asSet;
import static java.util.Collections.emptySet;
/**
@ -23,16 +24,16 @@ import static java.util.Collections.emptySet;
public abstract class BpmTaskAssignLeaderAbstractScript implements BpmTaskAssignScript {
@Resource
private SysUserCoreService userCoreService;
private AdminUserApi adminUserApi;
@Resource
private SysDeptCoreService deptCoreService;
private DeptApi deptApi;
protected Set<Long> calculateTaskCandidateUsers(TaskEntity task, int level) {
Assert.isTrue(level > 0, "level 必须大于 0");
// 获得发起人
Long startUserId = Long.parseLong(task.getProcessInstance().getStartUserId());
// 获得对应 leve 的部门
SysDeptDO dept = null;
DeptRespDTO dept = null;
for (int i = 0; i < level; i++) {
// 获得 level 对应的部门
if (dept == null) {
@ -41,7 +42,7 @@ public abstract class BpmTaskAssignLeaderAbstractScript implements BpmTaskAssign
return emptySet();
}
} else {
SysDeptDO parentDept = deptCoreService.getDept(dept.getParentId());
DeptRespDTO parentDept = deptApi.getDept(dept.getParentId());
if (parentDept == null) { // 找不到父级部门所以只好结束寻找原因是例如说级别比较高的人所在部门层级比较少
break;
}
@ -51,12 +52,12 @@ public abstract class BpmTaskAssignLeaderAbstractScript implements BpmTaskAssign
return dept.getLeaderUserId() != null ? asSet(dept.getLeaderUserId()) : emptySet();
}
private SysDeptDO getStartUserDept(Long startUserId) {
SysUserDO startUser = userCoreService.getUser(startUserId);
private DeptRespDTO getStartUserDept(Long startUserId) {
AdminUserRespDTO startUser = adminUserApi.getUser(startUserId);
if (startUser.getDeptId() == null) { // 找不到部门所以无法使用该规则
return null;
}
return deptCoreService.getDept(startUser.getDeptId());
return deptApi.getDept(startUser.getDeptId());
}
}

View File

@ -1,26 +1,22 @@
package cn.iocoder.yudao.adminserver.modules.bpm.service.definition.impl;
package cn.iocoder.yudao.adminserver.modules.bpm.service.definition;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.model.*;
import cn.iocoder.yudao.module.bpm.controller.definition.vo.model.*;
import cn.iocoder.yudao.module.bpm.controller.definition.vo.rule.BpmTaskAssignRuleRespVO;
import cn.iocoder.yudao.adminserver.modules.bpm.convert.definition.BpmModelConvert;
import cn.iocoder.yudao.module.bpm.enums.definition.BpmModelFormTypeEnum;
import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmModelService;
import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmProcessDefinitionService;
import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmTaskAssignRuleService;
import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.dto.BpmModelMetaInfoRespDTO;
import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.dto.BpmProcessDefinitionCreateReqDTO;
import cn.iocoder.yudao.module.bpm.api.form.BpmFormServiceApi;
import cn.iocoder.yudao.module.bpm.api.form.dto.BpmFormDTO;
import cn.iocoder.yudao.framework.activiti.core.util.ActivitiUtils;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
import cn.iocoder.yudao.framework.common.util.object.PageUtils;
import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils;
import cn.iocoder.yudao.module.bpm.controller.definition.vo.model.*;
import cn.iocoder.yudao.module.bpm.controller.definition.vo.rule.BpmTaskAssignRuleRespVO;
import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO;
import cn.iocoder.yudao.module.bpm.enums.definition.BpmModelFormTypeEnum;
import cn.iocoder.yudao.module.bpm.service.definition.BpmFormService;
import lombok.extern.slf4j.Slf4j;
import org.activiti.bpmn.model.BpmnModel;
import org.activiti.engine.RepositoryService;
@ -38,9 +34,9 @@ import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.util.*;
import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.*;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.*;
/**
* 流程定义实现
@ -57,7 +53,7 @@ public class BpmModelServiceImpl implements BpmModelService {
@Resource
private RepositoryService repositoryService;
@Resource
private BpmFormServiceApi formServiceApi;
private BpmFormService bpmFormService;
@Resource
private BpmProcessDefinitionService processDefinitionService;
@Resource
@ -85,7 +81,7 @@ public class BpmModelServiceImpl implements BpmModelService {
BpmModelMetaInfoRespDTO metaInfo = JsonUtils.parseObject(model.getMetaInfo(), BpmModelMetaInfoRespDTO.class);
return metaInfo != null ? metaInfo.getFormId() : null;
});
Map<Long, BpmFormDTO> formMap = formServiceApi.getFormMap(formIds);
Map<Long, BpmFormDO> formMap = bpmFormService.getFormMap(formIds);
// 获得 Deployment Map
Set<String> deploymentIds = new HashSet<>();
@ -172,7 +168,7 @@ public class BpmModelServiceImpl implements BpmModelService {
}
// TODO 芋艿校验流程图的有效性例如说是否有开始的元素是否有结束的元素
// 校验表单已配
BpmFormDTO form = checkFormConfig(model);
BpmFormDO form = checkFormConfig(model);
// 校验任务分配规则已配置
checkTaskAssignRuleAllConfig(id);
@ -225,14 +221,14 @@ public class BpmModelServiceImpl implements BpmModelService {
* @param model 流程模型
* @return 流程表单
*/
private BpmFormDTO checkFormConfig(Model model) {
private BpmFormDO checkFormConfig(Model model) {
BpmModelMetaInfoRespDTO metaInfo = JsonUtils.parseObject(model.getMetaInfo(), BpmModelMetaInfoRespDTO.class);
if (metaInfo == null || metaInfo.getFormType() == null) {
throw exception(MODEL_DEPLOY_FAIL_FORM_NOT_CONFIG);
}
// 校验表单存在
if (Objects.equals(metaInfo.getFormType(), BpmModelFormTypeEnum.NORMAL.getType())) {
BpmFormDTO form = formServiceApi.getForm(metaInfo.getFormId());
BpmFormDO form = bpmFormService.getForm(metaInfo.getFormId());
if (form == null) {
throw exception(FORM_NOT_EXISTS);
}

View File

@ -1,22 +1,21 @@
package cn.iocoder.yudao.adminserver.modules.bpm.service.definition.impl;
package cn.iocoder.yudao.adminserver.modules.bpm.service.definition;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.adminserver.modules.bpm.convert.definition.BpmProcessDefinitionConvert;
import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.dto.BpmProcessDefinitionCreateReqDTO;
import cn.iocoder.yudao.framework.activiti.core.util.ActivitiUtils;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.PageUtils;
import cn.iocoder.yudao.module.bpm.controller.definition.vo.process.BpmProcessDefinitionListReqVO;
import cn.iocoder.yudao.module.bpm.controller.definition.vo.process.BpmProcessDefinitionPageItemRespVO;
import cn.iocoder.yudao.module.bpm.controller.definition.vo.process.BpmProcessDefinitionPageReqVO;
import cn.iocoder.yudao.module.bpm.controller.definition.vo.process.BpmProcessDefinitionRespVO;
import cn.iocoder.yudao.adminserver.modules.bpm.convert.definition.BpmProcessDefinitionConvert;
import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO;
import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessDefinitionExtDO;
import cn.iocoder.yudao.adminserver.modules.bpm.dal.mysql.definition.BpmProcessDefinitionExtMapper;
import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmProcessDefinitionService;
import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.dto.BpmProcessDefinitionCreateReqDTO;
import cn.iocoder.yudao.module.bpm.api.form.BpmFormServiceApi;
import cn.iocoder.yudao.module.bpm.api.form.dto.BpmFormDTO;
import cn.iocoder.yudao.framework.activiti.core.util.ActivitiUtils;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.PageUtils;
import cn.iocoder.yudao.module.bpm.dal.mysql.definition.BpmProcessDefinitionExtMapper;
import cn.iocoder.yudao.module.bpm.service.definition.BpmFormService;
import lombok.extern.slf4j.Slf4j;
import org.activiti.bpmn.model.BpmnModel;
import org.activiti.engine.RepositoryService;
@ -31,10 +30,10 @@ import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.util.*;
import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.PROCESS_DEFINITION_KEY_NOT_MATCH;
import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.PROCESS_DEFINITION_NAME_NOT_MATCH;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*;
import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.PROCESS_DEFINITION_KEY_NOT_MATCH;
import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.PROCESS_DEFINITION_NAME_NOT_MATCH;
import static java.util.Collections.emptyList;
/**
@ -55,7 +54,7 @@ public class BpmProcessDefinitionServiceImpl implements BpmProcessDefinitionServ
@Resource
private RepositoryService repositoryService;
@Resource
private BpmFormServiceApi bpmFormServiceApi;
private BpmFormService formService;
@Resource
private BpmProcessDefinitionExtMapper processDefinitionMapper;
@ -86,7 +85,7 @@ public class BpmProcessDefinitionServiceImpl implements BpmProcessDefinitionServ
// 获得 Form Map
Set<Long> formIds = convertSet(processDefinitionDOs, BpmProcessDefinitionExtDO::getFormId);
Map<Long, BpmFormDTO> formMap = bpmFormServiceApi.getFormMap(formIds);
Map<Long, BpmFormDO> formMap = formService.getFormMap(formIds);
// 拼接结果
long definitionCount = definitionQuery.count();

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.adminserver.modules.bpm.service.definition.impl;
package cn.iocoder.yudao.adminserver.modules.bpm.service.definition;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
@ -8,21 +8,18 @@ import cn.iocoder.yudao.module.bpm.controller.definition.vo.rule.BpmTaskAssignRu
import cn.iocoder.yudao.module.bpm.controller.definition.vo.rule.BpmTaskAssignRuleUpdateReqVO;
import cn.iocoder.yudao.adminserver.modules.bpm.convert.definition.BpmTaskAssignRuleConvert;
import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmTaskAssignRuleDO;
import cn.iocoder.yudao.adminserver.modules.bpm.dal.mysql.definition.BpmTaskAssignRuleMapper;
import cn.iocoder.yudao.module.bpm.dal.mysql.definition.BpmTaskAssignRuleMapper;
import cn.iocoder.yudao.module.bpm.enums.definition.BpmTaskAssignRuleTypeEnum;
import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmModelService;
import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmProcessDefinitionService;
import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmTaskAssignRuleService;
import cn.iocoder.yudao.module.bpm.api.group.BpmUserGroupServiceApi;
import cn.iocoder.yudao.module.system.enums.SysDictTypeConstants;
import cn.iocoder.yudao.module.system.service.dept.SysDeptCoreService;
import cn.iocoder.yudao.module.system.service.dept.SysPostCoreService;
import cn.iocoder.yudao.module.system.service.dict.DictDataCoreService;
import cn.iocoder.yudao.module.system.service.permission.SysRoleCoreService;
import cn.iocoder.yudao.module.system.service.user.SysUserCoreService;
import cn.iocoder.yudao.framework.activiti.core.util.ActivitiUtils;
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
import cn.iocoder.yudao.framework.common.util.object.ObjectUtils;
import cn.iocoder.yudao.module.bpm.service.definition.BpmUserGroupService;
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
import cn.iocoder.yudao.module.system.api.dept.PostApi;
import cn.iocoder.yudao.module.system.api.dict.DictDataApi;
import cn.iocoder.yudao.module.system.api.permission.RoleApi;
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
import cn.iocoder.yudao.module.system.enums.DictTypeConstants;
import lombok.extern.slf4j.Slf4j;
import org.activiti.bpmn.model.BpmnModel;
import org.activiti.bpmn.model.UserTask;
@ -34,6 +31,7 @@ import javax.annotation.Resource;
import java.util.*;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.*;
/**
* BPM 任务分配规则 Service 实现类
@ -53,17 +51,17 @@ public class BpmTaskAssignRuleServiceImpl implements BpmTaskAssignRuleService {
@Lazy // 解决循环依赖
private BpmProcessDefinitionService processDefinitionService;
@Resource
private SysRoleCoreService roleCoreService;
private BpmUserGroupService userGroupService;
@Resource
private SysDeptCoreService deptCoreService;
private RoleApi roleApi;
@Resource
private SysPostCoreService postService;
private DeptApi deptApi;
@Resource
private SysUserCoreService userCoreService;
private PostApi postApi;
@Resource
private BpmUserGroupServiceApi userGroupServiceApi;
private AdminUserApi adminUserApi;
@Resource
private DictDataCoreService dictDataCoreService;
private DictDataApi dictDataApi;
@Override
public List<BpmTaskAssignRuleDO> getTaskAssignRuleListByProcessDefinitionId(String processDefinitionId,
@ -178,18 +176,18 @@ public class BpmTaskAssignRuleServiceImpl implements BpmTaskAssignRuleService {
private void validTaskAssignRuleOptions(Integer type, Set<Long> options) {
if (Objects.equals(type, BpmTaskAssignRuleTypeEnum.ROLE.getType())) {
roleCoreService.validRoles(options);
roleApi.validRoles(options);
} else if (ObjectUtils.equalsAny(type, BpmTaskAssignRuleTypeEnum.DEPT_MEMBER.getType(),
BpmTaskAssignRuleTypeEnum.DEPT_LEADER.getType())) {
deptCoreService.validDepts(options);
deptApi.validDepts(options);
} else if (Objects.equals(type, BpmTaskAssignRuleTypeEnum.POST.getType())) {
postService.validPosts(options);
postApi.validPosts(options);
} else if (Objects.equals(type, BpmTaskAssignRuleTypeEnum.USER.getType())) {
userCoreService.validUsers(options);
adminUserApi.validUsers(options);
} else if (Objects.equals(type, BpmTaskAssignRuleTypeEnum.USER_GROUP.getType())) {
userGroupServiceApi.validUserGroups(options);
userGroupService.validUserGroups(options);
} else if (Objects.equals(type, BpmTaskAssignRuleTypeEnum.SCRIPT.getType())) {
dictDataCoreService.validDictDatas(SysDictTypeConstants.BPM_TASK_ASSIGN_SCRIPT,
dictDataApi.validDictDatas(DictTypeConstants.BPM_TASK_ASSIGN_SCRIPT,
CollectionUtils.convertSet(options, String::valueOf));
} else {
throw new IllegalArgumentException(StrUtil.format("未知的规则类型({})", type));

View File

@ -1,7 +1,8 @@
package cn.iocoder.yudao.adminserver.modules.bpm.service.oa;
import cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo.*;
import cn.iocoder.yudao.module.bpm.controller.oa.vo.BpmOALeaveCreateReqVO;
import cn.iocoder.yudao.module.bpm.controller.oa.vo.BpmOALeavePageReqVO;
import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOALeaveDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;

View File

@ -1,12 +1,12 @@
package cn.iocoder.yudao.adminserver.modules.bpm.service.oa.impl;
package cn.iocoder.yudao.adminserver.modules.bpm.service.oa;
import cn.hutool.core.date.DateUtil;
import cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo.*;
import cn.iocoder.yudao.adminserver.modules.bpm.convert.oa.BpmOALeaveConvert;
import cn.iocoder.yudao.module.bpm.controller.oa.vo.BpmOALeaveCreateReqVO;
import cn.iocoder.yudao.module.bpm.controller.oa.vo.BpmOALeavePageReqVO;
import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOALeaveDO;
import cn.iocoder.yudao.adminserver.modules.bpm.dal.mysql.oa.BpmOALeaveMapper;
import cn.iocoder.yudao.module.bpm.dal.mysql.oa.BpmOALeaveMapper;
import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceResultEnum;
import cn.iocoder.yudao.adminserver.modules.bpm.service.oa.BpmOALeaveService;
import cn.iocoder.yudao.adminserver.modules.bpm.service.task.BpmProcessInstanceService;
import cn.iocoder.yudao.adminserver.modules.bpm.service.task.dto.BpmProcessInstanceCreateReqDTO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
@ -18,6 +18,7 @@ import javax.annotation.Resource;
import java.util.*;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.*;
/**
* OA 请假申请 Service 实现类

View File

@ -3,7 +3,7 @@ package cn.iocoder.yudao.adminserver.modules.bpm.service.oa.listener;
import cn.iocoder.yudao.adminserver.modules.bpm.framework.activiti.core.event.BpmProcessInstanceResultEvent;
import cn.iocoder.yudao.adminserver.modules.bpm.framework.activiti.core.event.BpmProcessInstanceResultEventListener;
import cn.iocoder.yudao.adminserver.modules.bpm.service.oa.BpmOALeaveService;
import cn.iocoder.yudao.adminserver.modules.bpm.service.oa.impl.BpmOALeaveServiceImpl;
import cn.iocoder.yudao.adminserver.modules.bpm.service.oa.BpmOALeaveServiceImpl;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;

View File

@ -1,6 +1,6 @@
package cn.iocoder.yudao.adminserver.modules.bpm.service.task;
import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.activity.BpmActivityRespVO;
import cn.iocoder.yudao.module.bpm.controller.task.vo.activity.BpmActivityRespVO;
import java.util.List;

View File

@ -1,13 +1,10 @@
package cn.iocoder.yudao.adminserver.modules.bpm.service.task.impl;
package cn.iocoder.yudao.adminserver.modules.bpm.service.task;
import cn.hutool.core.io.IoUtil;
import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.activity.BpmActivityRespVO;
import cn.iocoder.yudao.adminserver.modules.bpm.convert.task.BpmActivityConvert;
import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmProcessDefinitionService;
import cn.iocoder.yudao.adminserver.modules.bpm.service.task.BpmActivityService;
import cn.iocoder.yudao.adminserver.modules.bpm.service.task.BpmProcessInstanceService;
import cn.iocoder.yudao.adminserver.modules.bpm.service.task.BpmTaskService;
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
import cn.iocoder.yudao.module.bpm.controller.task.vo.activity.BpmActivityRespVO;
import lombok.extern.slf4j.Slf4j;
import org.activiti.bpmn.model.BpmnModel;
import org.activiti.engine.HistoryService;
@ -24,7 +21,7 @@ import java.util.Collections;
import java.util.List;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.*;
/**
* BPM 活动实例 Service 实现类

View File

@ -1,6 +1,6 @@
package cn.iocoder.yudao.adminserver.modules.bpm.service.task;
import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.instance.*;
import cn.iocoder.yudao.module.bpm.controller.task.vo.instance.*;
import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceDeleteReasonEnum;
import cn.iocoder.yudao.adminserver.modules.bpm.service.task.dto.BpmProcessInstanceCreateReqDTO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;

View File

@ -1,29 +1,27 @@
package cn.iocoder.yudao.adminserver.modules.bpm.service.task.impl;
package cn.iocoder.yudao.adminserver.modules.bpm.service.task;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.instance.*;
import cn.iocoder.yudao.adminserver.modules.bpm.convert.message.BpmMessageConvert;
import cn.iocoder.yudao.adminserver.modules.bpm.convert.task.BpmProcessInstanceConvert;
import cn.iocoder.yudao.module.bpm.controller.task.vo.instance.*;
import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessDefinitionExtDO;
import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmProcessInstanceExtDO;
import cn.iocoder.yudao.adminserver.modules.bpm.dal.mysql.task.BpmProcessInstanceExtMapper;
import cn.iocoder.yudao.module.bpm.dal.mysql.task.BpmProcessInstanceExtMapper;
import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceDeleteReasonEnum;
import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceResultEnum;
import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceStatusEnum;
import cn.iocoder.yudao.adminserver.modules.bpm.framework.activiti.core.event.BpmProcessInstanceResultEventPublisher;
import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmProcessDefinitionService;
import cn.iocoder.yudao.module.bpm.service.message.BpmMessageService;
import cn.iocoder.yudao.adminserver.modules.bpm.service.task.BpmProcessInstanceService;
import cn.iocoder.yudao.adminserver.modules.bpm.service.task.BpmTaskService;
import cn.iocoder.yudao.adminserver.modules.bpm.service.task.dto.BpmProcessInstanceCreateReqDTO;
import cn.iocoder.yudao.module.system.dal.dataobject.dept.SysDeptDO;
import cn.iocoder.yudao.module.system.dal.dataobject.user.SysUserDO;
import cn.iocoder.yudao.module.system.service.dept.SysDeptCoreService;
import cn.iocoder.yudao.module.system.service.user.SysUserCoreService;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.number.NumberUtils;
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
import lombok.extern.slf4j.Slf4j;
import org.activiti.engine.HistoryService;
import org.activiti.engine.RuntimeService;
@ -41,6 +39,7 @@ import java.util.*;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.*;
/**
* 流程实例 Service 实现类
@ -65,9 +64,9 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService
private HistoryService historyService;
@Resource
private SysUserCoreService userCoreService;
private AdminUserApi adminUserApi;
@Resource
private SysDeptCoreService deptCoreService;
private DeptApi deptApi;
@Resource
@Lazy // 解决循环依赖
private BpmTaskService taskService;
@ -189,10 +188,10 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService
String bpmnXml = processDefinitionService.getProcessDefinitionBpmnXML(processInstance.getProcessDefinitionId());
// 获得 User
SysUserDO startUser = userCoreService.getUser(NumberUtils.parseLong(processInstance.getStartUserId()));
SysDeptDO dept = null;
AdminUserRespDTO startUser = adminUserApi.getUser(NumberUtils.parseLong(processInstance.getStartUserId()));
DeptRespDTO dept = null;
if (startUser != null) {
dept = deptCoreService.getDept(startUser.getDeptId());
dept = deptApi.getDept(startUser.getDeptId());
}
// 拼接结果

View File

@ -1,6 +1,6 @@
package cn.iocoder.yudao.adminserver.modules.bpm.service.task;
import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.task.*;
import cn.iocoder.yudao.module.bpm.controller.task.vo.task.*;
import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmTaskExtDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;

View File

@ -1,25 +1,23 @@
package cn.iocoder.yudao.adminserver.modules.bpm.service.task.impl;
package cn.iocoder.yudao.adminserver.modules.bpm.service.task;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.task.*;
import cn.iocoder.yudao.adminserver.modules.bpm.convert.message.BpmMessageConvert;
import cn.iocoder.yudao.adminserver.modules.bpm.convert.task.BpmTaskConvert;
import cn.iocoder.yudao.module.bpm.controller.task.vo.task.*;
import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmTaskExtDO;
import cn.iocoder.yudao.adminserver.modules.bpm.dal.mysql.task.BpmTaskExtMapper;
import cn.iocoder.yudao.module.bpm.dal.mysql.task.BpmTaskExtMapper;
import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceResultEnum;
import cn.iocoder.yudao.module.bpm.service.message.BpmMessageService;
import cn.iocoder.yudao.adminserver.modules.bpm.service.task.BpmProcessInstanceService;
import cn.iocoder.yudao.adminserver.modules.bpm.service.task.BpmTaskService;
import cn.iocoder.yudao.module.system.dal.dataobject.dept.SysDeptDO;
import cn.iocoder.yudao.module.system.dal.dataobject.user.SysUserDO;
import cn.iocoder.yudao.module.system.service.dept.SysDeptCoreService;
import cn.iocoder.yudao.module.system.service.user.SysUserCoreService;
import cn.iocoder.yudao.framework.activiti.core.util.ActivitiUtils;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.number.NumberUtils;
import cn.iocoder.yudao.framework.common.util.object.PageUtils;
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
import lombok.extern.slf4j.Slf4j;
import org.activiti.engine.HistoryService;
import org.activiti.engine.TaskService;
@ -42,6 +40,7 @@ import java.util.*;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.*;
/**
* 流程任务实例 Service 实现类
@ -59,9 +58,9 @@ public class BpmTaskServiceImpl implements BpmTaskService {
private HistoryService historyService;
@Resource
private SysUserCoreService userCoreService;
private AdminUserApi adminUserApi;
@Resource
private SysDeptCoreService deptCoreService;
private DeptApi deptApi;
@Resource
@Lazy // 解决循环依赖
private BpmProcessInstanceService processInstanceService;
@ -95,9 +94,9 @@ public class BpmTaskServiceImpl implements BpmTaskService {
// 获得 User Map
Set<Long> userIds = convertSet(tasks, task -> NumberUtils.parseLong(task.getAssignee()));
userIds.add(NumberUtils.parseLong(processInstance.getStartUserId()));
Map<Long, SysUserDO> userMap = userCoreService.getUserMap(userIds);
Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(userIds);
// 获得 Dept Map
Map<Long, SysDeptDO> deptMap = deptCoreService.getDeptMap(convertSet(userMap.values(), SysUserDO::getDeptId));
Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap(convertSet(userMap.values(), AdminUserRespDTO::getDeptId));
// 拼接数据
return BpmTaskConvert.INSTANCE.convertList3(tasks, bpmTaskExtDOMap, processInstance, userMap, deptMap);
@ -144,7 +143,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
Map<String, ProcessInstance> processInstanceMap = processInstanceService.getProcessInstanceMap(
convertSet(tasks, Task::getProcessInstanceId));
// 获得 User Map
Map<Long, SysUserDO> userMap = userCoreService.getUserMap(
Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(
convertSet(processInstanceMap.values(), instance -> Long.valueOf(instance.getStartUserId())));
// 拼接结果
return new PageResult<>(BpmTaskConvert.INSTANCE.convertList1(tasks, processInstanceMap, userMap),
@ -180,7 +179,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
Map<String, HistoricProcessInstance> historicProcessInstanceMap = processInstanceService.getHistoricProcessInstanceMap(
convertSet(tasks, HistoricTaskInstance::getProcessInstanceId));
// 获得 User Map
Map<Long, SysUserDO> userMap = userCoreService.getUserMap(
Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(
convertSet(historicProcessInstanceMap.values(), instance -> Long.valueOf(instance.getStartUserId())));
// 拼接结果
return new PageResult<>(BpmTaskConvert.INSTANCE.convertList2(tasks, bpmTaskExtDOMap, historicProcessInstanceMap, userMap),
@ -291,7 +290,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
@Override
public void afterCommit() {
ProcessInstance processInstance = processInstanceService.getProcessInstance(task.getProcessInstanceId());
SysUserDO startUser = userCoreService.getUser(Long.valueOf(processInstance.getStartUserId()));
AdminUserRespDTO startUser = adminUserApi.getUser(Long.valueOf(processInstance.getStartUserId()));
messageService.sendMessageWhenTaskAssigned(BpmMessageConvert.INSTANCE.convert(processInstance, startUser, task));
}
});

View File

@ -1,21 +1,21 @@
package cn.iocoder.yudao.adminserver.modules.bpm.framework.activiti.core.behavior;
import cn.hutool.core.map.MapUtil;
import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmTaskAssignRuleDO;
import cn.iocoder.yudao.module.bpm.enums.definition.BpmTaskAssignRuleTypeEnum;
import cn.iocoder.yudao.module.bpm.enums.definition.BpmTaskRuleScriptEnum;
import cn.iocoder.yudao.adminserver.modules.bpm.framework.activiti.core.behavior.script.BpmTaskAssignScript;
import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmTaskAssignRuleService;
import cn.iocoder.yudao.module.bpm.api.group.BpmUserGroupServiceApi;
import cn.iocoder.yudao.module.bpm.api.group.dto.BpmUserGroupDTO;
import cn.iocoder.yudao.module.system.dal.dataobject.dept.SysDeptDO;
import cn.iocoder.yudao.module.system.dal.dataobject.user.SysUserDO;
import cn.iocoder.yudao.module.system.service.dept.SysDeptCoreService;
import cn.iocoder.yudao.module.system.service.permission.SysPermissionCoreService;
import cn.iocoder.yudao.module.system.service.user.SysUserCoreService;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest;
import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmTaskAssignRuleDO;
import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmUserGroupDO;
import cn.iocoder.yudao.module.bpm.enums.definition.BpmTaskAssignRuleTypeEnum;
import cn.iocoder.yudao.module.bpm.enums.definition.BpmTaskRuleScriptEnum;
import cn.iocoder.yudao.module.bpm.service.definition.BpmUserGroupService;
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
import cn.iocoder.yudao.module.system.api.permission.PermissionApi;
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
import org.activiti.engine.impl.persistence.entity.TaskEntity;
import org.junit.jupiter.api.Test;
import org.mockito.InjectMocks;
@ -40,13 +40,14 @@ public class BpmUserTaskActivitiBehaviorTest extends BaseMockitoUnitTest {
@Mock
private BpmTaskAssignRuleService bpmTaskRuleService;
@Mock
private SysPermissionCoreService permissionCoreService;
private BpmUserGroupService userGroupService;
@Mock
private SysDeptCoreService deptCoreService;
private DeptApi deptApi;
@Mock
private BpmUserGroupServiceApi userGroupServiceApi;
private AdminUserApi adminUserApi;
@Mock
private SysUserCoreService userCoreService;
private PermissionApi permissionApi;
@Test
public void testCalculateTaskCandidateUsers_Role() {
@ -54,7 +55,7 @@ public class BpmUserTaskActivitiBehaviorTest extends BaseMockitoUnitTest {
BpmTaskAssignRuleDO rule = new BpmTaskAssignRuleDO().setOptions(asSet(1L, 2L))
.setType(BpmTaskAssignRuleTypeEnum.ROLE.getType());
// mock 方法
when(permissionCoreService.getUserRoleIdListByRoleIds(eq(rule.getOptions())))
when(permissionApi.getUserRoleIdListByRoleIds(eq(rule.getOptions())))
.thenReturn(asSet(11L, 22L));
mockGetUserMap(asSet(11L, 22L));
@ -70,9 +71,9 @@ public class BpmUserTaskActivitiBehaviorTest extends BaseMockitoUnitTest {
BpmTaskAssignRuleDO rule = new BpmTaskAssignRuleDO().setOptions(asSet(1L, 2L))
.setType(BpmTaskAssignRuleTypeEnum.DEPT_MEMBER.getType());
// mock 方法
List<SysUserDO> users = CollectionUtils.convertList(asSet(11L, 22L),
id -> new SysUserDO().setId(id));
when(userCoreService.getUsersByDeptIds(eq(rule.getOptions()))).thenReturn(users);
List<AdminUserRespDTO> users = CollectionUtils.convertList(asSet(11L, 22L),
id -> new AdminUserRespDTO().setId(id));
when(adminUserApi.getUsersByDeptIds(eq(rule.getOptions()))).thenReturn(users);
mockGetUserMap(asSet(11L, 22L));
// 调用
@ -87,9 +88,9 @@ public class BpmUserTaskActivitiBehaviorTest extends BaseMockitoUnitTest {
BpmTaskAssignRuleDO rule = new BpmTaskAssignRuleDO().setOptions(asSet(1L, 2L))
.setType(BpmTaskAssignRuleTypeEnum.DEPT_LEADER.getType());
// mock 方法
SysDeptDO dept1 = randomPojo(SysDeptDO.class, o -> o.setLeaderUserId(11L));
SysDeptDO dept2 = randomPojo(SysDeptDO.class, o -> o.setLeaderUserId(22L));
when(deptCoreService.getDepts(eq(rule.getOptions()))).thenReturn(Arrays.asList(dept1, dept2));
DeptRespDTO dept1 = randomPojo(DeptRespDTO.class, o -> o.setLeaderUserId(11L));
DeptRespDTO dept2 = randomPojo(DeptRespDTO.class, o -> o.setLeaderUserId(22L));
when(deptApi.getDepts(eq(rule.getOptions()))).thenReturn(Arrays.asList(dept1, dept2));
mockGetUserMap(asSet(11L, 22L));
// 调用
@ -104,9 +105,9 @@ public class BpmUserTaskActivitiBehaviorTest extends BaseMockitoUnitTest {
BpmTaskAssignRuleDO rule = new BpmTaskAssignRuleDO().setOptions(asSet(1L, 2L))
.setType(BpmTaskAssignRuleTypeEnum.POST.getType());
// mock 方法
List<SysUserDO> users = CollectionUtils.convertList(asSet(11L, 22L),
id -> new SysUserDO().setId(id));
when(userCoreService.getUsersByPostIds(eq(rule.getOptions()))).thenReturn(users);
List<AdminUserRespDTO> users = CollectionUtils.convertList(asSet(11L, 22L),
id -> new AdminUserRespDTO().setId(id));
when(adminUserApi.getUsersByPostIds(eq(rule.getOptions()))).thenReturn(users);
mockGetUserMap(asSet(11L, 22L));
// 调用
@ -135,9 +136,9 @@ public class BpmUserTaskActivitiBehaviorTest extends BaseMockitoUnitTest {
BpmTaskAssignRuleDO rule = new BpmTaskAssignRuleDO().setOptions(asSet(1L, 2L))
.setType(BpmTaskAssignRuleTypeEnum.USER_GROUP.getType());
// mock 方法
BpmUserGroupDTO userGroup1 = randomPojo(BpmUserGroupDTO.class, o -> o.setMemberUserIds(asSet(11L, 12L)));
BpmUserGroupDTO userGroup2 = randomPojo(BpmUserGroupDTO.class, o -> o.setMemberUserIds(asSet(21L, 22L)));
when(userGroupServiceApi.getUserGroupList(eq(rule.getOptions()))).thenReturn(Arrays.asList(userGroup1, userGroup2));
BpmUserGroupDO userGroup1 = randomPojo(BpmUserGroupDO.class, o -> o.setMemberUserIds(asSet(11L, 12L)));
BpmUserGroupDO userGroup2 = randomPojo(BpmUserGroupDO.class, o -> o.setMemberUserIds(asSet(21L, 22L)));
when(userGroupService.getUserGroupList(eq(rule.getOptions()))).thenReturn(Arrays.asList(userGroup1, userGroup2));
mockGetUserMap(asSet(11L, 12L, 21L, 22L));
// 调用
@ -190,13 +191,13 @@ public class BpmUserTaskActivitiBehaviorTest extends BaseMockitoUnitTest {
// 准备参数. 1L 可以找到2L 是禁用的3L 找不到
Set<Long> assigneeUserIds = asSet(1L, 2L, 3L);
// mock 方法
SysUserDO user1 = randomPojo(SysUserDO.class, o -> o.setId(1L)
AdminUserRespDTO user1 = randomPojo(AdminUserRespDTO.class, o -> o.setId(1L)
.setStatus(CommonStatusEnum.ENABLE.getStatus()));
SysUserDO user2 = randomPojo(SysUserDO.class, o -> o.setId(2L)
AdminUserRespDTO user2 = randomPojo(AdminUserRespDTO.class, o -> o.setId(2L)
.setStatus(CommonStatusEnum.DISABLE.getStatus()));
Map<Long, SysUserDO> userMap = MapUtil.builder(user1.getId(), user1)
Map<Long, AdminUserRespDTO> userMap = MapUtil.builder(user1.getId(), user1)
.put(user2.getId(), user2).build();
when(userCoreService.getUserMap(eq(assigneeUserIds))).thenReturn(userMap);
when(adminUserApi.getUserMap(eq(assigneeUserIds))).thenReturn(userMap);
// 调用
behavior.removeDisableUsers(assigneeUserIds);
@ -205,9 +206,9 @@ public class BpmUserTaskActivitiBehaviorTest extends BaseMockitoUnitTest {
}
private void mockGetUserMap(Set<Long> assigneeUserIds) {
Map<Long, SysUserDO> userMap = CollectionUtils.convertMap(assigneeUserIds, id -> id,
id -> new SysUserDO().setId(id).setStatus(CommonStatusEnum.ENABLE.getStatus()));
when(userCoreService.getUserMap(eq(assigneeUserIds))).thenReturn(userMap);
Map<Long, AdminUserRespDTO> userMap = CollectionUtils.convertMap(assigneeUserIds, id -> id,
id -> new AdminUserRespDTO().setId(id).setStatus(CommonStatusEnum.ENABLE.getStatus()));
when(adminUserApi.getUserMap(eq(assigneeUserIds))).thenReturn(userMap);
}
}

View File

@ -1,16 +1,16 @@
package cn.iocoder.yudao.adminserver.modules.bpm.framework.activiti.core.behavior.script.impl;
import cn.iocoder.yudao.module.system.dal.dataobject.dept.SysDeptDO;
import cn.iocoder.yudao.module.system.dal.dataobject.user.SysUserDO;
import cn.iocoder.yudao.module.system.service.dept.SysDeptCoreService;
import cn.iocoder.yudao.module.system.service.user.SysUserCoreService;
import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest;
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
import org.activiti.engine.impl.persistence.entity.ExecutionEntityImpl;
import org.activiti.engine.impl.persistence.entity.TaskEntity;
import org.activiti.engine.impl.persistence.entity.TaskEntityImpl;
import org.junit.jupiter.api.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.springframework.boot.test.mock.mockito.MockBean;
import java.util.Set;
@ -25,18 +25,18 @@ class BpmTaskAssignLeaderX2ScriptTest extends BaseMockitoUnitTest {
@InjectMocks
private BpmTaskAssignLeaderX2Script script;
@Mock
private SysUserCoreService userCoreService;
@Mock
private SysDeptCoreService deptCoreService;
@MockBean
private AdminUserApi adminUserApi;
@MockBean
private DeptApi deptApi;
@Test
public void testCalculateTaskCandidateUsers_noDept() {
// 准备参数
TaskEntity task = buildTaskEntity(1L);
// mock 方法(startUser)
SysUserDO startUser = randomPojo(SysUserDO.class, o -> o.setDeptId(10L));
when(userCoreService.getUser(eq(1L))).thenReturn(startUser);
AdminUserRespDTO startUser = randomPojo(AdminUserRespDTO.class, o -> o.setDeptId(10L));
when(adminUserApi.getUser(eq(1L))).thenReturn(startUser);
// 调用
Set<Long> result = script.calculateTaskCandidateUsers(task);
@ -49,11 +49,11 @@ class BpmTaskAssignLeaderX2ScriptTest extends BaseMockitoUnitTest {
// 准备参数
TaskEntity task = buildTaskEntity(1L);
// mock 方法(startUser)
SysUserDO startUser = randomPojo(SysUserDO.class, o -> o.setDeptId(10L));
when(userCoreService.getUser(eq(1L))).thenReturn(startUser);
SysDeptDO startUserDept = randomPojo(SysDeptDO.class, o -> o.setId(10L).setParentId(100L)
AdminUserRespDTO startUser = randomPojo(AdminUserRespDTO.class, o -> o.setDeptId(10L));
when(adminUserApi.getUser(eq(1L))).thenReturn(startUser);
DeptRespDTO startUserDept = randomPojo(DeptRespDTO.class, o -> o.setId(10L).setParentId(100L)
.setLeaderUserId(20L));
when(deptCoreService.getDept(eq(10L))).thenReturn(startUserDept);
when(deptApi.getDept(eq(10L))).thenReturn(startUserDept);
// 调用
Set<Long> result = script.calculateTaskCandidateUsers(task);
@ -66,15 +66,15 @@ class BpmTaskAssignLeaderX2ScriptTest extends BaseMockitoUnitTest {
// 准备参数
TaskEntity task = buildTaskEntity(1L);
// mock 方法(startUser)
SysUserDO startUser = randomPojo(SysUserDO.class, o -> o.setDeptId(10L));
when(userCoreService.getUser(eq(1L))).thenReturn(startUser);
SysDeptDO startUserDept = randomPojo(SysDeptDO.class, o -> o.setId(10L).setParentId(100L)
AdminUserRespDTO startUser = randomPojo(AdminUserRespDTO.class, o -> o.setDeptId(10L));
when(adminUserApi.getUser(eq(1L))).thenReturn(startUser);
DeptRespDTO startUserDept = randomPojo(DeptRespDTO.class, o -> o.setId(10L).setParentId(100L)
.setLeaderUserId(20L));
when(deptCoreService.getDept(eq(10L))).thenReturn(startUserDept);
when(deptApi.getDept(eq(10L))).thenReturn(startUserDept);
// mock 方法 dept
SysDeptDO parentDept = randomPojo(SysDeptDO.class, o -> o.setId(100L).setParentId(1000L)
DeptRespDTO parentDept = randomPojo(DeptRespDTO.class, o -> o.setId(100L).setParentId(1000L)
.setLeaderUserId(200L));
when(deptCoreService.getDept(eq(100L))).thenReturn(parentDept);
when(deptApi.getDept(eq(100L))).thenReturn(parentDept);
// 调用
Set<Long> result = script.calculateTaskCandidateUsers(task);

View File

@ -4,8 +4,8 @@ import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
import cn.iocoder.yudao.framework.security.core.LoginUser;
import cn.iocoder.yudao.module.member.controller.app.auth.vo.*;
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
import cn.iocoder.yudao.module.system.api.sms.dto.SmsCodeSendReqDTO;
import cn.iocoder.yudao.module.system.api.sms.dto.SmsCodeUseReqDTO;
import cn.iocoder.yudao.module.system.api.sms.dto.code.SmsCodeSendReqDTO;
import cn.iocoder.yudao.module.system.api.sms.dto.code.SmsCodeUseReqDTO;
import cn.iocoder.yudao.module.system.api.social.dto.SocialUserBindReqDTO;
import cn.iocoder.yudao.module.system.api.social.dto.SocialUserUnbindReqDTO;
import cn.iocoder.yudao.module.system.enums.sms.SmsSceneEnum;

View File

@ -8,7 +8,7 @@ import cn.iocoder.yudao.module.member.controller.app.user.vo.AppUserUpdateMobile
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
import cn.iocoder.yudao.module.member.dal.mysql.user.MemberUserMapper;
import cn.iocoder.yudao.module.system.api.sms.SmsCodeApi;
import cn.iocoder.yudao.module.system.api.sms.dto.SmsCodeUseReqDTO;
import cn.iocoder.yudao.module.system.api.sms.dto.code.SmsCodeUseReqDTO;
import cn.iocoder.yudao.module.system.enums.sms.SmsSceneEnum;
import com.google.common.annotations.VisibleForTesting;
import lombok.extern.slf4j.Slf4j;

View File

@ -0,0 +1,50 @@
package cn.iocoder.yudao.module.system.api.dept;
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* 部门 API 接口
*
* @author 芋道源码
*/
public interface DeptApi {
/**
* 获得部门信息
*
* @param id 部门编号
* @return 部门信息
*/
DeptRespDTO getDept(Long id);
/**
* 获得部门信息数组
*
* @param ids 部门编号数组
* @return 部门信息数组
*/
List<DeptRespDTO> getDepts(Collection<Long> ids);
/**
* 校验部门们是否有效如下情况视为无效
* 1. 部门编号不存在
* 2. 部门被禁用
*
* @param ids 角色编号数组
*/
void validDepts(Collection<Long> ids);
/**
* 获得指定编号的部门 Map
*
* @param ids 部门编号数组
* @return 部门 Map
*/
Map<Long, DeptRespDTO> getDeptMap(Set<Long> ids);
}

View File

@ -0,0 +1,21 @@
package cn.iocoder.yudao.module.system.api.dept;
import java.util.Collection;
/**
* 岗位 API 接口
*
* @author 芋道源码
*/
public interface PostApi {
/**
* 校验岗位们是否有效如下情况视为无效
* 1. 岗位编号不存在
* 2. 岗位被禁用
*
* @param ids 岗位编号数组
*/
void validPosts(Collection<Long> ids);
}

View File

@ -0,0 +1,37 @@
package cn.iocoder.yudao.module.system.api.dept.dto;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import lombok.Data;
/**
* 部门 Response DTO
*
* @author 芋道源码
*/
@Data
public class DeptRespDTO {
/**
* 部门编号
*/
private Long id;
/**
* 部门名称
*/
private String name;
/**
* 父部门编号
*/
private Long parentId;
/**
* 负责人的用户编号
*/
private Long leaderUserId;
/**
* 部门状态
*
* 枚举 {@link CommonStatusEnum}
*/
private Integer status;
}

View File

@ -0,0 +1,22 @@
package cn.iocoder.yudao.module.system.api.dict;
import java.util.Collection;
/**
* 字典数据 API 接口
*
* @author 芋道源码
*/
public interface DictDataApi {
/**
* 校验字典数据们是否有效如下情况视为无效
* 1. 字典数据不存在
* 2. 字典数据被禁用
*
* @param dictType 字典类型
* @param values 字典数据值的数组
*/
void validDictDatas(String dictType, Collection<String> values);
}

View File

@ -0,0 +1,21 @@
package cn.iocoder.yudao.module.system.api.permission;
import java.util.Collection;
import java.util.Set;
/**
* 权限 API 接口
*
* @author 芋道源码
*/
public interface PermissionApi {
/**
* 获得拥有多个角色的用户编号集合
*
* @param roleIds 角色编号集合
* @return 用户编号集合
*/
Set<Long> getUserRoleIdListByRoleIds(Collection<Long> roleIds);
}

View File

@ -0,0 +1,21 @@
package cn.iocoder.yudao.module.system.api.permission;
import java.util.Collection;
/**
* 角色 API 接口
*
* @author 芋道源码
*/
public interface RoleApi {
/**
* 校验角色们是否有效如下情况视为无效
* 1. 角色编号不存在
* 2. 角色被禁用
*
* @param ids 角色编号数组
*/
void validRoles(Collection<Long> ids);
}

View File

@ -1,9 +1,9 @@
package cn.iocoder.yudao.module.system.api.sms;
import cn.iocoder.yudao.framework.common.exception.ServiceException;
import cn.iocoder.yudao.module.system.api.sms.dto.SmsCodeCheckReqDTO;
import cn.iocoder.yudao.module.system.api.sms.dto.SmsCodeSendReqDTO;
import cn.iocoder.yudao.module.system.api.sms.dto.SmsCodeUseReqDTO;
import cn.iocoder.yudao.module.system.api.sms.dto.code.SmsCodeCheckReqDTO;
import cn.iocoder.yudao.module.system.api.sms.dto.code.SmsCodeSendReqDTO;
import cn.iocoder.yudao.module.system.api.sms.dto.code.SmsCodeUseReqDTO;
import javax.validation.Valid;

View File

@ -0,0 +1,34 @@
package cn.iocoder.yudao.module.system.api.sms;
import cn.iocoder.yudao.module.system.api.sms.dto.send.SmsSendSingleToUserReqDTO;
import javax.validation.Valid;
/**
* 短信发送 API 接口
*
* @author 芋道源码
*/
public interface SmsSendApi {
/**
* 发送单条短信给 Admin 用户
*
* mobile 为空时使用 userId 加载对应 Admin 的手机号
*
* @param reqDTO 发送请求
* @return 发送日志编号
*/
Long sendSingleSmsToAdmin(@Valid SmsSendSingleToUserReqDTO reqDTO);
/**
* 发送单条短信给 Member 用户
*
* mobile 为空时使用 userId 加载对应 Member 的手机号
*
* @param reqDTO 发送请求
* @return 发送日志编号
*/
Long sendSingleSmsToMember(@Valid SmsSendSingleToUserReqDTO reqDTO);
}

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.module.system.api.sms.dto;
package cn.iocoder.yudao.module.system.api.sms.dto.code;
import cn.iocoder.yudao.framework.common.validation.InEnum;
import cn.iocoder.yudao.framework.common.validation.Mobile;

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.module.system.api.sms.dto;
package cn.iocoder.yudao.module.system.api.sms.dto.code;
import cn.iocoder.yudao.framework.common.validation.InEnum;
import cn.iocoder.yudao.framework.common.validation.Mobile;

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.module.system.api.sms.dto;
package cn.iocoder.yudao.module.system.api.sms.dto.code;
import cn.iocoder.yudao.framework.common.validation.InEnum;
import cn.iocoder.yudao.framework.common.validation.Mobile;

View File

@ -0,0 +1,38 @@
package cn.iocoder.yudao.module.system.api.sms.dto.send;
import cn.iocoder.yudao.framework.common.validation.Mobile;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.Map;
/**
* 短信发送给 Admin 或者 Member 用户
*
* @author 芋道源码
*/
@Data
public class SmsSendSingleToUserReqDTO {
/**
* 用户编号
*/
@NotNull(message = "用户编号不能为空")
private Long userId;
/**
* 手机号
*/
@Mobile
private String mobile;
/**
* 短信模板编号
*/
@NotEmpty(message = "短信模板编号不能为空")
private String templateCode;
/**
* 短信模板参数
*/
private Map<String, Object> templateParams;
}

View File

@ -0,0 +1,58 @@
package cn.iocoder.yudao.module.system.api.user;
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* Admin 用户 API 接口
*
* @author 芋道源码
*/
public interface AdminUserApi {
/**
* 通过用户 ID 查询用户
*
* @param id 用户ID
* @return 用户对象信息
*/
AdminUserRespDTO getUser(Long id);
/**
* 获得指定部门的用户数组
*
* @param deptIds 部门数组
* @return 用户数组
*/
List<AdminUserRespDTO> getUsersByDeptIds(Collection<Long> deptIds);
/**
* 获得指定岗位的用户数组
*
* @param postIds 岗位数组
* @return 用户数组
*/
List<AdminUserRespDTO> getUsersByPostIds(Collection<Long> postIds);
/**
* 获得用户 Map
*
* @param ids 用户编号数组
* @return 用户 Map
*/
Map<Long, AdminUserRespDTO> getUserMap(Collection<Long> ids);
/**
* 校验用户们是否有效如下情况视为无效
* 1. 用户编号不存在
* 2. 用户被禁用
*
* @param ids 用户编号数组
*/
void validUsers(Set<Long> ids);
}

View File

@ -0,0 +1,44 @@
package cn.iocoder.yudao.module.system.api.user.dto;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import lombok.Data;
import java.util.Set;
/**
* Admin 用户 Response DTO
*
* @author 芋道源码
*/
@Data
public class AdminUserRespDTO {
/**
* 用户ID
*/
private Long id;
/**
* 用户昵称
*/
private String nickname;
/**
* 帐号状态
*
* 枚举 {@link CommonStatusEnum}
*/
private Integer status;
/**
* 部门ID
*/
private Long deptId;
/**
* 岗位编号数组
*/
private Set<Long> postIds;
/**
* 手机号码
*/
private String mobile;
}

View File

@ -0,0 +1,49 @@
package cn.iocoder.yudao.module.system.api.dept;
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
import cn.iocoder.yudao.module.system.convert.dept.DeptConvert;
import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
import cn.iocoder.yudao.module.system.service.dept.DeptService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* 部门 API 实现类
*
* @author 芋道源码
*/
@Service
public class DeptApiImpl implements DeptApi {
@Resource
private DeptService deptService;
@Override
public DeptRespDTO getDept(Long id) {
DeptDO dept = deptService.getDept(id);
return DeptConvert.INSTANCE.convert03(dept);
}
@Override
public List<DeptRespDTO> getDepts(Collection<Long> ids) {
List<DeptDO> depts = deptService.getDepts(ids);
return DeptConvert.INSTANCE.convertList03(depts);
}
@Override
public void validDepts(Collection<Long> ids) {
deptService.validDepts(ids);
}
@Override
public Map<Long, DeptRespDTO> getDeptMap(Set<Long> ids) {
Map<Long, DeptDO> depts = deptService.getDeptMap(ids);
return DeptConvert.INSTANCE.convertMap(depts);
}
}

View File

@ -0,0 +1,26 @@
package cn.iocoder.yudao.module.system.api.permission;
import cn.iocoder.yudao.module.system.service.permission.PermissionService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Collection;
import java.util.Set;
/**
* 权限 API 实现类
*
* @author 芋道源码
*/
@Service
public class PermissionApiImpl implements PermissionApi {
@Resource
private PermissionService permissionService;
@Override
public Set<Long> getUserRoleIdListByRoleIds(Collection<Long> roleIds) {
return permissionService.getUserRoleIdListByRoleIds(roleIds);
}
}

View File

@ -1,8 +1,8 @@
package cn.iocoder.yudao.module.system.api.sms;
import cn.iocoder.yudao.module.system.api.sms.dto.SmsCodeCheckReqDTO;
import cn.iocoder.yudao.module.system.api.sms.dto.SmsCodeSendReqDTO;
import cn.iocoder.yudao.module.system.api.sms.dto.SmsCodeUseReqDTO;
import cn.iocoder.yudao.module.system.api.sms.dto.code.SmsCodeCheckReqDTO;
import cn.iocoder.yudao.module.system.api.sms.dto.code.SmsCodeSendReqDTO;
import cn.iocoder.yudao.module.system.api.sms.dto.code.SmsCodeUseReqDTO;
import cn.iocoder.yudao.module.system.service.sms.SmsCodeService;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;

View File

@ -0,0 +1,34 @@
package cn.iocoder.yudao.module.system.api.sms;
import cn.iocoder.yudao.module.system.api.sms.dto.send.SmsSendSingleToUserReqDTO;
import cn.iocoder.yudao.module.system.service.sms.SmsSendService;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
/**
* 短信发送 API 接口
*
* @author 芋道源码
*/
@Service
@Validated
public class SmsSendApiImpl implements SmsSendApi {
@Resource
private SmsSendService smsSendService;
@Override
public Long sendSingleSmsToAdmin(SmsSendSingleToUserReqDTO reqDTO) {
return smsSendService.sendSingleSmsToAdmin(reqDTO.getMobile(), reqDTO.getUserId(),
reqDTO.getTemplateCode(), reqDTO.getTemplateParams());
}
@Override
public Long sendSingleSmsToMember(SmsSendSingleToUserReqDTO reqDTO) {
return smsSendService.sendSingleSmsToMember(reqDTO.getMobile(), reqDTO.getUserId(),
reqDTO.getTemplateCode(), reqDTO.getTemplateParams());
}
}

View File

@ -0,0 +1,55 @@
package cn.iocoder.yudao.module.system.api.user;
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
import cn.iocoder.yudao.module.system.convert.user.UserConvert;
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
import cn.iocoder.yudao.module.system.service.user.AdminUserService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* Admin 用户 API 实现类
*
* @author 芋道源码
*/
@Service
public class AdminUserApiImpl implements AdminUserApi {
@Resource
private AdminUserService userService;
@Override
public AdminUserRespDTO getUser(Long id) {
AdminUserDO user = userService.getUser(id);
return UserConvert.INSTANCE.convert4(user);
}
@Override
public List<AdminUserRespDTO> getUsersByDeptIds(Collection<Long> deptIds) {
List<AdminUserDO> users = userService.getUsersByDeptIds(deptIds);
return UserConvert.INSTANCE.convertList4(users);
}
@Override
public List<AdminUserRespDTO> getUsersByPostIds(Collection<Long> postIds) {
List<AdminUserDO> users = userService.getUsersByPostIds(postIds);
return UserConvert.INSTANCE.convertList4(users);
}
@Override
public Map<Long, AdminUserRespDTO> getUserMap(Collection<Long> ids) {
Map<Long, AdminUserDO> userMap = userService.getUserMap(ids);
return UserConvert.INSTANCE.convertMap4(userMap);
}
@Override
public void validUsers(Set<Long> ids) {
userService.validUsers(ids);
}
}

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.system.convert.dept;
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
import cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept.DeptCreateReqVO;
import cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept.DeptRespVO;
import cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept.DeptSimpleRespVO;
@ -9,6 +10,7 @@ import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import java.util.List;
import java.util.Map;
@Mapper
public interface DeptConvert {
@ -25,4 +27,10 @@ public interface DeptConvert {
DeptDO convert(DeptUpdateReqVO bean);
List<DeptRespDTO> convertList03(List<DeptDO> list);
DeptRespDTO convert03(DeptDO bean);
Map<Long, DeptRespDTO> convertMap(Map<Long, DeptDO> map);
}

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.system.convert.user;
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
import cn.iocoder.yudao.module.system.controller.admin.user.vo.profile.UserProfileRespVO;
import cn.iocoder.yudao.module.system.controller.admin.user.vo.profile.UserProfileUpdatePasswordReqVO;
import cn.iocoder.yudao.module.system.controller.admin.user.vo.profile.UserProfileUpdateReqVO;
@ -13,6 +14,7 @@ import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import java.util.List;
import java.util.Map;
@Mapper
public interface UserConvert {
@ -46,4 +48,11 @@ public interface UserConvert {
List<UserProfileRespVO.SocialUser> convertList03(List<SocialUserDO> list);
List<UserSimpleRespVO> convertList04(List<AdminUserDO> list);
AdminUserRespDTO convert4(AdminUserDO bean);
List<AdminUserRespDTO> convertList4(List<AdminUserDO> users);
Map<Long, AdminUserRespDTO> convertMap4(Map<Long, AdminUserDO> map);
}

View File

@ -46,7 +46,6 @@ public interface DeptService {
*/
void deleteDept(Long id);
/**
* 筛选部门列表
*

Some files were not shown because too many files have changed in this diff Show More