SpringBoot - MyBatis-Plus - UpdateWrapper、LambdaUpdateWrapper和LambdaUpdateChainWrapper的用法
在这一篇spring boot学习第三篇:spring boot与mybatis plus结合-CSDN博客文档的基础上学习
一、UpdateWrapper
GirlController.java追加该接口
/**
* 修改一个女生
* @param girl
* @return
*/
@RequestMapping(value = "/girls",method = RequestMethod.PUT)
public int updateGirl(@RequestBody Girl girl){
return girlService.updateGirl(girl);
}
2、GirlService增加一个service
int updateGirl(Girl girl);
3、GirlServiceImpl对应增加一个service
@Override
public int updateGirl(Girl girl) {
UpdateWrapper upt = new UpdateWrapper();
upt.eq("id",girl.getId());
//upt.set("cup_size",girl.getCupSize());
//upt.set("age",girl.getAge());
return girlMapper.update(girl,upt);
}
4、调用接口

5、查看数据
本文介绍了如何在SpringBoot项目中使用MyBatis-Plus的UpdateWrapper进行数据更新操作。通过GirlController的PUT请求接口,调用GirlService的updateGirl方法,利用UpdateWrapper设置更新条件,如id,然后执行girlMapper的update方法完成更新。示例代码展示了具体实现过程。

1043

被折叠的 条评论
为什么被折叠?



