点赞模块
用户点赞评论后端的书写
//谁,同意了哪个评论?(id)
@RequestMapping("/addCommentAgree")publicString addCommentAgree(String id,String userId)
{
User user= (User) session.getAttribute("user");//拿到用户的持久化对象
User findUser =userService.findUserById(user.getId().toString());
Comment comment=commentService.findCommentById(id);
findUser.getAgreeComments().add(comment);
comment.getAgreeUsers().add(findUser);
userService.saveUser(findUser);
commentService.saveComment(comment);return "redirect:/findUserCommentsById?id=" +userId;
}
前端代码的书写
| Reply