编写Web访问层Controller文件
java
@RestController
@RequestMapping("api") //窄化请求路径
public class ApiCommentController {
@Autowired
private ApiCommentService commentService;
@RequestMapping(value = "/findCommentById")
public Comment findCommentById(Integer id){
Comment comment = commentService.findCommentById(id);
return comment;
}
@RequestMapping(value = "/updateComment")
public void updateComment(Comment comment){
Comment comment2 = commentService.findCommentById(comment.getId());
comment.setAuthor(comment.getAuthor());
commentService.updateComment(comment);
}
@RequestMapping(value = "/deleteComment")
public void deleteComment(int id){
commentService.deleteComment(id);
}
}
* 基于API的Redis缓存实现的相关配置。基于API的Redis缓存实现不需要@EnableCaching注解开启基于注解的缓存支持,所以这里可以选择将添加在项目启动类上的@EnableCaching进行删除或者注释
这些内容,是从拉勾教育的《Java工程师高薪训练营》里学到的,课程内容非常全面,还有拉勾的内推大厂服务,推荐你也看看。
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。