部门修改同步ancestor
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.ruoyi.project.system.dept.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.ruoyi.project.system.dept.domain.Dept;
|
||||
|
||||
/**
|
||||
@@ -65,6 +66,14 @@ public interface DeptMapper
|
||||
*/
|
||||
public int updateDept(Dept dept);
|
||||
|
||||
/**
|
||||
* 修改子元素关系
|
||||
*
|
||||
* @param depts 子元素
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateDeptChildren(@Param("depts") List<Dept> depts);
|
||||
|
||||
/**
|
||||
* 根据部门ID查询信息
|
||||
*
|
||||
|
@@ -135,11 +135,34 @@ public class DeptServiceImpl implements IDeptService
|
||||
public int updateDept(Dept dept)
|
||||
{
|
||||
Dept info = deptMapper.selectDeptById(dept.getParentId());
|
||||
String ancestors = info.getAncestors() + "," + dept.getParentId();
|
||||
dept.setUpdateBy(ShiroUtils.getLoginName());
|
||||
dept.setAncestors(info.getAncestors() + "," + dept.getParentId());
|
||||
dept.setAncestors(ancestors);
|
||||
updateDeptChildren(dept.getDeptId(), ancestors);
|
||||
return deptMapper.updateDept(dept);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改子元素关系
|
||||
*
|
||||
* @param deptId 部门ID
|
||||
* @param ancestors 元素列表
|
||||
*/
|
||||
public void updateDeptChildren(Long deptId, String ancestors)
|
||||
{
|
||||
Dept dept = new Dept();
|
||||
dept.setParentId(deptId);
|
||||
List<Dept> childrens = deptMapper.selectDeptList(dept);
|
||||
for (Dept children : childrens)
|
||||
{
|
||||
children.setAncestors(ancestors + "," + dept.getParentId());
|
||||
}
|
||||
if (childrens.size() > 0)
|
||||
{
|
||||
deptMapper.updateDeptChildren(childrens);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据部门ID查询信息
|
||||
*
|
||||
|
Reference in New Issue
Block a user