From 25b96c4b510fa4c70511bc99a0e79483acbfd7d9 Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期二, 03 六月 2025 15:53:38 +0800
Subject: [PATCH] 代码提交

---
 ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml                  |    2 +-
 ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java |    8 +++++++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java
index ebf45c3..2525558 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java
@@ -21,6 +21,7 @@
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
+import org.springframework.util.ObjectUtils;
 
 import javax.validation.Validator;
 import java.util.*;
@@ -464,6 +465,9 @@
         if (!CollectionUtils.isEmpty(user.getDeptCodes())) {
             for (String deptCode : user.getDeptCodes()) {
                 SysDept sysDept = sysDeptMapper.selectDeptByCode(deptCode);
+                if(ObjectUtils.isEmpty(sysDept)){
+                    continue;
+                }
 
                 SysUserDept sysUserDept = new SysUserDept();
                 sysUserDept.setUserId(user.getUserId());
@@ -487,7 +491,9 @@
         if (!CollectionUtils.isEmpty(user.getWardCodes())) {
             for (String wardCode : user.getWardCodes()) {
                 SysDept sysDept = sysDeptMapper.selectDeptByCode(wardCode);
-
+                if(ObjectUtils.isEmpty(sysDept)){
+                    continue;
+                }
                 SysUserDept sysUserDept = new SysUserDept();
                 sysUserDept.setUserId(user.getUserId());
                 sysUserDept.setDeptCode(wardCode);
diff --git a/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml
index 6830b7a..e2b39f7 100644
--- a/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml
+++ b/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml
@@ -79,7 +79,7 @@
         </if>
         <!-- 鏁版嵁鑼冨洿杩囨护 -->
         ${params.dataScope}
-        order by d.parent_id, d.order_num
+        order by d.dept_type asc, d.parent_id, d.order_num
     </select>
 
     <select id="selectDeptListByRoleId" resultType="Long">

--
Gitblit v1.9.3