一、Dao层,用逆向生成的pojo
1.分析,jsp代码,其参数为id和name,url为/content/category/update
$.post("/content/category/update",{id:node.id,name:node.text});
2.Dao层,因为是单表查询,直接使用逆向工程生成的pojo
二、.Service层
1.定义一个接口
TaotaoResult updateContentCategory(long id,String name);
2.继承
@Override
public TaotaoResult updateContentCategory(long id, String name) {
TbContentCategory contentCategory = contentCategoryMapper.selectByPrimaryKey(id);
contentCategory.setName(name);
contentCategoryMapper.updateByPrimaryKey(contentCategory);
return TaotaoResult.ok(contentCategory);
}
三、controller层
@RequestMapping("/update")
@ResponseBody
public TaotaoResult updateContentCategory(Long id,String name){
TaotaoResult result = contentCategoryService.updateContentCategory(id, name);
return result;
}