diff --git a/bonus-modules/bonus-system/src/main/java/com/bonus/system/mapper/SysDeptMapper.java b/bonus-modules/bonus-system/src/main/java/com/bonus/system/mapper/SysDeptMapper.java index 0649f6b..d95a10a 100644 --- a/bonus-modules/bonus-system/src/main/java/com/bonus/system/mapper/SysDeptMapper.java +++ b/bonus-modules/bonus-system/src/main/java/com/bonus/system/mapper/SysDeptMapper.java @@ -135,7 +135,7 @@ public interface SysDeptMapper */ public int updateDeptChildren(@Param("depts") List depts); - public int updateDeptFullName(@Param("depts") List depts); + public int updateDeptChildrenFullName(@Param("depts") List depts); /** * 删除部门管理信息 diff --git a/bonus-modules/bonus-system/src/main/java/com/bonus/system/service/impl/SysDeptServiceImpl.java b/bonus-modules/bonus-system/src/main/java/com/bonus/system/service/impl/SysDeptServiceImpl.java index 9f0ad1c..2245b67 100644 --- a/bonus-modules/bonus-system/src/main/java/com/bonus/system/service/impl/SysDeptServiceImpl.java +++ b/bonus-modules/bonus-system/src/main/java/com/bonus/system/service/impl/SysDeptServiceImpl.java @@ -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 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); +// } + /** * 删除部门管理信息 * diff --git a/bonus-modules/bonus-system/src/main/resources/mapper/system/SysDeptMapper.xml b/bonus-modules/bonus-system/src/main/resources/mapper/system/SysDeptMapper.xml index 7c6598a..9ca6b99 100644 --- a/bonus-modules/bonus-system/src/main/resources/mapper/system/SysDeptMapper.xml +++ b/bonus-modules/bonus-system/src/main/resources/mapper/system/SysDeptMapper.xml @@ -280,7 +280,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - + update sys_dept set dept_full_name =