From 1dd85abe4bc00c50008271ac2e63d67d6f14f5bd Mon Sep 17 00:00:00 2001 From: Kim Yongbin <80311590+yongbin97@users.noreply.github.com> Date: Fri, 4 Oct 2024 17:28:33 +0900 Subject: [PATCH] =?UTF-8?q?[Fix]=20=EA=B2=8C=EC=8B=9C=EB=AC=BC=20=EA=B4=80?= =?UTF-8?q?=EB=A0=A8=20QA=20(#57)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: 게시물 수정 시 archive null 대응 (#56) * fix: 프롬프트 글자 제한 추가 (#56) --- .../backend/business/archive/implement/ArchiveReader.java | 8 ++++++++ .../backend/business/post/implement/PostManager.java | 2 +- .../backend/business/post/implement/SummaryManager.java | 3 ++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/java/project/backend/business/archive/implement/ArchiveReader.java b/src/main/java/project/backend/business/archive/implement/ArchiveReader.java index 1f97f3e..2db09af 100644 --- a/src/main/java/project/backend/business/archive/implement/ArchiveReader.java +++ b/src/main/java/project/backend/business/archive/implement/ArchiveReader.java @@ -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)); diff --git a/src/main/java/project/backend/business/post/implement/PostManager.java b/src/main/java/project/backend/business/post/implement/PostManager.java index 14745a7..a5af3ba 100644 --- a/src/main/java/project/backend/business/post/implement/PostManager.java +++ b/src/main/java/project/backend/business/post/implement/PostManager.java @@ -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(), diff --git a/src/main/java/project/backend/business/post/implement/SummaryManager.java b/src/main/java/project/backend/business/post/implement/SummaryManager.java index a3dc0d9..681cebc 100644 --- a/src/main/java/project/backend/business/post/implement/SummaryManager.java +++ b/src/main/java/project/backend/business/post/implement/SummaryManager.java @@ -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"