From ed87b45dffe83608e68479bdb95749e76cd40dce Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sun, 14 Jun 2026 01:26:41 +0800 Subject: [PATCH] =?UTF-8?q?fix(rpc):=20=E7=BB=9F=E4=B8=80=20RPC=20API=20?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=20CommonResult?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将 ConfigApi、DeptApi、AdminUserApi 的 RPC 方法返回值改为 CommonResult - 调整对应 ApiImpl 使用 success 包装响应 - 更新调用方显式 getCheckedData/checkError 处理 RPC 返回 - 补充相关单测 mock 的 CommonResult 包装 --- .../UserProfileQueryToolFunction.java | 2 +- .../task/BpmProcessInstanceController.java | 8 ++-- .../BpmTaskAssignLeaderExpression.java | 6 +-- ...actBpmTaskCandidateDeptLeaderStrategy.java | 10 ++--- ...mTaskCandidateDeptLeaderMultiStrategy.java | 2 +- .../BpmTaskCandidateDeptLeaderStrategy.java | 4 +- .../BpmTaskCandidateDeptMemberStrategy.java | 4 +- .../user/BpmTaskCandidatePostStrategy.java | 2 +- .../user/BpmTaskCandidateUserStrategy.java | 2 +- .../BpmProcessDefinitionServiceImpl.java | 2 +- .../task/BpmProcessInstanceServiceImpl.java | 4 +- .../bpm/service/task/BpmTaskServiceImpl.java | 30 +++++++-------- .../BpmTaskAssignLeaderExpressionTest.java | 17 +++++---- ...kCandidateDeptLeaderMultiStrategyTest.java | 7 ++-- ...pmTaskCandidateDeptLeaderStrategyTest.java | 5 ++- ...pmTaskCandidateDeptMemberStrategyTest.java | 5 ++- ...eStartUserDeptLeaderMultiStrategyTest.java | 9 +++-- ...didateStartUserDeptLeaderStrategyTest.java | 9 +++-- .../BpmTaskCandidatePostStrategyTest.java | 3 +- .../business/CrmBusinessStatusController.java | 2 +- .../core/SysAdminUserParseFunction.java | 2 +- .../operatelog/core/SysDeptParseFunction.java | 2 +- .../core/aop/CrmPermissionAspect.java | 2 +- .../crm/service/clue/CrmClueServiceImpl.java | 2 +- .../CrmCustomerLimitConfigServiceImpl.java | 6 +-- .../customer/CrmCustomerServiceImpl.java | 4 +- .../permission/CrmPermissionServiceImpl.java | 8 ++-- .../product/CrmProductServiceImpl.java | 2 +- .../CrmStatisticsCustomerServiceImpl.java | 4 +- .../CrmStatisticsFunnelServiceImpl.java | 4 +- .../CrmStatisticsPerformanceServiceImpl.java | 4 +- .../CrmStatisticsPortraitServiceImpl.java | 4 +- .../CrmStatisticsRankServiceImpl.java | 4 +- .../module/crm/util/CrmPermissionUtils.java | 2 +- .../admin/group/ImGroupMemberController.java | 2 +- .../friend/ImFriendRequestServiceImpl.java | 4 +- .../group/ImGroupRequestServiceImpl.java | 2 +- .../im/service/rtc/ImRtcCallServiceImpl.java | 10 ++--- .../ImFriendRequestServiceImplTest.java | 7 ++-- .../group/ImGroupRequestServiceImplTest.java | 5 ++- .../module/infra/api/config/ConfigApi.java | 3 +- .../infra/api/config/ConfigApiImpl.java | 7 +++- .../alert/IotAlertConfigServiceImpl.java | 4 +- .../service/kefu/KeFuMessageServiceImpl.java | 2 +- .../DeliveryPickUpStoreController.java | 2 +- .../DeliveryPickUpStoreServiceImpl.java | 2 +- .../MesProWorkRecordController.java | 2 +- .../cal/team/MesCalTeamMemberServiceImpl.java | 2 +- .../yudao/module/system/api/dept/DeptApi.java | 12 +++--- .../module/system/api/user/AdminUserApi.java | 23 ++++++------ .../module/system/api/dept/DeptApiImpl.java | 18 +++++---- .../system/api/user/AdminUserApiImpl.java | 37 ++++++++++--------- .../service/user/AdminUserServiceImpl.java | 4 +- .../user/AdminUserServiceImplTest.java | 3 +- 54 files changed, 178 insertions(+), 156 deletions(-) diff --git a/yudao-module-ai/yudao-module-ai-server/src/main/java/cn/iocoder/yudao/module/ai/tool/function/UserProfileQueryToolFunction.java b/yudao-module-ai/yudao-module-ai-server/src/main/java/cn/iocoder/yudao/module/ai/tool/function/UserProfileQueryToolFunction.java index a4e00d644..06a2641da 100644 --- a/yudao-module-ai/yudao-module-ai-server/src/main/java/cn/iocoder/yudao/module/ai/tool/function/UserProfileQueryToolFunction.java +++ b/yudao-module-ai/yudao-module-ai-server/src/main/java/cn/iocoder/yudao/module/ai/tool/function/UserProfileQueryToolFunction.java @@ -84,7 +84,7 @@ public class UserProfileQueryToolFunction request.setId(loginUser.getId()); } return TenantUtils.execute(tenantId, () -> { - AdminUserRespDTO user = adminUserApi.getUser(request.getId()); + AdminUserRespDTO user = adminUserApi.getUser(request.getId()).getCheckedData(); return BeanUtils.toBean(user, Response.class); }); } diff --git a/yudao-module-bpm/yudao-module-bpm-server/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmProcessInstanceController.java b/yudao-module-bpm/yudao-module-bpm-server/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmProcessInstanceController.java index 09df9b7e6..bf293c314 100644 --- a/yudao-module-bpm/yudao-module-bpm-server/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmProcessInstanceController.java +++ b/yudao-module-bpm/yudao-module-bpm-server/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmProcessInstanceController.java @@ -143,10 +143,10 @@ public class BpmProcessInstanceController { processInstance.getProcessDefinitionId()); BpmProcessDefinitionInfoDO processDefinitionInfo = processDefinitionService.getProcessDefinitionInfo( processInstance.getProcessDefinitionId()); - AdminUserRespDTO startUser = adminUserApi.getUser(NumberUtils.parseLong(processInstance.getStartUserId())); + AdminUserRespDTO startUser = adminUserApi.getUser(NumberUtils.parseLong(processInstance.getStartUserId())).getCheckedData(); DeptRespDTO dept = null; if (startUser != null && startUser.getDeptId() != null) { - dept = deptApi.getDept(startUser.getDeptId()); + dept = deptApi.getDept(startUser.getDeptId()).getCheckedData(); } return success(BpmProcessInstanceConvert.INSTANCE.buildProcessInstance(processInstance, processDefinition, processDefinitionInfo, startUser, dept)); @@ -211,8 +211,8 @@ public class BpmProcessInstanceController { if (historicProcessInstance == null) { throw exception(PROCESS_INSTANCE_NOT_EXISTS); } - AdminUserRespDTO startUser = adminUserApi.getUser(Long.valueOf(historicProcessInstance.getStartUserId())); - DeptRespDTO dept = deptApi.getDept(startUser.getDeptId()); + AdminUserRespDTO startUser = adminUserApi.getUser(Long.valueOf(historicProcessInstance.getStartUserId())).getCheckedData(); + DeptRespDTO dept = deptApi.getDept(startUser.getDeptId()).getCheckedData(); List tasks = taskService.getFinishedTaskListByProcessInstanceIdWithoutCancel(processInstanceId); Map userMap = adminUserApi.getUserMap( convertSet(tasks, item -> Long.valueOf(item.getAssignee()))); diff --git a/yudao-module-bpm/yudao-module-bpm-server/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/expression/BpmTaskAssignLeaderExpression.java b/yudao-module-bpm/yudao-module-bpm-server/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/expression/BpmTaskAssignLeaderExpression.java index e9180c869..68593bb4c 100644 --- a/yudao-module-bpm/yudao-module-bpm-server/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/expression/BpmTaskAssignLeaderExpression.java +++ b/yudao-module-bpm/yudao-module-bpm-server/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/expression/BpmTaskAssignLeaderExpression.java @@ -57,7 +57,7 @@ public class BpmTaskAssignLeaderExpression { return emptySet(); } } else { - DeptRespDTO parentDept = deptApi.getDept(dept.getParentId()); + DeptRespDTO parentDept = deptApi.getDept(dept.getParentId()).getCheckedData(); if (parentDept == null) { // 找不到父级部门,所以只好结束寻找。原因是:例如说,级别比较高的人,所在部门层级比较少 break; } @@ -68,11 +68,11 @@ public class BpmTaskAssignLeaderExpression { } private DeptRespDTO getStartUserDept(Long startUserId) { - AdminUserRespDTO startUser = adminUserApi.getUser(startUserId); + AdminUserRespDTO startUser = adminUserApi.getUser(startUserId).getCheckedData(); if (startUser.getDeptId() == null) { // 找不到部门,所以无法使用该规则 return null; } - return deptApi.getDept(startUser.getDeptId()); + return deptApi.getDept(startUser.getDeptId()).getCheckedData(); } } diff --git a/yudao-module-bpm/yudao-module-bpm-server/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/dept/AbstractBpmTaskCandidateDeptLeaderStrategy.java b/yudao-module-bpm/yudao-module-bpm-server/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/dept/AbstractBpmTaskCandidateDeptLeaderStrategy.java index 1a2b067c0..5cd249252 100644 --- a/yudao-module-bpm/yudao-module-bpm-server/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/dept/AbstractBpmTaskCandidateDeptLeaderStrategy.java +++ b/yudao-module-bpm/yudao-module-bpm-server/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/dept/AbstractBpmTaskCandidateDeptLeaderStrategy.java @@ -40,7 +40,7 @@ public abstract class AbstractBpmTaskCandidateDeptLeaderStrategy implements BpmT } DeptRespDTO currentDept = dept; for (int i = 1; i < level; i++) { - DeptRespDTO parentDept = deptApi.getDept(currentDept.getParentId()); + DeptRespDTO parentDept = deptApi.getDept(currentDept.getParentId()).getCheckedData(); if (parentDept == null) { // 找不到父级部门,到了最高级。返回最高级的部门负责人 break; } @@ -63,12 +63,12 @@ public abstract class AbstractBpmTaskCandidateDeptLeaderStrategy implements BpmT } Set deptLeaderIds = new LinkedHashSet<>(); // 保证有序 for (Long deptId : deptIds) { - DeptRespDTO dept = deptApi.getDept(deptId); + DeptRespDTO dept = deptApi.getDept(deptId).getCheckedData(); for (int i = 0; i < level; i++) { if (dept.getLeaderUserId() != null) { deptLeaderIds.add(dept.getLeaderUserId()); } - DeptRespDTO parentDept = deptApi.getDept(dept.getParentId()); + DeptRespDTO parentDept = deptApi.getDept(dept.getParentId()).getCheckedData(); if (parentDept == null) { // 找不到父级部门. 已经到了最高层级了 break; } @@ -84,11 +84,11 @@ public abstract class AbstractBpmTaskCandidateDeptLeaderStrategy implements BpmT * @param startUserId 发起人 Id */ protected DeptRespDTO getStartUserDept(Long startUserId) { - AdminUserRespDTO startUser = adminUserApi.getUser(startUserId); + AdminUserRespDTO startUser = adminUserApi.getUser(startUserId).getCheckedData(); if (startUser.getDeptId() == null) { // 找不到部门 return null; } - return deptApi.getDept(startUser.getDeptId()); + return deptApi.getDept(startUser.getDeptId()).getCheckedData(); } } diff --git a/yudao-module-bpm/yudao-module-bpm-server/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/dept/BpmTaskCandidateDeptLeaderMultiStrategy.java b/yudao-module-bpm/yudao-module-bpm-server/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/dept/BpmTaskCandidateDeptLeaderMultiStrategy.java index ce8b2accb..61767ff89 100644 --- a/yudao-module-bpm/yudao-module-bpm-server/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/dept/BpmTaskCandidateDeptLeaderMultiStrategy.java +++ b/yudao-module-bpm/yudao-module-bpm-server/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/dept/BpmTaskCandidateDeptLeaderMultiStrategy.java @@ -30,7 +30,7 @@ public class BpmTaskCandidateDeptLeaderMultiStrategy extends AbstractBpmTaskCand List deptIds = StrUtils.splitToLong(params[0], ","); int level = Integer.parseInt(params[1]); // 校验部门存在 - deptApi.validateDeptList(deptIds); + deptApi.validateDeptList(deptIds).checkError(); Assert.isTrue(level > 0, "部门层级必须大于 0"); } diff --git a/yudao-module-bpm/yudao-module-bpm-server/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/dept/BpmTaskCandidateDeptLeaderStrategy.java b/yudao-module-bpm/yudao-module-bpm-server/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/dept/BpmTaskCandidateDeptLeaderStrategy.java index 336f97b7f..f5d4a6a26 100644 --- a/yudao-module-bpm/yudao-module-bpm-server/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/dept/BpmTaskCandidateDeptLeaderStrategy.java +++ b/yudao-module-bpm/yudao-module-bpm-server/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/dept/BpmTaskCandidateDeptLeaderStrategy.java @@ -32,13 +32,13 @@ public class BpmTaskCandidateDeptLeaderStrategy implements BpmTaskCandidateStrat @Override public void validateParam(String param) { Set deptIds = StrUtils.splitToLongSet(param); - deptApi.validateDeptList(deptIds); + deptApi.validateDeptList(deptIds).checkError(); } @Override public Set calculateUsers(String param) { Set deptIds = StrUtils.splitToLongSet(param); - List depts = deptApi.getDeptList(deptIds); + List depts = deptApi.getDeptList(deptIds).getCheckedData(); return convertSet(depts, DeptRespDTO::getLeaderUserId); } diff --git a/yudao-module-bpm/yudao-module-bpm-server/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/dept/BpmTaskCandidateDeptMemberStrategy.java b/yudao-module-bpm/yudao-module-bpm-server/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/dept/BpmTaskCandidateDeptMemberStrategy.java index 703ec7d5e..aa1059933 100644 --- a/yudao-module-bpm/yudao-module-bpm-server/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/dept/BpmTaskCandidateDeptMemberStrategy.java +++ b/yudao-module-bpm/yudao-module-bpm-server/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/dept/BpmTaskCandidateDeptMemberStrategy.java @@ -35,13 +35,13 @@ public class BpmTaskCandidateDeptMemberStrategy implements BpmTaskCandidateStrat @Override public void validateParam(String param) { Set deptIds = StrUtils.splitToLongSet(param); - deptApi.validateDeptList(deptIds); + deptApi.validateDeptList(deptIds).checkError(); } @Override public Set calculateUsers(String param) { Set deptIds = StrUtils.splitToLongSet(param); - List users = adminUserApi.getUserListByDeptIds(deptIds); + List users = adminUserApi.getUserListByDeptIds(deptIds).getCheckedData(); return convertSet(users, AdminUserRespDTO::getId); } diff --git a/yudao-module-bpm/yudao-module-bpm-server/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/user/BpmTaskCandidatePostStrategy.java b/yudao-module-bpm/yudao-module-bpm-server/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/user/BpmTaskCandidatePostStrategy.java index 873c4bad1..573b2ff08 100644 --- a/yudao-module-bpm/yudao-module-bpm-server/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/user/BpmTaskCandidatePostStrategy.java +++ b/yudao-module-bpm/yudao-module-bpm-server/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/user/BpmTaskCandidatePostStrategy.java @@ -41,7 +41,7 @@ public class BpmTaskCandidatePostStrategy implements BpmTaskCandidateStrategy { @Override public Set calculateUsers(String param) { Set postIds = StrUtils.splitToLongSet(param); - List users = adminUserApi.getUserListByPostIds(postIds); + List users = adminUserApi.getUserListByPostIds(postIds).getCheckedData(); return convertSet(users, AdminUserRespDTO::getId); } diff --git a/yudao-module-bpm/yudao-module-bpm-server/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/user/BpmTaskCandidateUserStrategy.java b/yudao-module-bpm/yudao-module-bpm-server/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/user/BpmTaskCandidateUserStrategy.java index 15002d91f..44fb1df4c 100644 --- a/yudao-module-bpm/yudao-module-bpm-server/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/user/BpmTaskCandidateUserStrategy.java +++ b/yudao-module-bpm/yudao-module-bpm-server/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/user/BpmTaskCandidateUserStrategy.java @@ -28,7 +28,7 @@ public class BpmTaskCandidateUserStrategy implements BpmTaskCandidateStrategy { @Override public void validateParam(String param) { - adminUserApi.validateUserList(StrUtils.splitToLongSet(param)); + adminUserApi.validateUserList(StrUtils.splitToLongSet(param)).checkError(); } @Override diff --git a/yudao-module-bpm/yudao-module-bpm-server/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmProcessDefinitionServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-server/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmProcessDefinitionServiceImpl.java index 836b5181c..01a09338e 100644 --- a/yudao-module-bpm/yudao-module-bpm-server/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmProcessDefinitionServiceImpl.java +++ b/yudao-module-bpm/yudao-module-bpm-server/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmProcessDefinitionServiceImpl.java @@ -101,7 +101,7 @@ public class BpmProcessDefinitionServiceImpl implements BpmProcessDefinitionServ // 校验用户是否在允许发起的部门列表中 if (CollUtil.isNotEmpty(processDefinition.getStartDeptIds())) { - AdminUserRespDTO user = adminUserApi.getUser(userId); + AdminUserRespDTO user = adminUserApi.getUser(userId).getCheckedData(); return user != null && user.getDeptId() != null && processDefinition.getStartDeptIds().contains(user.getDeptId()); diff --git a/yudao-module-bpm/yudao-module-bpm-server/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmProcessInstanceServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-server/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmProcessInstanceServiceImpl.java index 5344dd7c5..c55d8df0c 100644 --- a/yudao-module-bpm/yudao-module-bpm-server/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmProcessInstanceServiceImpl.java +++ b/yudao-module-bpm/yudao-module-bpm-server/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmProcessInstanceServiceImpl.java @@ -872,7 +872,7 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService if (titleSetting == null || !BooleanUtil.isTrue(titleSetting.getEnable())) { return definition.getName(); } - AdminUserRespDTO user = adminUserApi.getUser(userId); + AdminUserRespDTO user = adminUserApi.getUser(userId).getCheckedData(); Map cloneVariables = new HashMap<>(variables); cloneVariables.put(BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_START_USER_ID, user.getNickname()); cloneVariables.put(BpmnVariableConstants.PROCESS_START_TIME, DateUtil.now()); @@ -920,7 +920,7 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService } // 2. 取消流程 - AdminUserRespDTO user = adminUserApi.getUser(userId); + AdminUserRespDTO user = adminUserApi.getUser(userId).getCheckedData(); updateProcessInstanceCancel(cancelReqVO.getId(), BpmReasonEnum.CANCEL_PROCESS_INSTANCE_BY_ADMIN.format(user.getNickname(), cancelReqVO.getReason())); } diff --git a/yudao-module-bpm/yudao-module-bpm-server/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-server/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskServiceImpl.java index c178ea270..b0adbb90d 100644 --- a/yudao-module-bpm/yudao-module-bpm-server/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskServiceImpl.java +++ b/yudao-module-bpm/yudao-module-bpm-server/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskServiceImpl.java @@ -787,8 +787,8 @@ public class BpmTaskServiceImpl implements BpmTaskService { */ private void approveDelegateTask(BpmTaskApproveReqVO reqVO, Task task) { // 1. 添加审批意见 - AdminUserRespDTO currentUser = adminUserApi.getUser(WebFrameworkUtils.getLoginUserId()); - AdminUserRespDTO ownerUser = adminUserApi.getUser(NumberUtils.parseLong(task.getOwner())); // 发起委托的用户 + AdminUserRespDTO currentUser = adminUserApi.getUser(WebFrameworkUtils.getLoginUserId()).getCheckedData(); + AdminUserRespDTO ownerUser = adminUserApi.getUser(NumberUtils.parseLong(task.getOwner())).getCheckedData(); // 发起委托的用户 Assert.notNull(ownerUser, "委派任务找不到原审批人,需要检查数据"); taskService.addComment(reqVO.getId(), task.getProcessInstanceId(), BpmCommentTypeEnum.DELEGATE_END.getType(), BpmCommentTypeEnum.DELEGATE_END.formatComment(currentUser.getNickname(), ownerUser.getNickname(), reqVO.getReason())); @@ -1015,13 +1015,13 @@ public class BpmTaskServiceImpl implements BpmTaskService { throw exception(TASK_DELEGATE_FAIL_USER_REPEAT); } // 1.2 校验目标用户存在 - AdminUserRespDTO delegateUser = adminUserApi.getUser(reqVO.getDelegateUserId()); + AdminUserRespDTO delegateUser = adminUserApi.getUser(reqVO.getDelegateUserId()).getCheckedData(); if (delegateUser == null) { throw exception(TASK_DELEGATE_FAIL_USER_NOT_EXISTS); } // 2. 添加委托意见 - AdminUserRespDTO currentUser = adminUserApi.getUser(userId); + AdminUserRespDTO currentUser = adminUserApi.getUser(userId).getCheckedData(); taskService.addComment(taskId, task.getProcessInstanceId(), BpmCommentTypeEnum.DELEGATE_START.getType(), BpmCommentTypeEnum.DELEGATE_START.formatComment(currentUser.getNickname(), delegateUser.getNickname(), reqVO.getReason())); @@ -1046,13 +1046,13 @@ public class BpmTaskServiceImpl implements BpmTaskService { throw exception(TASK_TRANSFER_FAIL_USER_REPEAT); } // 1.2 校验目标用户存在 - AdminUserRespDTO assigneeUser = adminUserApi.getUser(reqVO.getAssigneeUserId()); + AdminUserRespDTO assigneeUser = adminUserApi.getUser(reqVO.getAssigneeUserId()).getCheckedData(); if (assigneeUser == null) { throw exception(TASK_TRANSFER_FAIL_USER_NOT_EXISTS); } // 2. 添加委托意见 - AdminUserRespDTO currentUser = adminUserApi.getUser(userId); + AdminUserRespDTO currentUser = adminUserApi.getUser(userId).getCheckedData(); taskService.addComment(taskId, task.getProcessInstanceId(), BpmCommentTypeEnum.TRANSFER.getType(), BpmCommentTypeEnum.TRANSFER.formatComment(currentUser.getNickname(), assigneeUser.getNickname(), reqVO.getReason())); @@ -1111,7 +1111,7 @@ public class BpmTaskServiceImpl implements BpmTaskService { public void createSignTask(Long userId, BpmTaskSignCreateReqVO reqVO) { // 1. 获取和校验任务 TaskEntityImpl taskEntity = validateTaskCanCreateSign(userId, reqVO); - List userList = adminUserApi.getUserList(reqVO.getUserIds()); + List userList = adminUserApi.getUserList(reqVO.getUserIds()).getCheckedData(); if (CollUtil.isEmpty(userList)) { throw exception(TASK_SIGN_CREATE_USER_NOT_EXIST); } @@ -1138,7 +1138,7 @@ public class BpmTaskServiceImpl implements BpmTaskService { createSignTaskList(convertList(reqVO.getUserIds(), String::valueOf), taskEntity); // 4. 记录加签的评论到 task 任务 - AdminUserRespDTO currentUser = adminUserApi.getUser(userId); + AdminUserRespDTO currentUser = adminUserApi.getUser(userId).getCheckedData(); String comment = StrUtil.format(BpmCommentTypeEnum.ADD_SIGN.getComment(), currentUser.getNickname(), BpmTaskSignTypeEnum.nameOfType(reqVO.getType()), String.join(",", convertList(userList, AdminUserRespDTO::getNickname)), reqVO.getReason()); @@ -1170,7 +1170,7 @@ public class BpmTaskServiceImpl implements BpmTaskService { List currentAssigneeList = convertListByFlatMap(taskList, task -> // 需要考虑 owner 的情况,因为向后加签时,它暂时没 assignee 而是 owner Stream.of(NumberUtils.parseLong(task.getAssignee()), NumberUtils.parseLong(task.getOwner()))); if (CollUtil.containsAny(currentAssigneeList, reqVO.getUserIds())) { - List userList = adminUserApi.getUserList(CollUtil.intersection(currentAssigneeList, reqVO.getUserIds())); + List userList = adminUserApi.getUserList(CollUtil.intersection(currentAssigneeList, reqVO.getUserIds())).getCheckedData(); throw exception(TASK_SIGN_CREATE_USER_REPEAT, String.join(",", convertList(userList, AdminUserRespDTO::getNickname))); } return taskEntity; @@ -1232,10 +1232,10 @@ public class BpmTaskServiceImpl implements BpmTaskService { // 1.2 校验取消人存在 AdminUserRespDTO cancelUser = null; if (StrUtil.isNotBlank(task.getAssignee())) { - cancelUser = adminUserApi.getUser(NumberUtils.parseLong(task.getAssignee())); + cancelUser = adminUserApi.getUser(NumberUtils.parseLong(task.getAssignee())).getCheckedData(); } if (cancelUser == null && StrUtil.isNotBlank(task.getOwner())) { - cancelUser = adminUserApi.getUser(NumberUtils.parseLong(task.getOwner())); + cancelUser = adminUserApi.getUser(NumberUtils.parseLong(task.getOwner())).getCheckedData(); } Assert.notNull(cancelUser, "任务中没有所有者和审批人,数据错误"); @@ -1249,7 +1249,7 @@ public class BpmTaskServiceImpl implements BpmTaskService { taskService.deleteTasks(convertList(childTaskList, Task::getId)); // 3. 记录日志到父任务中。先记录日志是因为,通过 handleParentTask 方法之后,任务可能被完成了,并且不存在了,会报异常,所以先记录 - AdminUserRespDTO user = adminUserApi.getUser(userId); + AdminUserRespDTO user = adminUserApi.getUser(userId).getCheckedData(); taskService.addComment(task.getParentTaskId(), task.getProcessInstanceId(), BpmCommentTypeEnum.SUB_SIGN.getType(), StrUtil.format(BpmCommentTypeEnum.SUB_SIGN.getComment(), user.getNickname(), cancelUser.getNickname())); @@ -1555,9 +1555,9 @@ public class BpmTaskServiceImpl implements BpmTaskService { // 情况二:转交给部门负责人审批 if (ObjectUtils.equalsAny(assignStartUserHandlerType, BpmUserTaskAssignStartUserHandlerTypeEnum.TRANSFER_DEPT_LEADER.getType())) { - AdminUserRespDTO startUser = adminUserApi.getUser(Long.valueOf(processInstance.getStartUserId())); + AdminUserRespDTO startUser = adminUserApi.getUser(Long.valueOf(processInstance.getStartUserId())).getCheckedData(); Assert.notNull(startUser, "提交人({})信息为空", processInstance.getStartUserId()); - DeptRespDTO dept = startUser.getDeptId() != null ? deptApi.getDept(startUser.getDeptId()) : null; + DeptRespDTO dept = startUser.getDeptId() != null ? deptApi.getDept(startUser.getDeptId()).getCheckedData() : null; Assert.notNull(dept, "提交人({})部门({})信息为空", processInstance.getStartUserId(), startUser.getDeptId()); // 找不到部门负责人的情况下,自动审批通过 // noinspection DataFlowIssue @@ -1579,7 +1579,7 @@ public class BpmTaskServiceImpl implements BpmTaskService { } // 发送消息 - AdminUserRespDTO startUser = adminUserApi.getUser(Long.valueOf(processInstance.getStartUserId())); + AdminUserRespDTO startUser = adminUserApi.getUser(Long.valueOf(processInstance.getStartUserId())).getCheckedData(); messageService.sendMessageWhenTaskAssigned(BpmTaskConvert.INSTANCE.convert(processInstance, startUser, task)); }); } diff --git a/yudao-module-bpm/yudao-module-bpm-server/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/expression/BpmTaskAssignLeaderExpressionTest.java b/yudao-module-bpm/yudao-module-bpm-server/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/expression/BpmTaskAssignLeaderExpressionTest.java index f7eac7ca0..251af1d9f 100644 --- a/yudao-module-bpm/yudao-module-bpm-server/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/expression/BpmTaskAssignLeaderExpressionTest.java +++ b/yudao-module-bpm/yudao-module-bpm-server/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/expression/BpmTaskAssignLeaderExpressionTest.java @@ -14,6 +14,7 @@ import org.mockito.Mock; import java.util.Set; +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.common.util.collection.SetUtils.asSet; import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomString; @@ -40,9 +41,9 @@ public class BpmTaskAssignLeaderExpressionTest extends BaseMockitoUnitTest { DelegateExecution execution = mockDelegateExecution(1L); // mock 方法(startUser) AdminUserRespDTO startUser = randomPojo(AdminUserRespDTO.class, o -> o.setDeptId(10L)); - when(adminUserApi.getUser(eq(1L))).thenReturn(startUser); + when(adminUserApi.getUser(eq(1L))).thenReturn(success(startUser)); // mock 方法(getStartUserDept)没有部门 - when(deptApi.getDept(eq(10L))).thenReturn(null); + when(deptApi.getDept(eq(10L))).thenReturn(success(null)); // 调用 Set result = expression.calculateUsers(execution, 1); @@ -56,12 +57,12 @@ public class BpmTaskAssignLeaderExpressionTest extends BaseMockitoUnitTest { DelegateExecution execution = mockDelegateExecution(1L); // mock 方法(startUser) AdminUserRespDTO startUser = randomPojo(AdminUserRespDTO.class, o -> o.setDeptId(10L)); - when(adminUserApi.getUser(eq(1L))).thenReturn(startUser); + when(adminUserApi.getUser(eq(1L))).thenReturn(success(startUser)); DeptRespDTO startUserDept = randomPojo(DeptRespDTO.class, o -> o.setId(10L).setParentId(100L) .setLeaderUserId(20L)); // mock 方法(getDept) - when(deptApi.getDept(eq(10L))).thenReturn(startUserDept); - when(deptApi.getDept(eq(100L))).thenReturn(null); + when(deptApi.getDept(eq(10L))).thenReturn(success(startUserDept)); + when(deptApi.getDept(eq(100L))).thenReturn(success(null)); // 调用 Set result = expression.calculateUsers(execution, 2); @@ -75,14 +76,14 @@ public class BpmTaskAssignLeaderExpressionTest extends BaseMockitoUnitTest { DelegateExecution execution = mockDelegateExecution(1L); // mock 方法(startUser) AdminUserRespDTO startUser = randomPojo(AdminUserRespDTO.class, o -> o.setDeptId(10L)); - when(adminUserApi.getUser(eq(1L))).thenReturn(startUser); + when(adminUserApi.getUser(eq(1L))).thenReturn(success(startUser)); DeptRespDTO startUserDept = randomPojo(DeptRespDTO.class, o -> o.setId(10L).setParentId(100L) .setLeaderUserId(20L)); - when(deptApi.getDept(eq(10L))).thenReturn(startUserDept); + when(deptApi.getDept(eq(10L))).thenReturn(success(startUserDept)); // mock 方法(父 dept) DeptRespDTO parentDept = randomPojo(DeptRespDTO.class, o -> o.setId(100L).setParentId(1000L) .setLeaderUserId(200L)); - when(deptApi.getDept(eq(100L))).thenReturn(parentDept); + when(deptApi.getDept(eq(100L))).thenReturn(success(parentDept)); // 调用 Set result = expression.calculateUsers(execution, 2); diff --git a/yudao-module-bpm/yudao-module-bpm-server/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/dept/BpmTaskCandidateDeptLeaderMultiStrategyTest.java b/yudao-module-bpm/yudao-module-bpm-server/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/dept/BpmTaskCandidateDeptLeaderMultiStrategyTest.java index 3d671cf32..60309be39 100644 --- a/yudao-module-bpm/yudao-module-bpm-server/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/dept/BpmTaskCandidateDeptLeaderMultiStrategyTest.java +++ b/yudao-module-bpm/yudao-module-bpm-server/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/dept/BpmTaskCandidateDeptLeaderMultiStrategyTest.java @@ -7,10 +7,10 @@ import org.assertj.core.util.Sets; import org.junit.jupiter.api.Test; import org.mockito.InjectMocks; import org.mockito.Mock; -import org.mockito.stubbing.Answer; import java.util.Set; +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.ArgumentMatchers.any; @@ -29,9 +29,10 @@ public class BpmTaskCandidateDeptLeaderMultiStrategyTest extends BaseMockitoUnit // 准备参数 String param = "10,20|2"; // mock 方法 - when(deptApi.getDept(any())).thenAnswer((Answer) invocationOnMock -> { + when(deptApi.getDept(any())).thenAnswer(invocationOnMock -> { Long deptId = invocationOnMock.getArgument(0); - return randomPojo(DeptRespDTO.class, o -> o.setId(deptId).setParentId(deptId * 100).setLeaderUserId(deptId + 1)); + return success(randomPojo(DeptRespDTO.class, + o -> o.setId(deptId).setParentId(deptId * 100).setLeaderUserId(deptId + 1))); }); // 调用 diff --git a/yudao-module-bpm/yudao-module-bpm-server/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/dept/BpmTaskCandidateDeptLeaderStrategyTest.java b/yudao-module-bpm/yudao-module-bpm-server/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/dept/BpmTaskCandidateDeptLeaderStrategyTest.java index fc27bcd8e..8d515e6fb 100644 --- a/yudao-module-bpm/yudao-module-bpm-server/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/dept/BpmTaskCandidateDeptLeaderStrategyTest.java +++ b/yudao-module-bpm/yudao-module-bpm-server/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/dept/BpmTaskCandidateDeptLeaderStrategyTest.java @@ -11,6 +11,7 @@ import org.mockito.Mock; import java.util.Set; +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; import static java.util.Arrays.asList; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -30,9 +31,9 @@ public class BpmTaskCandidateDeptLeaderStrategyTest extends BaseMockitoUnitTest // 准备参数 String param = "10,20"; // mock 方法 - when(deptApi.getDeptList(eq(SetUtils.asSet(10L, 20L)))).thenReturn(asList( + when(deptApi.getDeptList(eq(SetUtils.asSet(10L, 20L)))).thenReturn(success(asList( randomPojo(DeptRespDTO.class, o -> o.setId(10L).setParentId(10L).setLeaderUserId(11L)), - randomPojo(DeptRespDTO.class, o -> o.setId(20L).setParentId(20L).setLeaderUserId(21L)))); + randomPojo(DeptRespDTO.class, o -> o.setId(20L).setParentId(20L).setLeaderUserId(21L))))); // 调用 Set userIds = strategy.calculateUsers(param); diff --git a/yudao-module-bpm/yudao-module-bpm-server/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/dept/BpmTaskCandidateDeptMemberStrategyTest.java b/yudao-module-bpm/yudao-module-bpm-server/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/dept/BpmTaskCandidateDeptMemberStrategyTest.java index 57ab22850..809d714e2 100644 --- a/yudao-module-bpm/yudao-module-bpm-server/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/dept/BpmTaskCandidateDeptMemberStrategyTest.java +++ b/yudao-module-bpm/yudao-module-bpm-server/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/dept/BpmTaskCandidateDeptMemberStrategyTest.java @@ -12,6 +12,7 @@ import org.mockito.Mock; import java.util.Set; +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; import static java.util.Arrays.asList; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -33,9 +34,9 @@ public class BpmTaskCandidateDeptMemberStrategyTest extends BaseMockitoUnitTest // 准备参数 String param = "10,20"; // mock 方法 - when(adminUserApi.getUserListByDeptIds(eq(SetUtils.asSet(10L, 20L)))).thenReturn(asList( + when(adminUserApi.getUserListByDeptIds(eq(SetUtils.asSet(10L, 20L)))).thenReturn(success(asList( randomPojo(AdminUserRespDTO.class, o -> o.setId(11L)), - randomPojo(AdminUserRespDTO.class, o -> o.setId(21L)))); + randomPojo(AdminUserRespDTO.class, o -> o.setId(21L))))); // 调用 Set userIds = strategy.calculateUsers(param); diff --git a/yudao-module-bpm/yudao-module-bpm-server/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/dept/BpmTaskCandidateStartUserDeptLeaderMultiStrategyTest.java b/yudao-module-bpm/yudao-module-bpm-server/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/dept/BpmTaskCandidateStartUserDeptLeaderMultiStrategyTest.java index 2f66a83b5..39ccb9948 100644 --- a/yudao-module-bpm/yudao-module-bpm-server/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/dept/BpmTaskCandidateStartUserDeptLeaderMultiStrategyTest.java +++ b/yudao-module-bpm/yudao-module-bpm-server/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/dept/BpmTaskCandidateStartUserDeptLeaderMultiStrategyTest.java @@ -12,10 +12,10 @@ import org.flowable.engine.runtime.ProcessInstance; import org.junit.jupiter.api.Test; import org.mockito.InjectMocks; import org.mockito.Mock; -import org.mockito.stubbing.Answer; import java.util.Set; +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.ArgumentMatchers.any; @@ -72,10 +72,11 @@ public class BpmTaskCandidateStartUserDeptLeaderMultiStrategyTest extends BaseMo private void mockGetStartUserDept(Long startUserId) { when(adminUserApi.getUser(eq(startUserId))).thenReturn( - randomPojo(AdminUserRespDTO.class, o -> o.setId(startUserId).setDeptId(10L))); - when(deptApi.getDept(any())).thenAnswer((Answer) invocationOnMock -> { + success(randomPojo(AdminUserRespDTO.class, o -> o.setId(startUserId).setDeptId(10L)))); + when(deptApi.getDept(any())).thenAnswer(invocationOnMock -> { Long deptId = invocationOnMock.getArgument(0); - return randomPojo(DeptRespDTO.class, o -> o.setId(deptId).setParentId(deptId * 100).setLeaderUserId(deptId + 1)); + return success(randomPojo(DeptRespDTO.class, + o -> o.setId(deptId).setParentId(deptId * 100).setLeaderUserId(deptId + 1))); }); } diff --git a/yudao-module-bpm/yudao-module-bpm-server/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/dept/BpmTaskCandidateStartUserDeptLeaderStrategyTest.java b/yudao-module-bpm/yudao-module-bpm-server/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/dept/BpmTaskCandidateStartUserDeptLeaderStrategyTest.java index a5f863f24..1c4cad64b 100644 --- a/yudao-module-bpm/yudao-module-bpm-server/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/dept/BpmTaskCandidateStartUserDeptLeaderStrategyTest.java +++ b/yudao-module-bpm/yudao-module-bpm-server/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/dept/BpmTaskCandidateStartUserDeptLeaderStrategyTest.java @@ -12,10 +12,10 @@ import org.flowable.engine.runtime.ProcessInstance; import org.junit.jupiter.api.Test; import org.mockito.InjectMocks; import org.mockito.Mock; -import org.mockito.stubbing.Answer; import java.util.Set; +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.ArgumentMatchers.any; @@ -72,10 +72,11 @@ public class BpmTaskCandidateStartUserDeptLeaderStrategyTest extends BaseMockito private void mockGetStartUserDeptLeader(Long startUserId) { when(adminUserApi.getUser(eq(startUserId))).thenReturn( - randomPojo(AdminUserRespDTO.class, o -> o.setId(startUserId).setDeptId(10L))); - when(deptApi.getDept(any())).thenAnswer((Answer) invocationOnMock -> { + success(randomPojo(AdminUserRespDTO.class, o -> o.setId(startUserId).setDeptId(10L)))); + when(deptApi.getDept(any())).thenAnswer(invocationOnMock -> { Long deptId = invocationOnMock.getArgument(0); - return randomPojo(DeptRespDTO.class, o -> o.setId(deptId).setParentId(deptId * 100).setLeaderUserId(deptId + 1)); + return success(randomPojo(DeptRespDTO.class, + o -> o.setId(deptId).setParentId(deptId * 100).setLeaderUserId(deptId + 1))); }); } diff --git a/yudao-module-bpm/yudao-module-bpm-server/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/user/BpmTaskCandidatePostStrategyTest.java b/yudao-module-bpm/yudao-module-bpm-server/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/user/BpmTaskCandidatePostStrategyTest.java index a4442240e..8d2191eeb 100644 --- a/yudao-module-bpm/yudao-module-bpm-server/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/user/BpmTaskCandidatePostStrategyTest.java +++ b/yudao-module-bpm/yudao-module-bpm-server/src/test/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/user/BpmTaskCandidatePostStrategyTest.java @@ -12,6 +12,7 @@ import org.mockito.Mock; import java.util.List; import java.util.Set; +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; import static cn.iocoder.yudao.framework.common.util.collection.SetUtils.asSet; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -36,7 +37,7 @@ public class BpmTaskCandidatePostStrategyTest extends BaseMockitoUnitTest { // mock 方法 List users = convertList(asSet(11L, 22L), id -> new AdminUserRespDTO().setId(id)); - when(adminUserApi.getUserListByPostIds(eq(asSet(1L, 2L)))).thenReturn(users); + when(adminUserApi.getUserListByPostIds(eq(asSet(1L, 2L)))).thenReturn(success(users)); // 调用 Set userIds = strategy.calculateUsersByTask(null, param); diff --git a/yudao-module-crm/yudao-module-crm-server/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessStatusController.java b/yudao-module-crm/yudao-module-crm-server/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessStatusController.java index 0663d1f28..1536582de 100644 --- a/yudao-module-crm/yudao-module-crm-server/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessStatusController.java +++ b/yudao-module-crm/yudao-module-crm-server/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessStatusController.java @@ -110,7 +110,7 @@ public class CrmBusinessStatusController { public CommonResult> getBusinessStatusTypeSimpleList() { List list = businessStatusTypeService.getBusinessStatusTypeList(); // 过滤掉部门不匹配的 - Long deptId = adminUserApi.getUser(getLoginUserId()).getDeptId(); + Long deptId = adminUserApi.getUser(getLoginUserId()).getCheckedData().getDeptId(); list.removeIf(statusType -> CollUtil.isNotEmpty(statusType.getDeptIds()) && !statusType.getDeptIds().contains(deptId)); return success(BeanUtils.toBean(list, CrmBusinessStatusRespVO.class)); } diff --git a/yudao-module-crm/yudao-module-crm-server/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/SysAdminUserParseFunction.java b/yudao-module-crm/yudao-module-crm-server/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/SysAdminUserParseFunction.java index 05f96c586..224638957 100644 --- a/yudao-module-crm/yudao-module-crm-server/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/SysAdminUserParseFunction.java +++ b/yudao-module-crm/yudao-module-crm-server/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/SysAdminUserParseFunction.java @@ -34,7 +34,7 @@ public class SysAdminUserParseFunction implements IParseFunction { } // 获取用户信息 - AdminUserRespDTO user = adminUserApi.getUser(Long.parseLong(value.toString())); + AdminUserRespDTO user = adminUserApi.getUser(Long.parseLong(value.toString())).getCheckedData(); if (user == null) { log.warn("[apply][获取用户{{}}为空", value); return ""; diff --git a/yudao-module-crm/yudao-module-crm-server/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/SysDeptParseFunction.java b/yudao-module-crm/yudao-module-crm-server/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/SysDeptParseFunction.java index 6d01f9f97..5b002c9ce 100644 --- a/yudao-module-crm/yudao-module-crm-server/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/SysDeptParseFunction.java +++ b/yudao-module-crm/yudao-module-crm-server/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/SysDeptParseFunction.java @@ -34,7 +34,7 @@ public class SysDeptParseFunction implements IParseFunction { } // 获取部门信息 - DeptRespDTO dept = deptApi.getDept(Long.parseLong(value.toString())); + DeptRespDTO dept = deptApi.getDept(Long.parseLong(value.toString())).getCheckedData(); if (dept == null) { log.warn("[apply][获取部门{{}}为空", value); return ""; diff --git a/yudao-module-crm/yudao-module-crm-server/src/main/java/cn/iocoder/yudao/module/crm/framework/permission/core/aop/CrmPermissionAspect.java b/yudao-module-crm/yudao-module-crm-server/src/main/java/cn/iocoder/yudao/module/crm/framework/permission/core/aop/CrmPermissionAspect.java index 8e4970117..e642636ba 100644 --- a/yudao-module-crm/yudao-module-crm-server/src/main/java/cn/iocoder/yudao/module/crm/framework/permission/core/aop/CrmPermissionAspect.java +++ b/yudao-module-crm/yudao-module-crm-server/src/main/java/cn/iocoder/yudao/module/crm/framework/permission/core/aop/CrmPermissionAspect.java @@ -95,7 +95,7 @@ public class CrmPermissionAspect { } // 3. 考虑下级的权限 - List subordinateUserIds = adminUserApi.getUserListBySubordinate(userId); + List subordinateUserIds = adminUserApi.getUserListBySubordinate(userId).getCheckedData(); for (Long subordinateUserId : convertSet(subordinateUserIds, AdminUserRespDTO::getId)) { CrmPermissionDO subordinatePermission = CollUtil.findOne(bizPermissions, permission -> ObjUtil.equal(permission.getUserId(), subordinateUserId)); diff --git a/yudao-module-crm/yudao-module-crm-server/src/main/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImpl.java b/yudao-module-crm/yudao-module-crm-server/src/main/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImpl.java index e11c34626..b5c301a28 100644 --- a/yudao-module-crm/yudao-module-crm-server/src/main/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-server/src/main/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImpl.java @@ -112,7 +112,7 @@ public class CrmClueServiceImpl implements CrmClueService { private void validateRelationDataExists(CrmClueSaveReqVO reqVO) { // 校验负责人 if (Objects.nonNull(reqVO.getOwnerUserId()) && - Objects.isNull(adminUserApi.getUser(reqVO.getOwnerUserId()))) { + Objects.isNull(adminUserApi.getUser(reqVO.getOwnerUserId()).getCheckedData())) { throw exception(USER_NOT_EXISTS); } } diff --git a/yudao-module-crm/yudao-module-crm-server/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerLimitConfigServiceImpl.java b/yudao-module-crm/yudao-module-crm-server/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerLimitConfigServiceImpl.java index 6d6a49f46..610447f86 100644 --- a/yudao-module-crm/yudao-module-crm-server/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerLimitConfigServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-server/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerLimitConfigServiceImpl.java @@ -110,13 +110,13 @@ public class CrmCustomerLimitConfigServiceImpl implements CrmCustomerLimitConfig * @param deptIds 部门 ids */ private void validateUserAndDept(Collection userIds, Collection deptIds) { - deptApi.validateDeptList(deptIds); - adminUserApi.validateUserList(userIds); + deptApi.validateDeptList(deptIds).checkError(); + adminUserApi.validateUserList(userIds).checkError(); } @Override public List getCustomerLimitConfigListByUserId(Integer type, Long userId) { - AdminUserRespDTO user = adminUserApi.getUser(userId); + AdminUserRespDTO user = adminUserApi.getUser(userId).getCheckedData(); Assert.notNull(user, "用户({})不存在", userId); return customerLimitConfigMapper.selectListByTypeAndUserIdAndDeptId(type, userId, user.getDeptId()); } diff --git a/yudao-module-crm/yudao-module-crm-server/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java b/yudao-module-crm/yudao-module-crm-server/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java index 11ac107d9..a010e4390 100644 --- a/yudao-module-crm/yudao-module-crm-server/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-server/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java @@ -391,7 +391,7 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { throw exception(CUSTOMER_NOT_EXISTS); } // 1.2 校验负责人是否存在 - adminUserApi.validateUserList(singletonList(ownerUserId)); + adminUserApi.validateUserList(singletonList(ownerUserId)).checkError(); // 1.3 校验状态 customers.forEach(customer -> { // 校验是否已有负责人 @@ -424,7 +424,7 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { // 3. 记录操作日志 AdminUserRespDTO user = null; if (!isReceive) { - user = adminUserApi.getUser(ownerUserId); + user = adminUserApi.getUser(ownerUserId).getCheckedData(); } for (CrmCustomerDO customer : customers) { getSelf().receiveCustomerLog(customer, user == null ? null : user.getNickname()); diff --git a/yudao-module-crm/yudao-module-crm-server/src/main/java/cn/iocoder/yudao/module/crm/service/permission/CrmPermissionServiceImpl.java b/yudao-module-crm/yudao-module-crm-server/src/main/java/cn/iocoder/yudao/module/crm/service/permission/CrmPermissionServiceImpl.java index 6e2c37c89..b98503c57 100644 --- a/yudao-module-crm/yudao-module-crm-server/src/main/java/cn/iocoder/yudao/module/crm/service/permission/CrmPermissionServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-server/src/main/java/cn/iocoder/yudao/module/crm/service/permission/CrmPermissionServiceImpl.java @@ -136,7 +136,7 @@ public class CrmPermissionServiceImpl implements CrmPermissionService { private void createBizTypePermissions(CrmPermissionSaveReqVO reqVO, Integer type, Long bizId, String name, List createPermissions) { - AdminUserRespDTO user = adminUserApi.getUser(reqVO.getUserId()); + AdminUserRespDTO user = adminUserApi.getUser(reqVO.getUserId()).getCheckedData(); // 1. 需要考虑,被添加人,是不是应该有对应的权限了; CrmPermissionDO permission = hasAnyPermission(type, bizId, reqVO.getUserId()); if (ObjUtil.isNotNull(permission)) { @@ -157,7 +157,7 @@ public class CrmPermissionServiceImpl implements CrmPermissionService { private Long createPermission0(CrmPermissionCreateReqBO createReqBO) { validatePermissionNotExists(Collections.singletonList(createReqBO)); // 1. 校验用户是否存在 - adminUserApi.validateUserList(Collections.singletonList(createReqBO.getUserId())); + adminUserApi.validateUserList(Collections.singletonList(createReqBO.getUserId())).checkError(); // 2. 插入权限 CrmPermissionDO permission = BeanUtils.toBean(createReqBO, CrmPermissionDO.class); permissionMapper.insert(permission); @@ -168,7 +168,7 @@ public class CrmPermissionServiceImpl implements CrmPermissionService { public void createPermissionBatch(List createReqBOs) { validatePermissionNotExists(createReqBOs); // 1. 校验用户是否存在 - adminUserApi.validateUserList(convertSet(createReqBOs, CrmPermissionCreateReqBO::getUserId)); + adminUserApi.validateUserList(convertSet(createReqBOs, CrmPermissionCreateReqBO::getUserId)).checkError(); // 2. 创建 List permissions = BeanUtils.toBean(createReqBOs, CrmPermissionDO.class); @@ -219,7 +219,7 @@ public class CrmPermissionServiceImpl implements CrmPermissionService { throw exception(CRM_PERMISSION_MODEL_TRANSFER_FAIL_OWNER_USER_EXISTS, bizTypeName); } // 1.2 校验新负责人是否存在 - adminUserApi.validateUserList(Collections.singletonList(transferReqBO.getNewOwnerUserId())); + adminUserApi.validateUserList(Collections.singletonList(transferReqBO.getNewOwnerUserId())).checkError(); // 2. 修改新负责人的权限 List permissions = permissionMapper.selectByBizTypeAndBizId( diff --git a/yudao-module-crm/yudao-module-crm-server/src/main/java/cn/iocoder/yudao/module/crm/service/product/CrmProductServiceImpl.java b/yudao-module-crm/yudao-module-crm-server/src/main/java/cn/iocoder/yudao/module/crm/service/product/CrmProductServiceImpl.java index e45c4db22..45ad66d64 100644 --- a/yudao-module-crm/yudao-module-crm-server/src/main/java/cn/iocoder/yudao/module/crm/service/product/CrmProductServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-server/src/main/java/cn/iocoder/yudao/module/crm/service/product/CrmProductServiceImpl.java @@ -60,7 +60,7 @@ public class CrmProductServiceImpl implements CrmProductService { success = CRM_PRODUCT_CREATE_SUCCESS) public Long createProduct(CrmProductSaveReqVO createReqVO) { // 1. 校验产品 - adminUserApi.validateUserList(Collections.singleton(createReqVO.getOwnerUserId())); + adminUserApi.validateUserList(Collections.singleton(createReqVO.getOwnerUserId())).checkError(); validateProductNoDuplicate(null, createReqVO.getNo()); validateProductCategoryExists(createReqVO.getCategoryId()); diff --git a/yudao-module-crm/yudao-module-crm-server/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsCustomerServiceImpl.java b/yudao-module-crm/yudao-module-crm-server/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsCustomerServiceImpl.java index 1df4d5a60..744279e5a 100644 --- a/yudao-module-crm/yudao-module-crm-server/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsCustomerServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-server/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsCustomerServiceImpl.java @@ -359,10 +359,10 @@ public class CrmStatisticsCustomerServiceImpl implements CrmStatisticsCustomerSe } // 情况二:选中某个部门 // 2.1 获得部门列表 - List deptIds = convertList(deptApi.getChildDeptList(reqVO.getDeptId()), DeptRespDTO::getId); + List deptIds = convertList(deptApi.getChildDeptList(reqVO.getDeptId()).getCheckedData(), DeptRespDTO::getId); deptIds.add(reqVO.getDeptId()); // 2.2 获得用户编号 - return convertList(adminUserApi.getUserListByDeptIds(deptIds), AdminUserRespDTO::getId); + return convertList(adminUserApi.getUserListByDeptIds(deptIds).getCheckedData(), AdminUserRespDTO::getId); } } diff --git a/yudao-module-crm/yudao-module-crm-server/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsFunnelServiceImpl.java b/yudao-module-crm/yudao-module-crm-server/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsFunnelServiceImpl.java index f4a04ed3f..504593189 100644 --- a/yudao-module-crm/yudao-module-crm-server/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsFunnelServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-server/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsFunnelServiceImpl.java @@ -145,10 +145,10 @@ public class CrmStatisticsFunnelServiceImpl implements CrmStatisticsFunnelServic } // 情况二:选中某个部门 // 2.1 获得部门列表 - List deptIds = convertList(deptApi.getChildDeptList(reqVO.getDeptId()), DeptRespDTO::getId); + List deptIds = convertList(deptApi.getChildDeptList(reqVO.getDeptId()).getCheckedData(), DeptRespDTO::getId); deptIds.add(reqVO.getDeptId()); // 2.2 获得用户编号 - return convertList(adminUserApi.getUserListByDeptIds(deptIds), AdminUserRespDTO::getId); + return convertList(adminUserApi.getUserListByDeptIds(deptIds).getCheckedData(), AdminUserRespDTO::getId); } } diff --git a/yudao-module-crm/yudao-module-crm-server/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsPerformanceServiceImpl.java b/yudao-module-crm/yudao-module-crm-server/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsPerformanceServiceImpl.java index 719813e7b..fbe0c99c1 100644 --- a/yudao-module-crm/yudao-module-crm-server/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsPerformanceServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-server/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsPerformanceServiceImpl.java @@ -111,10 +111,10 @@ public class CrmStatisticsPerformanceServiceImpl implements CrmStatisticsPerform // 情况二:选中某个部门 // 2.1 获得部门列表 final Long deptId = reqVO.getDeptId(); - List deptIds = convertList(deptApi.getChildDeptList(deptId), DeptRespDTO::getId); + List deptIds = convertList(deptApi.getChildDeptList(deptId).getCheckedData(), DeptRespDTO::getId); deptIds.add(deptId); // 2.2 获得用户编号 - return convertList(adminUserApi.getUserListByDeptIds(deptIds), AdminUserRespDTO::getId); + return convertList(adminUserApi.getUserListByDeptIds(deptIds).getCheckedData(), AdminUserRespDTO::getId); } } \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-crm-server/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsPortraitServiceImpl.java b/yudao-module-crm/yudao-module-crm-server/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsPortraitServiceImpl.java index 913ffb08c..3febdea08 100644 --- a/yudao-module-crm/yudao-module-crm-server/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsPortraitServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-server/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsPortraitServiceImpl.java @@ -122,10 +122,10 @@ public class CrmStatisticsPortraitServiceImpl implements CrmStatisticsPortraitSe } // 情况二:选中某个部门 // 2.1 获得部门列表 - List deptIds = convertList(deptApi.getChildDeptList(reqVO.getDeptId()), DeptRespDTO::getId); + List deptIds = convertList(deptApi.getChildDeptList(reqVO.getDeptId()).getCheckedData(), DeptRespDTO::getId); deptIds.add(reqVO.getDeptId()); // 2.2 获得用户编号 - return convertList(adminUserApi.getUserListByDeptIds(deptIds), AdminUserRespDTO::getId); + return convertList(adminUserApi.getUserListByDeptIds(deptIds).getCheckedData(), AdminUserRespDTO::getId); } } diff --git a/yudao-module-crm/yudao-module-crm-server/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsRankServiceImpl.java b/yudao-module-crm/yudao-module-crm-server/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsRankServiceImpl.java index e591c35c0..b0d90a881 100644 --- a/yudao-module-crm/yudao-module-crm-server/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsRankServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-server/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsRankServiceImpl.java @@ -125,10 +125,10 @@ public class CrmStatisticsRankServiceImpl implements CrmStatisticsRankService { */ public List getUserIds(Long deptId) { // 1. 获得部门列表 - List deptIds = convertList(deptApi.getChildDeptList(deptId), DeptRespDTO::getId); + List deptIds = convertList(deptApi.getChildDeptList(deptId).getCheckedData(), DeptRespDTO::getId); deptIds.add(deptId); // 2. 获得用户编号 - return convertList(adminUserApi.getUserListByDeptIds(deptIds), AdminUserRespDTO::getId); + return convertList(adminUserApi.getUserListByDeptIds(deptIds).getCheckedData(), AdminUserRespDTO::getId); } } \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-crm-server/src/main/java/cn/iocoder/yudao/module/crm/util/CrmPermissionUtils.java b/yudao-module-crm/yudao-module-crm-server/src/main/java/cn/iocoder/yudao/module/crm/util/CrmPermissionUtils.java index eb5cddaa4..b3882486c 100644 --- a/yudao-module-crm/yudao-module-crm-server/src/main/java/cn/iocoder/yudao/module/crm/util/CrmPermissionUtils.java +++ b/yudao-module-crm/yudao-module-crm-server/src/main/java/cn/iocoder/yudao/module/crm/util/CrmPermissionUtils.java @@ -67,7 +67,7 @@ public class CrmPermissionUtils { // 场景三:下属负责的数据(下属是负责人) if (CrmSceneTypeEnum.isSubordinate(sceneType)) { AdminUserApi adminUserApi = SpringUtil.getBean(AdminUserApi.class); - List subordinateUsers = adminUserApi.getUserListBySubordinate(userId); + List subordinateUsers = adminUserApi.getUserListBySubordinate(userId).getCheckedData(); if (CollUtil.isEmpty(subordinateUsers)) { query.eq(ownerUserIdField, -1); // 不返回任何结果 } else { diff --git a/yudao-module-im/yudao-module-im-server/src/main/java/cn/iocoder/yudao/module/im/controller/admin/group/ImGroupMemberController.java b/yudao-module-im/yudao-module-im-server/src/main/java/cn/iocoder/yudao/module/im/controller/admin/group/ImGroupMemberController.java index 4c62469eb..5584af6b4 100644 --- a/yudao-module-im/yudao-module-im-server/src/main/java/cn/iocoder/yudao/module/im/controller/admin/group/ImGroupMemberController.java +++ b/yudao-module-im/yudao-module-im-server/src/main/java/cn/iocoder/yudao/module/im/controller/admin/group/ImGroupMemberController.java @@ -79,7 +79,7 @@ public class ImGroupMemberController { // 3. 转化 VO ImGroupMemberRespVO memberVO = BeanUtils.toBean(member, ImGroupMemberRespVO.class); - AdminUserRespDTO user = adminUserApi.getUser(member.getUserId()); + AdminUserRespDTO user = adminUserApi.getUser(member.getUserId()).getCheckedData(); if (user != null) { memberVO.setNickname(user.getNickname()).setAvatar(user.getAvatar()); } diff --git a/yudao-module-im/yudao-module-im-server/src/main/java/cn/iocoder/yudao/module/im/service/friend/ImFriendRequestServiceImpl.java b/yudao-module-im/yudao-module-im-server/src/main/java/cn/iocoder/yudao/module/im/service/friend/ImFriendRequestServiceImpl.java index 12b5fb159..362e899b1 100644 --- a/yudao-module-im/yudao-module-im-server/src/main/java/cn/iocoder/yudao/module/im/service/friend/ImFriendRequestServiceImpl.java +++ b/yudao-module-im/yudao-module-im-server/src/main/java/cn/iocoder/yudao/module/im/service/friend/ImFriendRequestServiceImpl.java @@ -97,7 +97,7 @@ public class ImFriendRequestServiceImpl implements ImFriendRequestService { ImFriendRequestDO request = createOrResetRequest(fromUserId, reqVO); // 3. 推送 FRIEND_REQUEST_RECEIVED 给 toUser 多端;payload 携带申请方昵称 / 头像,前端按 requestId 直推 push 进列表 - AdminUserRespDTO fromUser = adminUserApi.getUser(fromUserId); + AdminUserRespDTO fromUser = adminUserApi.getUser(fromUserId).getCheckedData(); FriendRequestNotification payload = (FriendRequestNotification) new FriendRequestNotification() .setRequestId(request.getId()).setApplyContent(request.getApplyContent()).setAddSource(request.getAddSource()) .setOperatorUserId(fromUserId).setFriendUserId(fromUserId); @@ -172,7 +172,7 @@ public class ImFriendRequestServiceImpl implements ImFriendRequestService { // 1.1 校验申请存在、未处理、操作人是接收方 ImFriendRequestDO request = validateRequestForHandle(userId, requestId); // 1.2 复验双方用户有效 - adminUserApi.validateUserList(List.of(request.getFromUserId(), request.getToUserId())); + adminUserApi.validateUserList(List.of(request.getFromUserId(), request.getToUserId())).checkError(); // 2. 乐观锁更新申请处理结果 ImFriendRequestDO updateObj = new ImFriendRequestDO() diff --git a/yudao-module-im/yudao-module-im-server/src/main/java/cn/iocoder/yudao/module/im/service/group/ImGroupRequestServiceImpl.java b/yudao-module-im/yudao-module-im-server/src/main/java/cn/iocoder/yudao/module/im/service/group/ImGroupRequestServiceImpl.java index 71d3d76af..4b6093504 100644 --- a/yudao-module-im/yudao-module-im-server/src/main/java/cn/iocoder/yudao/module/im/service/group/ImGroupRequestServiceImpl.java +++ b/yudao-module-im/yudao-module-im-server/src/main/java/cn/iocoder/yudao/module/im/service/group/ImGroupRequestServiceImpl.java @@ -98,7 +98,7 @@ public class ImGroupRequestServiceImpl implements ImGroupRequestService { ImGroupRequestDO request = createOrResetApplyRequest(groupId, userId, reqVO); // 4. 1503 私聊定向推群主 + 全部管理员(多端同步);payload 携带申请方昵称 / 头像 - AdminUserRespDTO applyUser = adminUserApi.getUser(userId); + AdminUserRespDTO applyUser = adminUserApi.getUser(userId).getCheckedData(); GroupRequestReceivedNotification payload = buildRequestNotification(group, request, applyUser); for (Long receiverUserId : getGroupMemberListByOwnerAndAdminUserIds(group)) { websocketService.sendPrivateMessageAsync(receiverUserId, ImPrivateMessageDTO.ofGroupNotification( diff --git a/yudao-module-im/yudao-module-im-server/src/main/java/cn/iocoder/yudao/module/im/service/rtc/ImRtcCallServiceImpl.java b/yudao-module-im/yudao-module-im-server/src/main/java/cn/iocoder/yudao/module/im/service/rtc/ImRtcCallServiceImpl.java index 28bf9b894..695921fbb 100644 --- a/yudao-module-im/yudao-module-im-server/src/main/java/cn/iocoder/yudao/module/im/service/rtc/ImRtcCallServiceImpl.java +++ b/yudao-module-im/yudao-module-im-server/src/main/java/cn/iocoder/yudao/module/im/service/rtc/ImRtcCallServiceImpl.java @@ -235,7 +235,7 @@ public class ImRtcCallServiceImpl implements ImRtcCallService { rtcParticipantMapper.insertBatch(participants); // 3.1 推送通知:RTC_CALL(INVITE) 给每个被邀请人 - AdminUserRespDTO inviterUser = adminUserApi.getUser(inviterId); + AdminUserRespDTO inviterUser = adminUserApi.getUser(inviterId).getCheckedData(); Map inviteeMap = adminUserApi.getUserMap(invitees); for (Long inviteeId : invitees) { pushCallInviteNotification(call, inviterUser, inviteeId, inviteeMap.get(inviteeId), invitees); @@ -303,7 +303,7 @@ public class ImRtcCallServiceImpl implements ImRtcCallService { rtcParticipantMapper.insertBatch(participants); // 3. 推送通知:RTC_CALL(INVITE) 给每个新邀请人 - AdminUserRespDTO inviter = adminUserApi.getUser(inviterId); + AdminUserRespDTO inviter = adminUserApi.getUser(inviterId).getCheckedData(); Map inviteeMap = adminUserApi.getUserMap(incomingUserIds); for (Long inviteeId : incomingUserIds) { pushCallInviteNotification(call, inviter, inviteeId, inviteeMap.get(inviteeId), incomingUserIds); @@ -491,7 +491,7 @@ public class ImRtcCallServiceImpl implements ImRtcCallService { if (!ImRtcParticipantStatusEnum.isJoined(participant.getStatus())) { throw exception(RTC_NOT_PARTICIPANT); } - return signToken(userId, resolveDisplayName(adminUserApi.getUser(userId), userId), room); + return signToken(userId, resolveDisplayName(adminUserApi.getUser(userId).getCheckedData(), userId), room); } @Override @@ -1016,7 +1016,7 @@ public class ImRtcCallServiceImpl implements ImRtcCallService { * @param operatorUserId 拒接者用户编号 */ private void pushCallRejectNotification(ImRtcCallDO call, Long operatorUserId) { - AdminUserRespDTO operator = operatorUserId != null ? adminUserApi.getUser(operatorUserId) : null; + AdminUserRespDTO operator = operatorUserId != null ? adminUserApi.getUser(operatorUserId).getCheckedData() : null; ImRtcCallNotification payload = ImRtcCallNotification.ofReject(call, operatorUserId, operator); for (Long receiverUserId : getCallAudienceUserIdList(call)) { webSocketService.sendPrivateMessageAsync(receiverUserId, ImPrivateMessageDTO.ofRtcNotification( @@ -1107,7 +1107,7 @@ public class ImRtcCallServiceImpl implements ImRtcCallService { */ private void pushCallEndNotification(ImRtcCallDO call, Long operatorId, ImRtcCallEndReasonEnum reason, Long durationSeconds) { - AdminUserRespDTO operator = operatorId != null ? adminUserApi.getUser(operatorId) : null; + AdminUserRespDTO operator = operatorId != null ? adminUserApi.getUser(operatorId).getCheckedData() : null; ImRtcCallEndNotification payload = ImRtcCallEndNotification.of(call, reason, durationSeconds, operatorId, operator); Long peerUserId = null; if (!ImConversationTypeEnum.isGroup(call.getConversationType())) { diff --git a/yudao-module-im/yudao-module-im-server/src/test/java/cn/iocoder/yudao/module/im/service/friend/ImFriendRequestServiceImplTest.java b/yudao-module-im/yudao-module-im-server/src/test/java/cn/iocoder/yudao/module/im/service/friend/ImFriendRequestServiceImplTest.java index 0bbf441bd..901ef276d 100644 --- a/yudao-module-im/yudao-module-im-server/src/test/java/cn/iocoder/yudao/module/im/service/friend/ImFriendRequestServiceImplTest.java +++ b/yudao-module-im/yudao-module-im-server/src/test/java/cn/iocoder/yudao/module/im/service/friend/ImFriendRequestServiceImplTest.java @@ -24,6 +24,7 @@ import org.springframework.dao.DuplicateKeyException; import java.time.LocalDateTime; import java.util.List; +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.module.im.enums.ErrorCodeConstants.*; import static org.junit.jupiter.api.Assertions.*; import static org.mockito.ArgumentMatchers.any; @@ -142,7 +143,7 @@ public class ImFriendRequestServiceImplTest extends BaseMockitoUnitTest { when(friendService.getFriendState(1L, 2L)).thenReturn(ImFriendStateEnum.NONE.getState()); when(friendService.getFriend(2L, 1L)).thenReturn(null); when(friendRequestMapper.selectByFromUserIdAndToUserId(1L, 2L)).thenReturn(null); - when(adminUserApi.getUser(1L)).thenReturn(new AdminUserRespDTO().setNickname("张三").setAvatar("a.png")); + when(adminUserApi.getUser(1L)).thenReturn(success(new AdminUserRespDTO().setNickname("张三").setAvatar("a.png"))); when(imProperties.getFriend()).thenReturn(new ImProperties.Friend()); // 调用 @@ -172,7 +173,7 @@ public class ImFriendRequestServiceImplTest extends BaseMockitoUnitTest { .setHandleResult(ImFriendRequestHandleResultEnum.REFUSED.getResult()) .setHandleContent("旧拒绝").setApplyContent("旧内容"); when(friendRequestMapper.selectByFromUserIdAndToUserId(1L, 2L)).thenReturn(old); - when(adminUserApi.getUser(1L)).thenReturn(null); + when(adminUserApi.getUser(1L)).thenReturn(success(null)); when(imProperties.getFriend()).thenReturn(new ImProperties.Friend()); // 调用 @@ -200,7 +201,7 @@ public class ImFriendRequestServiceImplTest extends BaseMockitoUnitTest { .setHandleResult(ImFriendRequestHandleResultEnum.REFUSED.getResult()); when(friendRequestMapper.selectByFromUserIdAndToUserId(1L, 2L)).thenReturn(null, old); when(friendRequestMapper.insert(any(ImFriendRequestDO.class))).thenThrow(new DuplicateKeyException("dup")); - when(adminUserApi.getUser(1L)).thenReturn(null); + when(adminUserApi.getUser(1L)).thenReturn(success(null)); when(imProperties.getFriend()).thenReturn(new ImProperties.Friend()); // 调用 diff --git a/yudao-module-im/yudao-module-im-server/src/test/java/cn/iocoder/yudao/module/im/service/group/ImGroupRequestServiceImplTest.java b/yudao-module-im/yudao-module-im-server/src/test/java/cn/iocoder/yudao/module/im/service/group/ImGroupRequestServiceImplTest.java index c4f41a729..282809a51 100644 --- a/yudao-module-im/yudao-module-im-server/src/test/java/cn/iocoder/yudao/module/im/service/group/ImGroupRequestServiceImplTest.java +++ b/yudao-module-im/yudao-module-im-server/src/test/java/cn/iocoder/yudao/module/im/service/group/ImGroupRequestServiceImplTest.java @@ -29,6 +29,7 @@ import org.springframework.dao.DuplicateKeyException; import java.util.Collection; import java.util.List; +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.module.im.enums.ErrorCodeConstants.*; import static org.junit.jupiter.api.Assertions.*; import static org.mockito.ArgumentMatchers.*; @@ -102,7 +103,7 @@ public class ImGroupRequestServiceImplTest extends BaseMockitoUnitTest { ImGroupMemberDO.builder().groupId(10L).userId(98L) .role(ImGroupMemberRoleEnum.ADMIN.getRole()) .status(CommonStatusEnum.ENABLE.getStatus()).build())); - when(adminUserApi.getUser(1L)).thenReturn(buildUser(1L, "申请人")); + when(adminUserApi.getUser(1L)).thenReturn(success(buildUser(1L, "申请人"))); ImGroupRequestApplyReqVO reqVO = new ImGroupRequestApplyReqVO(); reqVO.setGroupId(10L); @@ -131,7 +132,7 @@ public class ImGroupRequestServiceImplTest extends BaseMockitoUnitTest { ImGroupMemberDO.builder().groupId(10L).userId(99L) .role(ImGroupMemberRoleEnum.OWNER.getRole()) .status(CommonStatusEnum.ENABLE.getStatus()).build())); - when(adminUserApi.getUser(1L)).thenReturn(buildUser(1L, "申请人")); + when(adminUserApi.getUser(1L)).thenReturn(success(buildUser(1L, "申请人"))); ImGroupRequestDO old = new ImGroupRequestDO().setId(50L).setGroupId(10L).setUserId(1L) .setHandleResult(ImGroupRequestHandleResultEnum.REFUSED.getResult()); when(groupRequestMapper.selectByGroupIdAndUserId(10L, 1L)).thenReturn(null, old); diff --git a/yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/api/config/ConfigApi.java b/yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/api/config/ConfigApi.java index e0f8c6dc6..53803d4d1 100644 --- a/yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/api/config/ConfigApi.java +++ b/yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/api/config/ConfigApi.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.infra.api.config; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.module.infra.enums.ApiConstants; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; @@ -15,6 +16,6 @@ public interface ConfigApi { @GetMapping(PREFIX + "/get-value-by-key") @Operation(summary = "根据参数键查询参数值") - String getConfigValueByKey(@RequestParam("key") String key); + CommonResult getConfigValueByKey(@RequestParam("key") String key); } diff --git a/yudao-module-infra/yudao-module-infra-server/src/main/java/cn/iocoder/yudao/module/infra/api/config/ConfigApiImpl.java b/yudao-module-infra/yudao-module-infra-server/src/main/java/cn/iocoder/yudao/module/infra/api/config/ConfigApiImpl.java index 80d36bfbe..5ab67c2c2 100644 --- a/yudao-module-infra/yudao-module-infra-server/src/main/java/cn/iocoder/yudao/module/infra/api/config/ConfigApiImpl.java +++ b/yudao-module-infra/yudao-module-infra-server/src/main/java/cn/iocoder/yudao/module/infra/api/config/ConfigApiImpl.java @@ -1,11 +1,14 @@ package cn.iocoder.yudao.module.infra.api.config; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.module.infra.dal.dataobject.config.ConfigDO; import cn.iocoder.yudao.module.infra.service.config.ConfigService; import jakarta.annotation.Resource; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.RestController; +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + @RestController // 提供 RESTful API 接口,给 Feign 调用 @Validated public class ConfigApiImpl implements ConfigApi { @@ -14,9 +17,9 @@ public class ConfigApiImpl implements ConfigApi { private ConfigService configService; @Override - public String getConfigValueByKey(String key) { + public CommonResult getConfigValueByKey(String key) { ConfigDO config = configService.getConfigByKey(key); - return config != null ? config.getValue() : null; + return success(config != null ? config.getValue() : null); } } diff --git a/yudao-module-iot/yudao-module-iot-server/src/main/java/cn/iocoder/yudao/module/iot/service/alert/IotAlertConfigServiceImpl.java b/yudao-module-iot/yudao-module-iot-server/src/main/java/cn/iocoder/yudao/module/iot/service/alert/IotAlertConfigServiceImpl.java index 7310ca68c..820cc41c1 100644 --- a/yudao-module-iot/yudao-module-iot-server/src/main/java/cn/iocoder/yudao/module/iot/service/alert/IotAlertConfigServiceImpl.java +++ b/yudao-module-iot/yudao-module-iot-server/src/main/java/cn/iocoder/yudao/module/iot/service/alert/IotAlertConfigServiceImpl.java @@ -47,7 +47,7 @@ public class IotAlertConfigServiceImpl implements IotAlertConfigService { public Long createAlertConfig(IotAlertConfigSaveReqVO createReqVO) { // 校验关联数据是否存在 sceneRuleService.validateSceneRuleList(createReqVO.getSceneRuleIds()); - adminUserApi.validateUserList(createReqVO.getReceiveUserIds()); + adminUserApi.validateUserList(createReqVO.getReceiveUserIds()).checkError(); validateReceiveTemplates(createReqVO); // 插入 @@ -62,7 +62,7 @@ public class IotAlertConfigServiceImpl implements IotAlertConfigService { validateAlertConfigExists(updateReqVO.getId()); // 校验关联数据是否存在 sceneRuleService.validateSceneRuleList(updateReqVO.getSceneRuleIds()); - adminUserApi.validateUserList(updateReqVO.getReceiveUserIds()); + adminUserApi.validateUserList(updateReqVO.getReceiveUserIds()).checkError(); validateReceiveTemplates(updateReqVO); // 更新 diff --git a/yudao-module-mall/yudao-module-promotion-server/src/main/java/cn/iocoder/yudao/module/promotion/service/kefu/KeFuMessageServiceImpl.java b/yudao-module-mall/yudao-module-promotion-server/src/main/java/cn/iocoder/yudao/module/promotion/service/kefu/KeFuMessageServiceImpl.java index ce808790a..cfca03a9b 100644 --- a/yudao-module-mall/yudao-module-promotion-server/src/main/java/cn/iocoder/yudao/module/promotion/service/kefu/KeFuMessageServiceImpl.java +++ b/yudao-module-mall/yudao-module-promotion-server/src/main/java/cn/iocoder/yudao/module/promotion/service/kefu/KeFuMessageServiceImpl.java @@ -69,7 +69,7 @@ public class KeFuMessageServiceImpl implements KeFuMessageService { conversationService.updateConversationLastMessage(kefuMessage); // 3.1 发送消息给会员 - AdminUserRespDTO user = adminUserApi.getUser(kefuMessage.getSenderId()); + AdminUserRespDTO user = adminUserApi.getUser(kefuMessage.getSenderId()).getCheckedData(); KeFuMessageRespVO message = BeanUtils.toBean(kefuMessage, KeFuMessageRespVO.class).setSenderAvatar(user.getAvatar()); getSelf().sendAsyncMessageToMember(conversation.getUserId(), KEFU_MESSAGE_TYPE, message); // 3.2 通知所有管理员更新对话 diff --git a/yudao-module-mall/yudao-module-trade-server/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/DeliveryPickUpStoreController.java b/yudao-module-mall/yudao-module-trade-server/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/DeliveryPickUpStoreController.java index 904c246f2..71432ec81 100644 --- a/yudao-module-mall/yudao-module-trade-server/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/DeliveryPickUpStoreController.java +++ b/yudao-module-mall/yudao-module-trade-server/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/DeliveryPickUpStoreController.java @@ -72,7 +72,7 @@ public class DeliveryPickUpStoreController { return success(null); } List verifyUsers = CollUtil.isNotEmpty(deliveryPickUpStore.getVerifyUserIds()) ? - adminUserApi.getUserList(deliveryPickUpStore.getVerifyUserIds()) : null; + adminUserApi.getUserList(deliveryPickUpStore.getVerifyUserIds()).getCheckedData() : null; return success(BeanUtils.toBean(deliveryPickUpStore, DeliveryPickUpStoreRespVO.class) .setVerifyUsers(BeanUtils.toBean(verifyUsers, UserSimpleBaseVO.class))); } diff --git a/yudao-module-mall/yudao-module-trade-server/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryPickUpStoreServiceImpl.java b/yudao-module-mall/yudao-module-trade-server/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryPickUpStoreServiceImpl.java index c8090a793..f2e38ce5e 100644 --- a/yudao-module-mall/yudao-module-trade-server/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryPickUpStoreServiceImpl.java +++ b/yudao-module-mall/yudao-module-trade-server/src/main/java/cn/iocoder/yudao/module/trade/service/delivery/DeliveryPickUpStoreServiceImpl.java @@ -93,7 +93,7 @@ public class DeliveryPickUpStoreServiceImpl implements DeliveryPickUpStoreServic // 1.1 校验门店存在 validateDeliveryPickUpStoreExists(bindReqVO.getId()); // 1.2 校验用户存在 - adminUserApi.validateUserList(bindReqVO.getVerifyUserIds()); + adminUserApi.validateUserList(bindReqVO.getVerifyUserIds()).checkError(); // 2. 更新 DeliveryPickUpStoreDO updateObj = BeanUtils.toBean(bindReqVO, DeliveryPickUpStoreDO.class); diff --git a/yudao-module-mes/yudao-module-mes-server/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pro/workrecord/MesProWorkRecordController.java b/yudao-module-mes/yudao-module-mes-server/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pro/workrecord/MesProWorkRecordController.java index 2b95fa021..5a594103f 100644 --- a/yudao-module-mes/yudao-module-mes-server/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pro/workrecord/MesProWorkRecordController.java +++ b/yudao-module-mes/yudao-module-mes-server/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pro/workrecord/MesProWorkRecordController.java @@ -143,7 +143,7 @@ public class MesProWorkRecordController { vo.setWorkstationCode(ws.getCode()).setWorkstationName(ws.getName()); } // 拼接用户信息 - AdminUserRespDTO user = adminUserApi.getUser(record.getUserId()); + AdminUserRespDTO user = adminUserApi.getUser(record.getUserId()).getCheckedData(); if (user != null) { vo.setUserNickname(user.getNickname()); } diff --git a/yudao-module-mes/yudao-module-mes-server/src/main/java/cn/iocoder/yudao/module/mes/service/cal/team/MesCalTeamMemberServiceImpl.java b/yudao-module-mes/yudao-module-mes-server/src/main/java/cn/iocoder/yudao/module/mes/service/cal/team/MesCalTeamMemberServiceImpl.java index dcf717ae8..eb89f54ce 100644 --- a/yudao-module-mes/yudao-module-mes-server/src/main/java/cn/iocoder/yudao/module/mes/service/cal/team/MesCalTeamMemberServiceImpl.java +++ b/yudao-module-mes/yudao-module-mes-server/src/main/java/cn/iocoder/yudao/module/mes/service/cal/team/MesCalTeamMemberServiceImpl.java @@ -95,7 +95,7 @@ public class MesCalTeamMemberServiceImpl implements MesCalTeamMemberService { } private void validateUserExists(Long userId) { - if (adminUserApi.getUser(userId) == null) { + if (adminUserApi.getUser(userId).getCheckedData() == null) { throw exception(CAL_TEAM_MEMBER_USER_NOT_EXISTS); } } diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/dept/DeptApi.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/dept/DeptApi.java index 9545904ea..d0cb76d7f 100644 --- a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/dept/DeptApi.java +++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/dept/DeptApi.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.system.api.dept; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; import cn.iocoder.yudao.module.system.enums.ApiConstants; @@ -13,7 +14,6 @@ import org.springframework.web.bind.annotation.RequestParam; import java.util.Collection; import java.util.List; import java.util.Map; -import java.util.Set; @FeignClient(name = ApiConstants.NAME) // TODO 芋艿:fallbackFactory = @Tag(name = "RPC 服务 - 部门") @@ -24,17 +24,17 @@ public interface DeptApi { @GetMapping(PREFIX + "/get") @Operation(summary = "获得部门信息") @Parameter(name = "id", description = "部门编号", example = "1024", required = true) - DeptRespDTO getDept(@RequestParam("id") Long id); + CommonResult getDept(@RequestParam("id") Long id); @GetMapping(PREFIX + "/list") @Operation(summary = "获得部门信息数组") @Parameter(name = "ids", description = "部门编号数组", example = "1,2", required = true) - List getDeptList(@RequestParam("ids") Collection ids); + CommonResult> getDeptList(@RequestParam("ids") Collection ids); @GetMapping(PREFIX + "/valid") @Operation(summary = "校验部门是否合法") @Parameter(name = "ids", description = "部门编号数组", example = "1,2", required = true) - void validateDeptList(@RequestParam("ids") Collection ids); + CommonResult validateDeptList(@RequestParam("ids") Collection ids); /** * 获得指定编号的部门 Map @@ -43,13 +43,13 @@ public interface DeptApi { * @return 部门 Map */ default Map getDeptMap(Collection ids) { - List list = getDeptList(ids); + List list = getDeptList(ids).getCheckedData(); return CollectionUtils.convertMap(list, DeptRespDTO::getId); } @GetMapping(PREFIX + "/list-child") @Operation(summary = "获得指定部门的所有子部门") @Parameter(name = "id", description = "部门编号", example = "1024", required = true) - List getChildDeptList(@RequestParam("id") Long id); + CommonResult> getChildDeptList(@RequestParam("id") Long id); } diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/user/AdminUserApi.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/user/AdminUserApi.java index 6794c8c86..dd85c25d3 100644 --- a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/user/AdminUserApi.java +++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/user/AdminUserApi.java @@ -1,6 +1,7 @@ package cn.iocoder.yudao.module.system.api.user; import cn.hutool.core.convert.Convert; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; import cn.iocoder.yudao.module.system.enums.ApiConstants; @@ -31,32 +32,32 @@ public interface AdminUserApi extends AutoTransable { @GetMapping(PREFIX + "/get") @Operation(summary = "通过用户 ID 查询用户") @Parameter(name = "id", description = "用户编号", example = "1", required = true) - AdminUserRespDTO getUser(@RequestParam("id") Long id); + CommonResult getUser(@RequestParam("id") Long id); @GetMapping(PREFIX + "/list-by-subordinate") @Operation(summary = "通过用户 ID 查询用户下属") @Parameter(name = "id", description = "用户编号", example = "1", required = true) - List getUserListBySubordinate(@RequestParam("id") Long id); + CommonResult> getUserListBySubordinate(@RequestParam("id") Long id); @GetMapping(PREFIX + "/list") @Operation(summary = "通过用户 ID 查询用户们") @Parameter(name = "ids", description = "部门编号数组", example = "1,2", required = true) - List getUserList(@RequestParam("ids") Collection ids); + CommonResult> getUserList(@RequestParam("ids") Collection ids); @GetMapping(PREFIX + "/list-by-dept-id") @Operation(summary = "获得指定部门的用户数组") @Parameter(name = "deptIds", description = "部门编号数组", example = "1,2", required = true) - List getUserListByDeptIds(@RequestParam("deptIds") Collection deptIds); + CommonResult> getUserListByDeptIds(@RequestParam("deptIds") Collection deptIds); @GetMapping(PREFIX + "/list-by-post-id") @Operation(summary = "获得指定岗位的用户数组") @Parameter(name = "postIds", description = "岗位编号数组", example = "2,3", required = true) - List getUserListByPostIds(@RequestParam("postIds") Collection postIds); + CommonResult> getUserListByPostIds(@RequestParam("postIds") Collection postIds); @GetMapping(PREFIX + "/list-by-nickname") @Operation(summary = "根据昵称模糊搜索用户") @Parameter(name = "nickname", description = "昵称关键词", example = "芋道", required = true) - List getUserListByNickname(@RequestParam("nickname") String nickname); + CommonResult> getUserListByNickname(@RequestParam("nickname") String nickname); /** * 获得用户 Map @@ -65,7 +66,7 @@ public interface AdminUserApi extends AutoTransable { * @return 用户 Map */ default Map getUserMap(Collection ids) { - List users = getUserList(ids); + List users = getUserList(ids).getCheckedData(); return CollectionUtils.convertMap(users, AdminUserRespDTO::getId); } @@ -77,24 +78,24 @@ public interface AdminUserApi extends AutoTransable { * @param id 用户编号 */ default void validateUser(Long id) { - validateUserList(Collections.singleton(id)); + validateUserList(Collections.singleton(id)).checkError(); } @GetMapping(PREFIX + "/valid") @Operation(summary = "校验用户们是否有效") @Parameter(name = "ids", description = "用户编号数组", example = "3,5", required = true) - void validateUserList(@RequestParam("ids") Collection ids); + CommonResult validateUserList(@RequestParam("ids") Collection ids); @Override @FeignIgnore default List selectByIds(List ids) { - return getUserList(Convert.toList(Long.class, ids)); + return getUserList(Convert.toList(Long.class, ids)).getCheckedData(); } @Override @FeignIgnore default AdminUserRespDTO selectById(Object id) { - return getUser(Convert.toLong(id)); + return getUser(Convert.toLong(id)).getCheckedData(); } } diff --git a/yudao-module-system/yudao-module-system-server/src/main/java/cn/iocoder/yudao/module/system/api/dept/DeptApiImpl.java b/yudao-module-system/yudao-module-system-server/src/main/java/cn/iocoder/yudao/module/system/api/dept/DeptApiImpl.java index 1fd87ffb5..7bae3434a 100644 --- a/yudao-module-system/yudao-module-system-server/src/main/java/cn/iocoder/yudao/module/system/api/dept/DeptApiImpl.java +++ b/yudao-module-system/yudao-module-system-server/src/main/java/cn/iocoder/yudao/module/system/api/dept/DeptApiImpl.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.system.api.dept; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO; @@ -11,6 +12,8 @@ import jakarta.annotation.Resource; import java.util.Collection; import java.util.List; +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + @RestController // 提供 RESTful API 接口,给 Feign 调用 @Validated public class DeptApiImpl implements DeptApi { @@ -19,26 +22,27 @@ public class DeptApiImpl implements DeptApi { private DeptService deptService; @Override - public DeptRespDTO getDept(Long id) { + public CommonResult getDept(Long id) { DeptDO dept = deptService.getDept(id); - return BeanUtils.toBean(dept, DeptRespDTO.class); + return success(BeanUtils.toBean(dept, DeptRespDTO.class)); } @Override - public List getDeptList(Collection ids) { + public CommonResult> getDeptList(Collection ids) { List depts = deptService.getDeptList(ids); - return BeanUtils.toBean(depts, DeptRespDTO.class); + return success(BeanUtils.toBean(depts, DeptRespDTO.class)); } @Override - public void validateDeptList(Collection ids) { + public CommonResult validateDeptList(Collection ids) { deptService.validateDeptList(ids); + return success(true); } @Override - public List getChildDeptList(Long id) { + public CommonResult> getChildDeptList(Long id) { List depts = deptService.getChildDeptList(id); - return BeanUtils.toBean(depts, DeptRespDTO.class); + return success(BeanUtils.toBean(depts, DeptRespDTO.class)); } } diff --git a/yudao-module-system/yudao-module-system-server/src/main/java/cn/iocoder/yudao/module/system/api/user/AdminUserApiImpl.java b/yudao-module-system/yudao-module-system-server/src/main/java/cn/iocoder/yudao/module/system/api/user/AdminUserApiImpl.java index 4e22dae82..b57744d83 100644 --- a/yudao-module-system/yudao-module-system-server/src/main/java/cn/iocoder/yudao/module/system/api/user/AdminUserApiImpl.java +++ b/yudao-module-system/yudao-module-system-server/src/main/java/cn/iocoder/yudao/module/system/api/user/AdminUserApiImpl.java @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.system.api.user; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.ObjUtil; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import cn.iocoder.yudao.framework.datapermission.core.annotation.DataPermission; import cn.iocoder.yudao.framework.datapermission.core.util.DataPermissionUtils; @@ -19,6 +20,7 @@ import java.util.Collection; import java.util.Collections; import java.util.List; +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; @RestController // 提供 RESTful API 接口,给 Feign 调用 @@ -32,25 +34,25 @@ public class AdminUserApiImpl implements AdminUserApi { @Override @DataPermission(enable = false) // 忽略数据权限,避免因为过滤,导致无法查询用户。类似:https://github.com/YunaiV/ruoyi-vue-pro/issues/1051 - public AdminUserRespDTO getUser(Long id) { + public CommonResult getUser(Long id) { AdminUserDO user = userService.getUser(id); - return BeanUtils.toBean(user, AdminUserRespDTO.class); + return success(BeanUtils.toBean(user, AdminUserRespDTO.class)); } @Override - public List getUserListBySubordinate(Long id) { + public CommonResult> getUserListBySubordinate(Long id) { // 1.1 获取用户负责的部门 AdminUserDO user = userService.getUser(id); if (user == null) { - return Collections.emptyList(); + return success(Collections.emptyList()); } ArrayList deptIds = new ArrayList<>(); DeptDO dept = deptService.getDept(user.getDeptId()); if (dept == null) { - return Collections.emptyList(); + return success(Collections.emptyList()); } if (ObjUtil.notEqual(dept.getLeaderUserId(), id)) { // 校验为负责人 - return Collections.emptyList(); + return success(Collections.emptyList()); } deptIds.add(dept.getId()); // 1.2 获取所有子部门 @@ -62,38 +64,39 @@ public class AdminUserApiImpl implements AdminUserApi { // 2. 获取部门对应的用户信息 List users = userService.getUserListByDeptIds(deptIds); users.removeIf(item -> ObjUtil.equal(item.getId(), id)); // 排除自己 - return BeanUtils.toBean(users, AdminUserRespDTO.class); + return success(BeanUtils.toBean(users, AdminUserRespDTO.class)); } @Override - public List getUserList(Collection ids) { - return DataPermissionUtils.executeIgnore(() -> { // 禁用数据权限。原因是,一般基于指定 id 的 API 查询,都是数据拼接为主 + public CommonResult> getUserList(Collection ids) { + return success(DataPermissionUtils.executeIgnore(() -> { // 禁用数据权限。原因是,一般基于指定 id 的 API 查询,都是数据拼接为主 List users = userService.getUserList(ids); return BeanUtils.toBean(users, AdminUserRespDTO.class); - }); + })); } @Override - public List getUserListByDeptIds(Collection deptIds) { + public CommonResult> getUserListByDeptIds(Collection deptIds) { List users = userService.getUserListByDeptIds(deptIds); - return BeanUtils.toBean(users, AdminUserRespDTO.class); + return success(BeanUtils.toBean(users, AdminUserRespDTO.class)); } @Override - public List getUserListByPostIds(Collection postIds) { + public CommonResult> getUserListByPostIds(Collection postIds) { List users = userService.getUserListByPostIds(postIds); - return BeanUtils.toBean(users, AdminUserRespDTO.class); + return success(BeanUtils.toBean(users, AdminUserRespDTO.class)); } @Override - public List getUserListByNickname(String nickname) { + public CommonResult> getUserListByNickname(String nickname) { List users = userService.getUserListByNickname(nickname); - return BeanUtils.toBean(users, AdminUserRespDTO.class); + return success(BeanUtils.toBean(users, AdminUserRespDTO.class)); } @Override - public void validateUserList(Collection ids) { + public CommonResult validateUserList(Collection ids) { userService.validateUserList(ids); + return success(true); } } diff --git a/yudao-module-system/yudao-module-system-server/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImpl.java b/yudao-module-system/yudao-module-system-server/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImpl.java index c2840b887..f6868eca9 100644 --- a/yudao-module-system/yudao-module-system-server/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImpl.java +++ b/yudao-module-system/yudao-module-system-server/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImpl.java @@ -126,7 +126,7 @@ public class AdminUserServiceImpl implements AdminUserService { @Override public Long registerUser(AuthRegisterReqVO registerReqVO) { // 1.1 校验是否开启注册 - if (ObjUtil.notEqual(configApi.getConfigValueByKey(USER_REGISTER_ENABLED_KEY), "true")) { + if (ObjUtil.notEqual(configApi.getConfigValueByKey(USER_REGISTER_ENABLED_KEY).getCheckedData(), "true")) { throw exception(USER_REGISTER_DISABLED); } // 1.2 校验账户配合 @@ -509,7 +509,7 @@ public class AdminUserServiceImpl implements AdminUserService { throw exception(USER_IMPORT_LIST_IS_EMPTY); } // 1.2 初始化密码不能为空 - String initPassword = configApi.getConfigValueByKey(USER_INIT_PASSWORD_KEY); + String initPassword = configApi.getConfigValueByKey(USER_INIT_PASSWORD_KEY).getCheckedData(); if (StrUtil.isEmpty(initPassword)) { throw exception(USER_IMPORT_INIT_PASSWORD); } diff --git a/yudao-module-system/yudao-module-system-server/src/test/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImplTest.java b/yudao-module-system/yudao-module-system-server/src/test/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImplTest.java index 68c85103a..a0f169163 100644 --- a/yudao-module-system/yudao-module-system-server/src/test/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImplTest.java +++ b/yudao-module-system/yudao-module-system-server/src/test/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImplTest.java @@ -43,6 +43,7 @@ import java.util.Map; import java.util.function.Consumer; import static cn.hutool.core.util.RandomUtil.randomEle; +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.common.util.collection.SetUtils.asSet; import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime; @@ -92,7 +93,7 @@ public class AdminUserServiceImplTest extends BaseDbUnitTest { @BeforeEach public void before() { // mock 初始化密码 - when(configApi.getConfigValueByKey(USER_INIT_PASSWORD_KEY)).thenReturn("yudaoyuanma"); + when(configApi.getConfigValueByKey(USER_INIT_PASSWORD_KEY)).thenReturn(success("yudaoyuanma")); } @Test