Skip to content

Commit

Permalink
[Fix] 게시물 관련 QA (#57)
Browse files Browse the repository at this point in the history
* fix: 게시물 수정 시 archive null 대응 (#56)

* fix: 프롬프트 글자 제한 추가 (#56)
  • Loading branch information
yongbin97 authored Oct 4, 2024
1 parent c139511 commit 1dd85ab
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ public class ArchiveReader {

private final ArchiveRepository archiveRepository;

public Archive readActivatedArchiveByIdIfNotNull(Long archiveId) {
if (archiveId == null) {
return null;
}
return archiveRepository.findByIdAndActivatedTrue(archiveId)
.orElseThrow(() -> new CustomException(ErrorCode.BAD_REQUEST));
}

public Archive readActivatedArchiveById(Long archiveId) {
return archiveRepository.findByIdAndActivatedTrue(archiveId)
.orElseThrow(() -> new CustomException(ErrorCode.BAD_REQUEST));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public Post createPost(User user, String url, SummaryResultDto summaryResultDto)
}

public Post updatePost(User user, Post post, UpdatePostServiceRequest updatePostServiceRequest) {
Archive archive = archiveReader.readActivatedArchiveById(
Archive archive = archiveReader.readActivatedArchiveByIdIfNotNull(
updatePostServiceRequest.getArchiveId());

post.updatePost(user, updatePostServiceRequest.getTitle(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ private Prompt createPrompt(CreatePostServiceRequest createPostServiceRequest) {

String promptMessage = "URL: " + createPostServiceRequest.getUrl() + "\n" +
"Summarize the website corresponding to the URL below in a blog style according to the following summary conditions.\n"
+ "Please also recommend the title\n"
+ "Please also recommend the title, composed only of English letters or Hangul, and "
+ "ensure it is less than 30 characters, including spaces.\n"
+ "The answer is given in json format string with title and content as keys.\n"
+ "Translate the content into the summary language!\n"
+ "Summary conditions: \n"
Expand Down

0 comments on commit 1dd85ab

Please sign in to comment.