From 093fc57beccecbf8d5d51d45edb3ae484e8f8ffd Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期五, 06 十一月 2026 16:32:52 +0800
Subject: [PATCH] fix(hrm/transfer): 调岗申请按所选员工创建并补齐校验提示
---
yudao-module-hrm/src/main/java/cn/iocoder/yudao/module/hrm/service/approval/HrmTransferApplicationServiceImpl.java | 33 +++++++++++++++++++++------------
1 files changed, 21 insertions(+), 12 deletions(-)
diff --git a/yudao-module-hrm/src/main/java/cn/iocoder/yudao/module/hrm/service/approval/HrmTransferApplicationServiceImpl.java b/yudao-module-hrm/src/main/java/cn/iocoder/yudao/module/hrm/service/approval/HrmTransferApplicationServiceImpl.java
index fb14bad..9482aed 100644
--- a/yudao-module-hrm/src/main/java/cn/iocoder/yudao/module/hrm/service/approval/HrmTransferApplicationServiceImpl.java
+++ b/yudao-module-hrm/src/main/java/cn/iocoder/yudao/module/hrm/service/approval/HrmTransferApplicationServiceImpl.java
@@ -2,8 +2,10 @@
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjUtil;
+import cn.iocoder.yudao.framework.common.exception.ServiceException;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
+import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.module.bpm.api.task.BpmProcessInstanceApi;
import cn.iocoder.yudao.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO;
import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessDefinitionInfoDO;
@@ -85,18 +87,25 @@
if (Objects.equals(createReqVO.getTargetPostId(), createReqVO.getCurrentPostId())) {
throw exception(TRANSFER_APPLICATION_SAME_POST);
}
- // 3. 鐢熸垚鐢宠鍗曞彿
- String no = generateUniqueNo();
- // 4. 璁剧疆鐢宠浜轰俊鎭�
- Long userId = createReqVO.getUserId();
- if (userId == null) {
- userId = getCurrentUserId();
- }
- AdminUserRespDTO user = adminUserApi.getUser(userId);
+ // 3. 纭畾琚皟宀楀憳宸ワ紙鏈寚瀹氭椂榛樿褰撳墠鐧诲綍鐢ㄦ埛锛�
+ Long userId = createReqVO.getUserId() != null ? createReqVO.getUserId() : getLoginUserId();
+ AdminUserRespDTO user = userId != null ? adminUserApi.getUser(userId) : null;
if (user == null) {
- userId = getCurrentUserId();
+ throw new ServiceException(TRANSFER_APPLICATION_APPLICANT_NOT_EXISTS.getCode(),
+ String.format("璋冨矖鐢宠澶辫触锛氭墍閫夊憳宸ユ湭鍏宠仈鏈夋晥鐨勭郴缁熻处鍙凤紙鐢ㄦ埛缂栧彿 %s锛夈�傝鍒般�屽憳宸ョ鐞嗐�嶇‘璁よ鍛樺伐宸茬粦瀹氳处鍙蜂笖璐﹀彿鏈仠鐢ㄥ悗閲嶆柊閫夋嫨銆�", userId));
}
- // 5. 鎻掑叆
+ // 4. 鏍¢獙鍘熼儴闂ㄣ�佸師宀椾綅锛堣〃瀛楁闈炵┖锛涘憳宸ユ。妗堢己澶辨椂缁欏嚭鍙墽琛屾彁绀猴紝閬垮厤鐩存帴鎶涙暟鎹簱寮傚父锛�
+ if (createReqVO.getCurrentDeptId() == null) {
+ throw new ServiceException(TRANSFER_APPLICATION_APPLICANT_DEPT_EMPTY.getCode(),
+ String.format("璋冨矖鐢宠澶辫触锛氬憳宸%s]鏈缃儴闂紝鏃犳硶纭畾鍘熼儴闂ㄣ�傝鍏堝埌銆屽憳宸ョ鐞嗐�嶇紪杈戣鍛樺伐妗f琛ュ叏閮ㄩ棬锛屽啀閲嶆柊鍙戣捣璋冨矖鐢宠銆�", user.getNickname()));
+ }
+ if (createReqVO.getCurrentPostId() == null) {
+ throw new ServiceException(TRANSFER_APPLICATION_APPLICANT_POST_EMPTY.getCode(),
+ String.format("璋冨矖鐢宠澶辫触锛氬憳宸%s]鏈缃矖浣嶏紝鏃犳硶纭畾鍘熷矖浣嶃�傝鍏堝埌銆屽憳宸ョ鐞嗐�嶇紪杈戣鍛樺伐妗f琛ュ叏宀椾綅锛屽啀閲嶆柊鍙戣捣璋冨矖鐢宠銆�", user.getNickname()));
+ }
+ // 5. 鐢熸垚鐢宠鍗曞彿
+ String no = generateUniqueNo();
+ // 6. 鎻掑叆
HrmTransferApplicationDO application = BeanUtils.toBean(createReqVO, HrmTransferApplicationDO.class);
application.setNo(no);
application.setUserId(userId);
@@ -107,8 +116,8 @@
return application.getId();
}
- private Long getCurrentUserId() {
- return 1L;
+ private Long getLoginUserId() {
+ return SecurityFrameworkUtils.getLoginUserId();
}
private String generateUniqueNo() {
--
Gitblit v1.9.3