递归方法,这个方法是无尽的执行,遇到一个false才结束
因此在执行方法前,先设一个Boolean
boolean i=true;
在设一个
while(i)这样在这个方法执行遇到是false时才会停住
下面用for循环执行
for循环里必须有个if,在达到这个条件以后if里执行i=false;
TbContentCategoryQuery example = new TbContentCategoryQuery();
Criteria criteria = example.createCriteria().andParentIdEqualTo(id);
List<TbContentCategory> list = tbContentCategoryDao.selectByExample(example);
List<TbContentCategory> other = tbContentCategoryDao.selectByExample(example);
boolean i=true;
while (i) {
for(TbContentCategory tbContentCategory:list){
if(list.size()!=0){
example = new TbContentCategoryQuery();
example.createCriteria().andParentIdEqualTo(tbContentCategory.getId());
list = tbContentCategoryDao.selectByExample(example);
}
if(list.size()==0){
if(tbContentCategory.getParentId()==id){
tbContentCategoryDao.deleteByPrimaryKey(tbContentCategory.getId());
tbContentCategoryDao.deleteByPrimaryKey(id);
i=false;
}
tbContentCategoryDao.deleteByPrimaryKey(tbContentCategory.getId());
list=other;
}
}
}
}
这里遇到一个example,必须要重新new一个,不然只会执行以前设定的值
可能有一些if判断,做了处理