From 83c119511534213ac3496888a658bcbbfc5bccfd Mon Sep 17 00:00:00 2001 From: RyuKwanKon Date: Mon, 1 Apr 2024 13:35:53 +0900 Subject: [PATCH 1/9] =?UTF-8?q?[fix]=20#71=20post=20=EC=A1=B0=ED=9A=8C?= =?UTF-8?q?=EC=8B=9C=20title,=20content=20=EB=8D=B0=EC=9D=B4=ED=84=B0=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/post/repository/PostCustomRepositoryImpl.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/org/gachon/checkmate/domain/post/repository/PostCustomRepositoryImpl.java b/src/main/java/org/gachon/checkmate/domain/post/repository/PostCustomRepositoryImpl.java index 14bfdf7..689fc1e 100644 --- a/src/main/java/org/gachon/checkmate/domain/post/repository/PostCustomRepositoryImpl.java +++ b/src/main/java/org/gachon/checkmate/domain/post/repository/PostCustomRepositoryImpl.java @@ -30,6 +30,8 @@ public Optional findPostDetail(Long postId) { return Optional.ofNullable(queryFactory .select(new QPostDetailDto( user.id, + post.title, + post.content, user.major, user.mbtiType, user.gender, From 0dc255c2efbea2a0fe19ce9c69301e24ecddfaa6 Mon Sep 17 00:00:00 2001 From: RyuKwanKon Date: Mon, 1 Apr 2024 13:35:59 +0900 Subject: [PATCH 2/9] =?UTF-8?q?[fix]=20#71=20post=20=EC=A1=B0=ED=9A=8C?= =?UTF-8?q?=EC=8B=9C=20title,=20content=20=EB=8D=B0=EC=9D=B4=ED=84=B0=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/post/dto/response/PostDetailResponseDto.java | 4 ++++ .../checkmate/domain/post/dto/support/PostDetailDto.java | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/gachon/checkmate/domain/post/dto/response/PostDetailResponseDto.java b/src/main/java/org/gachon/checkmate/domain/post/dto/response/PostDetailResponseDto.java index e61f37c..4e32ec9 100644 --- a/src/main/java/org/gachon/checkmate/domain/post/dto/response/PostDetailResponseDto.java +++ b/src/main/java/org/gachon/checkmate/domain/post/dto/response/PostDetailResponseDto.java @@ -7,6 +7,8 @@ @Builder public record PostDetailResponseDto( Long memberId, + String title, + String content, String name, String major, String profile, @@ -20,6 +22,8 @@ public record PostDetailResponseDto( public static PostDetailResponseDto of(PostDetailDto postDetailDto, CheckListResponseDto checkList, boolean isScrap) { return PostDetailResponseDto.builder() .memberId(postDetailDto.memberId()) + .title(postDetailDto.title()) + .content(postDetailDto.content()) .name(postDetailDto.name()) .major(postDetailDto.major()) .profile(postDetailDto.profile()) diff --git a/src/main/java/org/gachon/checkmate/domain/post/dto/support/PostDetailDto.java b/src/main/java/org/gachon/checkmate/domain/post/dto/support/PostDetailDto.java index 1603a20..ea120bb 100644 --- a/src/main/java/org/gachon/checkmate/domain/post/dto/support/PostDetailDto.java +++ b/src/main/java/org/gachon/checkmate/domain/post/dto/support/PostDetailDto.java @@ -10,6 +10,8 @@ public record PostDetailDto( Long memberId, + String title, + String content, String major, MbtiType mbti, GenderType gender, @@ -20,8 +22,10 @@ public record PostDetailDto( PostCheckList postCheckList ) { @QueryProjection - public PostDetailDto(Long memberId, String major, MbtiType mbti, GenderType gender, RoomType roomType, DormitoryType dormitoryType, String name, String profile, PostCheckList postCheckList) { + public PostDetailDto(Long memberId, String title, String content, String major, MbtiType mbti, GenderType gender, RoomType roomType, DormitoryType dormitoryType, String name, String profile, PostCheckList postCheckList) { this.memberId = memberId; + this.title = title; + this.content = content; this.major = major; this.mbti = mbti; this.gender = gender; From 943ce145f0fc58fd3e2a41dd5f586a8d1759fe5d Mon Sep 17 00:00:00 2001 From: RyuKwanKon Date: Mon, 1 Apr 2024 14:12:27 +0900 Subject: [PATCH 3/9] =?UTF-8?q?[fix]=20#71=20post=20=EC=A1=B0=ED=9A=8C?= =?UTF-8?q?=EC=8B=9C=20key=20=EA=B0=92=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../post/dto/response/PostDetailResponseDto.java | 4 ++++ .../domain/post/dto/support/PostDetailDto.java | 10 +++++++++- .../post/repository/PostCustomRepositoryImpl.java | 2 ++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/gachon/checkmate/domain/post/dto/response/PostDetailResponseDto.java b/src/main/java/org/gachon/checkmate/domain/post/dto/response/PostDetailResponseDto.java index 4e32ec9..0569b69 100644 --- a/src/main/java/org/gachon/checkmate/domain/post/dto/response/PostDetailResponseDto.java +++ b/src/main/java/org/gachon/checkmate/domain/post/dto/response/PostDetailResponseDto.java @@ -16,6 +16,8 @@ public record PostDetailResponseDto( String mbti, String roomType, String dormitoryType, + String importantKeyType, + String similarityKeyType, boolean isScrap, CheckListResponseDto checkList ) { @@ -31,6 +33,8 @@ public static PostDetailResponseDto of(PostDetailDto postDetailDto, CheckListRes .roomType(postDetailDto.roomType().getDesc()) .dormitoryType(postDetailDto.dormitoryType().getDesc()) .mbti(postDetailDto.mbti().getDesc()) + .importantKeyType(postDetailDto.importantKeyType().getDesc()) + .similarityKeyType(postDetailDto.similarityKeyType().getDesc()) .isScrap(isScrap) .checkList(checkList) .build(); diff --git a/src/main/java/org/gachon/checkmate/domain/post/dto/support/PostDetailDto.java b/src/main/java/org/gachon/checkmate/domain/post/dto/support/PostDetailDto.java index ea120bb..2acec4b 100644 --- a/src/main/java/org/gachon/checkmate/domain/post/dto/support/PostDetailDto.java +++ b/src/main/java/org/gachon/checkmate/domain/post/dto/support/PostDetailDto.java @@ -6,7 +6,9 @@ import org.gachon.checkmate.domain.member.entity.MbtiType; import org.gachon.checkmate.domain.member.entity.ProfileImageType; import org.gachon.checkmate.domain.post.entity.DormitoryType; +import org.gachon.checkmate.domain.post.entity.ImportantKeyType; import org.gachon.checkmate.domain.post.entity.RoomType; +import org.gachon.checkmate.domain.post.entity.SimilarityKeyType; public record PostDetailDto( Long memberId, @@ -19,10 +21,14 @@ public record PostDetailDto( DormitoryType dormitoryType, String name, String profile, + ImportantKeyType importantKeyType, + SimilarityKeyType similarityKeyType, PostCheckList postCheckList ) { @QueryProjection - public PostDetailDto(Long memberId, String title, String content, String major, MbtiType mbti, GenderType gender, RoomType roomType, DormitoryType dormitoryType, String name, String profile, PostCheckList postCheckList) { + public PostDetailDto(Long memberId, String title, String content, String major, MbtiType mbti, + GenderType gender, RoomType roomType, DormitoryType dormitoryType, String name, + String profile, ImportantKeyType importantKeyType, SimilarityKeyType similarityKeyType, PostCheckList postCheckList) { this.memberId = memberId; this.title = title; this.content = content; @@ -33,6 +39,8 @@ public PostDetailDto(Long memberId, String title, String content, String major, this.dormitoryType = dormitoryType; this.name = name; this.profile = profile; + this.importantKeyType = importantKeyType; + this.similarityKeyType = similarityKeyType; this.postCheckList = postCheckList; } } diff --git a/src/main/java/org/gachon/checkmate/domain/post/repository/PostCustomRepositoryImpl.java b/src/main/java/org/gachon/checkmate/domain/post/repository/PostCustomRepositoryImpl.java index 689fc1e..7d6f88f 100644 --- a/src/main/java/org/gachon/checkmate/domain/post/repository/PostCustomRepositoryImpl.java +++ b/src/main/java/org/gachon/checkmate/domain/post/repository/PostCustomRepositoryImpl.java @@ -39,6 +39,8 @@ public Optional findPostDetail(Long postId) { post.dormitoryType, user.name, user.profile, + post.importantKeyType, + post.similarityKeyType, post.postCheckList )) .from(post) From 7a93b47eebc90274983e315199ce8ecb13299323 Mon Sep 17 00:00:00 2001 From: RyuKwanKon Date: Mon, 1 Apr 2024 14:29:08 +0900 Subject: [PATCH 4/9] =?UTF-8?q?[fix]=20#71=20scrap=20=EC=82=AD=EC=A0=9C?= =?UTF-8?q?=EC=8B=9C=20=EA=B2=8C=EC=8B=9C=EA=B8=80=20=EC=95=84=EC=9D=B4?= =?UTF-8?q?=EB=94=94=EB=A5=BC=20=EC=82=AC=EC=9A=A9=ED=95=98=EA=B2=8C=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../checkmate/domain/scrap/controller/ScrapController.java | 4 ++-- .../checkmate/domain/scrap/repository/ScrapRepository.java | 2 +- .../gachon/checkmate/domain/scrap/service/ScrapService.java | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/gachon/checkmate/domain/scrap/controller/ScrapController.java b/src/main/java/org/gachon/checkmate/domain/scrap/controller/ScrapController.java index b317418..b83d970 100644 --- a/src/main/java/org/gachon/checkmate/domain/scrap/controller/ScrapController.java +++ b/src/main/java/org/gachon/checkmate/domain/scrap/controller/ScrapController.java @@ -32,8 +32,8 @@ public ResponseEntity> createScrapPost(@UserId final Long use @DeleteMapping("/{id}") public ResponseEntity> deleteScrapPost(@UserId final Long userId, - @PathVariable("id") final Long scrapId) { - scrapService.deleteScrapPost(userId, scrapId); + @PathVariable("id") final Long postId) { + scrapService.deleteScrapPost(userId, postId); return SuccessResponse.ok(null); } } diff --git a/src/main/java/org/gachon/checkmate/domain/scrap/repository/ScrapRepository.java b/src/main/java/org/gachon/checkmate/domain/scrap/repository/ScrapRepository.java index f413ab9..e50670b 100644 --- a/src/main/java/org/gachon/checkmate/domain/scrap/repository/ScrapRepository.java +++ b/src/main/java/org/gachon/checkmate/domain/scrap/repository/ScrapRepository.java @@ -4,6 +4,6 @@ import org.springframework.data.jpa.repository.JpaRepository; public interface ScrapRepository extends JpaRepository, ScrapCustomRepository { - void deleteByIdAndUserId(Long scrapId, Long userId); + void deleteByPostIdAndUserId(Long postId, Long userId); boolean existsByPostIdAndUserId(Long postId, Long userId); } diff --git a/src/main/java/org/gachon/checkmate/domain/scrap/service/ScrapService.java b/src/main/java/org/gachon/checkmate/domain/scrap/service/ScrapService.java index b520a9c..5e33069 100644 --- a/src/main/java/org/gachon/checkmate/domain/scrap/service/ScrapService.java +++ b/src/main/java/org/gachon/checkmate/domain/scrap/service/ScrapService.java @@ -51,8 +51,8 @@ public void creatScrapPost(Long userId, ScrapRequestDto scrapRequestDto) { createScrapAndSave(user, post); } - public void deleteScrapPost(Long userId, Long scrapId) { - scrapRepository.deleteByIdAndUserId(scrapId, userId); + public void deleteScrapPost(Long userId, Long postId) { + scrapRepository.deleteByPostIdAndUserId(postId, userId); } private List createPostSearchResponseDto(Page postSearchDtoList, CheckList checkList) { From 0ca5c917c8de420d0fe2e53a19687d62e52340d0 Mon Sep 17 00:00:00 2001 From: RyuKwanKon Date: Mon, 1 Apr 2024 14:34:30 +0900 Subject: [PATCH 5/9] =?UTF-8?q?[feat]=20#71=20scrap=20=EC=A4=91=EB=B3=B5?= =?UTF-8?q?=20=EC=98=88=EC=99=B8=20=EC=BD=94=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/org/gachon/checkmate/global/error/ErrorCode.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/org/gachon/checkmate/global/error/ErrorCode.java b/src/main/java/org/gachon/checkmate/global/error/ErrorCode.java index e41b40b..25abe6c 100644 --- a/src/main/java/org/gachon/checkmate/global/error/ErrorCode.java +++ b/src/main/java/org/gachon/checkmate/global/error/ErrorCode.java @@ -59,6 +59,7 @@ public enum ErrorCode { */ CONFLICT(HttpStatus.CONFLICT, "이미 존재하는 리소스입니다."), DUPLICATE_EMAIL(HttpStatus.CONFLICT, "이미 가입된 이메일입니다."), + DUPLICATE_SCRAP(HttpStatus.CONFLICT, "이미 등록된 스크랩입니다."), DUPLICATE_CHECK_LIST(HttpStatus.CONFLICT, "체크리스트가 이미 존재합니다."), DUPLICATE_POST_REPORT(HttpStatus.CONFLICT, "이전에 신고했던 게시물입니다."), DUPLICATE_CHATROOM_REPORT(HttpStatus.CONFLICT, "이전에 신고했던 채팅방입니다."), From b8404c554118ac74153c8ab67e1f5156289abae9 Mon Sep 17 00:00:00 2001 From: RyuKwanKon Date: Mon, 1 Apr 2024 14:34:37 +0900 Subject: [PATCH 6/9] =?UTF-8?q?[feat]=20#71=20scrap=20=EC=A4=91=EB=B3=B5?= =?UTF-8?q?=20=EC=98=88=EC=99=B8=20=EB=A1=9C=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../checkmate/domain/scrap/service/ScrapService.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/java/org/gachon/checkmate/domain/scrap/service/ScrapService.java b/src/main/java/org/gachon/checkmate/domain/scrap/service/ScrapService.java index 5e33069..e161cde 100644 --- a/src/main/java/org/gachon/checkmate/domain/scrap/service/ScrapService.java +++ b/src/main/java/org/gachon/checkmate/domain/scrap/service/ScrapService.java @@ -14,7 +14,9 @@ import org.gachon.checkmate.domain.scrap.dto.support.ScrapSearchCondition; import org.gachon.checkmate.domain.scrap.entity.Scrap; import org.gachon.checkmate.domain.scrap.repository.ScrapRepository; +import org.gachon.checkmate.global.error.exception.ConflictException; import org.gachon.checkmate.global.error.exception.EntityNotFoundException; +import org.gachon.checkmate.global.error.exception.InvalidValueException; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; @@ -48,6 +50,7 @@ public PostSearchResponseDto getScrapPosts(Long userId, Pageable pageable) { public void creatScrapPost(Long userId, ScrapRequestDto scrapRequestDto) { User user = findUserOrThrow(userId); Post post = findPostOrThrow(scrapRequestDto.postId()); + validateDuplicateScrap(post.getId(), user.getId()); createScrapAndSave(user, post); } @@ -74,6 +77,15 @@ private void createScrapAndSave(User user, Post post) { scrapRepository.save(scrap); } + private void validateDuplicateScrap(Long postId, Long userId) { + if(existPostInScrap(postId, userId)) + throw new ConflictException(DUPLICATE_SCRAP); + } + + private boolean existPostInScrap(Long postId, Long userId) { + return scrapRepository.existsByPostIdAndUserId(postId, userId); + } + private CheckList getCheckList(Long userId) { return checkListRepository.findByUserId(userId) .orElseThrow(() -> new EntityNotFoundException(CHECK_LIST_NOT_FOUND)); From ead2951ae30f6e42a25aef2d57f080dec439b913 Mon Sep 17 00:00:00 2001 From: RyuKwanKon Date: Mon, 1 Apr 2024 14:37:19 +0900 Subject: [PATCH 7/9] =?UTF-8?q?[feat]=20#71=20=EB=93=B1=EB=A1=9D=EB=90=98?= =?UTF-8?q?=EC=A7=80=20=EC=95=8A=EC=9D=80=20=EC=8A=A4=ED=81=AC=EB=9E=A9=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C=EC=8B=9C=20=EC=98=88=EC=99=B8=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gachon/checkmate/domain/scrap/service/ScrapService.java | 5 +++++ .../java/org/gachon/checkmate/global/error/ErrorCode.java | 1 + 2 files changed, 6 insertions(+) diff --git a/src/main/java/org/gachon/checkmate/domain/scrap/service/ScrapService.java b/src/main/java/org/gachon/checkmate/domain/scrap/service/ScrapService.java index e161cde..8a1ba68 100644 --- a/src/main/java/org/gachon/checkmate/domain/scrap/service/ScrapService.java +++ b/src/main/java/org/gachon/checkmate/domain/scrap/service/ScrapService.java @@ -82,6 +82,11 @@ private void validateDuplicateScrap(Long postId, Long userId) { throw new ConflictException(DUPLICATE_SCRAP); } + private void validateExistScrap(Long postId, Long userId) { + if(!existPostInScrap(postId, userId)) + throw new InvalidValueException(); + } + private boolean existPostInScrap(Long postId, Long userId) { return scrapRepository.existsByPostIdAndUserId(postId, userId); } diff --git a/src/main/java/org/gachon/checkmate/global/error/ErrorCode.java b/src/main/java/org/gachon/checkmate/global/error/ErrorCode.java index 25abe6c..035e5d9 100644 --- a/src/main/java/org/gachon/checkmate/global/error/ErrorCode.java +++ b/src/main/java/org/gachon/checkmate/global/error/ErrorCode.java @@ -17,6 +17,7 @@ public enum ErrorCode { INVALID_PASSWORD(HttpStatus.BAD_REQUEST, "비밀번호는 8~20자 대소문자 영문, 숫자, 특수문자의 조합이어야 합니다."), INVALID_POST_TITLE(HttpStatus.BAD_REQUEST, "이미 존재하는 게시물입니다."), INVALID_POST_DATE(HttpStatus.BAD_REQUEST, "마감시간이 지난 게시물입니다."), + INVALID_DELETE_SCRAP(HttpStatus.BAD_REQUEST, "등록되지 않은 스크랩입니다."), /** * 401 Unauthorized From f43f6f1cd48265f3a20c9b535da483c5ed584eef Mon Sep 17 00:00:00 2001 From: RyuKwanKon Date: Mon, 1 Apr 2024 14:40:17 +0900 Subject: [PATCH 8/9] =?UTF-8?q?[feat]=20#71=20=EB=93=B1=EB=A1=9D=EB=90=98?= =?UTF-8?q?=EC=A7=80=20=EC=95=8A=EC=9D=80=20=EC=8A=A4=ED=81=AC=EB=9E=A9=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C=EC=8B=9C=20=EC=98=88=EC=99=B8=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/gachon/checkmate/domain/scrap/service/ScrapService.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/org/gachon/checkmate/domain/scrap/service/ScrapService.java b/src/main/java/org/gachon/checkmate/domain/scrap/service/ScrapService.java index 8a1ba68..075e783 100644 --- a/src/main/java/org/gachon/checkmate/domain/scrap/service/ScrapService.java +++ b/src/main/java/org/gachon/checkmate/domain/scrap/service/ScrapService.java @@ -55,6 +55,7 @@ public void creatScrapPost(Long userId, ScrapRequestDto scrapRequestDto) { } public void deleteScrapPost(Long userId, Long postId) { + validateExistScrap(postId, userId); scrapRepository.deleteByPostIdAndUserId(postId, userId); } From e9f0fac724e629e3defdf404c0dd7bc88e9aff2a Mon Sep 17 00:00:00 2001 From: RyuKwanKon Date: Mon, 1 Apr 2024 14:44:05 +0900 Subject: [PATCH 9/9] =?UTF-8?q?[feat]=20#71=20=EC=82=AD=EC=A0=9C=20?= =?UTF-8?q?=EA=B0=80=EB=8A=A5=20=EC=97=AC=EB=B6=80=20=EC=98=88=EC=99=B8=20?= =?UTF-8?q?=EB=A9=94=EC=84=B8=EC=A7=80=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/gachon/checkmate/domain/scrap/service/ScrapService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/gachon/checkmate/domain/scrap/service/ScrapService.java b/src/main/java/org/gachon/checkmate/domain/scrap/service/ScrapService.java index 075e783..fbaa8e8 100644 --- a/src/main/java/org/gachon/checkmate/domain/scrap/service/ScrapService.java +++ b/src/main/java/org/gachon/checkmate/domain/scrap/service/ScrapService.java @@ -85,7 +85,7 @@ private void validateDuplicateScrap(Long postId, Long userId) { private void validateExistScrap(Long postId, Long userId) { if(!existPostInScrap(postId, userId)) - throw new InvalidValueException(); + throw new InvalidValueException(INVALID_DELETE_SCRAP); } private boolean existPostInScrap(Long postId, Long userId) {