From c9b9eced071f53beda1754371b6d489e40e3151c Mon Sep 17 00:00:00 2001 From: YunaiV Date: Mon, 17 Jan 2022 12:53:43 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=81=E7=A8=8B=E8=AF=A6=E6=83=85=E9=A1=B5?= =?UTF-8?q?=2090%=20-=20=E6=8E=A5=E5=85=A5=E5=AE=A1=E6=89=B9=E9=80=9A?= =?UTF-8?q?=E8=BF=87=E3=80=81=E5=AE=A1=E6=89=B9=E4=B8=8D=E9=80=9A=E8=BF=87?= =?UTF-8?q?=E7=9A=84=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bpm/controller/task/BpmTaskController.java | 4 ++-- .../modules/bpm/enums/BpmErrorCodeConstants.java | 1 + .../modules/bpm/service/task/BpmTaskService.java | 7 ++++--- .../bpm/service/task/impl/BpmTaskServiceImpl.java | 11 +++++++++-- .../auth/vo/auth/SysAuthPermissionInfoRespVO.java | 3 +++ .../modules/system/convert/auth/SysAuthConvert.java | 2 +- yudao-admin-ui/src/store/getters.js | 1 + yudao-admin-ui/src/store/modules/user.js | 5 +++++ .../src/views/bpm/processInstance/detail.vue | 8 ++++++-- .../src/views/bpm/processInstance/index.vue | 5 +++++ yudao-admin-ui/src/views/bpm/task/done.vue | 8 ++++++-- .../framework/activiti/core/util/ActivitiUtils.java | 6 ++++++ 12 files changed, 49 insertions(+), 12 deletions(-) diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/BpmTaskController.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/BpmTaskController.java index 67fc48b60..324fda596 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/BpmTaskController.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/BpmTaskController.java @@ -46,14 +46,14 @@ public class BpmTaskController { @PutMapping("/approve") @ApiOperation("通过任务") public CommonResult approveTask(@Valid @RequestBody BpmTaskApproveReqVO reqVO) { - taskService.approveTask(reqVO); + taskService.approveTask(getLoginUserId(), reqVO); return success(true); } @PutMapping("/reject") @ApiOperation("不通过任务") public CommonResult rejectTask(@Valid @RequestBody BpmTaskRejectReqVO reqVO) { - taskService.rejectTask(reqVO); + taskService.rejectTask(getLoginUserId(), reqVO); return success(true); } diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/enums/BpmErrorCodeConstants.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/enums/BpmErrorCodeConstants.java index 62b924517..ec2cafa7e 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/enums/BpmErrorCodeConstants.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/enums/BpmErrorCodeConstants.java @@ -42,6 +42,7 @@ public interface BpmErrorCodeConstants { // ========== 流程任务 1-009-005-000 ========== ErrorCode TASK_COMPLETE_FAIL_NOT_EXISTS = new ErrorCode(1009004000, "审批任务失败,原因:该任务不处于未审批"); + ErrorCode TASK_COMPLETE_FAIL_ASSIGN_NOT_SELF = new ErrorCode(1009004001, "审批任务失败,原因:该任务的审批人不是你"); // ========== 流程任务分配规则 1-009-006-000 ========== ErrorCode TASK_ASSIGN_RULE_EXISTS = new ErrorCode(1009006000, "流程({}) 的任务({}) 已经存在分配规则"); diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/BpmTaskService.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/BpmTaskService.java index 99df5dde7..971e4c510 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/BpmTaskService.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/BpmTaskService.java @@ -21,7 +21,6 @@ public interface BpmTaskService { * 获得指定流程实例的 Running 进行中的流程任务列表 * * @param processInstanceId 流程实例的编号 - * @return 流程任务列表 */ List getRunningTaskListByProcessInstanceId(String processInstanceId); @@ -81,16 +80,18 @@ public interface BpmTaskService { /** * 通过任务 * + * @param userId 用户编号 * @param reqVO 通过请求 */ - void approveTask(@Valid BpmTaskApproveReqVO reqVO); + void approveTask(Long userId, @Valid BpmTaskApproveReqVO reqVO); /** * 不通过任务 * + * @param userId 用户编号 * @param reqVO 不通过请求 */ - void rejectTask(@Valid BpmTaskRejectReqVO reqVO); + void rejectTask(Long userId, @Valid BpmTaskRejectReqVO reqVO); /** * 返回高亮的流转进程 diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/impl/BpmTaskServiceImpl.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/impl/BpmTaskServiceImpl.java index b988e2554..933b43c3f 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/impl/BpmTaskServiceImpl.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/impl/BpmTaskServiceImpl.java @@ -14,6 +14,7 @@ import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.dept.SysDeptDO import cn.iocoder.yudao.adminserver.modules.system.service.dept.SysDeptService; import cn.iocoder.yudao.adminserver.modules.system.service.user.SysUserService; import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.user.SysUserDO; +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.number.NumberUtils; @@ -200,12 +201,15 @@ public class BpmTaskServiceImpl implements BpmTaskService { @Override @Transactional(rollbackFor = Exception.class) - public void approveTask(BpmTaskApproveReqVO reqVO) { + public void approveTask(Long userId, BpmTaskApproveReqVO reqVO) { // 校验任务存在 Task task = getTask(reqVO.getId()); if (task == null) { throw exception(TASK_COMPLETE_FAIL_NOT_EXISTS); } + if (!ActivitiUtils.equals(task.getAssignee(), userId)) { + throw exception(TASK_COMPLETE_FAIL_ASSIGN_NOT_SELF); + } // 校验流程实例存在 ProcessInstance instance = processInstanceService.getProcessInstance(task.getProcessInstanceId()); if (instance == null) { @@ -224,12 +228,15 @@ public class BpmTaskServiceImpl implements BpmTaskService { @Override @Transactional(rollbackFor = Exception.class) - public void rejectTask(@Valid BpmTaskRejectReqVO reqVO) { + public void rejectTask(Long userId, @Valid BpmTaskRejectReqVO reqVO) { // 校验任务存在 Task task = getTask(reqVO.getId()); if (task == null) { throw exception(TASK_COMPLETE_FAIL_NOT_EXISTS); } + if (!ActivitiUtils.equals(task.getAssignee(), userId)) { + throw exception(TASK_COMPLETE_FAIL_ASSIGN_NOT_SELF); + } // 校验流程实例存在 ProcessInstance instance = processInstanceService.getProcessInstance(task.getProcessInstanceId()); if (instance == null) { diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/controller/auth/vo/auth/SysAuthPermissionInfoRespVO.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/controller/auth/vo/auth/SysAuthPermissionInfoRespVO.java index 39cc9679c..c3bd0923b 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/controller/auth/vo/auth/SysAuthPermissionInfoRespVO.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/controller/auth/vo/auth/SysAuthPermissionInfoRespVO.java @@ -32,6 +32,9 @@ public class SysAuthPermissionInfoRespVO { @Builder public static class UserVO { + @ApiModelProperty(value = "用户编号", required = true, example = "1024") + private Long id; + @ApiModelProperty(value = "用户昵称", required = true, example = "芋道源码") private String nickname; diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/convert/auth/SysAuthConvert.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/convert/auth/SysAuthConvert.java index 80b7d2bd4..dfe3ac3ea 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/convert/auth/SysAuthConvert.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/convert/auth/SysAuthConvert.java @@ -31,7 +31,7 @@ public interface SysAuthConvert { default SysAuthPermissionInfoRespVO convert(SysUserDO user, List roleList, List menuList) { return SysAuthPermissionInfoRespVO.builder() - .user(SysAuthPermissionInfoRespVO.UserVO.builder().nickname(user.getNickname()).avatar(user.getAvatar()).build()) + .user(SysAuthPermissionInfoRespVO.UserVO.builder().id(user.getId()).nickname(user.getNickname()).avatar(user.getAvatar()).build()) .roles(CollectionUtils.convertSet(roleList, SysRoleDO::getCode)) .permissions(CollectionUtils.convertSet(menuList, SysMenuDO::getPermission)) .build(); diff --git a/yudao-admin-ui/src/store/getters.js b/yudao-admin-ui/src/store/getters.js index 4d17d51ad..3c4cd46d1 100644 --- a/yudao-admin-ui/src/store/getters.js +++ b/yudao-admin-ui/src/store/getters.js @@ -4,6 +4,7 @@ const getters = { device: state => state.app.device, visitedViews: state => state.tagsView.visitedViews, cachedViews: state => state.tagsView.cachedViews, + userId: state => state.user.id, token: state => state.user.token, avatar: state => state.user.avatar, name: state => state.user.name, diff --git a/yudao-admin-ui/src/store/modules/user.js b/yudao-admin-ui/src/store/modules/user.js index e9c4286af..57472374e 100644 --- a/yudao-admin-ui/src/store/modules/user.js +++ b/yudao-admin-ui/src/store/modules/user.js @@ -4,6 +4,7 @@ import { getToken, setToken, removeToken } from '@/utils/auth' const user = { state: { token: getToken(), + id: 0, // 用户编号 name: '', avatar: '', roles: [], @@ -11,6 +12,9 @@ const user = { }, mutations: { + SET_ID: (state, id) => { + state.id = id + }, SET_TOKEN: (state, token) => { state.token = token }, @@ -96,6 +100,7 @@ const user = { } else { commit('SET_ROLES', ['ROLE_DEFAULT']) } + commit('SET_ID', user.id) commit('SET_NAME', user.userName) commit('SET_AVATAR', avatar) resolve(res) diff --git a/yudao-admin-ui/src/views/bpm/processInstance/detail.vue b/yudao-admin-ui/src/views/bpm/processInstance/detail.vue index bdc19df09..9b2ac8277 100644 --- a/yudao-admin-ui/src/views/bpm/processInstance/detail.vue +++ b/yudao-admin-ui/src/views/bpm/processInstance/detail.vue @@ -21,7 +21,7 @@
通过 不通过 - + 委派 退回
@@ -81,7 +81,7 @@ diff --git a/yudao-admin-ui/src/views/bpm/task/done.vue b/yudao-admin-ui/src/views/bpm/task/done.vue index 09c1b6942..25ccca82f 100644 --- a/yudao-admin-ui/src/views/bpm/task/done.vue +++ b/yudao-admin-ui/src/views/bpm/task/done.vue @@ -60,7 +60,7 @@ @@ -127,7 +127,11 @@ export default { }, getDateStar(ms) { return getDate(ms); - } + }, + /** 处理审批按钮 */ + handleAudit(row) { + this.$router.push({ path: "/bpm/process-instance/detail", query: { id: row.processInstance.id}}); + }, } }; diff --git a/yudao-framework/yudao-spring-boot-starter-activiti/src/main/java/cn/iocoder/yudao/framework/activiti/core/util/ActivitiUtils.java b/yudao-framework/yudao-spring-boot-starter-activiti/src/main/java/cn/iocoder/yudao/framework/activiti/core/util/ActivitiUtils.java index f2b508ae2..eb051c0a0 100644 --- a/yudao-framework/yudao-spring-boot-starter-activiti/src/main/java/cn/iocoder/yudao/framework/activiti/core/util/ActivitiUtils.java +++ b/yudao-framework/yudao-spring-boot-starter-activiti/src/main/java/cn/iocoder/yudao/framework/activiti/core/util/ActivitiUtils.java @@ -2,6 +2,7 @@ package cn.iocoder.yudao.framework.activiti.core.util; import cn.hutool.core.util.ReflectUtil; import cn.hutool.core.util.StrUtil; +import cn.iocoder.yudao.framework.common.util.number.NumberUtils; import com.alibaba.ttl.TransmittableThreadLocal; import org.activiti.bpmn.converter.BpmnXMLConverter; import org.activiti.bpmn.model.BpmnModel; @@ -13,6 +14,7 @@ import org.activiti.engine.impl.util.io.BytesStreamSource; import javax.xml.bind.Element; import java.util.ArrayList; import java.util.List; +import java.util.Objects; import java.util.function.Consumer; /** @@ -45,6 +47,10 @@ public class ActivitiUtils { Authentication.setAuthenticatedUserId(null); } + public static boolean equals(String userIdStr, Long userId) { + return Objects.equals(userId, NumberUtils.parseLong(userIdStr)); + } + // ========== BPMN XML 相关 ========== /**