From 17a7a0c0df3dbc3e6225dddb55f6332deccdb201 Mon Sep 17 00:00:00 2001
From: liding <756868258@qq.com>
Date: 星期三, 03 六月 2026 11:38:30 +0800
Subject: [PATCH] 浪潮部署

---
 src/main/java/com/ruoyi/project/system/service/impl/SysDeptServiceImpl.java |   96 +++++++++++++++++++++++++++++------------------
 1 files changed, 59 insertions(+), 37 deletions(-)

diff --git a/src/main/java/com/ruoyi/project/system/service/impl/SysDeptServiceImpl.java b/src/main/java/com/ruoyi/project/system/service/impl/SysDeptServiceImpl.java
index 25899a3..fe1324b 100644
--- a/src/main/java/com/ruoyi/project/system/service/impl/SysDeptServiceImpl.java
+++ b/src/main/java/com/ruoyi/project/system/service/impl/SysDeptServiceImpl.java
@@ -1,11 +1,5 @@
 package com.ruoyi.project.system.service.impl;
 
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.stream.Collectors;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
 import com.ruoyi.common.constant.UserConstants;
 import com.ruoyi.common.core.text.Convert;
 import com.ruoyi.common.exception.ServiceException;
@@ -20,24 +14,29 @@
 import com.ruoyi.project.system.mapper.SysDeptMapper;
 import com.ruoyi.project.system.mapper.SysRoleMapper;
 import com.ruoyi.project.system.service.ISysDeptService;
+import lombok.RequiredArgsConstructor;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * 閮ㄩ棬绠$悊 鏈嶅姟瀹炵幇
- * 
+ *
  * @author ruoyi
  */
 @Service
+@RequiredArgsConstructor
 public class SysDeptServiceImpl implements ISysDeptService
 {
-    @Autowired
-    private SysDeptMapper deptMapper;
-    
-    @Autowired
-    private SysRoleMapper roleMapper;
+    private final SysDeptMapper deptMapper;
+    private final SysRoleMapper roleMapper;
 
     /**
      * 鏌ヨ閮ㄩ棬绠$悊鏁版嵁
-     * 
+     *
      * @param dept 閮ㄩ棬淇℃伅
      * @return 閮ㄩ棬淇℃伅闆嗗悎
      */
@@ -49,8 +48,21 @@
     }
 
     /**
+     * 鏌ヨ閮ㄩ棬鏍戠粨鏋勪俊鎭�
+     *
+     * @param dept 閮ㄩ棬淇℃伅
+     * @return 閮ㄩ棬鏍戜俊鎭泦鍚�
+     */
+    @Override
+    public List<TreeSelect> selectDeptTreeList(SysDept dept)
+    {
+        List<SysDept> depts = SpringUtils.getAopProxy(this).selectDeptList(dept);
+        return buildDeptTreeSelect(depts);
+    }
+
+    /**
      * 鏋勫缓鍓嶇鎵�闇�瑕佹爲缁撴瀯
-     * 
+     *
      * @param depts 閮ㄩ棬鍒楄〃
      * @return 鏍戠粨鏋勫垪琛�
      */
@@ -58,14 +70,9 @@
     public List<SysDept> buildDeptTree(List<SysDept> depts)
     {
         List<SysDept> returnList = new ArrayList<SysDept>();
-        List<Long> tempList = new ArrayList<Long>();
+        List<Long> tempList = depts.stream().map(SysDept::getDeptId).collect(Collectors.toList());
         for (SysDept dept : depts)
         {
-            tempList.add(dept.getDeptId());
-        }
-        for (Iterator<SysDept> iterator = depts.iterator(); iterator.hasNext();)
-        {
-            SysDept dept = (SysDept) iterator.next();
             // 濡傛灉鏄《绾ц妭鐐�, 閬嶅巻璇ョ埗鑺傜偣鐨勬墍鏈夊瓙鑺傜偣
             if (!tempList.contains(dept.getParentId()))
             {
@@ -82,7 +89,7 @@
 
     /**
      * 鏋勫缓鍓嶇鎵�闇�瑕佷笅鎷夋爲缁撴瀯
-     * 
+     *
      * @param depts 閮ㄩ棬鍒楄〃
      * @return 涓嬫媺鏍戠粨鏋勫垪琛�
      */
@@ -95,7 +102,7 @@
 
     /**
      * 鏍规嵁瑙掕壊ID鏌ヨ閮ㄩ棬鏍戜俊鎭�
-     * 
+     *
      * @param roleId 瑙掕壊ID
      * @return 閫変腑閮ㄩ棬鍒楄〃
      */
@@ -108,7 +115,7 @@
 
     /**
      * 鏍规嵁閮ㄩ棬ID鏌ヨ淇℃伅
-     * 
+     *
      * @param deptId 閮ㄩ棬ID
      * @return 閮ㄩ棬淇℃伅
      */
@@ -120,7 +127,7 @@
 
     /**
      * 鏍规嵁ID鏌ヨ鎵�鏈夊瓙閮ㄩ棬锛堟甯哥姸鎬侊級
-     * 
+     *
      * @param deptId 閮ㄩ棬ID
      * @return 瀛愰儴闂ㄦ暟
      */
@@ -132,7 +139,7 @@
 
     /**
      * 鏄惁瀛樺湪瀛愯妭鐐�
-     * 
+     *
      * @param deptId 閮ㄩ棬ID
      * @return 缁撴灉
      */
@@ -140,12 +147,12 @@
     public boolean hasChildByDeptId(Long deptId)
     {
         int result = deptMapper.hasChildByDeptId(deptId);
-        return result > 0 ? true : false;
+        return result > 0;
     }
 
     /**
      * 鏌ヨ閮ㄩ棬鏄惁瀛樺湪鐢ㄦ埛
-     * 
+     *
      * @param deptId 閮ㄩ棬ID
      * @return 缁撴灉 true 瀛樺湪 false 涓嶅瓨鍦�
      */
@@ -153,17 +160,17 @@
     public boolean checkDeptExistUser(Long deptId)
     {
         int result = deptMapper.checkDeptExistUser(deptId);
-        return result > 0 ? true : false;
+        return result > 0;
     }
 
     /**
      * 鏍¢獙閮ㄩ棬鍚嶇О鏄惁鍞竴
-     * 
+     *
      * @param dept 閮ㄩ棬淇℃伅
      * @return 缁撴灉
      */
     @Override
-    public String checkDeptNameUnique(SysDept dept)
+    public boolean checkDeptNameUnique(SysDept dept)
     {
         Long deptId = StringUtils.isNull(dept.getDeptId()) ? -1L : dept.getDeptId();
         SysDept info = deptMapper.checkDeptNameUnique(dept.getDeptName(), dept.getParentId());
@@ -176,13 +183,13 @@
 
     /**
      * 鏍¢獙閮ㄩ棬鏄惁鏈夋暟鎹潈闄�
-     * 
+     *
      * @param deptId 閮ㄩ棬id
      */
     @Override
     public void checkDeptDataScope(Long deptId)
     {
-        if (!SysUser.isAdmin(SecurityUtils.getUserId()))
+        if (!SysUser.isAdmin(SecurityUtils.getUserId()) && StringUtils.isNotNull(deptId))
         {
             SysDept dept = new SysDept();
             dept.setDeptId(deptId);
@@ -196,7 +203,7 @@
 
     /**
      * 鏂板淇濆瓨閮ㄩ棬淇℃伅
-     * 
+     *
      * @param dept 閮ㄩ棬淇℃伅
      * @return 缁撴灉
      */
@@ -215,7 +222,7 @@
 
     /**
      * 淇敼淇濆瓨閮ㄩ棬淇℃伅
-     * 
+     *
      * @param dept 閮ㄩ棬淇℃伅
      * @return 缁撴灉
      */
@@ -243,7 +250,7 @@
 
     /**
      * 淇敼璇ラ儴闂ㄧ殑鐖剁骇閮ㄩ棬鐘舵��
-     * 
+     *
      * @param dept 褰撳墠閮ㄩ棬
      */
     private void updateParentDeptStatusNormal(SysDept dept)
@@ -255,7 +262,7 @@
 
     /**
      * 淇敼瀛愬厓绱犲叧绯�
-     * 
+     *
      * @param deptId 琚慨鏀圭殑閮ㄩ棬ID
      * @param newAncestors 鏂扮殑鐖禝D闆嗗悎
      * @param oldAncestors 鏃х殑鐖禝D闆嗗悎
@@ -275,7 +282,7 @@
 
     /**
      * 鍒犻櫎閮ㄩ棬绠$悊淇℃伅
-     * 
+     *
      * @param deptId 閮ㄩ棬ID
      * @return 缁撴灉
      */
@@ -283,6 +290,16 @@
     public int deleteDeptById(Long deptId)
     {
         return deptMapper.deleteDeptById(deptId);
+    }
+
+    /**
+     * 鏌ヨ椤跺眰閮ㄩ棬id
+     * @param deptId
+     * @return
+     */
+    @Override
+    public Long maxLevelDeptId(Long deptId) {
+        return deptMapper.maxLevelDeptId(deptId);
     }
 
     /**
@@ -302,6 +319,11 @@
         }
     }
 
+    @Override
+    public SysDept selectDeptByDeptName(String deptName) {
+        return deptMapper.selectDeptByDeptName(deptName);
+    }
+
     /**
      * 寰楀埌瀛愯妭鐐瑰垪琛�
      */

--
Gitblit v1.9.3