Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] 게시물 아카이브 대응 및 리팩토링 #43

Merged
merged 17 commits into from
Oct 3, 2024

Conversation

yongbin97
Copy link
Collaborator

💡 연관된 이슈

#41

📝 작업 내용

  1. 게시물 목록 조회 아카이브 대응
  2. 게시물 생성 및 수정 아카이브 대응
  3. 요약 요청 시 출처 제거
  4. 요약 요청 시 제목 요청
  5. 게시물 관련 API 리팩토링
  6. swagger https 대응

💬 리뷰 요구 사항

�그동안 말씀해주신 리뷰 사항들 수정하였습니다.
놓친 부분 있다면 알려주세요.

@yongbin97 yongbin97 added the ✨ Feature 기능 개발 label Oct 2, 2024
@yongbin97 yongbin97 requested a review from junseoplee October 2, 2024 16:15
@yongbin97 yongbin97 self-assigned this Oct 2, 2024
Copy link
Collaborator

@junseoplee junseoplee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생하셨습니다!
전체적으로 코드 수준이 높아졌어요!
추가적인 개선 사항이 보여서 코멘트 남겼습니다. 어떻게 생각하시는지 알려주세요!

Comment on lines 17 to 24
public void createUpdateMemo(Post post, String content) {
post.setMemo(content);
post.setMemoCreatedAt(LocalDateTime.now());
post.updatePostMemo(content, LocalDateTime.now());
postRepository.save(post);
}

public void deleteMemo(Post post) {
post.setMemo(null);
post.setMemoCreatedAt(null);
post.updatePostMemo(null, null);
postRepository.save(post);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -61,27 +71,27 @@ public PostDetailResponse getPostDetail(Long userId,
PostDetailDto postDetailDto = postReader.readPostDetailWithTags(userId,
postDetailServiceRequest);

return new PostDetailResponse(postDetailDto);
return PostDetailResponse.from(postDetailDto);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Long postId = postManager.createTempPost(user, createPostServiceRequest.getUrl(), summary);
SummaryResultDto summaryResultDto = summaryAIManager.getSummary(createPostServiceRequest);
User user = userReader.readUserByIdOrNull(userId);
Post post = postManager.createPost(user, createPostServiceRequest.getUrl(), summaryResultDto);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment on lines +89 to +92
UpdatePostServiceRequest updatePostServiceRequest) {
User user = userReader.readUserById(userId);
Post post = postReader.readActivatedPostAndWriter(postId);
Post updatedPost = postManager.updatePost(user, post, updatePostServiceRequest);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment on lines +25 to +29
public Post createPost(User user, String url, SummaryResultDto summaryResultDto) {
Post newPost = Post.createPost(user, summaryResultDto.getTitle(), summaryResultDto.getContent(),
PostStatus.DRAFT, url);

return postRepository.save(newPost);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import lombok.*;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment on lines 90 to 91
Post post = Post.builder().title(title).content(content).type(PostType.PRIVATE).status(status)
.url(url).activated(true).build();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

혹시 바꾼 이유가 있을까요?
특별한 경우가 아니라면 코드 스타일 유지 부탁드립니다.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ide에서 자동으로 포맷팅하는 거에 걸렸나보네요 수정하겠습니다~

@@ -17,22 +17,22 @@

@RestController
@RequiredArgsConstructor
@RequestMapping("/memo")
@RequestMapping("/posts/{postId}/memos")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment on lines +30 to +37
public UpdatePostServiceRequest toServiceRequest() {
return UpdatePostServiceRequest.builder()
.title(title)
.content(content)
.tagList(tagList)
.archiveId(archiveId)
.memo(memo)
.build();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -34,6 +34,16 @@ public static Specification<Post> getSearch(String search) {
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 클래스에서 null 이면 바로 null을 반환하니 else 가 필요 없는 메서드들이 있는 거 같아요.
그리고
getSearch의 경우 이렇게 하면 더 깔끔해지지 않을까 생각해봅니다.

public static Specification getSearch(String search) {
if (search == null) {
return null;
}

return (root, query, criteriaBuilder) -> {
  if (search.startsWith("#")) {
    Join<Post, PostTag> postTagJoin = root.join("postTagList");
    Join<PostTag, Tag> tagJoin = postTagJoin.join("tag");
    return criteriaBuilder.like(tagJoin.get("name"), "%" + search.substring(1) + "%");
  }
  return criteriaBuilder.like(root.get("title"), "%" + search + "%");
};

}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

좋은 의견 감사합니다. 하지만 이 경우에 준섭님 의견대로 구현했을 때, 저는 로직이 분리되어 약간 가독성이 떨어지는 느낌이 났습니다.
일단 else문을 제거하고 if문 블럭 두 개로 수정해보았습니다.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

좋아요!

Comment on lines 64 to 79
private Map<String, String> extractSummaryDataFromJson(JSONObject jsonObject) {
try {
String title = jsonObject.getString("title");
String content = jsonObject.getString("content");

Map<String, String> summaryDataMap = new HashMap<>();

summaryDataMap.put("title", title);
summaryDataMap.put("content", content);

return summaryDataMap;

} catch (JSONException e) {
throw new CustomException(ErrorCode.INVALID_SUMMARY);
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@yongbin97 yongbin97 merged commit 71c8707 into develop Oct 3, 2024
1 check passed
@yongbin97 yongbin97 deleted the feature/41-post branch October 3, 2024 05:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ Feature 기능 개발
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants