From 37d4080b22325bd4ed476acd4f2e3a19f55ff52f Mon Sep 17 00:00:00 2001
From: RuoYi <yzz_ivy@163.com>
Date: 星期四, 10 六月 2021 15:38:53 +0800
Subject: [PATCH] 优化部门父级启用状态
---
src/main/java/com/ruoyi/project/system/service/impl/SysDeptServiceImpl.java | 12 ++++++------
src/main/java/com/ruoyi/project/system/mapper/SysDeptMapper.java | 6 +++---
src/main/resources/mybatis/system/SysDeptMapper.xml | 13 +++++--------
3 files changed, 14 insertions(+), 17 deletions(-)
diff --git a/src/main/java/com/ruoyi/project/system/mapper/SysDeptMapper.java b/src/main/java/com/ruoyi/project/system/mapper/SysDeptMapper.java
index b16a7fa..cb5c44b 100644
--- a/src/main/java/com/ruoyi/project/system/mapper/SysDeptMapper.java
+++ b/src/main/java/com/ruoyi/project/system/mapper/SysDeptMapper.java
@@ -94,11 +94,11 @@
public int updateDept(SysDept dept);
/**
- * 淇敼鎵�鍦ㄩ儴闂ㄧ殑鐖剁骇閮ㄩ棬鐘舵��
+ * 淇敼鎵�鍦ㄩ儴闂ㄦ甯哥姸鎬�
*
- * @param dept 閮ㄩ棬
+ * @param deptIds 閮ㄩ棬ID缁�
*/
- public void updateDeptStatus(SysDept dept);
+ public void updateDeptStatusNormal(Long[] deptIds);
/**
* 淇敼瀛愬厓绱犲叧绯�
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 566cf07..5dc8e74 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,6 +7,7 @@
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.CustomException;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.framework.aspectj.lang.annotation.DataScope;
@@ -211,7 +212,7 @@
if (UserConstants.DEPT_NORMAL.equals(dept.getStatus()))
{
// 濡傛灉璇ラ儴闂ㄦ槸鍚敤鐘舵�侊紝鍒欏惎鐢ㄨ閮ㄩ棬鐨勬墍鏈変笂绾ч儴闂�
- updateParentDeptStatus(dept);
+ updateParentDeptStatusNormal(dept);
}
return result;
}
@@ -221,12 +222,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);
}
/**
diff --git a/src/main/resources/mybatis/system/SysDeptMapper.xml b/src/main/resources/mybatis/system/SysDeptMapper.xml
index 78cbb06..9cbfb92 100644
--- a/src/main/resources/mybatis/system/SysDeptMapper.xml
+++ b/src/main/resources/mybatis/system/SysDeptMapper.xml
@@ -140,14 +140,11 @@
</foreach>
</update>
- <update id="updateDeptStatus" parameterType="SysDept">
- update sys_dept
- <set>
- <if test="status != null and status != ''">status = #{status},</if>
- <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
- update_time = sysdate()
- </set>
- where find_in_set(#{deptId}, ancestors)
+ <update id="updateDeptStatusNormal" parameterType="Long">
+ update sys_dept set status = '0' where dept_id in
+ <foreach collection="array" item="deptId" open="(" separator="," close=")">
+ #{deptId}
+ </foreach>
</update>
<delete id="deleteDeptById" parameterType="Long">
--
Gitblit v1.9.3