|
@@ -4,9 +4,7 @@ import nju.seec.helper.dao.CommentDAO;
|
|
|
import nju.seec.helper.dao.SlideDAO;
|
|
import nju.seec.helper.dao.SlideDAO;
|
|
|
import nju.seec.helper.dto.CommentDTO;
|
|
import nju.seec.helper.dto.CommentDTO;
|
|
|
import nju.seec.helper.dto.LoginUser;
|
|
import nju.seec.helper.dto.LoginUser;
|
|
|
-import nju.seec.helper.dto.ReplyDTO;
|
|
|
|
|
import nju.seec.helper.entity.Comment;
|
|
import nju.seec.helper.entity.Comment;
|
|
|
-import nju.seec.helper.entity.Reply;
|
|
|
|
|
import nju.seec.helper.service.CommentService;
|
|
import nju.seec.helper.service.CommentService;
|
|
|
import nju.seec.helper.util.exception.HelperException;
|
|
import nju.seec.helper.util.exception.HelperException;
|
|
|
import nju.seec.helper.vo.CommentVO;
|
|
import nju.seec.helper.vo.CommentVO;
|
|
@@ -33,8 +31,8 @@ public class CommentServiceImpl implements CommentService {
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@Override
|
|
@Override
|
|
|
public CommentVO createComment(LoginUser user, CommentDTO commentDTO) {
|
|
public CommentVO createComment(LoginUser user, CommentDTO commentDTO) {
|
|
|
- Comment comment = new Comment();
|
|
|
|
|
- comment.setSlideId(commentDTO.getSlideId())
|
|
|
|
|
|
|
+ Comment comment = new Comment()
|
|
|
|
|
+ .setSlideId(commentDTO.getSlideId())
|
|
|
.setPageNumber(commentDTO.getPageNumber())
|
|
.setPageNumber(commentDTO.getPageNumber())
|
|
|
.setUserId(user.getId())
|
|
.setUserId(user.getId())
|
|
|
.setUserName(user.getName())
|
|
.setUserName(user.getName())
|
|
@@ -79,20 +77,4 @@ public class CommentServiceImpl implements CommentService {
|
|
|
.map(CommentVO::new)
|
|
.map(CommentVO::new)
|
|
|
.collect(Collectors.toList());
|
|
.collect(Collectors.toList());
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
|
|
- @Override
|
|
|
|
|
- public void replyComment(LoginUser user, ReplyDTO replyDTO) {
|
|
|
|
|
- Comment comment = commentDAO.findCommentById(replyDTO.getCommentId());
|
|
|
|
|
- if (!slideDAO.findSlideById(comment.getSlideId()).getTeacherId().equals(user.getId())) {
|
|
|
|
|
- throw HelperException.of(HelperException.ExceptionType.FORBIDDEN, "您无权回复该评论");
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- Reply reply = new Reply();
|
|
|
|
|
- reply.setComment(comment)
|
|
|
|
|
- .setTeacherId(user.getId())
|
|
|
|
|
- .setContent(replyDTO.getContent());
|
|
|
|
|
- comment.setReply(reply);
|
|
|
|
|
- commentDAO.save(comment);
|
|
|
|
|
- }
|
|
|
|
|
}
|
|
}
|