dept_full_name

This commit is contained in:
sxu 2025-03-28 15:13:08 +08:00
parent cf56370e57
commit ff815314ca
3 changed files with 18 additions and 7 deletions

View File

@ -135,7 +135,7 @@ public interface SysDeptMapper
*/
public int updateDeptChildren(@Param("depts") List<SysDept> depts);
public int updateDeptFullName(@Param("depts") List<SysDept> depts);
public int updateDeptChildrenFullName(@Param("depts") List<SysDept> depts);
/**
* 删除部门管理信息

View File

@ -4,7 +4,6 @@ import java.util.*;
import java.util.stream.Collectors;
import com.bonus.common.core.utils.DateUtils;
import com.bonus.common.core.utils.id.Id;
import com.bonus.common.core.web.domain.BaseEntity;
import com.bonus.config.SystemConfig;
import com.bonus.system.api.domain.*;
@ -355,7 +354,7 @@ public class SysDeptServiceImpl implements ISysDeptService
String newDeptFullNames = newParentDept.getDeptFullName() + "/" + dept.getDeptName();
String oldDeptFullNames = oldDept.getDeptFullName();
dept.setDeptFullName(newDeptFullNames);
updateDeptFullName(dept.getDeptId(), newDeptFullNames, oldDeptFullNames);
updateDeptChildrenFullName(dept.getDeptId(), newDeptFullNames, oldDeptFullNames);
}
int result = deptMapper.updateDept(dept);
if (UserConstants.DEPT_NORMAL.equals(dept.getStatus()) && StringUtils.isNotEmpty(dept.getAncestors())
@ -367,7 +366,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());
@ -410,7 +409,7 @@ public class SysDeptServiceImpl implements ISysDeptService
}
}
public void updateDeptFullName(Long deptId, String newFullNames, String oldFullNames)
public void updateDeptChildrenFullName(Long deptId, String newFullNames, String oldFullNames)
{
List<SysDept> children = deptMapper.selectChildrenDeptById(deptId);
for (SysDept child : children)
@ -419,10 +418,22 @@ public class SysDeptServiceImpl implements ISysDeptService
}
if (children.size() > 0)
{
deptMapper.updateDeptFullName(children);
deptMapper.updateDeptChildrenFullName(children);
}
}
// public static void main(String[] args) {
// String original = "Hello world, hello Java, hello programming";
// String replaced = original.replaceFirst("Hello", "hi");
// System.out.println(replaced);
//
// String original2 = "安徽博创信息科技有限公司/新分公司2/其他/other1";
// String oldFullNames = "安徽博创信息科技有限公司/新分公司2";
// String newFullNames = "安徽博创信息科技有限公司/新分公司3";
// String replaced2 = original2.replaceFirst(oldFullNames, newFullNames);
// System.out.println(replaced2);
// }
/**
* 删除部门管理信息
*

View File

@ -280,7 +280,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach>
</update>
<update id="updateDeptFullName" parameterType="java.util.List">
<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">