From d5503d0cbe5af548541777a179ee39126b209b36 Mon Sep 17 00:00:00 2001
From: xiangpei <xiangpei@timesnew.cn>
Date: 星期三, 05 三月 2025 12:36:43 +0800
Subject: [PATCH] 转办日志查询bug
---
system/src/main/java/com/ycl/system/service/impl/SysDeptServiceImpl.java | 72 ++++++++++++++++++++++++------------
1 files changed, 48 insertions(+), 24 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 679a8a3..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);
}
/**
@@ -64,8 +69,14 @@
}
@Override
+ public List<TreeSelect> deptTreeNoDataAuth(SysDept dept) {
+ List<SysDept> depts = deptMapper.selectDeptList(dept);;
+ return buildDeptTreeSelect(depts);
+ }
+
+ @Override
public List<StringTreeSelect> flowDeptTree(SysDept dept) {
- List<SysDept> depts = SpringUtils.getAopProxy(this).selectDeptList(dept);
+ List<SysDept> depts = deptMapper.selectDeptList(dept);
List<StringTreeSelect> list = depts.stream().map(item -> {
StringTreeSelect d = new StringTreeSelect();
d.setId("dept:" + item.getDeptId());
@@ -166,6 +177,11 @@
return deptMapper.selectDeptById(deptId);
}
+ @Override
+ public List<SysDept> selectDeptByIds(List<Long> deptIds) {
+ return deptMapper.selectDeptByIds(deptIds);
+ }
+
/**
* 鏍规嵁ID鏌ヨ鎵�鏈夊瓙閮ㄩ棬锛堟甯哥姸鎬侊級
*
@@ -251,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);
}
@@ -270,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;
}
@@ -403,4 +425,6 @@
}).collect(Collectors.toList());
return list;
}
+
+
}
--
Gitblit v1.8.0