From afa0d623dba39989d66e03dbc1e7359076583fd5 Mon Sep 17 00:00:00 2001 From: jason <2667446@qq.com> Date: Thu, 27 Jan 2022 22:08:34 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20bpm-core-service=20?= =?UTF-8?q?=E5=A4=9A=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 22 + yudao-admin-server/pom.xml | 5 +- yudao-dependencies/pom.xml | 7 +- .../yudao-module-bpm-activiti/pom.xml | 5 +- .../bpm/enums/BpmErrorCodeConstants.java | 4 - .../config/BpmActivitiConfiguration.java | 7 +- .../behavior/BpmActivityBehaviorFactory.java | 6 +- .../behavior/BpmUserTaskActivitiBehavior.java | 10 +- .../impl/BpmTaskAssignRuleServiceImpl.java | 9 +- .../BpmUserTaskActivitiBehaviorTest.java | 12 +- .../src/test/resources/sql/clean.sql | 36 -- .../src/test/resources/sql/create_tables.sql | 608 ------------------ .../yudao-module-bpm-core-service/pom.xml | 6 +- .../yudao-module-bpm-core-service-api/pom.xml | 20 + .../bpm/api/group/BpmUserGroupServiceApi.java | 32 + .../bpm/api/group/dto/BpmUserGroupDTO.java | 17 + .../pom.xml | 35 + .../bpm/api/BpmUserGroupServiceApiImpl.java | 61 ++ .../definition/BpmUserGroupController.java | 0 .../vo/group/BpmUserGroupBaseVO.java | 0 .../vo/group/BpmUserGroupCreateReqVO.java | 0 .../vo/group/BpmUserGroupPageReqVO.java | 15 +- .../vo/group/BpmUserGroupRespVO.java | 0 .../vo/group/BpmUserGroupSimpleRespVO.java | 0 .../vo/group/BpmUserGroupUpdateReqVO.java | 0 .../definition/BpmUserGroupConvert.java | 3 + .../dataobject/definition/BpmUserGroupDO.java | 0 .../mysql/definition/BpmUserGroupMapper.java | 0 .../bpm/enums/BpmErrorCodeConstants.java | 10 + .../definition/BpmUserGroupService.java | 18 - .../impl/BpmUserGroupServiceImpl.java | 27 +- .../yudao/adminserver/BaseDbUnitTest.java | 39 ++ .../definition/BpmUserGroupServiceTest.java | 41 +- .../test/resources/application-unit-test.yaml | 38 ++ .../src/test/resources/application.yaml | 35 + .../src/test/resources/logback-spring.xml | 4 + .../src/test/resources/sql/clean.sql | 2 + .../src/test/resources/sql/create_tables.sql | 14 + 38 files changed, 401 insertions(+), 747 deletions(-) create mode 100644 yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-api/pom.xml create mode 100644 yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-api/src/main/java/cn/iocoder/yudao/coreservice/modules/bpm/api/group/BpmUserGroupServiceApi.java create mode 100644 yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-api/src/main/java/cn/iocoder/yudao/coreservice/modules/bpm/api/group/dto/BpmUserGroupDTO.java create mode 100644 yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl/pom.xml create mode 100644 yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/api/BpmUserGroupServiceApiImpl.java rename yudao-module-bpm/{yudao-module-bpm-activiti => yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl}/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/BpmUserGroupController.java (100%) rename yudao-module-bpm/{yudao-module-bpm-activiti => yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl}/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/vo/group/BpmUserGroupBaseVO.java (100%) rename yudao-module-bpm/{yudao-module-bpm-activiti => yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl}/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/vo/group/BpmUserGroupCreateReqVO.java (100%) rename yudao-module-bpm/{yudao-module-bpm-activiti => yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl}/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/vo/group/BpmUserGroupPageReqVO.java (63%) rename yudao-module-bpm/{yudao-module-bpm-activiti => yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl}/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/vo/group/BpmUserGroupRespVO.java (100%) rename yudao-module-bpm/{yudao-module-bpm-activiti => yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl}/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/vo/group/BpmUserGroupSimpleRespVO.java (100%) rename yudao-module-bpm/{yudao-module-bpm-activiti => yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl}/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/vo/group/BpmUserGroupUpdateReqVO.java (100%) rename yudao-module-bpm/{yudao-module-bpm-activiti => yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl}/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/definition/BpmUserGroupConvert.java (89%) rename yudao-module-bpm/{yudao-module-bpm-activiti => yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl}/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/dal/dataobject/definition/BpmUserGroupDO.java (100%) rename yudao-module-bpm/{yudao-module-bpm-activiti => yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl}/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/dal/mysql/definition/BpmUserGroupMapper.java (100%) create mode 100644 yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/enums/BpmErrorCodeConstants.java rename yudao-module-bpm/{yudao-module-bpm-activiti => yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl}/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/BpmUserGroupService.java (79%) rename yudao-module-bpm/{yudao-module-bpm-activiti => yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl}/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/impl/BpmUserGroupServiceImpl.java (76%) create mode 100644 yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl/src/test/java/cn/iocoder/yudao/adminserver/BaseDbUnitTest.java rename yudao-module-bpm/{yudao-module-bpm-activiti => yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl}/src/test/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/BpmUserGroupServiceTest.java (73%) create mode 100644 yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl/src/test/resources/application-unit-test.yaml create mode 100644 yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl/src/test/resources/application.yaml create mode 100644 yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl/src/test/resources/logback-spring.xml create mode 100644 yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl/src/test/resources/sql/clean.sql create mode 100644 yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl/src/test/resources/sql/create_tables.sql diff --git a/pom.xml b/pom.xml index 4b7c953e4..61e1b3379 100644 --- a/pom.xml +++ b/pom.xml @@ -27,6 +27,9 @@ ${java.version} ${java.version} 3.0.0-M5 + 3.8.0 + 1.18.20 + 1.4.1.Final UTF-8 @@ -52,6 +55,25 @@ maven-surefire-plugin ${maven-surefire-plugin.version} + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + + + org.projectlombok + lombok + ${lombok.version} + + + org.mapstruct + mapstruct-processor + ${mapstruct.version} + + + + diff --git a/yudao-admin-server/pom.xml b/yudao-admin-server/pom.xml index 3553b38b2..be72f792f 100644 --- a/yudao-admin-server/pom.xml +++ b/yudao-admin-server/pom.xml @@ -49,7 +49,10 @@ cn.iocoder.boot yudao-module-bpm-activiti - + + cn.iocoder.boot + yudao-module-bpm-core-service-impl + cn.iocoder.boot diff --git a/yudao-dependencies/pom.xml b/yudao-dependencies/pom.xml index 7aa40966b..512fefdc3 100644 --- a/yudao-dependencies/pom.xml +++ b/yudao-dependencies/pom.xml @@ -410,7 +410,12 @@ cn.iocoder.boot - yudao-module-bpm-core-service + yudao-module-bpm-core-service-impl + ${revision} + + + cn.iocoder.boot + yudao-module-bpm-core-service-api ${revision} diff --git a/yudao-module-bpm/yudao-module-bpm-activiti/pom.xml b/yudao-module-bpm/yudao-module-bpm-activiti/pom.xml index 775bdf6c0..a131ab089 100644 --- a/yudao-module-bpm/yudao-module-bpm-activiti/pom.xml +++ b/yudao-module-bpm/yudao-module-bpm-activiti/pom.xml @@ -19,6 +19,10 @@ cn.iocoder.boot yudao-core-service + + cn.iocoder.boot + yudao-module-bpm-core-service-api + cn.iocoder.boot @@ -26,5 +30,4 @@ test - \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-activiti/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/enums/BpmErrorCodeConstants.java b/yudao-module-bpm/yudao-module-bpm-activiti/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/enums/BpmErrorCodeConstants.java index e2a0ff3d7..771a04f5e 100644 --- a/yudao-module-bpm/yudao-module-bpm-activiti/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/enums/BpmErrorCodeConstants.java +++ b/yudao-module-bpm/yudao-module-bpm-activiti/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/enums/BpmErrorCodeConstants.java @@ -57,8 +57,4 @@ public interface BpmErrorCodeConstants { 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, "名字为【{}】的用户组已被禁用"); - } diff --git a/yudao-module-bpm/yudao-module-bpm-activiti/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/framework/activiti/config/BpmActivitiConfiguration.java b/yudao-module-bpm/yudao-module-bpm-activiti/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/framework/activiti/config/BpmActivitiConfiguration.java index 4e0938d46..72210a3af 100644 --- a/yudao-module-bpm/yudao-module-bpm-activiti/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/framework/activiti/config/BpmActivitiConfiguration.java +++ b/yudao-module-bpm/yudao-module-bpm-activiti/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/framework/activiti/config/BpmActivitiConfiguration.java @@ -6,11 +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.adminserver.modules.bpm.service.definition.BpmUserGroupService; +import cn.iocoder.yudao.coreservice.modules.bpm.api.group.BpmUserGroupServiceApi; 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 org.activiti.api.runtime.shared.identity.UserGroupManager; import org.activiti.spring.boot.ProcessEngineConfigurationConfigurer; import org.springframework.context.ApplicationEventPublisher; import org.springframework.context.annotation.Bean; @@ -60,14 +59,14 @@ public class BpmActivitiConfiguration { public BpmActivityBehaviorFactory bpmActivityBehaviorFactory(BpmTaskAssignRuleService taskRuleService, SysPermissionCoreService permissionCoreService, SysDeptCoreService deptCoreService, - BpmUserGroupService userGroupService, + BpmUserGroupServiceApi userGroupServiceApi, SysUserCoreService userCoreService, List scripts) { BpmActivityBehaviorFactory bpmActivityBehaviorFactory = new BpmActivityBehaviorFactory(); bpmActivityBehaviorFactory.setBpmTaskRuleService(taskRuleService); bpmActivityBehaviorFactory.setPermissionCoreService(permissionCoreService); bpmActivityBehaviorFactory.setDeptCoreService(deptCoreService); - bpmActivityBehaviorFactory.setUserGroupService(userGroupService); + bpmActivityBehaviorFactory.setUserGroupServiceApi(userGroupServiceApi); bpmActivityBehaviorFactory.setUserCoreService(userCoreService); bpmActivityBehaviorFactory.setScripts(scripts); return bpmActivityBehaviorFactory; diff --git a/yudao-module-bpm/yudao-module-bpm-activiti/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/framework/activiti/core/behavior/BpmActivityBehaviorFactory.java b/yudao-module-bpm/yudao-module-bpm-activiti/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/framework/activiti/core/behavior/BpmActivityBehaviorFactory.java index 2107fb72b..c426a23ee 100644 --- a/yudao-module-bpm/yudao-module-bpm-activiti/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/framework/activiti/core/behavior/BpmActivityBehaviorFactory.java +++ b/yudao-module-bpm/yudao-module-bpm-activiti/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/framework/activiti/core/behavior/BpmActivityBehaviorFactory.java @@ -2,7 +2,7 @@ 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.adminserver.modules.bpm.service.definition.BpmUserGroupService; +import cn.iocoder.yudao.coreservice.modules.bpm.api.group.BpmUserGroupServiceApi; 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; @@ -34,7 +34,7 @@ public class BpmActivityBehaviorFactory extends DefaultActivityBehaviorFactory { @Setter private SysDeptCoreService deptCoreService; @Setter - private BpmUserGroupService userGroupService; + private BpmUserGroupServiceApi userGroupServiceApi; @Setter private SysUserCoreService userCoreService; @Setter @@ -46,7 +46,7 @@ public class BpmActivityBehaviorFactory extends DefaultActivityBehaviorFactory { userTaskActivityBehavior.setBpmTaskRuleService(bpmTaskRuleService); userTaskActivityBehavior.setPermissionCoreService(permissionCoreService); userTaskActivityBehavior.setDeptCoreService(deptCoreService); - userTaskActivityBehavior.setUserGroupService(userGroupService); + userTaskActivityBehavior.setUserGroupServiceApi(userGroupServiceApi); userTaskActivityBehavior.setSysUserCoreService(userCoreService); userTaskActivityBehavior.setScripts(scripts); return userTaskActivityBehavior; diff --git a/yudao-module-bpm/yudao-module-bpm-activiti/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/framework/activiti/core/behavior/BpmUserTaskActivitiBehavior.java b/yudao-module-bpm/yudao-module-bpm-activiti/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/framework/activiti/core/behavior/BpmUserTaskActivitiBehavior.java index 69624d793..e2beba8e0 100644 --- a/yudao-module-bpm/yudao-module-bpm-activiti/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/framework/activiti/core/behavior/BpmUserTaskActivitiBehavior.java +++ b/yudao-module-bpm/yudao-module-bpm-activiti/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/framework/activiti/core/behavior/BpmUserTaskActivitiBehavior.java @@ -4,11 +4,11 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.RandomUtil; import cn.hutool.core.util.StrUtil; import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.definition.BpmTaskAssignRuleDO; -import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.definition.BpmUserGroupDO; import cn.iocoder.yudao.adminserver.modules.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.adminserver.modules.bpm.service.definition.BpmUserGroupService; +import cn.iocoder.yudao.coreservice.modules.bpm.api.group.BpmUserGroupServiceApi; +import cn.iocoder.yudao.coreservice.modules.bpm.api.group.dto.BpmUserGroupDTO; import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.dept.SysDeptDO; import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.user.SysUserDO; import cn.iocoder.yudao.coreservice.modules.system.service.dept.SysDeptCoreService; @@ -30,7 +30,7 @@ import java.util.*; import static cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants.TASK_ASSIGN_SCRIPT_NOT_EXISTS; import static cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants.TASK_CREATE_FAIL_NO_CANDIDATE_USER; -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.*; +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; @@ -53,7 +53,7 @@ public class BpmUserTaskActivitiBehavior extends UserTaskActivityBehavior { @Setter private SysDeptCoreService deptCoreService; @Setter - private BpmUserGroupService userGroupService; + private BpmUserGroupServiceApi userGroupServiceApi; @Setter private SysUserCoreService sysUserCoreService; /** @@ -156,7 +156,7 @@ public class BpmUserTaskActivitiBehavior extends UserTaskActivityBehavior { } private Set calculateTaskCandidateUsersByUserGroup(TaskEntity task, BpmTaskAssignRuleDO rule) { - List userGroups = userGroupService.getUserGroupList(rule.getOptions()); + List userGroups = userGroupServiceApi.getUserGroupList(rule.getOptions()); Set userIds = new HashSet<>(); userGroups.forEach(bpmUserGroupDO -> userIds.addAll(bpmUserGroupDO.getMemberUserIds())); return userIds; diff --git a/yudao-module-bpm/yudao-module-bpm-activiti/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/impl/BpmTaskAssignRuleServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-activiti/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/impl/BpmTaskAssignRuleServiceImpl.java index 82afa944c..dac572f1a 100644 --- a/yudao-module-bpm/yudao-module-bpm-activiti/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/impl/BpmTaskAssignRuleServiceImpl.java +++ b/yudao-module-bpm/yudao-module-bpm-activiti/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/impl/BpmTaskAssignRuleServiceImpl.java @@ -1,8 +1,6 @@ package cn.iocoder.yudao.adminserver.modules.bpm.service.definition.impl; import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.collection.ListUtil; -import cn.hutool.core.util.ArrayUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.rule.BpmTaskAssignRuleCreateReqVO; @@ -15,8 +13,7 @@ import cn.iocoder.yudao.adminserver.modules.bpm.enums.definition.BpmTaskAssignRu 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.BpmUserGroupService; - +import cn.iocoder.yudao.coreservice.modules.bpm.api.group.BpmUserGroupServiceApi; import cn.iocoder.yudao.coreservice.modules.system.enums.SysDictTypeConstants; import cn.iocoder.yudao.coreservice.modules.system.service.dept.SysDeptCoreService; import cn.iocoder.yudao.coreservice.modules.system.service.dept.SysPostCoreService; @@ -65,7 +62,7 @@ public class BpmTaskAssignRuleServiceImpl implements BpmTaskAssignRuleService { @Resource private SysUserCoreService userCoreService; @Resource - private BpmUserGroupService userGroupService; + private BpmUserGroupServiceApi userGroupServiceApi; @Resource private SysDictDataCoreService dictDataCoreService; @@ -191,7 +188,7 @@ public class BpmTaskAssignRuleServiceImpl implements BpmTaskAssignRuleService { } else if (Objects.equals(type, BpmTaskAssignRuleTypeEnum.USER.getType())) { userCoreService.validUsers(options); } else if (Objects.equals(type, BpmTaskAssignRuleTypeEnum.USER_GROUP.getType())) { - userGroupService.validUserGroups(options); + userGroupServiceApi.validUserGroups(options); } else if (Objects.equals(type, BpmTaskAssignRuleTypeEnum.SCRIPT.getType())) { dictDataCoreService.validDictDatas(SysDictTypeConstants.BPM_TASK_ASSIGN_SCRIPT, CollectionUtils.convertSet(options, String::valueOf)); diff --git a/yudao-module-bpm/yudao-module-bpm-activiti/src/test/java/cn/iocoder/yudao/adminserver/modules/bpm/framework/activiti/core/behavior/BpmUserTaskActivitiBehaviorTest.java b/yudao-module-bpm/yudao-module-bpm-activiti/src/test/java/cn/iocoder/yudao/adminserver/modules/bpm/framework/activiti/core/behavior/BpmUserTaskActivitiBehaviorTest.java index 8212b28c0..b9b9a1475 100644 --- a/yudao-module-bpm/yudao-module-bpm-activiti/src/test/java/cn/iocoder/yudao/adminserver/modules/bpm/framework/activiti/core/behavior/BpmUserTaskActivitiBehaviorTest.java +++ b/yudao-module-bpm/yudao-module-bpm-activiti/src/test/java/cn/iocoder/yudao/adminserver/modules/bpm/framework/activiti/core/behavior/BpmUserTaskActivitiBehaviorTest.java @@ -2,12 +2,12 @@ package cn.iocoder.yudao.adminserver.modules.bpm.framework.activiti.core.behavio import cn.hutool.core.map.MapUtil; import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.definition.BpmTaskAssignRuleDO; -import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.definition.BpmUserGroupDO; import cn.iocoder.yudao.adminserver.modules.bpm.enums.definition.BpmTaskAssignRuleTypeEnum; import cn.iocoder.yudao.adminserver.modules.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.adminserver.modules.bpm.service.definition.BpmUserGroupService; +import cn.iocoder.yudao.coreservice.modules.bpm.api.group.BpmUserGroupServiceApi; +import cn.iocoder.yudao.coreservice.modules.bpm.api.group.dto.BpmUserGroupDTO; import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.dept.SysDeptDO; import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.user.SysUserDO; import cn.iocoder.yudao.coreservice.modules.system.service.dept.SysDeptCoreService; @@ -44,7 +44,7 @@ public class BpmUserTaskActivitiBehaviorTest extends BaseMockitoUnitTest { @Mock private SysDeptCoreService deptCoreService; @Mock - private BpmUserGroupService userGroupService; + private BpmUserGroupServiceApi userGroupServiceApi; @Mock private SysUserCoreService userCoreService; @@ -135,9 +135,9 @@ public class BpmUserTaskActivitiBehaviorTest extends BaseMockitoUnitTest { BpmTaskAssignRuleDO rule = new BpmTaskAssignRuleDO().setOptions(asSet(1L, 2L)) .setType(BpmTaskAssignRuleTypeEnum.USER_GROUP.getType()); // mock 方法 - 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)); + 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)); mockGetUserMap(asSet(11L, 12L, 21L, 22L)); // 调用 diff --git a/yudao-module-bpm/yudao-module-bpm-activiti/src/test/resources/sql/clean.sql b/yudao-module-bpm/yudao-module-bpm-activiti/src/test/resources/sql/clean.sql index b565553f2..c14acfe99 100644 --- a/yudao-module-bpm/yudao-module-bpm-activiti/src/test/resources/sql/clean.sql +++ b/yudao-module-bpm/yudao-module-bpm-activiti/src/test/resources/sql/clean.sql @@ -1,38 +1,2 @@ --- inf 开头的 DB -DELETE FROM "inf_config"; -DELETE FROM "inf_file"; -DELETE FROM "inf_job"; -DELETE FROM "inf_job_log"; -DELETE FROM "inf_api_access_log"; -DELETE FROM "inf_api_error_log"; - --- sys 开头的 DB -DELETE FROM "sys_dept"; -DELETE FROM "sys_dict_data"; -DELETE FROM "sys_role"; -DELETE FROM "sys_role_menu"; -DELETE FROM "sys_menu"; -DELETE FROM "sys_user_role"; -DELETE FROM "sys_dict_type"; -DELETE FROM "sys_user_session"; -DELETE FROM "sys_post"; -DELETE FROM "sys_login_log"; -DELETE FROM "sys_operate_log"; -DELETE FROM "sys_user"; -DELETE FROM "sys_sms_channel"; -DELETE FROM "sys_sms_template"; -DELETE FROM "sys_sms_log"; -DELETE FROM "sys_error_code"; -DELETE FROM "sys_social_user"; -DELETE FROM "sys_tenant"; - --- pay 开头的 DB -DELETE FROM pay_merchant; -DELETE FROM pay_app; -DELETE FROM pay_channel; -DELETE FROM pay_order; -DELETE FROM pay_refund; - -- bpm 开头的 DB DELETE FROM "bpm_form"; -DELETE FROM "bpm_user_group"; diff --git a/yudao-module-bpm/yudao-module-bpm-activiti/src/test/resources/sql/create_tables.sql b/yudao-module-bpm/yudao-module-bpm-activiti/src/test/resources/sql/create_tables.sql index 9b2f0d69f..8b6433e69 100644 --- a/yudao-module-bpm/yudao-module-bpm-activiti/src/test/resources/sql/create_tables.sql +++ b/yudao-module-bpm/yudao-module-bpm-activiti/src/test/resources/sql/create_tables.sql @@ -1,597 +1,3 @@ --- inf 开头的 DB - -CREATE TABLE IF NOT EXISTS "inf_config" ( - "id" bigint(20) NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "group" varchar(50) NOT NULL, - "type" tinyint NOT NULL, - "name" varchar(100) NOT NULL DEFAULT '', - "key" varchar(100) NOT NULL DEFAULT '', - "value" varchar(500) NOT NULL DEFAULT '', - "sensitive" bit NOT NULL, - "remark" varchar(500) DEFAULT NULL, - "creator" varchar(64) DEFAULT '', - "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar(64) DEFAULT '', - "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '参数配置表'; - -CREATE TABLE IF NOT EXISTS "inf_file" ( - "id" varchar(188) NOT NULL, - "type" varchar(63) DEFAULT NULL, - "content" blob NOT NULL, - "creator" varchar(64) DEFAULT '', - "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar(64) DEFAULT '', - "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - "tenant_id" bigint not null default '0', - PRIMARY KEY ("id") -) COMMENT '文件表'; - -CREATE TABLE IF NOT EXISTS "inf_job" ( - "id" bigint(20) NOT NULL GENERATED BY DEFAULT AS IDENTITY COMMENT '任务编号', - "name" varchar(32) NOT NULL COMMENT '任务名称', - "status" tinyint(4) NOT NULL COMMENT '任务状态', - "handler_name" varchar(64) NOT NULL COMMENT '处理器的名字', - "handler_param" varchar(255) DEFAULT NULL COMMENT '处理器的参数', - "cron_expression" varchar(32) NOT NULL COMMENT 'CRON 表达式', - "retry_count" int(11) NOT NULL DEFAULT '0' COMMENT '重试次数', - "retry_interval" int(11) NOT NULL DEFAULT '0' COMMENT '重试间隔', - "monitor_timeout" int(11) NOT NULL DEFAULT '0' COMMENT '监控超时时间', - "creator" varchar(64) DEFAULT '' COMMENT '创建者', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - "updater" varchar(64) DEFAULT '' COMMENT '更新者', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - "deleted" bit NOT NULL DEFAULT FALSE COMMENT '是否删除', - PRIMARY KEY ("id") -) COMMENT='定时任务表'; - -CREATE TABLE IF NOT EXISTS "inf_job_log" ( - "id" bigint(20) NOT NULL GENERATED BY DEFAULT AS IDENTITY COMMENT '日志编号', - "job_id" bigint(20) NOT NULL COMMENT '任务编号', - "handler_name" varchar(64) NOT NULL COMMENT '处理器的名字', - "handler_param" varchar(255) DEFAULT NULL COMMENT '处理器的参数', - "execute_index" tinyint(4) NOT NULL DEFAULT '1' COMMENT '第几次执行', - "begin_time" datetime NOT NULL COMMENT '开始执行时间', - "end_time" datetime DEFAULT NULL COMMENT '结束执行时间', - "duration" int(11) DEFAULT NULL COMMENT '执行时长', - "status" tinyint(4) NOT NULL COMMENT '任务状态', - "result" varchar(4000) DEFAULT '' COMMENT '结果数据', - "creator" varchar(64) DEFAULT '' COMMENT '创建者', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - "updater" varchar(64) DEFAULT '' COMMENT '更新者', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - "deleted" bit(1) NOT NULL DEFAULT FALSE COMMENT '是否删除', - PRIMARY KEY ("id") -)COMMENT='定时任务日志表'; - --- sys 开头的 DB - -CREATE TABLE IF NOT EXISTS "sys_dept" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar(30) NOT NULL DEFAULT '', - "parent_id" bigint NOT NULL DEFAULT '0', - "sort" int NOT NULL DEFAULT '0', - "leader_user_id" bigint DEFAULT NULL, - "phone" varchar(11) DEFAULT NULL, - "email" varchar(50) DEFAULT NULL, - "status" tinyint NOT NULL, - "creator" varchar(64) DEFAULT '', - "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar(64) DEFAULT '', - "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - "tenant_id" bigint not null default '0', - PRIMARY KEY ("id") -) COMMENT '部门表'; - -CREATE TABLE IF NOT EXISTS "sys_dict_data" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "sort" int NOT NULL DEFAULT '0', - "label" varchar(100) NOT NULL DEFAULT '', - "value" varchar(100) NOT NULL DEFAULT '', - "dict_type" varchar(100) NOT NULL DEFAULT '', - "status" tinyint NOT NULL DEFAULT '0', - "remark" varchar(500) DEFAULT NULL, - "creator" varchar(64) DEFAULT '', - "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar(64) DEFAULT '', - "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '字典数据表'; - -CREATE TABLE IF NOT EXISTS "sys_role" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar(30) NOT NULL, - "code" varchar(100) NOT NULL, - "sort" int NOT NULL, - "data_scope" tinyint NOT NULL DEFAULT '1', - "data_scope_dept_ids" varchar(500) NOT NULL DEFAULT '', - "status" tinyint NOT NULL, - "type" tinyint NOT NULL, - "remark" varchar(500) DEFAULT NULL, - "creator" varchar(64) DEFAULT '', - "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar(64) DEFAULT '', - "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '角色信息表'; - -CREATE TABLE IF NOT EXISTS "sys_role_menu" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "role_id" bigint NOT NULL, - "menu_id" bigint NOT NULL, - "creator" varchar(64) DEFAULT '', - "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar(64) DEFAULT '', - "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '角色和菜单关联表'; - -CREATE TABLE IF NOT EXISTS "sys_menu" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar(50) NOT NULL, - "permission" varchar(100) NOT NULL DEFAULT '', - "menu_type" tinyint NOT NULL, - "sort" int NOT NULL DEFAULT '0', - "parent_id" bigint NOT NULL DEFAULT '0', - "path" varchar(200) DEFAULT '', - "icon" varchar(100) DEFAULT '#', - "component" varchar(255) DEFAULT NULL, - "status" tinyint NOT NULL DEFAULT '0', - "creator" varchar(64) DEFAULT '', - "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar(64) DEFAULT '', - "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '菜单权限表'; - -CREATE TABLE IF NOT EXISTS "sys_user_role" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "user_id" bigint NOT NULL, - "role_id" bigint NOT NULL, - "creator" varchar(64) DEFAULT '', - "create_time" timestamp DEFAULT NULL, - "updater" varchar(64) DEFAULT '', - "update_time" timestamp DEFAULT NULL, - "deleted" bit DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '用户和角色关联表'; - -CREATE TABLE IF NOT EXISTS "sys_dict_type" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar(100) NOT NULL DEFAULT '', - "type" varchar(100) NOT NULL DEFAULT '', - "status" tinyint NOT NULL DEFAULT '0', - "remark" varchar(500) DEFAULT NULL, - "creator" varchar(64) DEFAULT '', - "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar(64) DEFAULT '', - "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '字典类型表'; - -CREATE TABLE IF NOT EXISTS `sys_user_session` ( - `id` varchar(32) NOT NULL, - `user_id` bigint DEFAULT NULL, - "user_type" tinyint NOT NULL, - `username` varchar(50) NOT NULL DEFAULT '', - `user_ip` varchar(50) DEFAULT NULL, - `user_agent` varchar(512) DEFAULT NULL, - `session_timeout` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "creator" varchar(64) DEFAULT '', - "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updater` varchar(64) DEFAULT '' , - "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - "tenant_id" bigint not null default '0', - PRIMARY KEY (`id`) -) COMMENT '用户在线 Session'; - -CREATE TABLE IF NOT EXISTS "sys_post" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "code" varchar(64) NOT NULL, - "name" varchar(50) NOT NULL, - "sort" integer NOT NULL, - "status" tinyint NOT NULL, - "remark" varchar(500) DEFAULT NULL, - "creator" varchar(64) DEFAULT '', - "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar(64) DEFAULT '', - "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - "tenant_id" bigint not null default '0', - PRIMARY KEY ("id") -) COMMENT '岗位信息表'; - -CREATE TABLE IF NOT EXISTS "sys_notice" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "title" varchar(50) NOT NULL COMMENT '公告标题', - "content" text NOT NULL COMMENT '公告内容', - "notice_type" tinyint NOT NULL COMMENT '公告类型(1通知 2公告)', - "status" tinyint NOT NULL DEFAULT '0' COMMENT '公告状态(0正常 1关闭)', - "creator" varchar(64) DEFAULT '' COMMENT '创建者', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - "updater" varchar(64) DEFAULT '' COMMENT '更新者', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - "deleted" bit NOT NULL DEFAULT 0 COMMENT '是否删除', - "tenant_id" bigint not null default '0', - PRIMARY KEY("id") -) COMMENT '通知公告表'; - -CREATE TABLE IF NOT EXISTS `sys_login_log` ( - `id` bigint(20) NOT NULL GENERATED BY DEFAULT AS IDENTITY, - `log_type` bigint(4) NOT NULL, - "user_id" bigint not null default '0', - "user_type" tinyint NOT NULL, - `trace_id` varchar(64) NOT NULL DEFAULT '', - `username` varchar(50) NOT NULL DEFAULT '', - `result` tinyint(4) NOT NULL, - `user_ip` varchar(50) NOT NULL, - `user_agent` varchar(512) NOT NULL, - `creator` varchar(64) DEFAULT '', - `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updater` varchar(64) DEFAULT '', - `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `deleted` bit(1) NOT NULL DEFAULT '0', - PRIMARY KEY (`id`) -) COMMENT ='系统访问记录'; - -CREATE TABLE IF NOT EXISTS `sys_operate_log` ( - `id` bigint(20) NOT NULL GENERATED BY DEFAULT AS IDENTITY, - `trace_id` varchar(64) NOT NULL DEFAULT '', - `user_id` bigint(20) NOT NULL, - `module` varchar(50) NOT NULL, - `name` varchar(50) NOT NULL, - `operate_type` bigint(4) NOT NULL DEFAULT '0', - `content` varchar(2000) NOT NULL DEFAULT '', - `exts` varchar(512) NOT NULL DEFAULT '', - `request_method` varchar(16) DEFAULT '', - `request_url` varchar(255) DEFAULT '', - `user_ip` varchar(50) DEFAULT NULL, - `user_agent` varchar(200) DEFAULT NULL, - `java_method` varchar(512) NOT NULL DEFAULT '', - `java_method_args` varchar(8000) DEFAULT '', - `start_time` datetime NOT NULL, - `duration` int(11) NOT NULL, - `result_code` int(11) NOT NULL DEFAULT '0', - `result_msg` varchar(512) DEFAULT '', - `result_data` varchar(4000) DEFAULT '', - `creator` varchar(64) DEFAULT '', - `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updater` varchar(64) DEFAULT '', - `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `deleted` bit(1) NOT NULL DEFAULT '0', - "tenant_id" bigint not null default '0', - PRIMARY KEY (`id`) -) COMMENT ='操作日志记录'; - -CREATE TABLE IF NOT EXISTS "sys_user" ( - "id" bigint not null GENERATED BY DEFAULT AS IDENTITY, - "username" varchar(30) not null, - "password" varchar(100) not null default '', - "nickname" varchar(30) not null, - "remark" varchar(500) default null, - "dept_id" bigint default null, - "post_ids" varchar(255) default null, - "email" varchar(50) default '', - "mobile" varchar(11) default '', - "sex" tinyint default '0', - "avatar" varchar(100) default '', - "status" tinyint not null default '0', - "login_ip" varchar(50) default '', - "login_date" timestamp default null, - "creator" varchar(64) default '', - "create_time" timestamp not null default current_timestamp, - "updater" varchar(64) default '', - "update_time" timestamp not null default current_timestamp, - "deleted" bit not null default false, - "tenant_id" bigint not null default '0', - primary key ("id") -) comment '用户信息表'; - -CREATE TABLE IF NOT EXISTS "inf_api_access_log" ( - "id" bigint not null GENERATED BY DEFAULT AS IDENTITY, - "trace_id" varchar(64) not null default '', - "user_id" bigint not null default '0', - "user_type" tinyint not null default '0', - "application_name" varchar(50) not null, - "request_method" varchar(16) not null default '', - "request_url" varchar(255) not null default '', - "request_params" varchar(8000) not null default '', - "user_ip" varchar(50) not null, - "user_agent" varchar(512) not null, - "begin_time" timestamp not null, - "end_time" timestamp not null, - "duration" integer not null, - "result_code" integer not null default '0', - "result_msg" varchar(512) default '', - "creator" varchar(64) default '', - "create_time" timestamp not null default current_timestamp, - "updater" varchar(64) default '', - "update_time" timestamp not null default current_timestamp, - "deleted" bit not null default false, - "tenant_id" bigint not null default '0', - primary key ("id") -) COMMENT 'API 访问日志表'; - -CREATE TABLE IF NOT EXISTS "inf_api_error_log" ( - "id" bigint not null GENERATED BY DEFAULT AS IDENTITY, - "trace_id" varchar(64) not null, - "user_id" bigint not null default '0', - "user_type" tinyint not null default '0', - "application_name" varchar(50) not null, - "request_method" varchar(16) not null, - "request_url" varchar(255) not null, - "request_params" varchar(8000) not null, - "user_ip" varchar(50) not null, - "user_agent" varchar(512) not null, - "exception_time" timestamp not null, - "exception_name" varchar(128) not null default '', - "exception_message" clob not null, - "exception_root_cause_message" clob not null, - "exception_stack_trace" clob not null, - "exception_class_name" varchar(512) not null, - "exception_file_name" varchar(512) not null, - "exception_method_name" varchar(512) not null, - "exception_line_number" integer not null, - "process_status" tinyint not null, - "process_time" timestamp default null, - "process_user_id" bigint default '0', - "creator" varchar(64) default '', - "create_time" timestamp not null default current_timestamp, - "updater" varchar(64) default '', - "update_time" timestamp not null default current_timestamp, - "deleted" bit not null default false, - "tenant_id" bigint not null default '0', - primary key ("id") -) COMMENT '系统异常日志'; - -CREATE TABLE IF NOT EXISTS "sys_sms_channel" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "signature" varchar(10) NOT NULL, - "code" varchar(63) NOT NULL, - "status" tinyint NOT NULL, - "remark" varchar(255) DEFAULT NULL, - "api_key" varchar(63) NOT NULL, - "api_secret" varchar(63) DEFAULT NULL, - "callback_url" varchar(255) DEFAULT NULL, - "creator" varchar(64) DEFAULT '', - "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar(64) DEFAULT '', - "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '短信渠道'; - -CREATE TABLE IF NOT EXISTS "sys_sms_template" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "type" tinyint NOT NULL, - "status" tinyint NOT NULL, - "code" varchar(63) NOT NULL, - "name" varchar(63) NOT NULL, - "content" varchar(255) NOT NULL, - "params" varchar(255) NOT NULL, - "remark" varchar(255) DEFAULT NULL, - "api_template_id" varchar(63) NOT NULL, - "channel_id" bigint NOT NULL, - "channel_code" varchar(63) NOT NULL, - "creator" varchar(64) DEFAULT '', - "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar(64) DEFAULT '', - "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '短信模板'; - -CREATE TABLE IF NOT EXISTS "sys_sms_log" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "channel_id" bigint NOT NULL, - "channel_code" varchar(63) NOT NULL, - "template_id" bigint NOT NULL, - "template_code" varchar(63) NOT NULL, - "template_type" tinyint NOT NULL, - "template_content" varchar(255) NOT NULL, - "template_params" varchar(255) NOT NULL, - "api_template_id" varchar(63) NOT NULL, - "mobile" varchar(11) NOT NULL, - "user_id" bigint DEFAULT '0', - "user_type" tinyint DEFAULT '0', - "send_status" tinyint NOT NULL DEFAULT '0', - "send_time" timestamp DEFAULT NULL, - "send_code" int DEFAULT NULL, - "send_msg" varchar(255) DEFAULT NULL, - "api_send_code" varchar(63) DEFAULT NULL, - "api_send_msg" varchar(255) DEFAULT NULL, - "api_request_id" varchar(255) DEFAULT NULL, - "api_serial_no" varchar(255) DEFAULT NULL, - "receive_status" tinyint NOT NULL DEFAULT '0', - "receive_time" timestamp DEFAULT NULL, - "api_receive_code" varchar(63) DEFAULT NULL, - "api_receive_msg" varchar(255) DEFAULT NULL, - "creator" varchar(64) DEFAULT '', - "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar(64) DEFAULT '', - "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '短信日志'; - -CREATE TABLE IF NOT EXISTS "sys_error_code" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "type" tinyint NOT NULL DEFAULT '0', - "application_name" varchar(50) NOT NULL, - "code" int NOT NULL DEFAULT '0', - "message" varchar(512) NOT NULL DEFAULT '', - "memo" varchar(512) DEFAULT '', - "creator" varchar(64) DEFAULT '', - "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar(64) DEFAULT '', - "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '错误码表'; - -CREATE TABLE IF NOT EXISTS "sys_social_user" ( - "id" number NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "user_id" bigint NOT NULL, - "user_type" tinyint NOT NULL DEFAULT '0', - "type" tinyint NOT NULL, - "openid" varchar(32) NOT NULL, - "token" varchar(256) DEFAULT NULL, - "union_id" varchar(32) NOT NULL, - "raw_token_info" varchar(1024) NOT NULL, - "nickname" varchar(32) NOT NULL, - "avatar" varchar(255) DEFAULT NULL, - "raw_user_info" varchar(1024) NOT NULL, - "creator" varchar(64) DEFAULT '', - "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar(64) DEFAULT '', - "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '社交用户'; - -CREATE TABLE IF NOT EXISTS "sys_tenant" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar(63) NOT NULL, - "contact_name" varchar(255) NOT NULL, - "contact_mobile" varchar(255), - "status" tinyint NOT NULL, - "creator" varchar(64) DEFAULT '', - "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar(64) DEFAULT '', - "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '租户'; - - -CREATE TABLE IF NOT EXISTS "pay_merchant" -( - "id" number NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "no" varchar(32) NOT NULL, - "name" varchar(64) NOT NULL, - "short_name" varchar(64) NOT NULL, - "status" tinyint NOT NULL, - "remark" varchar(255) DEFAULT NULL, - "creator" varchar(64) DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar(64) DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit(1) NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '支付商户信息'; - --- bpm 开头的 DB - -CREATE TABLE IF NOT EXISTS "pay_app" ( - "id" number NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar(64) NOT NULL, - "status" tinyint NOT NULL, - "remark" varchar(255) DEFAULT NULL, - `pay_notify_url` varchar(1024) NOT NULL, - `refund_notify_url` varchar(1024) NOT NULL, - `merchant_id` bigint(20) NOT NULL, - "creator" varchar(64) DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar(64) DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit(1) NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT = '支付应用信息'; - -CREATE TABLE IF NOT EXISTS "pay_channel" ( - "id" number NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "code" varchar(32) NOT NULL, - "status" tinyint(4) NOT NULL, - "remark" varchar(255) DEFAULT NULL, - "fee_rate" double NOT NULL DEFAULT 0, - "merchant_id" bigint(20) NOT NULL, - "app_id" bigint(20) NOT NULL, - "config" varchar(10240) NOT NULL, - "creator" varchar(64) NULL DEFAULT '', - "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar(64) NULL DEFAULT '', - "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - "deleted" bit(1) NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT = '支付渠道'; - -CREATE TABLE IF NOT EXISTS `pay_order` ( - "id" number NOT NULL GENERATED BY DEFAULT AS IDENTITY, - `merchant_id` bigint(20) NOT NULL, - `app_id` bigint(20) NOT NULL, - `channel_id` bigint(20) DEFAULT NULL, - `channel_code` varchar(32) DEFAULT NULL, - `merchant_order_id` varchar(64) NOT NULL, - `subject` varchar(32) NOT NULL, - `body` varchar(128) NOT NULL, - `notify_url` varchar(1024) NOT NULL, - `notify_status` tinyint(4) NOT NULL, - `amount` bigint(20) NOT NULL, - `channel_fee_rate` double DEFAULT 0, - `channel_fee_amount` bigint(20) DEFAULT 0, - `status` tinyint(4) NOT NULL, - `user_ip` varchar(50) NOT NULL, - `expire_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP, - `success_time` datetime(0) DEFAULT CURRENT_TIMESTAMP, - `notify_time` datetime(0) DEFAULT CURRENT_TIMESTAMP, - `success_extension_id` bigint(20) DEFAULT NULL COMMENT '支付成功的订单拓展单编号', - `refund_status` tinyint(4) NOT NULL, - `refund_times` tinyint(4) NOT NULL, - `refund_amount` bigint(20) NOT NULL, - `channel_user_id` varchar(255) DEFAULT NULL, - `channel_order_no` varchar(64) DEFAULT NULL, - `creator` varchar(64) DEFAULT '', - `create_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updater` varchar(64) DEFAULT '', - `update_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `deleted` bit(1) NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT = '支付订单'; - -CREATE TABLE IF NOT EXISTS `pay_refund` ( - "id" number NOT NULL GENERATED BY DEFAULT AS IDENTITY, - `merchant_id` bigint(20) NOT NULL, - `app_id` bigint(20) NOT NULL, - `channel_id` bigint(20) NOT NULL, - `channel_code` varchar(32) NOT NULL, - `order_id` bigint(20) NOT NULL, - `trade_no` varchar(64) NOT NULL, - `merchant_order_id` varchar(64) NOT NULL, - `merchant_refund_no` varchar(64) NOT NULL, - `notify_url` varchar(1024) NOT NULL, - `notify_status` tinyint(4) NOT NULL, - `status` tinyint(4) NOT NULL, - `type` tinyint(4) NOT NULL, - `pay_amount` bigint(20) NOT NULL, - `refund_amount` bigint(20) NOT NULL, - `reason` varchar(256) NOT NULL, - `user_ip` varchar(50) NULL DEFAULT NULL, - `channel_order_no` varchar(64) NOT NULL, - `channel_refund_no` varchar(64) NULL DEFAULT NULL, - `channel_error_code` varchar(128) NULL DEFAULT NULL, - `channel_error_msg` varchar(256) NULL DEFAULT NULL, - `channel_extras` varchar(1024) NULL DEFAULT NULL, - `expire_time` datetime(0) NULL DEFAULT NULL, - `success_time` datetime(0) NULL DEFAULT NULL, - `notify_time` datetime(0) NULL DEFAULT NULL, - `creator` varchar(64) NULL DEFAULT '', - `create_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updater` varchar(64) NULL DEFAULT '', - `update_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `deleted` bit(1) NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT = '退款订单'; - -- bpm 开头的 DB CREATE TABLE IF NOT EXISTS "bpm_form" ( @@ -608,17 +14,3 @@ CREATE TABLE IF NOT EXISTS "bpm_form" ( "deleted" bit NOT NULL DEFAULT FALSE, PRIMARY KEY ("id") ) COMMENT '动态表单'; - -CREATE TABLE IF NOT EXISTS "bpm_user_group" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar(63) NOT NULL, - "description" varchar(255) NOT NULL, - "status" tinyint NOT NULL, - "member_user_ids" varchar(255) NOT NULL, - "creator" varchar(64) DEFAULT '', - "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar(64) DEFAULT '', - "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") - ) COMMENT '用户组'; diff --git a/yudao-module-bpm/yudao-module-bpm-core-service/pom.xml b/yudao-module-bpm/yudao-module-bpm-core-service/pom.xml index b61a9db27..aa81886db 100644 --- a/yudao-module-bpm/yudao-module-bpm-core-service/pom.xml +++ b/yudao-module-bpm/yudao-module-bpm-core-service/pom.xml @@ -8,7 +8,11 @@ ${revision} 4.0.0 - + pom + + yudao-module-bpm-core-service-api + yudao-module-bpm-core-service-impl + yudao-module-bpm-core-service diff --git a/yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-api/pom.xml b/yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-api/pom.xml new file mode 100644 index 000000000..fb5a4f08e --- /dev/null +++ b/yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-api/pom.xml @@ -0,0 +1,20 @@ + + + + yudao-module-bpm-core-service + cn.iocoder.boot + ${revision} + + 4.0.0 + + yudao-module-bpm-core-service-api + + + + org.projectlombok + lombok + + + \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-api/src/main/java/cn/iocoder/yudao/coreservice/modules/bpm/api/group/BpmUserGroupServiceApi.java b/yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-api/src/main/java/cn/iocoder/yudao/coreservice/modules/bpm/api/group/BpmUserGroupServiceApi.java new file mode 100644 index 000000000..c83486970 --- /dev/null +++ b/yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-api/src/main/java/cn/iocoder/yudao/coreservice/modules/bpm/api/group/BpmUserGroupServiceApi.java @@ -0,0 +1,32 @@ +package cn.iocoder.yudao.coreservice.modules.bpm.api.group; + +import cn.iocoder.yudao.coreservice.modules.bpm.api.group.dto.BpmUserGroupDTO; + +import java.util.Collection; +import java.util.List; +import java.util.Set; + +/** + * Bpm 用户组 API 接口 + * + * @author jason + */ +public interface BpmUserGroupServiceApi { + + /** + * 获得用户组列表 + * + * @param ids 编号 + * @return 用户组列表 + */ + List getUserGroupList(Collection ids); + + /** + * 校验用户组们是否有效。如下情况,视为无效: + * 1. 用户组编号不存在 + * 2. 用户组被禁用 + * + * @param ids 用户组编号数组 + */ + void validUserGroups(Set ids); +} diff --git a/yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-api/src/main/java/cn/iocoder/yudao/coreservice/modules/bpm/api/group/dto/BpmUserGroupDTO.java b/yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-api/src/main/java/cn/iocoder/yudao/coreservice/modules/bpm/api/group/dto/BpmUserGroupDTO.java new file mode 100644 index 000000000..b85042527 --- /dev/null +++ b/yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-api/src/main/java/cn/iocoder/yudao/coreservice/modules/bpm/api/group/dto/BpmUserGroupDTO.java @@ -0,0 +1,17 @@ +package cn.iocoder.yudao.coreservice.modules.bpm.api.group.dto; + +import lombok.Data; + +import java.util.Set; +/** + * Bpm 用户组 DTO + * + * @author jason + */ +@Data +public class BpmUserGroupDTO { + /** + * 成员用户编号数组 + */ + private Set memberUserIds; +} diff --git a/yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl/pom.xml b/yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl/pom.xml new file mode 100644 index 000000000..1712458f6 --- /dev/null +++ b/yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl/pom.xml @@ -0,0 +1,35 @@ + + + + yudao-module-bpm-core-service + cn.iocoder.boot + ${revision} + + 4.0.0 + + yudao-module-bpm-core-service-impl + + + cn.iocoder.boot + yudao-spring-boot-starter-web + + + cn.iocoder.boot + yudao-spring-boot-starter-security + + + cn.iocoder.boot + yudao-spring-boot-starter-mybatis + + + cn.iocoder.boot + yudao-module-bpm-core-service-api + + + cn.iocoder.boot + yudao-spring-boot-starter-test + + + \ No newline at end of file diff --git a/yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/api/BpmUserGroupServiceApiImpl.java b/yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/api/BpmUserGroupServiceApiImpl.java new file mode 100644 index 000000000..b789ba9e1 --- /dev/null +++ b/yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/api/BpmUserGroupServiceApiImpl.java @@ -0,0 +1,61 @@ +package cn.iocoder.yudao.adminserver.modules.bpm.api; + +import cn.hutool.core.collection.CollUtil; +import cn.iocoder.yudao.adminserver.modules.bpm.convert.definition.BpmUserGroupConvert; +import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.definition.BpmUserGroupDO; +import cn.iocoder.yudao.adminserver.modules.bpm.dal.mysql.definition.BpmUserGroupMapper; +import cn.iocoder.yudao.coreservice.modules.bpm.api.group.BpmUserGroupServiceApi; +import cn.iocoder.yudao.coreservice.modules.bpm.api.group.dto.BpmUserGroupDTO; +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; +import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil; +import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; +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; + +import static cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants.USER_GROUP_IS_DISABLE; +import static cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants.USER_GROUP_NOT_EXISTS; +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; + +/** + * Bpm 用户组 API 接口 实现类 + * + * @author jason + */ +@Service +public class BpmUserGroupServiceApiImpl implements BpmUserGroupServiceApi { + + @Resource + private BpmUserGroupMapper userGroupMapper; + + @Override + public List getUserGroupList(Collection ids) { + return BpmUserGroupConvert.INSTANCE.convertList3(userGroupMapper.selectBatchIds(ids)); + } + + + @Override + public void validUserGroups(Set ids) { + + if (CollUtil.isEmpty(ids)) { + return; + } + // 获得用户组信息 + List userGroups = userGroupMapper.selectBatchIds(ids); + Map userGroupMap = CollectionUtils.convertMap(userGroups, BpmUserGroupDO::getId); + // 校验 + ids.forEach(id -> { + BpmUserGroupDO userGroup = userGroupMap.get(id); + if (userGroup == null) { + throw ServiceExceptionUtil.exception(USER_GROUP_NOT_EXISTS); + } + if (!CommonStatusEnum.ENABLE.getStatus().equals(userGroup.getStatus())) { + throw exception(USER_GROUP_IS_DISABLE, userGroup.getName()); + } + }); + } +} diff --git a/yudao-module-bpm/yudao-module-bpm-activiti/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/BpmUserGroupController.java b/yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/BpmUserGroupController.java similarity index 100% rename from yudao-module-bpm/yudao-module-bpm-activiti/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/BpmUserGroupController.java rename to yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/BpmUserGroupController.java diff --git a/yudao-module-bpm/yudao-module-bpm-activiti/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/vo/group/BpmUserGroupBaseVO.java b/yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/vo/group/BpmUserGroupBaseVO.java similarity index 100% rename from yudao-module-bpm/yudao-module-bpm-activiti/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/vo/group/BpmUserGroupBaseVO.java rename to yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/vo/group/BpmUserGroupBaseVO.java diff --git a/yudao-module-bpm/yudao-module-bpm-activiti/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/vo/group/BpmUserGroupCreateReqVO.java b/yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/vo/group/BpmUserGroupCreateReqVO.java similarity index 100% rename from yudao-module-bpm/yudao-module-bpm-activiti/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/vo/group/BpmUserGroupCreateReqVO.java rename to yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/vo/group/BpmUserGroupCreateReqVO.java diff --git a/yudao-module-bpm/yudao-module-bpm-activiti/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/vo/group/BpmUserGroupPageReqVO.java b/yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/vo/group/BpmUserGroupPageReqVO.java similarity index 63% rename from yudao-module-bpm/yudao-module-bpm-activiti/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/vo/group/BpmUserGroupPageReqVO.java rename to yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/vo/group/BpmUserGroupPageReqVO.java index 6a4497afc..303a3491e 100644 --- a/yudao-module-bpm/yudao-module-bpm-activiti/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/vo/group/BpmUserGroupPageReqVO.java +++ b/yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/vo/group/BpmUserGroupPageReqVO.java @@ -1,12 +1,15 @@ package cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.group; -import lombok.*; -import java.util.*; -import io.swagger.annotations.*; import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.common.util.date.DateUtils; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; import org.springframework.format.annotation.DateTimeFormat; -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; +import java.util.Date; @ApiModel("用户组分页 Request VO") @Data @@ -20,11 +23,11 @@ public class BpmUserGroupPageReqVO extends PageParam { @ApiModelProperty(value = "状态", example = "1") private Integer status; - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + @DateTimeFormat(pattern = DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) @ApiModelProperty(value = "开始创建时间") private Date beginCreateTime; - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + @DateTimeFormat(pattern = DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) @ApiModelProperty(value = "结束创建时间") private Date endCreateTime; diff --git a/yudao-module-bpm/yudao-module-bpm-activiti/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/vo/group/BpmUserGroupRespVO.java b/yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/vo/group/BpmUserGroupRespVO.java similarity index 100% rename from yudao-module-bpm/yudao-module-bpm-activiti/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/vo/group/BpmUserGroupRespVO.java rename to yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/vo/group/BpmUserGroupRespVO.java diff --git a/yudao-module-bpm/yudao-module-bpm-activiti/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/vo/group/BpmUserGroupSimpleRespVO.java b/yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/vo/group/BpmUserGroupSimpleRespVO.java similarity index 100% rename from yudao-module-bpm/yudao-module-bpm-activiti/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/vo/group/BpmUserGroupSimpleRespVO.java rename to yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/vo/group/BpmUserGroupSimpleRespVO.java diff --git a/yudao-module-bpm/yudao-module-bpm-activiti/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/vo/group/BpmUserGroupUpdateReqVO.java b/yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/vo/group/BpmUserGroupUpdateReqVO.java similarity index 100% rename from yudao-module-bpm/yudao-module-bpm-activiti/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/vo/group/BpmUserGroupUpdateReqVO.java rename to yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/definition/vo/group/BpmUserGroupUpdateReqVO.java diff --git a/yudao-module-bpm/yudao-module-bpm-activiti/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/definition/BpmUserGroupConvert.java b/yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/definition/BpmUserGroupConvert.java similarity index 89% rename from yudao-module-bpm/yudao-module-bpm-activiti/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/definition/BpmUserGroupConvert.java rename to yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/definition/BpmUserGroupConvert.java index 4e7cd997f..7f7e9afc8 100644 --- a/yudao-module-bpm/yudao-module-bpm-activiti/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/definition/BpmUserGroupConvert.java +++ b/yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/definition/BpmUserGroupConvert.java @@ -6,6 +6,7 @@ import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.group.B import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.group.BpmUserGroupRespVO; import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.group.BpmUserGroupUpdateReqVO; import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.definition.BpmUserGroupDO; +import cn.iocoder.yudao.coreservice.modules.bpm.api.group.dto.BpmUserGroupDTO; import cn.iocoder.yudao.framework.common.pojo.PageResult; import org.mapstruct.Mapper; @@ -34,4 +35,6 @@ public interface BpmUserGroupConvert { @Named("convertList2") List convertList2(List list); + + List convertList3(List list); } diff --git a/yudao-module-bpm/yudao-module-bpm-activiti/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/dal/dataobject/definition/BpmUserGroupDO.java b/yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/dal/dataobject/definition/BpmUserGroupDO.java similarity index 100% rename from yudao-module-bpm/yudao-module-bpm-activiti/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/dal/dataobject/definition/BpmUserGroupDO.java rename to yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/dal/dataobject/definition/BpmUserGroupDO.java diff --git a/yudao-module-bpm/yudao-module-bpm-activiti/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/dal/mysql/definition/BpmUserGroupMapper.java b/yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/dal/mysql/definition/BpmUserGroupMapper.java similarity index 100% rename from yudao-module-bpm/yudao-module-bpm-activiti/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/dal/mysql/definition/BpmUserGroupMapper.java rename to yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/dal/mysql/definition/BpmUserGroupMapper.java diff --git a/yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/enums/BpmErrorCodeConstants.java b/yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/enums/BpmErrorCodeConstants.java new file mode 100644 index 000000000..5fd230cef --- /dev/null +++ b/yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/enums/BpmErrorCodeConstants.java @@ -0,0 +1,10 @@ +package cn.iocoder.yudao.adminserver.modules.bpm.enums; + +import cn.iocoder.yudao.framework.common.exception.ErrorCode; + +public interface BpmErrorCodeConstants { + // ========== 用户组模块 1-009-011-000 ========== + ErrorCode USER_GROUP_NOT_EXISTS = new ErrorCode(1009011000, "用户组不存在"); + ErrorCode USER_GROUP_IS_DISABLE = new ErrorCode(1009011001, "名字为【{}】的用户组已被禁用"); + +} diff --git a/yudao-module-bpm/yudao-module-bpm-activiti/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/BpmUserGroupService.java b/yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/BpmUserGroupService.java similarity index 79% rename from yudao-module-bpm/yudao-module-bpm-activiti/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/BpmUserGroupService.java rename to yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/BpmUserGroupService.java index f1fd4debe..5d848656b 100644 --- a/yudao-module-bpm/yudao-module-bpm-activiti/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/BpmUserGroupService.java +++ b/yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/BpmUserGroupService.java @@ -46,14 +46,6 @@ public interface BpmUserGroupService { */ BpmUserGroupDO getUserGroup(Long id); - /** - * 获得用户组列表 - * - * @param ids 编号 - * @return 用户组列表 - */ - List getUserGroupList(Collection ids); - /** * 获得指定状态的用户组列表 * @@ -69,14 +61,4 @@ public interface BpmUserGroupService { * @return 用户组分页 */ PageResult getUserGroupPage(BpmUserGroupPageReqVO pageReqVO); - - /** - * 校验用户组们是否有效。如下情况,视为无效: - * 1. 用户组编号不存在 - * 2. 用户组被禁用 - * - * @param ids 用户组编号数组 - */ - void validUserGroups(Set ids); - } diff --git a/yudao-module-bpm/yudao-module-bpm-activiti/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/impl/BpmUserGroupServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/impl/BpmUserGroupServiceImpl.java similarity index 76% rename from yudao-module-bpm/yudao-module-bpm-activiti/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/impl/BpmUserGroupServiceImpl.java rename to yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/impl/BpmUserGroupServiceImpl.java index 8a342b0a2..7de593cdf 100644 --- a/yudao-module-bpm/yudao-module-bpm-activiti/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/impl/BpmUserGroupServiceImpl.java +++ b/yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/impl/BpmUserGroupServiceImpl.java @@ -9,6 +9,7 @@ import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.definition.BpmUse import cn.iocoder.yudao.adminserver.modules.bpm.dal.mysql.definition.BpmUserGroupMapper; import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmUserGroupService; import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; +import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; import org.springframework.stereotype.Service; @@ -64,7 +65,7 @@ public class BpmUserGroupServiceImpl implements BpmUserGroupService { private void validateUserGroupExists(Long id) { if (userGroupMapper.selectById(id) == null) { - throw exception(USER_GROUP_NOT_EXISTS); + throw ServiceExceptionUtil.exception(USER_GROUP_NOT_EXISTS); } } @@ -73,10 +74,6 @@ public class BpmUserGroupServiceImpl implements BpmUserGroupService { return userGroupMapper.selectById(id); } - @Override - public List getUserGroupList(Collection ids) { - return userGroupMapper.selectBatchIds(ids); - } @Override public List getUserGroupListByStatus(Integer status) { @@ -88,24 +85,4 @@ public class BpmUserGroupServiceImpl implements BpmUserGroupService { return userGroupMapper.selectPage(pageReqVO); } - @Override - public void validUserGroups(Set ids) { - if (CollUtil.isEmpty(ids)) { - return; - } - // 获得用户组信息 - List userGroups = userGroupMapper.selectBatchIds(ids); - Map userGroupMap = CollectionUtils.convertMap(userGroups, BpmUserGroupDO::getId); - // 校验 - ids.forEach(id -> { - BpmUserGroupDO userGroup = userGroupMap.get(id); - if (userGroup == null) { - throw exception(USER_GROUP_NOT_EXISTS); - } - if (!CommonStatusEnum.ENABLE.getStatus().equals(userGroup.getStatus())) { - throw exception(USER_GROUP_IS_DISABLE, userGroup.getName()); - } - }); - } - } diff --git a/yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl/src/test/java/cn/iocoder/yudao/adminserver/BaseDbUnitTest.java b/yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl/src/test/java/cn/iocoder/yudao/adminserver/BaseDbUnitTest.java new file mode 100644 index 000000000..5f7daeded --- /dev/null +++ b/yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl/src/test/java/cn/iocoder/yudao/adminserver/BaseDbUnitTest.java @@ -0,0 +1,39 @@ +package cn.iocoder.yudao.adminserver; + +import cn.iocoder.yudao.framework.datasource.config.YudaoDataSourceAutoConfiguration; +import cn.iocoder.yudao.framework.mybatis.config.YudaoMybatisAutoConfiguration; +import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure; +import com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration; +import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; +import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.annotation.Import; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.jdbc.Sql; + +/** + * 依赖内存 DB 的单元测试 + * + * 注意,Service 层同样适用。对于 Service 层的单元测试,我们针对自己模块的 Mapper 走的是 H2 内存数据库,针对别的模块的 Service 走的是 Mock 方法 + * + * @author 芋道源码 + */ +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE, classes = BaseDbUnitTest.Application.class) +@ActiveProfiles("unit-test") // 设置使用 application-unit-test 配置文件 +@Sql(scripts = "/sql/clean.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD) // 每个单元测试结束后,清理 DB +public class BaseDbUnitTest { + + @Import({ + // DB 配置类 + YudaoDataSourceAutoConfiguration.class, // 自己的 DB 配置类 + DataSourceAutoConfiguration.class, // Spring DB 自动配置类 + DataSourceTransactionManagerAutoConfiguration.class, // Spring 事务自动配置类 + DruidDataSourceAutoConfigure.class, // Druid 自动配置类 + // MyBatis 配置类 + YudaoMybatisAutoConfiguration.class, // 自己的 MyBatis 配置类 + MybatisPlusAutoConfiguration.class, // MyBatis 的自动配置类 + }) + public static class Application { + } + +} diff --git a/yudao-module-bpm/yudao-module-bpm-activiti/src/test/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/BpmUserGroupServiceTest.java b/yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl/src/test/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/BpmUserGroupServiceTest.java similarity index 73% rename from yudao-module-bpm/yudao-module-bpm-activiti/src/test/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/BpmUserGroupServiceTest.java rename to yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl/src/test/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/BpmUserGroupServiceTest.java index a8704dd61..ff1683816 100644 --- a/yudao-module-bpm/yudao-module-bpm-activiti/src/test/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/BpmUserGroupServiceTest.java +++ b/yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl/src/test/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/BpmUserGroupServiceTest.java @@ -1,6 +1,5 @@ package cn.iocoder.yudao.adminserver.modules.bpm.service.definition; -import cn.hutool.core.date.DateUtil; import cn.iocoder.yudao.adminserver.BaseDbUnitTest; import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.group.BpmUserGroupCreateReqVO; import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.group.BpmUserGroupPageReqVO; @@ -11,6 +10,9 @@ import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.impl.BpmUserG import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.date.DateUtils; +import cn.iocoder.yudao.framework.test.core.util.AssertUtils; +import cn.iocoder.yudao.framework.test.core.util.RandomUtils; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.springframework.context.annotation.Import; @@ -18,11 +20,6 @@ import javax.annotation.Resource; import static cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants.USER_GROUP_NOT_EXISTS; import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static org.junit.jupiter.api.Assertions.*; /** * {@link BpmUserGroupServiceImpl} 的单元测试类 @@ -41,24 +38,24 @@ public class BpmUserGroupServiceTest extends BaseDbUnitTest { @Test public void testCreateUserGroup_success() { // 准备参数 - BpmUserGroupCreateReqVO reqVO = randomPojo(BpmUserGroupCreateReqVO.class); + BpmUserGroupCreateReqVO reqVO = RandomUtils.randomPojo(BpmUserGroupCreateReqVO.class); // 调用 Long userGroupId = userGroupService.createUserGroup(reqVO); // 断言 - assertNotNull(userGroupId); + Assertions.assertNotNull(userGroupId); // 校验记录的属性是否正确 BpmUserGroupDO userGroup = userGroupMapper.selectById(userGroupId); - assertPojoEquals(reqVO, userGroup); + AssertUtils.assertPojoEquals(reqVO, userGroup); } @Test public void testUpdateUserGroup_success() { // mock 数据 - BpmUserGroupDO dbUserGroup = randomPojo(BpmUserGroupDO.class); + BpmUserGroupDO dbUserGroup = RandomUtils.randomPojo(BpmUserGroupDO.class); userGroupMapper.insert(dbUserGroup);// @Sql: 先插入出一条存在的数据 // 准备参数 - BpmUserGroupUpdateReqVO reqVO = randomPojo(BpmUserGroupUpdateReqVO.class, o -> { + BpmUserGroupUpdateReqVO reqVO = RandomUtils.randomPojo(BpmUserGroupUpdateReqVO.class, o -> { o.setId(dbUserGroup.getId()); // 设置更新的 ID }); @@ -66,22 +63,22 @@ public class BpmUserGroupServiceTest extends BaseDbUnitTest { userGroupService.updateUserGroup(reqVO); // 校验是否更新正确 BpmUserGroupDO userGroup = userGroupMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, userGroup); + AssertUtils.assertPojoEquals(reqVO, userGroup); } @Test public void testUpdateUserGroup_notExists() { // 准备参数 - BpmUserGroupUpdateReqVO reqVO = randomPojo(BpmUserGroupUpdateReqVO.class); + BpmUserGroupUpdateReqVO reqVO = RandomUtils.randomPojo(BpmUserGroupUpdateReqVO.class); // 调用, 并断言异常 - assertServiceException(() -> userGroupService.updateUserGroup(reqVO), USER_GROUP_NOT_EXISTS); + AssertUtils.assertServiceException(() -> userGroupService.updateUserGroup(reqVO), USER_GROUP_NOT_EXISTS); } @Test public void testDeleteUserGroup_success() { // mock 数据 - BpmUserGroupDO dbUserGroup = randomPojo(BpmUserGroupDO.class); + BpmUserGroupDO dbUserGroup = RandomUtils.randomPojo(BpmUserGroupDO.class); userGroupMapper.insert(dbUserGroup);// @Sql: 先插入出一条存在的数据 // 准备参数 Long id = dbUserGroup.getId(); @@ -89,22 +86,22 @@ public class BpmUserGroupServiceTest extends BaseDbUnitTest { // 调用 userGroupService.deleteUserGroup(id); // 校验数据不存在了 - assertNull(userGroupMapper.selectById(id)); + Assertions.assertNull(userGroupMapper.selectById(id)); } @Test public void testDeleteUserGroup_notExists() { // 准备参数 - Long id = randomLongId(); + Long id = RandomUtils.randomLongId(); // 调用, 并断言异常 - assertServiceException(() -> userGroupService.deleteUserGroup(id), USER_GROUP_NOT_EXISTS); + AssertUtils.assertServiceException(() -> userGroupService.deleteUserGroup(id), USER_GROUP_NOT_EXISTS); } @Test public void testGetUserGroupPage() { // mock 数据 - BpmUserGroupDO dbUserGroup = randomPojo(BpmUserGroupDO.class, o -> { // 等会查询到 + BpmUserGroupDO dbUserGroup = RandomUtils.randomPojo(BpmUserGroupDO.class, o -> { // 等会查询到 o.setName("芋道源码"); o.setStatus(CommonStatusEnum.ENABLE.getStatus()); o.setCreateTime(DateUtils.buildTime(2021, 11, 11)); @@ -126,9 +123,9 @@ public class BpmUserGroupServiceTest extends BaseDbUnitTest { // 调用 PageResult pageResult = userGroupService.getUserGroupPage(reqVO); // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbUserGroup, pageResult.getList().get(0)); + Assertions.assertEquals(1, pageResult.getTotal()); + Assertions.assertEquals(1, pageResult.getList().size()); + AssertUtils.assertPojoEquals(dbUserGroup, pageResult.getList().get(0)); } } diff --git a/yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl/src/test/resources/application-unit-test.yaml b/yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl/src/test/resources/application-unit-test.yaml new file mode 100644 index 000000000..ddad7ace2 --- /dev/null +++ b/yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl/src/test/resources/application-unit-test.yaml @@ -0,0 +1,38 @@ +spring: + main: + lazy-initialization: true # 开启懒加载,加快速度 + banner-mode: off # 单元测试,禁用 Banner + +--- #################### 数据库相关配置 #################### + +spring: + # 数据源配置项 + datasource: + name: ruoyi-vue-pro + url: jdbc:h2:mem:testdb;MODE=MYSQL;DATABASE_TO_UPPER=false; # MODE 使用 MySQL 模式;DATABASE_TO_UPPER 配置表和字段使用小写 + driver-class-name: org.h2.Driver + username: sa + password: + schema: classpath:sql/create_tables.sql # MySQL 转 H2 的语句,使用 https://www.jooq.org/translate/ 工具 + druid: + async-init: true # 单元测试,异步初始化 Druid 连接池,提升启动速度 + initial-size: 1 # 单元测试,配置为 1,提升启动速度 + +mybatis: + lazy-initialization: true # 单元测试,设置 MyBatis Mapper 延迟加载,加速每个单元测试 + +--- #################### 定时任务相关配置 #################### + +--- #################### 配置中心相关配置 #################### + +--- #################### 服务保障相关配置 #################### + +# Lock4j 配置项(单元测试,禁用 Lock4j) + +# Resilience4j 配置项 + +--- #################### 监控相关配置 #################### + +--- #################### 芋道相关配置 #################### + +# 芋道配置项,设置当前项目所有自定义的配置 diff --git a/yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl/src/test/resources/application.yaml b/yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl/src/test/resources/application.yaml new file mode 100644 index 000000000..2cfbb1abe --- /dev/null +++ b/yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl/src/test/resources/application.yaml @@ -0,0 +1,35 @@ +spring: + application: + name: yudao-module-bpm-service + + # Jackson 配置项 + jackson: + serialization: + write-dates-as-timestamps: true # 设置 Date 的格式,使用时间戳 + write-date-timestamps-as-nanoseconds: false # 设置不使用 nanoseconds 的格式。例如说 1611460870.401,而是直接 1611460870401 + write-durations-as-timestamps: true # 设置 Duration 的格式,使用时间戳 + fail-on-empty-beans: false # 允许序列化无属性的 Bean + +# MyBatis Plus 的配置项 +mybatis-plus: + configuration: + map-underscore-to-camel-case: true # 虽然默认为 true ,但是还是显示去指定下。 + log-impl: org.apache.ibatis.logging.stdout.StdOutImpl # 打印日志 + global-config: + db-config: + id-type: AUTO # 自增 ID + logic-delete-value: 1 # 逻辑已删除值(默认为 1) + logic-not-delete-value: 0 # 逻辑未删除值(默认为 0) + mapper-locations: classpath*:mapper/*.xml + type-aliases-package: ${yudao.core-service.base-package}.modules.*.dal.dataobject + +--- #################### 芋道相关配置 #################### + +yudao: + info: + version: 1.0.0 + base-package: cn.iocoder.yudao.adminserver + core-service: + base-package: cn.iocoder.yudao.coreservice + +debug: false diff --git a/yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl/src/test/resources/logback-spring.xml b/yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl/src/test/resources/logback-spring.xml new file mode 100644 index 000000000..daf756bff --- /dev/null +++ b/yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl/src/test/resources/logback-spring.xml @@ -0,0 +1,4 @@ + + + + diff --git a/yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl/src/test/resources/sql/clean.sql b/yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl/src/test/resources/sql/clean.sql new file mode 100644 index 000000000..45b43e0e8 --- /dev/null +++ b/yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl/src/test/resources/sql/clean.sql @@ -0,0 +1,2 @@ +-- bpm 开头的 DB +DELETE FROM "bpm_user_group"; diff --git a/yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl/src/test/resources/sql/create_tables.sql b/yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl/src/test/resources/sql/create_tables.sql new file mode 100644 index 000000000..da5b9a613 --- /dev/null +++ b/yudao-module-bpm/yudao-module-bpm-core-service/yudao-module-bpm-core-service-impl/src/test/resources/sql/create_tables.sql @@ -0,0 +1,14 @@ +-- bpm 开头的 DB +CREATE TABLE IF NOT EXISTS "bpm_user_group" ( + "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, + "name" varchar(63) NOT NULL, + "description" varchar(255) NOT NULL, + "status" tinyint NOT NULL, + "member_user_ids" varchar(255) NOT NULL, + "creator" varchar(64) DEFAULT '', + "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updater" varchar(64) DEFAULT '', + "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + "deleted" bit NOT NULL DEFAULT FALSE, + PRIMARY KEY ("id") + ) COMMENT '用户组';