dept_full_name
This commit is contained in:
parent
118ece6c6e
commit
cf56370e57
|
|
@ -42,6 +42,12 @@ public class SysDept extends BaseEntity {
|
|||
*/
|
||||
private String deptName;
|
||||
|
||||
/**
|
||||
* 全路径部门名称
|
||||
*/
|
||||
private String deptFullName;
|
||||
|
||||
|
||||
/**
|
||||
* 显示顺序
|
||||
*/
|
||||
|
|
@ -312,6 +318,14 @@ public class SysDept extends BaseEntity {
|
|||
this.deptName = deptName;
|
||||
}
|
||||
|
||||
public String getDeptFullName() {
|
||||
return deptFullName;
|
||||
}
|
||||
|
||||
public void setDeptFullName(String deptFullName) {
|
||||
this.deptFullName = deptFullName;
|
||||
}
|
||||
|
||||
@NotNull(message = "显示顺序不能为空")
|
||||
public Integer getOrderNum() {
|
||||
return orderNum;
|
||||
|
|
|
|||
|
|
@ -135,6 +135,8 @@ public interface SysDeptMapper
|
|||
*/
|
||||
public int updateDeptChildren(@Param("depts") List<SysDept> depts);
|
||||
|
||||
public int updateDeptFullName(@Param("depts") List<SysDept> depts);
|
||||
|
||||
/**
|
||||
* 删除部门管理信息
|
||||
*
|
||||
|
|
|
|||
|
|
@ -311,6 +311,7 @@ public class SysDeptServiceImpl implements ISysDeptService
|
|||
if (dept.getParentId() == null){
|
||||
dept.setParentId(0L);
|
||||
dept.setAncestors("0");
|
||||
dept.setDeptFullName(dept.getDeptName());
|
||||
dept.setStatus("0");//默认启用
|
||||
int result = deptMapper.insertDept(dept);
|
||||
if (SecurityUtils.isAdmin(SecurityUtils.getUserId()) && systemConfig.isAddRootCompany() && result > 0) {
|
||||
|
|
@ -328,6 +329,7 @@ public class SysDeptServiceImpl implements ISysDeptService
|
|||
throw new ServiceException("部门停用,不允许新增");
|
||||
}
|
||||
dept.setAncestors(info.getAncestors() + "," + dept.getParentId());
|
||||
dept.setDeptFullName(info.getDeptFullName() + "/" + dept.getDeptName());
|
||||
return deptMapper.insertDept(dept);
|
||||
}
|
||||
}
|
||||
|
|
@ -350,6 +352,10 @@ public class SysDeptServiceImpl implements ISysDeptService
|
|||
String oldAncestors = oldDept.getAncestors();
|
||||
dept.setAncestors(newAncestors);
|
||||
updateDeptChildren(dept.getDeptId(), newAncestors, oldAncestors);
|
||||
String newDeptFullNames = newParentDept.getDeptFullName() + "/" + dept.getDeptName();
|
||||
String oldDeptFullNames = oldDept.getDeptFullName();
|
||||
dept.setDeptFullName(newDeptFullNames);
|
||||
updateDeptFullName(dept.getDeptId(), newDeptFullNames, oldDeptFullNames);
|
||||
}
|
||||
int result = deptMapper.updateDept(dept);
|
||||
if (UserConstants.DEPT_NORMAL.equals(dept.getStatus()) && StringUtils.isNotEmpty(dept.getAncestors())
|
||||
|
|
@ -404,6 +410,19 @@ public class SysDeptServiceImpl implements ISysDeptService
|
|||
}
|
||||
}
|
||||
|
||||
public void updateDeptFullName(Long deptId, String newFullNames, String oldFullNames)
|
||||
{
|
||||
List<SysDept> children = deptMapper.selectChildrenDeptById(deptId);
|
||||
for (SysDept child : children)
|
||||
{
|
||||
child.setDeptFullName(child.getDeptFullName().replaceFirst(oldFullNames, newFullNames));
|
||||
}
|
||||
if (children.size() > 0)
|
||||
{
|
||||
deptMapper.updateDeptFullName(children);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除部门管理信息
|
||||
*
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<result property="parentId" column="parent_id" />
|
||||
<result property="ancestors" column="ancestors" />
|
||||
<result property="deptName" column="dept_name" />
|
||||
<result property="deptFullName" column="dept_full_name" />
|
||||
<result property="orderNum" column="order_num" />
|
||||
<result property="leader" column="leader" />
|
||||
<result property="phone" column="phone" />
|
||||
|
|
@ -37,6 +38,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
d.parent_id,
|
||||
d.ancestors,
|
||||
d.dept_name,
|
||||
d.dept_full_name,
|
||||
d.order_num,
|
||||
d.leader,
|
||||
d.phone,
|
||||
|
|
@ -53,6 +55,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
d.parent_id,
|
||||
d.ancestors,
|
||||
d.dept_name,
|
||||
d.dept_full_name,
|
||||
d.order_num,
|
||||
d.leader,
|
||||
d.phone,
|
||||
|
|
@ -193,6 +196,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="deptId != null and deptId != 0">dept_id,</if>
|
||||
<if test="parentId != null and parentId != 0">parent_id,</if>
|
||||
<if test="deptName != null and deptName != ''">dept_name,</if>
|
||||
<if test="deptFullName != null and deptFullName != ''">dept_full_name,</if>
|
||||
<if test="ancestors != null and ancestors != ''">ancestors,</if>
|
||||
<if test="orderNum != null">order_num,</if>
|
||||
<if test="leader != null and leader != ''">leader,</if>
|
||||
|
|
@ -214,6 +218,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="deptId != null and deptId != 0">#{deptId},</if>
|
||||
<if test="parentId != null and parentId != 0">#{parentId},</if>
|
||||
<if test="deptName != null and deptName != ''">#{deptName},</if>
|
||||
<if test="deptFullName != null and deptFullName != ''">#{deptFullName},</if>
|
||||
<if test="ancestors != null and ancestors != ''">#{ancestors},</if>
|
||||
<if test="orderNum != null">#{orderNum},</if>
|
||||
<if test="leader != null and leader != ''">#{leader},</if>
|
||||
|
|
@ -239,6 +244,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<set>
|
||||
<if test="parentId != null and parentId != 0">parent_id = #{parentId},</if>
|
||||
<if test="deptName != null and deptName != ''">dept_name = #{deptName},</if>
|
||||
<if test="deptFullName != null and deptFullName != ''">dept_full_name = #{deptFullName},</if>
|
||||
<if test="ancestors != null and ancestors != ''">ancestors = #{ancestors},</if>
|
||||
<if test="orderNum != null">order_num = #{orderNum},</if>
|
||||
<if test="leader != null">leader = #{leader},</if>
|
||||
|
|
@ -274,6 +280,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</foreach>
|
||||
</update>
|
||||
|
||||
<update id="updateDeptFullName" parameterType="java.util.List">
|
||||
update sys_dept set dept_full_name =
|
||||
<foreach collection="depts" item="item" index="index"
|
||||
separator=" " open="case dept_id" close="end">
|
||||
when #{item.deptId} then #{item.deptFullName}
|
||||
</foreach>
|
||||
where dept_id in
|
||||
<foreach collection="depts" item="item" index="index"
|
||||
separator="," open="(" close=")">
|
||||
#{item.deptId}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<update id="updateDeptStatusNormal" parameterType="Long">
|
||||
update sys_dept set status = '0' where dept_id in
|
||||
<foreach collection="array" item="deptId" open="(" separator="," close=")">
|
||||
|
|
|
|||
Loading…
Reference in New Issue