循环递归删除
程序员文章站
2022-05-26 10:19:45
...
//循环递归删除
public void getDeteleChuldList(String id){
userService.deleteByPrimaryKey(id);
//查询子菜单
UserServiceExample example = new UserServiceExample();
UserServiceExample.Criteria criteria =example.createCriteria();
criteria.andPidEqualTo(id);
List<User> userList=userMapper.selectByExample(example);
//说明有子
if(userList!=null&&userList.size()>0){
for(User user:userList){
getDeteleChuldList(user.getId());
}
}
}
public void getDeteleChuldList(String id){
userService.deleteByPrimaryKey(id);
//查询子菜单
UserServiceExample example = new UserServiceExample();
UserServiceExample.Criteria criteria =example.createCriteria();
criteria.andPidEqualTo(id);
List<User> userList=userMapper.selectByExample(example);
//说明有子
if(userList!=null&&userList.size()>0){
for(User user:userList){
getDeteleChuldList(user.getId());
}
}
}