原理
依次实现dao,service,controller对应方法实现即可。
实现步骤
- dao层:添加增加评论的数据并添加修改帖子的评论数量的方法。
//增加评论
int insertComment(Comment comment);
//修改帖子评论数量
int updateCommentCount(int id,int commentCount);
- service层:处理添加评论的业务,先添加评论,再更新帖子的评论数量。
//增加评论的业务
@Transactional(isolation = Isolation.READ_COMMITTED,propagation = Propagation.REQUIRED)
public int addComment(Comment comment){
if(comment &#