Browse Source

[fix]字符串替换bug,replace会从前往后替换所有target,"0,104".replace("0","0,1")的结果是"0,1,10,14"。

此处代码的本意是替换第一个符合的target字符串,应使用replaceFirst
pull/289/head
zhengxl5566 4 years ago
parent
commit
6a14c954e1
  1. 2
      ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java

2
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java

@ -259,7 +259,7 @@ public class SysDeptServiceImpl implements ISysDeptService
List<SysDept> children = deptMapper.selectChildrenDeptById(deptId);
for (SysDept child : children)
{
child.setAncestors(child.getAncestors().replace(oldAncestors, newAncestors));
child.setAncestors(child.getAncestors().replaceFirst(oldAncestors, newAncestors));
}
if (children.size() > 0)
{

Loading…
Cancel
Save