之前的删除方法没有返回值,其实应该有一个返回值,以t_role表为例
控制器:
//删除角色
@RequestMapping("/delete")
@ResponseBody
public Object delete(Integer id){
AJAXResult result = new AJAXResult();
try{
int n = roleService.deleteRoleById(id);
if(n == 1){
result.setSuccess(true);
}else{
result.setSuccess(false);
}
}catch(Exception e){
e.printStackTrace();
result.setSuccess(false);
}
return result;
}
Service接口:
public int deleteRoleById(Integer id);//根据id删除
Service实现类:
public int deleteRoleById(Integer id) {
return roleDao.deleteRoleById(id);
}
Dao接口:
//根据id删除
i