Service业务层
    @Override
    public boolean removeListById(Integer id) {
    ArrayList ids = new ArrayList<>();
    //把要删除的一级分类id放入集合中
    ids.add(id);
    //调用递归将一级分类下的id也加入到集合中
    this.getIds(ids, id);
    //批量删除集合中id
    int i = baseMapper.deleteBatchIds(ids);
    return i > 0;
    }
    //递归方法
    private void getIds(ArrayList ids, Integer id) {
    //查询二级分类的对象
    QueryWrapper wrapper = new QueryWrapper<>();
    //folder_id==数据库父id
    wrapper.eq(“folder_id”, id);
    List list = baseMapper.selectList(wrapper);
    //遍历二级分类的对象,把二级分类的id加入到要删除的集合中
    for (EmsFileEntity emsFileEntity : list) {
    Integer id1 = emsFileEntity.getId();
    ids.add(id1);
    //把二级分类的每一个ID,查询它下面的子节点
    this.getIds(ids, id1);
    }
    }
    mapper层

    boolean removeListById(Integer id);

    控制层controller
    @ApiOperation(“删除文件夹”)
    @RequestMapping(value = “/delete/{id}”, method = RequestMethod.POST)
    public R delete(@PathVariable(“id”) Integer id) {
    boolean b = emsFileService.removeListById(id);
    if (b){
    return R.ok();
    }
    return R.error();
    }