From 42a7552b9c8603aeab7f0785eb05270dfbeb0bd3 Mon Sep 17 00:00:00 2001
From: zxl <763096477@qq.com>
Date: 星期日, 02 三月 2025 10:16:20 +0800
Subject: [PATCH] Merge branch 'master' into dev
---
system/src/main/java/com/ycl/system/service/impl/SysDeptServiceImpl.java | 64 ++++++++++++++++++++-----------
1 files changed, 41 insertions(+), 23 deletions(-)
diff --git a/system/src/main/java/com/ycl/system/service/impl/SysDeptServiceImpl.java b/system/src/main/java/com/ycl/system/service/impl/SysDeptServiceImpl.java
index b24b1ea..af26005 100644
--- a/system/src/main/java/com/ycl/system/service/impl/SysDeptServiceImpl.java
+++ b/system/src/main/java/com/ycl/system/service/impl/SysDeptServiceImpl.java
@@ -6,6 +6,7 @@
import com.ycl.common.base.Result;
import com.ycl.common.core.domain.StringTreeSelect;
import com.ycl.system.domain.base.BaseSelect;
+import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ycl.common.annotation.DataScope;
@@ -29,13 +30,12 @@
* @author ycl
*/
@Service
+@RequiredArgsConstructor
public class SysDeptServiceImpl implements ISysDeptService
{
- @Autowired
- private SysDeptMapper deptMapper;
- @Autowired
- private SysRoleMapper roleMapper;
+ private final SysDeptMapper deptMapper;
+ private final SysRoleMapper roleMapper;
/**
* 鏌ヨ閮ㄩ棬绠$悊鏁版嵁
@@ -48,6 +48,11 @@
public List<SysDept> selectDeptList(SysDept dept)
{
return deptMapper.selectDeptList(dept);
+ }
+
+ @Override
+ public List<SysDept> selectDeptListNoAuth(SysDept dept) {
+ return deptMapper.selectDeptListNoAuth(dept);
}
/**
@@ -172,6 +177,11 @@
return deptMapper.selectDeptById(deptId);
}
+ @Override
+ public List<SysDept> selectDeptByIds(List<Long> deptIds) {
+ return deptMapper.selectDeptByIds(deptIds);
+ }
+
/**
* 鏍规嵁ID鏌ヨ鎵�鏈夊瓙閮ㄩ棬锛堟甯哥姸鎬侊級
*
@@ -257,13 +267,18 @@
@Override
public int insertDept(SysDept dept)
{
- SysDept info = deptMapper.selectDeptById(dept.getParentId());
- // 濡傛灉鐖惰妭鐐逛笉涓烘甯哥姸鎬�,鍒欎笉鍏佽鏂板瀛愯妭鐐�
- if (!UserConstants.DEPT_NORMAL.equals(info.getStatus()))
- {
- throw new ServiceException("閮ㄩ棬鍋滅敤锛屼笉鍏佽鏂板");
+ if (Objects.nonNull(dept.getParentId())) {
+ SysDept info = deptMapper.selectDeptById(dept.getParentId());
+ // 濡傛灉鐖惰妭鐐逛笉涓烘甯哥姸鎬�,鍒欎笉鍏佽鏂板瀛愯妭鐐�
+ if (!UserConstants.DEPT_NORMAL.equals(info.getStatus()))
+ {
+ throw new ServiceException("涓婄骇閮ㄩ棬宸插仠鐢紝涓嶅厑璁告柊澧炰笅绾ч儴闂�");
+ }
+ dept.setAncestors(info.getAncestors() + "," + dept.getParentId());
+ } else {
+ dept.setParentId(0L);
+ dept.setAncestors("");
}
- dept.setAncestors(info.getAncestors() + "," + dept.getParentId());
return deptMapper.insertDept(dept);
}
@@ -276,22 +291,23 @@
@Override
public int updateDept(SysDept dept)
{
- SysDept newParentDept = deptMapper.selectDeptById(dept.getParentId());
SysDept oldDept = deptMapper.selectDeptById(dept.getDeptId());
- if (StringUtils.isNotNull(newParentDept) && StringUtils.isNotNull(oldDept))
- {
- String newAncestors = newParentDept.getAncestors() + "," + newParentDept.getDeptId();
- String oldAncestors = oldDept.getAncestors();
- dept.setAncestors(newAncestors);
- updateDeptChildren(dept.getDeptId(), newAncestors, oldAncestors);
+ if (Objects.isNull(oldDept)) {
+ throw new RuntimeException("淇敼閮ㄩ棬琚垹闄ゆ垨涓嶅瓨鍦�");
+ }
+ if (Objects.nonNull(dept.getParentId())) {
+ SysDept newParentDept = deptMapper.selectDeptById(dept.getParentId());
+ if (Objects.nonNull(newParentDept)) {
+ String newAncestors = newParentDept.getAncestors() + "," + newParentDept.getDeptId();
+ String oldAncestors = oldDept.getAncestors();
+ dept.setAncestors(newAncestors);
+ updateDeptChildren(dept.getDeptId(), newAncestors, oldAncestors);
+ }
+ } else {
+ dept.setParentId(0L);
+ dept.setAncestors("");
}
int result = deptMapper.updateDept(dept);
- if (UserConstants.DEPT_NORMAL.equals(dept.getStatus()) && StringUtils.isNotEmpty(dept.getAncestors())
- && !StringUtils.equals("0", dept.getAncestors()))
- {
- // 濡傛灉璇ラ儴闂ㄦ槸鍚敤鐘舵�侊紝鍒欏惎鐢ㄨ閮ㄩ棬鐨勬墍鏈変笂绾ч儴闂�
- updateParentDeptStatusNormal(dept);
- }
return result;
}
@@ -409,4 +425,6 @@
}).collect(Collectors.toList());
return list;
}
+
+
}
--
Gitblit v1.8.0