From 20d6d3d73682b6fd25e038f898651b6e138b501e Mon Sep 17 00:00:00 2001
From: RuoYi <yzz_ivy@163.com>
Date: 星期一, 16 八月 2021 15:58:56 +0800
Subject: [PATCH] 优化异常信息
---
src/main/java/com/ruoyi/project/system/service/impl/SysDeptServiceImpl.java | 21 +++++++++++----------
1 files changed, 11 insertions(+), 10 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 6dee354..aae3800 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
@@ -7,7 +7,8 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.common.constant.UserConstants;
-import com.ruoyi.common.exception.CustomException;
+import com.ruoyi.common.core.text.Convert;
+import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.framework.aspectj.lang.annotation.DataScope;
import com.ruoyi.framework.web.domain.TreeSelect;
@@ -183,7 +184,7 @@
// 濡傛灉鐖惰妭鐐逛笉涓烘甯哥姸鎬�,鍒欎笉鍏佽鏂板瀛愯妭鐐�
if (!UserConstants.DEPT_NORMAL.equals(info.getStatus()))
{
- throw new CustomException("閮ㄩ棬鍋滅敤锛屼笉鍏佽鏂板");
+ throw new ServiceException("閮ㄩ棬鍋滅敤锛屼笉鍏佽鏂板");
}
dept.setAncestors(info.getAncestors() + "," + dept.getParentId());
return deptMapper.insertDept(dept);
@@ -208,10 +209,11 @@
updateDeptChildren(dept.getDeptId(), newAncestors, oldAncestors);
}
int result = deptMapper.updateDept(dept);
- if (UserConstants.DEPT_NORMAL.equals(dept.getStatus()))
+ if (UserConstants.DEPT_NORMAL.equals(dept.getStatus()) && StringUtils.isNotEmpty(dept.getAncestors())
+ && !StringUtils.equals("0", dept.getAncestors()))
{
// 濡傛灉璇ラ儴闂ㄦ槸鍚敤鐘舵�侊紝鍒欏惎鐢ㄨ閮ㄩ棬鐨勬墍鏈変笂绾ч儴闂�
- updateParentDeptStatus(dept);
+ updateParentDeptStatusNormal(dept);
}
return result;
}
@@ -221,12 +223,11 @@
*
* @param dept 褰撳墠閮ㄩ棬
*/
- private void updateParentDeptStatus(SysDept dept)
+ private void updateParentDeptStatusNormal(SysDept dept)
{
- String updateBy = dept.getUpdateBy();
- dept = deptMapper.selectDeptById(dept.getDeptId());
- dept.setUpdateBy(updateBy);
- deptMapper.updateDeptStatus(dept);
+ String ancestors = dept.getAncestors();
+ Long[] deptIds = Convert.toLongArray(ancestors);
+ deptMapper.updateDeptStatusNormal(deptIds);
}
/**
@@ -241,7 +242,7 @@
List<SysDept> children = deptMapper.selectChildrenDeptById(deptId);
for (SysDept child : children)
{
- child.setAncestors(child.getAncestors().replace(oldAncestors, newAncestors));
+ child.setAncestors(child.getAncestors().replaceFirst(oldAncestors, newAncestors));
}
if (children.size() > 0)
{
--
Gitblit v1.9.3