代码可以执行,但是就是会报下面这个错误,请问是为什么呢

public interface ContentCatService

//删除
    public void delete(Integer id) throws Exception;

public class ContentCatServiceImpl implements ContentCatService

//删除
    public void delete(Integer id) throws Exception {
        //1.基于id进行子元素查询
        int count = contentCatMapper.getChildCount(id);
        if(count>0) throw new Exception("请先删除子菜单");
        //2.删除菜单元素
        int rows= contentCatMapper.deleteObject(id);
        if(rows==0) throw new Exception("此菜单可能已经不存在");
        //3.删除角色,菜单关系数据
        contentMapper.deleteObjectsByMenuId(id);
    }

public class ContentCatController

//删除
    @RequestMapping(value = "/delete", method = RequestMethod.GET)
    private SysResult delete(Integer id){
        try {
            contentCatService.delete(id);
            return SysResult.ok();
        }catch (Exception e){
            e.printStackTrace();
            return SysResult.build(201,"删除失败");
        }
    }

public interface ContentCatMapper extends BaseMapper

   @Select("select count(*) from mt_content_category where parent_id=#{id}")
    int getChildCount(Integer id);

    @Select("delete from mt_content_category where id=#{id}")
    int deleteObject(Integer id);

public interface ContentMapper extends BaseMapper

 @Select("delete from mt_content where category_id=#{id}")
    int deleteObjectsByMenuId(Integer categoryId);

然后执行结果成功,返回参数失败,然后报异常了

图片说明

有大佬可以帮忙看看吗

@Select("delete from mt_content where category_id=#{id}")
    int deleteObjectsByMenuId(Integer categoryId);

改为

@Delete("delete from mt_content where category_id=#{id}")
    int deleteObjectsByMenuId(Integer categoryId);

你的 deleteObjectByMenuID这个方法中视图返回null,而你的类型是int的,不可能有null,检查下

注解用错了,应该用@Delete

你用@Select返回null,但你的返回值是int
改成@Delete,或者返回值Integer