mirror of https://gitee.com/xiaonuobase/snowy
【修复】更新菜单、机构等树时,父节点不能选择自己的子节点
parent
72094092b4
commit
7120afdf6b
|
@ -48,6 +48,7 @@ import com.cn.xiaonuo.sys.modular.menu.mapper.SysMenuMapper;
|
|||
import com.cn.xiaonuo.sys.modular.menu.node.MenuBaseTreeNode;
|
||||
import com.cn.xiaonuo.sys.modular.menu.param.SysMenuParam;
|
||||
import com.cn.xiaonuo.sys.modular.menu.service.SysMenuService;
|
||||
import com.cn.xiaonuo.sys.modular.org.enums.SysOrgExceptionEnum;
|
||||
import com.cn.xiaonuo.sys.modular.role.service.SysRoleMenuService;
|
||||
import com.cn.xiaonuo.sys.modular.user.entity.SysUser;
|
||||
import com.cn.xiaonuo.sys.modular.user.service.SysUserRoleService;
|
||||
|
@ -472,6 +473,14 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|||
if (sysMenuParam.getId().equals(sysMenuParam.getPid())) {
|
||||
throw new ServiceException(SysMenuExceptionEnum.PID_CANT_EQ_ID);
|
||||
}
|
||||
|
||||
// 如果是编辑,父id不能为自己的子节点
|
||||
List<Long> childIdListById = this.getChildIdListById(sysMenuParam.getId());
|
||||
if(ObjectUtil.isNotEmpty(childIdListById)) {
|
||||
if(childIdListById.contains(sysMenuParam.getPid())) {
|
||||
throw new ServiceException(SysMenuExceptionEnum.PID_CANT_EQ_CHILD_ID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Long id = sysMenuParam.getId();
|
||||
|
|
|
@ -272,6 +272,14 @@ public class SysOrgServiceImpl extends ServiceImpl<SysOrgMapper, SysOrg> impleme
|
|||
//不能修改状态,用修改状态接口修改状态
|
||||
sysOrg.setStatus(null);
|
||||
this.updateById(sysOrg);
|
||||
//将所有子的父id进行更新
|
||||
List<Long> childIdListById = this.getChildIdListById(sysOrg.getId());
|
||||
childIdListById.forEach(subChildId -> {
|
||||
SysOrg child = this.getById(subChildId);
|
||||
SysOrgParam childParam = new SysOrgParam();
|
||||
BeanUtil.copyProperties(child, childParam);
|
||||
this.edit(childParam);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -385,6 +393,14 @@ public class SysOrgServiceImpl extends ServiceImpl<SysOrgMapper, SysOrg> impleme
|
|||
if (sysOrgParam.getId().equals(sysOrgParam.getPid())) {
|
||||
throw new ServiceException(SysOrgExceptionEnum.ID_CANT_EQ_PID);
|
||||
}
|
||||
|
||||
// 如果是编辑,父id不能为自己的子节点
|
||||
List<Long> childIdListById = this.getChildIdListById(sysOrgParam.getId());
|
||||
if(ObjectUtil.isNotEmpty(childIdListById)) {
|
||||
if(childIdListById.contains(sysOrgParam.getPid())) {
|
||||
throw new ServiceException(SysOrgExceptionEnum.PID_CANT_EQ_CHILD_ID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LambdaQueryWrapper<SysOrg> queryWrapperByName = new LambdaQueryWrapper<>();
|
||||
|
|
Loading…
Reference in New Issue