From 0868955ffefd25260c659068355b0f097dd32890 Mon Sep 17 00:00:00 2001 From: chjcoder Date: Sat, 6 Jul 2024 17:11:17 +0900 Subject: [PATCH 1/6] =?UTF-8?q?chore(reward)=20:=20=EB=A6=AC=EC=9B=8C?= =?UTF-8?q?=EB=93=9C=20=EB=B2=94=EC=9C=84=2050~100,=2010=EB=8B=A8=EC=9C=84?= =?UTF-8?q?=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../grassdiary/domain/diary/service/DiaryService.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/main/java/chzzk/grassdiary/domain/diary/service/DiaryService.java b/src/main/java/chzzk/grassdiary/domain/diary/service/DiaryService.java index 99aabcca..c73eb44f 100644 --- a/src/main/java/chzzk/grassdiary/domain/diary/service/DiaryService.java +++ b/src/main/java/chzzk/grassdiary/domain/diary/service/DiaryService.java @@ -84,10 +84,7 @@ public DiarySaveResponseDTO update(Long id, DiaryUpdateRequestDTO requestDto, Mu } /** - * diaryId를 이용해서 diaryTag, MemberTag 를 찾아내기 - * diaryTag 삭제 -> deleteAllInBatch 고려해보기 - * MemberTag 삭제 - * 해당 일기의 좋아요 찾기 및 삭제 + * diaryId를 이용해서 diaryTag, MemberTag 를 찾아내기 diaryTag 삭제 -> deleteAllInBatch 고려해보기 MemberTag 삭제 해당 일기의 좋아요 찾기 및 삭제 * 이미지 삭제 */ @Transactional @@ -213,7 +210,7 @@ private void updateTags(Diary diary, List newHashtags) { private int makeRewardPoint() { long seed = System.currentTimeMillis(); Random random = new Random(seed); - return random.nextInt(10) + 1; + return 50 + (random.nextInt(6) * 10); } private void saveRewardPointAndHistory(Member member, int rewardPoint) { @@ -275,6 +272,7 @@ private void decrementTagsCount(List tags) { } } } + private void removeDiaryLikes(Long diaryId) { List diaryLikes = diaryLikeDAO.findAllByDiaryId(diaryId); diaryLikeDAO.deleteAll(diaryLikes); @@ -297,7 +295,8 @@ private String updateDiaryImage(boolean currentHasImage, MultipartFile image, Di return ""; } - private DiarySaveResponseDTO updateDiary(DiaryUpdateRequestDTO requestDto, Diary diary, boolean currentHasImage, String imagePath) { + private DiarySaveResponseDTO updateDiary(DiaryUpdateRequestDTO requestDto, Diary diary, boolean currentHasImage, + String imagePath) { diary.update(requestDto.getContent(), requestDto.getIsPrivate(), requestDto.getHasImage(), requestDto.getHasTag(), requestDto.getConditionLevel()); From 37fc99198d8214ae79fce92c707dbd8655b8a64b Mon Sep 17 00:00:00 2001 From: chjcoder Date: Sat, 27 Jul 2024 00:55:08 +0900 Subject: [PATCH 2/6] =?UTF-8?q?feat(Comment)=20:=20=EB=8C=93=EA=B8=80=20?= =?UTF-8?q?=EA=B9=8A=EC=9D=B4=201=EB=AF=B8=EB=A7=8C=EC=9C=BC=EB=A1=9C=20?= =?UTF-8?q?=EC=A0=9C=ED=95=9C=ED=95=98=EB=8A=94=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/comment/dto/CommentResponseDTO.java | 3 +++ .../comment/dto/CommentSaveRequestDTO.java | 3 ++- .../domain/comment/entity/Comment.java | 6 +++++- .../domain/comment/service/CommentService.java | 18 +++++++++++++++++- .../common/response/ClientErrorCode.java | 1 + 5 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/main/java/chzzk/grassdiary/domain/comment/dto/CommentResponseDTO.java b/src/main/java/chzzk/grassdiary/domain/comment/dto/CommentResponseDTO.java index 4912a875..5d53de04 100644 --- a/src/main/java/chzzk/grassdiary/domain/comment/dto/CommentResponseDTO.java +++ b/src/main/java/chzzk/grassdiary/domain/comment/dto/CommentResponseDTO.java @@ -14,6 +14,7 @@ public record CommentResponseDTO( boolean deleted, String createdDate, String createdAt, + int depth, List childComments ) { public static CommentResponseDTO from(Comment comment) { @@ -24,6 +25,7 @@ public static CommentResponseDTO from(Comment comment) { comment.isDeleted(), comment.getCreatedAt().format(DateTimeFormatter.ofPattern("yy년 MM월 dd일")), comment.getCreatedAt().format(DateTimeFormatter.ofPattern("HH:mm")), + comment.getDepth(), comment.getChildComments().stream().map(CommentResponseDTO::from).collect(Collectors.toList()) ); } @@ -36,6 +38,7 @@ public static CommentResponseDTO fromDeleted(Comment comment) { true, null, null, + comment.getDepth(), comment.getChildComments().stream().map(CommentResponseDTO::from).collect(Collectors.toList()) ); } diff --git a/src/main/java/chzzk/grassdiary/domain/comment/dto/CommentSaveRequestDTO.java b/src/main/java/chzzk/grassdiary/domain/comment/dto/CommentSaveRequestDTO.java index fe590d34..f3314d5b 100644 --- a/src/main/java/chzzk/grassdiary/domain/comment/dto/CommentSaveRequestDTO.java +++ b/src/main/java/chzzk/grassdiary/domain/comment/dto/CommentSaveRequestDTO.java @@ -10,12 +10,13 @@ public record CommentSaveRequestDTO( String content, Long parentCommentId ) { - public Comment toEntity(Member member, Diary diary, Comment parentComment) { + public Comment toEntity(Member member, Diary diary, Comment parentComment, int depth) { return Comment.builder() .member(member) .diary(diary) .content(content) .parentComment(parentComment) + .depth(depth) .build(); } } diff --git a/src/main/java/chzzk/grassdiary/domain/comment/entity/Comment.java b/src/main/java/chzzk/grassdiary/domain/comment/entity/Comment.java index 97221884..fead9088 100644 --- a/src/main/java/chzzk/grassdiary/domain/comment/entity/Comment.java +++ b/src/main/java/chzzk/grassdiary/domain/comment/entity/Comment.java @@ -54,13 +54,17 @@ public class Comment extends BaseTimeEntity { private boolean deleted; + @Column(nullable = false) + private int depth; + @Builder - protected Comment(Member member, Diary diary, String content, Comment parentComment) { + protected Comment(Member member, Diary diary, String content, Comment parentComment, int depth) { this.member = member; this.diary = diary; this.content = content; this.parentComment = parentComment; this.deleted = false; + this.depth = depth; } public void update(String content) { diff --git a/src/main/java/chzzk/grassdiary/domain/comment/service/CommentService.java b/src/main/java/chzzk/grassdiary/domain/comment/service/CommentService.java index e902d9f1..e38abe44 100644 --- a/src/main/java/chzzk/grassdiary/domain/comment/service/CommentService.java +++ b/src/main/java/chzzk/grassdiary/domain/comment/service/CommentService.java @@ -35,7 +35,10 @@ public CommentResponseDTO save(Long diaryId, CommentSaveRequestDTO requestDTO, L Member member = getMemberById(logInMemberId); Diary diary = getDiaryById(diaryId); Comment parentComment = getParentCommentById(requestDTO.parentCommentId()); - Comment comment = requestDTO.toEntity(member, diary, parentComment); + + int commentDepth = calculateCommentDepth(parentComment); + validateCommentDepth(commentDepth); + Comment comment = requestDTO.toEntity(member, diary, parentComment, commentDepth); commentDAO.save(comment); return CommentResponseDTO.from(comment); @@ -125,6 +128,13 @@ private Comment getCommentById(Long id) { .orElseThrow(() -> new SystemException(ClientErrorCode.COMMENT_NOT_FOUND_ERR)); } + private int calculateCommentDepth(Comment parentComment) { + if (parentComment == null) { + return 0; + } + return parentComment.getDepth() + 1; + } + private void validateCommentAuthor(Member member, Comment comment) { if (!member.equals(comment.getMember())) { throw new SystemException(ClientErrorCode.AUTHOR_MISMATCH_ERR); @@ -136,4 +146,10 @@ private void validateNotDeleted(Comment comment) { throw new SystemException(ClientErrorCode.COMMENT_ALREADY_DELETED_ERR); } } + + private void validateCommentDepth(int depth) { + if (depth > 1) { + throw new SystemException(ClientErrorCode.COMMENT_DEPTH_EXCEEDED_ERR); + } + } } diff --git a/src/main/java/chzzk/grassdiary/global/common/response/ClientErrorCode.java b/src/main/java/chzzk/grassdiary/global/common/response/ClientErrorCode.java index 9cce02a7..0a7a9175 100644 --- a/src/main/java/chzzk/grassdiary/global/common/response/ClientErrorCode.java +++ b/src/main/java/chzzk/grassdiary/global/common/response/ClientErrorCode.java @@ -21,6 +21,7 @@ public enum ClientErrorCode implements ErrorCodeModel { IMAGE_FILE_EMPTY(400, "IMAGE_FILE_EMPTY", "이미지 파일이 비어 있습니다."), AUTHOR_MISMATCH_ERR(403, "AUTHOR_MISMATCH_ERR", "작성자가 아닙니다."), COMMENT_ALREADY_DELETED_ERR(400, "COMMENT_ALREADY_DELETED_ERR", "이미 삭제된 댓글입니다."), + COMMENT_DEPTH_EXCEEDED_ERR(400, "COMMENT_DEPTH_EXCEEDED_ERR", "댓글은 대댓글까지만 허용합니다."), VALIDATION_ERR(400, "VALIDATION_ERR", "잘못된 입력입니다. 올바른 값을 입력해주세요."), PERMISSION_ERR(403, "PERMISSION_ERR", "접근 권한이 없습니다. 관리자에게 문의하세요."), From 220922d8fb634487ab00b4185126744eb76178ae Mon Sep 17 00:00:00 2001 From: jjaegii Date: Mon, 5 Aug 2024 21:37:29 +0900 Subject: [PATCH 3/6] =?UTF-8?q?fix(code-review.yml):=20job=20=EC=9D=B4?= =?UTF-8?q?=EB=A6=84=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/code-review.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/code-review.yml b/.github/workflows/code-review.yml index 93084711..c38e090a 100644 --- a/.github/workflows/code-review.yml +++ b/.github/workflows/code-review.yml @@ -7,7 +7,7 @@ on: - dev jobs: - deploy: + code_review: runs-on: ubuntu-latest steps: From 78f605332e27dc68f4bbf33661b84d84e4197c9d Mon Sep 17 00:00:00 2001 From: HongYeseul Date: Tue, 6 Aug 2024 12:36:02 +0900 Subject: [PATCH 4/6] =?UTF-8?q?fix(DiaryImageService):=20=EA=B8=B0?= =?UTF-8?q?=EC=A1=B4=20=EC=9D=B4=EB=AF=B8=EC=A7=80=EA=B0=80=20=EC=9E=88?= =?UTF-8?q?=EB=8A=94=20=EC=9D=BC=EA=B8=B0=20PATCH=20=EC=95=88=EB=90=98?= =?UTF-8?q?=EB=8A=94=20=EB=B2=84=EA=B7=B8=20=EC=88=98=EC=A0=95=20-=20?= =?UTF-8?q?=EC=9E=98=EB=AA=BB=20=EB=93=A4=EC=96=B4=EA=B0=80=EC=9E=88?= =?UTF-8?q?=EB=8A=94=20=EB=B3=80=EC=88=98=20=EC=97=85=EB=8D=B0=EC=9D=B4?= =?UTF-8?q?=ED=8A=B8=20=20=20:=20diaryImage.id=20->=20image.id?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../grassdiary/domain/image/service/DiaryImageService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/chzzk/grassdiary/domain/image/service/DiaryImageService.java b/src/main/java/chzzk/grassdiary/domain/image/service/DiaryImageService.java index 61c784ad..f2003659 100644 --- a/src/main/java/chzzk/grassdiary/domain/image/service/DiaryImageService.java +++ b/src/main/java/chzzk/grassdiary/domain/image/service/DiaryImageService.java @@ -31,7 +31,7 @@ public void mappingImageToDiary(Diary diary, Long imageId) { public void deleteImageAndMapping(Diary diary) { diaryToImageDAO.findByDiaryId(diary.getId()).ifPresent(diaryImage -> { - imageService.deleteImage(diaryImage.getId()); + imageService.deleteImage(diaryImage.getImage().getId()); diaryToImageDAO.delete(diaryImage); }); } From 3558550b75848c2fe792742801c984c6289f2c0e Mon Sep 17 00:00:00 2001 From: HongYeseul Date: Tue, 6 Aug 2024 12:36:27 +0900 Subject: [PATCH 5/6] =?UTF-8?q?refactor(ImageController):=20=ED=95=84?= =?UTF-8?q?=EC=9A=94=20=EC=97=86=EB=8A=94=20=EC=BB=A8=ED=8A=B8=EB=A1=A4?= =?UTF-8?q?=EB=9F=AC=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/image/controller/ImageController.java | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/main/java/chzzk/grassdiary/domain/image/controller/ImageController.java b/src/main/java/chzzk/grassdiary/domain/image/controller/ImageController.java index ebe2abd5..c2f625bc 100644 --- a/src/main/java/chzzk/grassdiary/domain/image/controller/ImageController.java +++ b/src/main/java/chzzk/grassdiary/domain/image/controller/ImageController.java @@ -10,9 +10,7 @@ import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestPart; @@ -40,14 +38,6 @@ public ResponseEntity uploadDiaryImage( .body(imageService.uploadImage(image, FileFolder.PERSONAL_DIARY)); } - @DeleteMapping("/diary/{diaryId}") - public ResponseEntity deleteDiaryImage( - @PathVariable Long diaryId - ) { - imageService.deleteImage(diaryId); - return ResponseEntity.ok().build(); - } - private ResponseEntity sendImage(String mainBannerUrl) throws IOException { Resource resource = new ClassPathResource(mainBannerUrl); if (!resource.exists()) { From a97763f5c36aed9f254bb1b02c74fc37b08bd63d Mon Sep 17 00:00:00 2001 From: jjaegii Date: Wed, 7 Aug 2024 20:15:48 +0900 Subject: [PATCH 6/6] =?UTF-8?q?fix(code-review.yml)=20:=20=EB=A6=AC?= =?UTF-8?q?=EB=B7=B0=20=EB=AA=A8=EB=8D=B8=20=EC=9D=B4=EB=A6=84=20=EB=B3=80?= =?UTF-8?q?=EC=88=98=20=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/code-review.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/code-review.yml b/.github/workflows/code-review.yml index c38e090a..dde59a5f 100644 --- a/.github/workflows/code-review.yml +++ b/.github/workflows/code-review.yml @@ -51,7 +51,7 @@ jobs: run: | ESCAPED_DIFF=$(echo "$DIFF_CONTENT" | jq -sRr @json) REQUEST_BODY=$(jq -n \ - --arg model "Meta-Llama-3_1-8B-Instruct_Q4_K_M" \ + --arg model "${{ secrets.REVIEW_MODEL_NAME }}" \ --arg prompt "Review the following code changes and provide feedback:$ESCAPED_DIFF" \ '{model: $model, prompt: $prompt, stream: false}') FULL_RESPONSE=$(curl -X POST ${REVIEW_API_URL} \