更新文章 2024-4-3
所花时间(包括上课): | 1 h左右 |
代码量(行): | 80左右 |
搏客量(篇): | 1 |
了解到的知识点: | |
备注(其他): |
//controller
@PutMapping
public Result update(@RequestBody @Validated Article article){
articleService.update(article);
return Result.success();
}
//service
void update(Article article);
//serviceImpl
@Override
public void update(Article article) {
article.setUpdateTime(LocalDateTime.now());
articleMapper.update(article);
}
//mapper
@Update("update article set title=#{title},content=#{content},cover_img=#{coverImg},state=#{state},category_id=#{categoryId},update_time=#{updateTime} where id=#{id}")
void update(Article article);