dept full name
This commit is contained in:
parent
4726c003e6
commit
a703e153ca
|
|
@ -39,6 +39,11 @@ public class SysDept extends BaseEntity {
|
|||
*/
|
||||
private String deptName;
|
||||
|
||||
/**
|
||||
* 部门名称(全称)
|
||||
*/
|
||||
private String deptFullName;
|
||||
|
||||
/**
|
||||
* 显示顺序
|
||||
*/
|
||||
|
|
@ -308,6 +313,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 updateDeptChildrenFullName(@Param("depts") List<SysDept> depts);
|
||||
|
||||
/**
|
||||
* 删除部门管理信息
|
||||
*
|
||||
|
|
|
|||
|
|
@ -310,6 +310,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) {
|
||||
|
|
@ -327,6 +328,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,7 @@ public class SysDeptServiceImpl implements ISysDeptService
|
|||
dept.setAncestors(newAncestors);
|
||||
updateDeptChildren(dept.getDeptId(), newAncestors, oldAncestors);
|
||||
}
|
||||
updateDeptChildrenFullName(dept, newParentDept);
|
||||
int result = deptMapper.updateDept(dept);
|
||||
if (UserConstants.DEPT_NORMAL.equals(dept.getStatus()) && StringUtils.isNotEmpty(dept.getAncestors())
|
||||
&& !StringUtils.equals("0", dept.getAncestors()))
|
||||
|
|
@ -360,7 +363,7 @@ public class SysDeptServiceImpl implements ISysDeptService
|
|||
//判断是否需要修改公司管理员用户信息
|
||||
if (SecurityUtils.isAdmin(SecurityUtils.getUserId()) && systemConfig.isAddRootCompany() && Objects.nonNull(dept.getParentId()) && dept.getParentId().equals(0L)){
|
||||
SysUser companyAdminUser = dept.getSysUser();
|
||||
if (Objects.nonNull(companyAdminUser.getRoleId())) {
|
||||
if (Objects.nonNull(companyAdminUser) && Objects.nonNull(companyAdminUser.getRoleId())) {
|
||||
companyAdminUser.setUpdateBy(SecurityUtils.getUsername());
|
||||
companyAdminUser.setUpdateTime(DateUtils.getNowDate());
|
||||
roleMenuMapper.deleteRoleMenuByRoleId(companyAdminUser.getRoleId());
|
||||
|
|
@ -371,6 +374,38 @@ public class SysDeptServiceImpl implements ISysDeptService
|
|||
return result;
|
||||
}
|
||||
|
||||
public void updateDeptChildrenFullName(SysDept dept, SysDept newParentDept)
|
||||
{
|
||||
if (Objects.isNull(newParentDept)) {
|
||||
dept.setDeptFullName(dept.getDeptName());
|
||||
} else {
|
||||
dept.setDeptFullName(newParentDept.getDeptFullName() + "/" + dept.getDeptName());
|
||||
}
|
||||
List<SysDept> children = deptMapper.selectChildrenDeptById(dept.getDeptId());
|
||||
List<SysDept> fullDeptList = deptMapper.selectDeptList(new SysDept());
|
||||
for (SysDept innerDept : fullDeptList) {
|
||||
if (innerDept.getDeptId().equals(dept.getDeptId())) {
|
||||
innerDept.setDeptName(dept.getDeptName());
|
||||
}
|
||||
}
|
||||
for (SysDept child : children) {
|
||||
if (child.getDeptId().equals(dept.getDeptId())) {
|
||||
child.setDeptName(dept.getDeptName());
|
||||
}
|
||||
}
|
||||
for (SysDept child : children) {
|
||||
String deptAncestors = child.getAncestors();
|
||||
deptAncestors = deptAncestors.replaceFirst("0,", "").replaceAll(",", "/");
|
||||
for (SysDept innerDept : fullDeptList) {
|
||||
deptAncestors = deptAncestors.replace(String.valueOf(innerDept.getDeptId()), innerDept.getDeptName());
|
||||
}
|
||||
child.setDeptFullName(deptAncestors + "/" + child.getDeptName());
|
||||
}
|
||||
if (children.size() > 0) {
|
||||
deptMapper.updateDeptChildrenFullName(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,
|
||||
|
|
@ -82,6 +85,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</if>
|
||||
<if test="deptId != null and deptId != 0">
|
||||
AND dept_id = #{deptId}
|
||||
-- AND (d.dept_id = #{deptId} OR d.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE find_in_set(#{deptId},
|
||||
-- ancestors) ))
|
||||
</if>
|
||||
<if test="parentId != null and parentId != 0">
|
||||
AND parent_id = #{parentId}
|
||||
|
|
@ -192,6 +197,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>
|
||||
|
|
@ -213,6 +219,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>
|
||||
|
|
@ -238,6 +245,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>
|
||||
|
|
@ -273,6 +281,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</foreach>
|
||||
</update>
|
||||
|
||||
<update id="updateDeptChildrenFullName" 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=")">
|
||||
|
|
|
|||
|
|
@ -1,3 +1,11 @@
|
|||
-- 照片地址
|
||||
alter table sys_user
|
||||
add photo_url varchar(255) null comment '照片地址';
|
||||
add photo_url varchar(255) null comment '照片地址';
|
||||
|
||||
-- 生日
|
||||
alter table sys_user
|
||||
add birthday date null comment '生日';
|
||||
|
||||
-- 生日
|
||||
alter table sys_dept
|
||||
add dept_full_name date null comment '组织全称';
|
||||
Loading…
Reference in New Issue