Skip to content

Commit

Permalink
Merge pull request #175 from pknu-wap/feature/또또추가사항
Browse files Browse the repository at this point in the history
댓글 익명 사용자 추가
  • Loading branch information
JONG-KYEONG authored Nov 30, 2023
2 parents bb15a6c + 19ed5e9 commit d0f3de2
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions server/src/main/java/com/project/Glog/service/ReplyService.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,29 @@ public Long createReply(UserPrincipal userPrincipal, ReplyCreateRequest req) {

public ReplyGetResponse getReplies(UserPrincipal userPrincipal, ReplyGetRequest req) {
Post post = postRepository.findById(req.getPostId()).get();
User currentUser = userRepository.findById(userPrincipal.getId()).get();
// Optional<User> currentUserOptional = userRepository.findById(userPrincipal.getId());
Boolean imOwner;
Long authorId = postRepository.findById(post.getId()).get().getUser().getId();
User currentUser = null;

if (userPrincipal == null){
imOwner = false;
currentUser = userRepository.findUserByNickname("anonymous");
}
else{
imOwner = (authorId == userPrincipal.getId());
currentUser = userRepository.findById(userPrincipal.getId()).get();
}




Boolean imOwner = (authorId == userPrincipal.getId());

PageRequest pageRequest = PageRequest.of(req.getPage(), 10, Sort.by(req.getOrder()).descending());
List<Reply> replys = replyRepository.findRepliesByPost(post, pageRequest).getContent();
List<ReplyDto> replyDtos = new ArrayList<>();
for(Reply reply : replys){
ReplyDto replyDto = ReplyDto.of(reply);

Boolean isLiked = replyLikeRepository.findByReplyAndUser(reply.getId(), currentUser.getId()).isPresent();
replyDto.setIsLiked(isLiked);

Expand Down

0 comments on commit d0f3de2

Please sign in to comment.