删除没有父节点的菜单

yun-zuoyi
feng.liu 3 years ago
parent ec7bc57f97
commit 79feab31fc

@ -44,6 +44,7 @@ import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@ -375,16 +376,23 @@ public class SysMenuController extends CrudBaseController<SysMenu> {
});
list.forEach(menu -> {
menu.setIsDeleted(CommonEnumUtil.IS_DEAL.NO.getValue());
menu.setIsValid(CommonEnumUtil.IS_VAILD.VAILD.getValue());
if(menu.getParentId().longValue() != -1){
SysMenu mu = map.get(menu.getParentId().toString());
ValidatorBean.checkNotNull(mu, "【"+menu.getParentId()+"】不存在的父节点信息");
menu.setNameZhShortening(StringTool.getAllFirstLetter(mu.getName()));
menu.setParentNameRdd(mu.getName());
Iterator<SysMenu> it = list.iterator();
while(it.hasNext()){
SysMenu sysMenu = it.next();
sysMenu.setIsDeleted(CommonEnumUtil.IS_DEAL.NO.getValue());
sysMenu.setIsValid(CommonEnumUtil.IS_VAILD.VAILD.getValue());
if(sysMenu.getParentId().longValue() != -1){
SysMenu mu = map.get(sysMenu.getParentId().toString());
//ValidatorBean.checkNotNull(mu, "【"+menu.getParentId()+"】不存在的父节点信息");
if(mu == null){
LOGGER.error("{}, 不存在的父节点信息", sysMenu.getParentId());
it.remove();
}else{
sysMenu.setNameZhShortening(StringTool.getAllFirstLetter(mu.getName()));
sysMenu.setParentNameRdd(mu.getName());
}
}
}
});
return ResultBean.success("上传成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode())
.setResultList(menuService.saveBatch(list));

Loading…
Cancel
Save