Skip to content

Commit

Permalink
Merge pull request #42 from goormthon-Univ/develop
Browse files Browse the repository at this point in the history
Deploy: Develop -> main
  • Loading branch information
chaeeun-Han committed Mar 22, 2024
2 parents a0981f1 + 5f1c1ae commit cf55a7d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.beotkkot.qtudy.dto.object;

import com.beotkkot.qtudy.domain.comments.Comments;
import com.beotkkot.qtudy.domain.user.Users;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
Expand All @@ -14,13 +15,17 @@ public class CommentListItem {
private Long commentId;
private String content;
private String createdAt;
private String name;
private String profileImageUrl;

public static CommentListItem of(Comments comment) {
public static CommentListItem of(Comments comment, Users user) {

return CommentListItem.builder()
.commentId(comment.getCommentId())
.content(comment.getContent())
.createdAt(comment.getCreatedAt())
.name(user.getName())
.profileImageUrl(user.getProfileImageUrl())
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.beotkkot.qtudy.domain.comments.Comments;
import com.beotkkot.qtudy.domain.posts.Posts;
import com.beotkkot.qtudy.domain.user.Users;
import com.beotkkot.qtudy.dto.object.CommentListItem;
import com.beotkkot.qtudy.dto.request.comments.CommentsRequestDto;
import com.beotkkot.qtudy.dto.response.ResponseDto;
Expand Down Expand Up @@ -68,11 +69,11 @@ public ResponseEntity<? super GetCommentsAllResponseDto> getAllComment(Long post
List<CommentListItem> commentListItems = new ArrayList<>();
Pageable pageable = PageRequest.of(page, 4, Sort.by("createdAt").descending());
try {
Posts post = postRepo.findByPostId(postId);
List<Comments> comments = commentRepo.findAllByPostId(postId, pageable).getContent();

for (Comments comment : comments) {
commentListItems.add(CommentListItem.of(comment));
Users user = userRepo.findByKakaoId(comment.getUserUid());
commentListItems.add(CommentListItem.of(comment, user));
}
} catch (Exception exception) {
log.info("error ", exception.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,12 @@ public ResponseEntity<? super PostsResponseDto> patchPost(Long postId, Long kaka
}

post.patchPost(dto);

// 요약
String summary = summaryService.summary(dto.getContent());
post.setContent(dto.getContent());
post.setSummary(summary);

postsRepo.save(post);

} catch (Exception exception) {
Expand Down

0 comments on commit cf55a7d

Please sign in to comment.