From a70ca1d6f9f92796e6dfd89a4ce219d66fffc145 Mon Sep 17 00:00:00 2001 From: mmingoo Date: Fri, 16 Aug 2024 14:26:51 +0900 Subject: [PATCH 01/24] =?UTF-8?q?=F0=9F=94=A7=20=EC=8A=A4=ED=84=B0?= =?UTF-8?q?=EB=94=94=EB=A3=B8=20=ED=8C=8C=EC=9D=BC=20=EA=B5=AC=EC=A1=B0=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 스터디룸 게시글, 스터디룸 트러블슈팅 게시글, 스터디룸 정보나눔 게시판 각각의 엔티티들을 패키지로 분류 --- .../java/gaji/service/domain/room/entity/Room.java | 3 +-- .../domain/roomBoard/converter/RoomPostConverter.java | 10 +++++----- .../roomBoard/entity/{common => }/RoomBoard.java | 4 ++-- .../roomBoard/entity/{ => RoomInfo}/RoomInfoPost.java | 7 ++----- .../entity/{common => RoomPost}/RoomComment.java | 3 +-- .../entity/{common => RoomPost}/RoomCommentLikes.java | 2 +- .../roomBoard/entity/{ => RoomPost}/RoomPost.java | 4 ++-- .../entity/{common => RoomPost}/RoomPostBookmark.java | 3 +-- .../entity/{common => RoomPost}/RoomPostFile.java | 3 +-- .../entity/{common => RoomPost}/RoomPostLikes.java | 3 +-- .../entity/{common => RoomPost}/RoomPostReport.java | 3 +-- .../entity/{ => RoomTrouble}/RoomTroublePost.java | 4 ++-- .../{ => RoomTrouble}/RoomTroublePostBookmark.java | 2 +- .../entity/{ => RoomTrouble}/RoomTroublePostLike.java | 2 +- .../entity/{ => RoomTrouble}/TroublePostComment.java | 2 +- .../roomBoard/repository/RoomBoardRepository.java | 2 +- .../roomBoard/repository/RoomInfoPostRepository.java | 2 +- .../repository/RoomPostCommentRepository.java | 2 +- .../roomBoard/repository/RoomPostRepository.java | 2 +- .../repository/RoomTroublePostBookmarkRepository.java | 4 ++-- .../repository/RoomTroublePostLikeRepository.java | 4 ++-- .../repository/RoomTroublePostRepository.java | 2 +- .../repository/TroublePostCommentRepository.java | 2 +- .../service/RoomInfoPostCommandServiceImpl.java | 4 ++-- .../roomBoard/service/RoomPostCommandService.java | 2 +- .../roomBoard/service/RoomPostCommandServiceImpl.java | 4 ++-- .../service/RoomTroublePostCommandService.java | 5 ++--- .../service/RoomTroublePostCommandServiceImpl.java | 7 +++++-- .../web/controller/RoomTroublePostController.java | 2 +- .../domain/roomBoard/web/dto/RoomPostRequestDto.java | 1 + .../service/domain/studyMate/entity/StudyMate.java | 8 ++++---- .../java/gaji/service/domain/user/entity/User.java | 3 +-- 32 files changed, 52 insertions(+), 59 deletions(-) rename src/main/java/gaji/service/domain/roomBoard/entity/{common => }/RoomBoard.java (90%) rename src/main/java/gaji/service/domain/roomBoard/entity/{ => RoomInfo}/RoomInfoPost.java (81%) rename src/main/java/gaji/service/domain/roomBoard/entity/{common => RoomPost}/RoomComment.java (91%) rename src/main/java/gaji/service/domain/roomBoard/entity/{common => RoomPost}/RoomCommentLikes.java (90%) rename src/main/java/gaji/service/domain/roomBoard/entity/{ => RoomPost}/RoomPost.java (93%) rename src/main/java/gaji/service/domain/roomBoard/entity/{common => RoomPost}/RoomPostBookmark.java (83%) rename src/main/java/gaji/service/domain/roomBoard/entity/{common => RoomPost}/RoomPostFile.java (84%) rename src/main/java/gaji/service/domain/roomBoard/entity/{common => RoomPost}/RoomPostLikes.java (83%) rename src/main/java/gaji/service/domain/roomBoard/entity/{common => RoomPost}/RoomPostReport.java (86%) rename src/main/java/gaji/service/domain/roomBoard/entity/{ => RoomTrouble}/RoomTroublePost.java (95%) rename src/main/java/gaji/service/domain/roomBoard/entity/{ => RoomTrouble}/RoomTroublePostBookmark.java (90%) rename src/main/java/gaji/service/domain/roomBoard/entity/{ => RoomTrouble}/RoomTroublePostLike.java (90%) rename src/main/java/gaji/service/domain/roomBoard/entity/{ => RoomTrouble}/TroublePostComment.java (96%) diff --git a/src/main/java/gaji/service/domain/room/entity/Room.java b/src/main/java/gaji/service/domain/room/entity/Room.java index 37880143..770a3186 100644 --- a/src/main/java/gaji/service/domain/room/entity/Room.java +++ b/src/main/java/gaji/service/domain/room/entity/Room.java @@ -1,13 +1,12 @@ package gaji.service.domain.room.entity; import gaji.service.domain.common.entity.BaseEntity; -import gaji.service.domain.common.entity.SelectCategory; import gaji.service.domain.curriculum.Curriculum; import gaji.service.domain.user.entity.User; import gaji.service.domain.enums.RecruitPostTypeEnum; import gaji.service.domain.recruit.entity.RecruitPostBookmark; import gaji.service.domain.recruit.entity.RecruitPostLikes; -import gaji.service.domain.roomBoard.entity.common.RoomBoard; +import gaji.service.domain.roomBoard.entity.RoomBoard; import gaji.service.domain.studyMate.entity.Chat; import gaji.service.domain.studyMate.entity.StudyApplicant; import gaji.service.domain.studyMate.entity.StudyMate; diff --git a/src/main/java/gaji/service/domain/roomBoard/converter/RoomPostConverter.java b/src/main/java/gaji/service/domain/roomBoard/converter/RoomPostConverter.java index 1dbfbfd9..0321bffe 100644 --- a/src/main/java/gaji/service/domain/roomBoard/converter/RoomPostConverter.java +++ b/src/main/java/gaji/service/domain/roomBoard/converter/RoomPostConverter.java @@ -1,10 +1,10 @@ package gaji.service.domain.roomBoard.converter; -import gaji.service.domain.roomBoard.entity.RoomInfoPost; -import gaji.service.domain.roomBoard.entity.common.RoomBoard; -import gaji.service.domain.roomBoard.entity.RoomPost; -import gaji.service.domain.roomBoard.entity.RoomTroublePost; -import gaji.service.domain.roomBoard.entity.TroublePostComment; +import gaji.service.domain.roomBoard.entity.RoomInfo.RoomInfoPost; +import gaji.service.domain.roomBoard.entity.RoomBoard; +import gaji.service.domain.roomBoard.entity.RoomPost.RoomPost; +import gaji.service.domain.roomBoard.entity.RoomTrouble.RoomTroublePost; +import gaji.service.domain.roomBoard.entity.RoomTrouble.TroublePostComment; import gaji.service.domain.roomBoard.web.dto.RoomPostRequestDto; import gaji.service.domain.roomBoard.web.dto.RoomPostResponseDto; import gaji.service.domain.studyMate.entity.StudyMate; diff --git a/src/main/java/gaji/service/domain/roomBoard/entity/common/RoomBoard.java b/src/main/java/gaji/service/domain/roomBoard/entity/RoomBoard.java similarity index 90% rename from src/main/java/gaji/service/domain/roomBoard/entity/common/RoomBoard.java rename to src/main/java/gaji/service/domain/roomBoard/entity/RoomBoard.java index 35c83a2a..e7cc5539 100644 --- a/src/main/java/gaji/service/domain/roomBoard/entity/common/RoomBoard.java +++ b/src/main/java/gaji/service/domain/roomBoard/entity/RoomBoard.java @@ -1,8 +1,8 @@ -package gaji.service.domain.roomBoard.entity.common; +package gaji.service.domain.roomBoard.entity; import gaji.service.domain.enums.RoomPostType; import gaji.service.domain.room.entity.Room; -import gaji.service.domain.roomBoard.entity.RoomPost; +import gaji.service.domain.roomBoard.entity.RoomPost.RoomPost; import jakarta.persistence.*; import lombok.*; diff --git a/src/main/java/gaji/service/domain/roomBoard/entity/RoomInfoPost.java b/src/main/java/gaji/service/domain/roomBoard/entity/RoomInfo/RoomInfoPost.java similarity index 81% rename from src/main/java/gaji/service/domain/roomBoard/entity/RoomInfoPost.java rename to src/main/java/gaji/service/domain/roomBoard/entity/RoomInfo/RoomInfoPost.java index 6388c9b6..cf8eabc3 100644 --- a/src/main/java/gaji/service/domain/roomBoard/entity/RoomInfoPost.java +++ b/src/main/java/gaji/service/domain/roomBoard/entity/RoomInfo/RoomInfoPost.java @@ -1,14 +1,11 @@ -package gaji.service.domain.roomBoard.entity; +package gaji.service.domain.roomBoard.entity.RoomInfo; -import gaji.service.domain.roomBoard.entity.common.*; +import gaji.service.domain.roomBoard.entity.RoomBoard; import gaji.service.domain.studyMate.entity.StudyMate; -import gaji.service.domain.user.entity.User; import jakarta.persistence.*; import lombok.*; import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.List; @Entity @Getter diff --git a/src/main/java/gaji/service/domain/roomBoard/entity/common/RoomComment.java b/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomComment.java similarity index 91% rename from src/main/java/gaji/service/domain/roomBoard/entity/common/RoomComment.java rename to src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomComment.java index 9dbeeb6f..f8b892f6 100644 --- a/src/main/java/gaji/service/domain/roomBoard/entity/common/RoomComment.java +++ b/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomComment.java @@ -1,7 +1,6 @@ -package gaji.service.domain.roomBoard.entity.common; +package gaji.service.domain.roomBoard.entity.RoomPost; import gaji.service.domain.enums.UserAlarmTypeEnum; -import gaji.service.domain.roomBoard.entity.RoomPost; import gaji.service.domain.user.entity.User; import jakarta.persistence.*; import lombok.AccessLevel; diff --git a/src/main/java/gaji/service/domain/roomBoard/entity/common/RoomCommentLikes.java b/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomCommentLikes.java similarity index 90% rename from src/main/java/gaji/service/domain/roomBoard/entity/common/RoomCommentLikes.java rename to src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomCommentLikes.java index 68b5187b..2004bc7c 100644 --- a/src/main/java/gaji/service/domain/roomBoard/entity/common/RoomCommentLikes.java +++ b/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomCommentLikes.java @@ -1,4 +1,4 @@ -package gaji.service.domain.roomBoard.entity.common; +package gaji.service.domain.roomBoard.entity.RoomPost; import gaji.service.domain.user.entity.User; import jakarta.persistence.*; diff --git a/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost.java b/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPost.java similarity index 93% rename from src/main/java/gaji/service/domain/roomBoard/entity/RoomPost.java rename to src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPost.java index 3f8d0db0..f44f65ec 100644 --- a/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost.java +++ b/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPost.java @@ -1,6 +1,6 @@ -package gaji.service.domain.roomBoard.entity; +package gaji.service.domain.roomBoard.entity.RoomPost; -import gaji.service.domain.roomBoard.entity.common.*; +import gaji.service.domain.roomBoard.entity.RoomBoard; import gaji.service.domain.user.entity.User; import jakarta.persistence.*; import lombok.*; diff --git a/src/main/java/gaji/service/domain/roomBoard/entity/common/RoomPostBookmark.java b/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPostBookmark.java similarity index 83% rename from src/main/java/gaji/service/domain/roomBoard/entity/common/RoomPostBookmark.java rename to src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPostBookmark.java index 999f17d1..75aec6e4 100644 --- a/src/main/java/gaji/service/domain/roomBoard/entity/common/RoomPostBookmark.java +++ b/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPostBookmark.java @@ -1,6 +1,5 @@ -package gaji.service.domain.roomBoard.entity.common; +package gaji.service.domain.roomBoard.entity.RoomPost; -import gaji.service.domain.roomBoard.entity.RoomPost; import gaji.service.domain.user.entity.User; import jakarta.persistence.*; import lombok.AccessLevel; diff --git a/src/main/java/gaji/service/domain/roomBoard/entity/common/RoomPostFile.java b/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPostFile.java similarity index 84% rename from src/main/java/gaji/service/domain/roomBoard/entity/common/RoomPostFile.java rename to src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPostFile.java index ed95c895..08b4df4d 100644 --- a/src/main/java/gaji/service/domain/roomBoard/entity/common/RoomPostFile.java +++ b/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPostFile.java @@ -1,6 +1,5 @@ -package gaji.service.domain.roomBoard.entity.common; +package gaji.service.domain.roomBoard.entity.RoomPost; -import gaji.service.domain.roomBoard.entity.RoomPost; import gaji.service.domain.user.entity.User; import jakarta.persistence.*; import lombok.AccessLevel; diff --git a/src/main/java/gaji/service/domain/roomBoard/entity/common/RoomPostLikes.java b/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPostLikes.java similarity index 83% rename from src/main/java/gaji/service/domain/roomBoard/entity/common/RoomPostLikes.java rename to src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPostLikes.java index 170a9212..82d49126 100644 --- a/src/main/java/gaji/service/domain/roomBoard/entity/common/RoomPostLikes.java +++ b/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPostLikes.java @@ -1,6 +1,5 @@ -package gaji.service.domain.roomBoard.entity.common; +package gaji.service.domain.roomBoard.entity.RoomPost; -import gaji.service.domain.roomBoard.entity.RoomPost; import gaji.service.domain.user.entity.User; import jakarta.persistence.*; import lombok.AccessLevel; diff --git a/src/main/java/gaji/service/domain/roomBoard/entity/common/RoomPostReport.java b/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPostReport.java similarity index 86% rename from src/main/java/gaji/service/domain/roomBoard/entity/common/RoomPostReport.java rename to src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPostReport.java index b8167f0b..39ba829e 100644 --- a/src/main/java/gaji/service/domain/roomBoard/entity/common/RoomPostReport.java +++ b/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPostReport.java @@ -1,6 +1,5 @@ -package gaji.service.domain.roomBoard.entity.common; +package gaji.service.domain.roomBoard.entity.RoomPost; -import gaji.service.domain.roomBoard.entity.RoomPost; import gaji.service.domain.user.entity.User; import gaji.service.domain.enums.ReportPostTypeEnum; import jakarta.persistence.*; diff --git a/src/main/java/gaji/service/domain/roomBoard/entity/RoomTroublePost.java b/src/main/java/gaji/service/domain/roomBoard/entity/RoomTrouble/RoomTroublePost.java similarity index 95% rename from src/main/java/gaji/service/domain/roomBoard/entity/RoomTroublePost.java rename to src/main/java/gaji/service/domain/roomBoard/entity/RoomTrouble/RoomTroublePost.java index c0dec9cc..ca2d1b1c 100644 --- a/src/main/java/gaji/service/domain/roomBoard/entity/RoomTroublePost.java +++ b/src/main/java/gaji/service/domain/roomBoard/entity/RoomTrouble/RoomTroublePost.java @@ -1,7 +1,7 @@ -package gaji.service.domain.roomBoard.entity; +package gaji.service.domain.roomBoard.entity.RoomTrouble; import gaji.service.domain.common.entity.BaseEntity; -import gaji.service.domain.roomBoard.entity.common.RoomBoard; +import gaji.service.domain.roomBoard.entity.RoomBoard; import gaji.service.domain.studyMate.entity.StudyMate; import jakarta.persistence.*; import lombok.*; diff --git a/src/main/java/gaji/service/domain/roomBoard/entity/RoomTroublePostBookmark.java b/src/main/java/gaji/service/domain/roomBoard/entity/RoomTrouble/RoomTroublePostBookmark.java similarity index 90% rename from src/main/java/gaji/service/domain/roomBoard/entity/RoomTroublePostBookmark.java rename to src/main/java/gaji/service/domain/roomBoard/entity/RoomTrouble/RoomTroublePostBookmark.java index 4ab5b1d1..4263f8a6 100644 --- a/src/main/java/gaji/service/domain/roomBoard/entity/RoomTroublePostBookmark.java +++ b/src/main/java/gaji/service/domain/roomBoard/entity/RoomTrouble/RoomTroublePostBookmark.java @@ -1,4 +1,4 @@ -package gaji.service.domain.roomBoard.entity; +package gaji.service.domain.roomBoard.entity.RoomTrouble; import gaji.service.domain.studyMate.entity.StudyMate; import jakarta.persistence.*; diff --git a/src/main/java/gaji/service/domain/roomBoard/entity/RoomTroublePostLike.java b/src/main/java/gaji/service/domain/roomBoard/entity/RoomTrouble/RoomTroublePostLike.java similarity index 90% rename from src/main/java/gaji/service/domain/roomBoard/entity/RoomTroublePostLike.java rename to src/main/java/gaji/service/domain/roomBoard/entity/RoomTrouble/RoomTroublePostLike.java index f285d109..df2413b3 100644 --- a/src/main/java/gaji/service/domain/roomBoard/entity/RoomTroublePostLike.java +++ b/src/main/java/gaji/service/domain/roomBoard/entity/RoomTrouble/RoomTroublePostLike.java @@ -1,4 +1,4 @@ -package gaji.service.domain.roomBoard.entity; +package gaji.service.domain.roomBoard.entity.RoomTrouble; import gaji.service.domain.studyMate.entity.StudyMate; import jakarta.persistence.*; diff --git a/src/main/java/gaji/service/domain/roomBoard/entity/TroublePostComment.java b/src/main/java/gaji/service/domain/roomBoard/entity/RoomTrouble/TroublePostComment.java similarity index 96% rename from src/main/java/gaji/service/domain/roomBoard/entity/TroublePostComment.java rename to src/main/java/gaji/service/domain/roomBoard/entity/RoomTrouble/TroublePostComment.java index 7e6b4303..95b82db7 100644 --- a/src/main/java/gaji/service/domain/roomBoard/entity/TroublePostComment.java +++ b/src/main/java/gaji/service/domain/roomBoard/entity/RoomTrouble/TroublePostComment.java @@ -1,4 +1,4 @@ -package gaji.service.domain.roomBoard.entity; +package gaji.service.domain.roomBoard.entity.RoomTrouble; import gaji.service.domain.user.entity.User; import jakarta.persistence.*; diff --git a/src/main/java/gaji/service/domain/roomBoard/repository/RoomBoardRepository.java b/src/main/java/gaji/service/domain/roomBoard/repository/RoomBoardRepository.java index 4a049784..f88e4b48 100644 --- a/src/main/java/gaji/service/domain/roomBoard/repository/RoomBoardRepository.java +++ b/src/main/java/gaji/service/domain/roomBoard/repository/RoomBoardRepository.java @@ -1,6 +1,6 @@ package gaji.service.domain.roomBoard.repository; -import gaji.service.domain.roomBoard.entity.common.RoomBoard; +import gaji.service.domain.roomBoard.entity.RoomBoard; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; diff --git a/src/main/java/gaji/service/domain/roomBoard/repository/RoomInfoPostRepository.java b/src/main/java/gaji/service/domain/roomBoard/repository/RoomInfoPostRepository.java index 56073d8f..c49bad17 100644 --- a/src/main/java/gaji/service/domain/roomBoard/repository/RoomInfoPostRepository.java +++ b/src/main/java/gaji/service/domain/roomBoard/repository/RoomInfoPostRepository.java @@ -1,6 +1,6 @@ package gaji.service.domain.roomBoard.repository; -import gaji.service.domain.roomBoard.entity.RoomInfoPost; +import gaji.service.domain.roomBoard.entity.RoomInfo.RoomInfoPost; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; diff --git a/src/main/java/gaji/service/domain/roomBoard/repository/RoomPostCommentRepository.java b/src/main/java/gaji/service/domain/roomBoard/repository/RoomPostCommentRepository.java index 970d95df..08a79131 100644 --- a/src/main/java/gaji/service/domain/roomBoard/repository/RoomPostCommentRepository.java +++ b/src/main/java/gaji/service/domain/roomBoard/repository/RoomPostCommentRepository.java @@ -1,7 +1,7 @@ package gaji.service.domain.roomBoard.repository; -import gaji.service.domain.roomBoard.entity.TroublePostComment; +import gaji.service.domain.roomBoard.entity.RoomTrouble.TroublePostComment; import org.springframework.data.jpa.repository.JpaRepository; public interface RoomPostCommentRepository extends JpaRepository { diff --git a/src/main/java/gaji/service/domain/roomBoard/repository/RoomPostRepository.java b/src/main/java/gaji/service/domain/roomBoard/repository/RoomPostRepository.java index f955dc8a..b0d67ff1 100644 --- a/src/main/java/gaji/service/domain/roomBoard/repository/RoomPostRepository.java +++ b/src/main/java/gaji/service/domain/roomBoard/repository/RoomPostRepository.java @@ -1,6 +1,6 @@ package gaji.service.domain.roomBoard.repository; -import gaji.service.domain.roomBoard.entity.RoomPost; +import gaji.service.domain.roomBoard.entity.RoomPost.RoomPost; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; diff --git a/src/main/java/gaji/service/domain/roomBoard/repository/RoomTroublePostBookmarkRepository.java b/src/main/java/gaji/service/domain/roomBoard/repository/RoomTroublePostBookmarkRepository.java index 3923e32d..aebeee06 100644 --- a/src/main/java/gaji/service/domain/roomBoard/repository/RoomTroublePostBookmarkRepository.java +++ b/src/main/java/gaji/service/domain/roomBoard/repository/RoomTroublePostBookmarkRepository.java @@ -1,7 +1,7 @@ package gaji.service.domain.roomBoard.repository; -import gaji.service.domain.roomBoard.entity.RoomTroublePost; -import gaji.service.domain.roomBoard.entity.RoomTroublePostBookmark; +import gaji.service.domain.roomBoard.entity.RoomTrouble.RoomTroublePost; +import gaji.service.domain.roomBoard.entity.RoomTrouble.RoomTroublePostBookmark; import gaji.service.domain.studyMate.entity.StudyMate; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; diff --git a/src/main/java/gaji/service/domain/roomBoard/repository/RoomTroublePostLikeRepository.java b/src/main/java/gaji/service/domain/roomBoard/repository/RoomTroublePostLikeRepository.java index 50cefed1..bede49e4 100644 --- a/src/main/java/gaji/service/domain/roomBoard/repository/RoomTroublePostLikeRepository.java +++ b/src/main/java/gaji/service/domain/roomBoard/repository/RoomTroublePostLikeRepository.java @@ -1,7 +1,7 @@ package gaji.service.domain.roomBoard.repository; -import gaji.service.domain.roomBoard.entity.RoomTroublePost; -import gaji.service.domain.roomBoard.entity.RoomTroublePostLike; +import gaji.service.domain.roomBoard.entity.RoomTrouble.RoomTroublePost; +import gaji.service.domain.roomBoard.entity.RoomTrouble.RoomTroublePostLike; import gaji.service.domain.studyMate.entity.StudyMate; import org.springframework.data.jpa.repository.JpaRepository; diff --git a/src/main/java/gaji/service/domain/roomBoard/repository/RoomTroublePostRepository.java b/src/main/java/gaji/service/domain/roomBoard/repository/RoomTroublePostRepository.java index 3523db2f..e4b64be1 100644 --- a/src/main/java/gaji/service/domain/roomBoard/repository/RoomTroublePostRepository.java +++ b/src/main/java/gaji/service/domain/roomBoard/repository/RoomTroublePostRepository.java @@ -1,6 +1,6 @@ package gaji.service.domain.roomBoard.repository; -import gaji.service.domain.roomBoard.entity.RoomTroublePost; +import gaji.service.domain.roomBoard.entity.RoomTrouble.RoomTroublePost; import gaji.service.domain.roomBoard.web.dto.RoomPostResponseDto; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; diff --git a/src/main/java/gaji/service/domain/roomBoard/repository/TroublePostCommentRepository.java b/src/main/java/gaji/service/domain/roomBoard/repository/TroublePostCommentRepository.java index 655c88bb..8527eb19 100644 --- a/src/main/java/gaji/service/domain/roomBoard/repository/TroublePostCommentRepository.java +++ b/src/main/java/gaji/service/domain/roomBoard/repository/TroublePostCommentRepository.java @@ -1,6 +1,6 @@ package gaji.service.domain.roomBoard.repository; -import gaji.service.domain.roomBoard.entity.TroublePostComment; +import gaji.service.domain.roomBoard.entity.RoomTrouble.TroublePostComment; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomInfoPostCommandServiceImpl.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomInfoPostCommandServiceImpl.java index 8eac8545..f6f3ca8c 100644 --- a/src/main/java/gaji/service/domain/roomBoard/service/RoomInfoPostCommandServiceImpl.java +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomInfoPostCommandServiceImpl.java @@ -4,8 +4,8 @@ import gaji.service.domain.room.entity.Room; import gaji.service.domain.room.service.RoomQueryService; import gaji.service.domain.roomBoard.converter.RoomPostConverter; -import gaji.service.domain.roomBoard.entity.RoomInfoPost; -import gaji.service.domain.roomBoard.entity.common.RoomBoard; +import gaji.service.domain.roomBoard.entity.RoomInfo.RoomInfoPost; +import gaji.service.domain.roomBoard.entity.RoomBoard; import gaji.service.domain.roomBoard.repository.RoomBoardRepository; import gaji.service.domain.roomBoard.repository.RoomInfoPostRepository; import gaji.service.domain.roomBoard.repository.RoomTroublePostRepository; diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomPostCommandService.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomPostCommandService.java index a92ebdc1..7e4da37b 100644 --- a/src/main/java/gaji/service/domain/roomBoard/service/RoomPostCommandService.java +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomPostCommandService.java @@ -1,6 +1,6 @@ package gaji.service.domain.roomBoard.service; -import gaji.service.domain.roomBoard.entity.RoomPost; +import gaji.service.domain.roomBoard.entity.RoomPost.RoomPost; import gaji.service.domain.roomBoard.web.dto.RoomPostRequestDto; public interface RoomPostCommandService { diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomPostCommandServiceImpl.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomPostCommandServiceImpl.java index 0ea89264..acfbf44c 100644 --- a/src/main/java/gaji/service/domain/roomBoard/service/RoomPostCommandServiceImpl.java +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomPostCommandServiceImpl.java @@ -3,8 +3,8 @@ import gaji.service.domain.room.entity.Room; import gaji.service.domain.room.service.RoomQueryService; import gaji.service.domain.roomBoard.converter.RoomPostConverter; -import gaji.service.domain.roomBoard.entity.common.RoomBoard; -import gaji.service.domain.roomBoard.entity.RoomPost; +import gaji.service.domain.roomBoard.entity.RoomBoard; +import gaji.service.domain.roomBoard.entity.RoomPost.RoomPost; import gaji.service.domain.roomBoard.repository.RoomBoardRepository; import gaji.service.domain.roomBoard.repository.RoomPostRepository; import gaji.service.domain.roomBoard.web.dto.RoomPostRequestDto; diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomTroublePostCommandService.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomTroublePostCommandService.java index 93a1167b..39d253d3 100644 --- a/src/main/java/gaji/service/domain/roomBoard/service/RoomTroublePostCommandService.java +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomTroublePostCommandService.java @@ -1,10 +1,9 @@ package gaji.service.domain.roomBoard.service; -import gaji.service.domain.roomBoard.entity.RoomTroublePost; -import gaji.service.domain.roomBoard.entity.TroublePostComment; +import gaji.service.domain.roomBoard.entity.RoomTrouble.RoomTroublePost; +import gaji.service.domain.roomBoard.entity.RoomTrouble.TroublePostComment; import gaji.service.domain.roomBoard.web.dto.RoomPostRequestDto; import gaji.service.domain.roomBoard.web.dto.RoomPostResponseDto; -import jakarta.transaction.Transactional; public interface RoomTroublePostCommandService { TroublePostComment writeCommentOnTroublePost(Long userId, Long postId, RoomPostRequestDto.RoomTroubleCommentDto request); diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomTroublePostCommandServiceImpl.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomTroublePostCommandServiceImpl.java index ad34c1fd..33102b7e 100644 --- a/src/main/java/gaji/service/domain/roomBoard/service/RoomTroublePostCommandServiceImpl.java +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomTroublePostCommandServiceImpl.java @@ -5,8 +5,11 @@ import gaji.service.domain.room.service.RoomQueryService; import gaji.service.domain.roomBoard.code.RoomPostErrorStatus; import gaji.service.domain.roomBoard.converter.RoomPostConverter; -import gaji.service.domain.roomBoard.entity.*; -import gaji.service.domain.roomBoard.entity.common.RoomBoard; +import gaji.service.domain.roomBoard.entity.RoomTrouble.RoomTroublePost; +import gaji.service.domain.roomBoard.entity.RoomTrouble.RoomTroublePostBookmark; +import gaji.service.domain.roomBoard.entity.RoomTrouble.RoomTroublePostLike; +import gaji.service.domain.roomBoard.entity.RoomTrouble.TroublePostComment; +import gaji.service.domain.roomBoard.entity.RoomBoard; import gaji.service.domain.roomBoard.repository.*; import gaji.service.domain.roomBoard.web.dto.RoomPostRequestDto; import gaji.service.domain.roomBoard.web.dto.RoomPostResponseDto; diff --git a/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomTroublePostController.java b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomTroublePostController.java index 693d87ae..ed990825 100644 --- a/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomTroublePostController.java +++ b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomTroublePostController.java @@ -1,7 +1,7 @@ package gaji.service.domain.roomBoard.web.controller; import gaji.service.domain.roomBoard.converter.RoomPostConverter; -import gaji.service.domain.roomBoard.entity.TroublePostComment; +import gaji.service.domain.roomBoard.entity.RoomTrouble.TroublePostComment; import gaji.service.domain.roomBoard.service.RoomPostQueryService; import gaji.service.domain.roomBoard.service.RoomTroublePostCommandService; import gaji.service.domain.roomBoard.web.dto.RoomPostRequestDto; diff --git a/src/main/java/gaji/service/domain/roomBoard/web/dto/RoomPostRequestDto.java b/src/main/java/gaji/service/domain/roomBoard/web/dto/RoomPostRequestDto.java index bd67edcf..9cf42291 100644 --- a/src/main/java/gaji/service/domain/roomBoard/web/dto/RoomPostRequestDto.java +++ b/src/main/java/gaji/service/domain/roomBoard/web/dto/RoomPostRequestDto.java @@ -34,6 +34,7 @@ public static class RoomTroubloePostDto { @NotBlank(message = "게시글 본문을 입력해주세요.") private final String body; } + @Schema(description = " 게시글 댓글 작성 DTO") @Getter @RequiredArgsConstructor diff --git a/src/main/java/gaji/service/domain/studyMate/entity/StudyMate.java b/src/main/java/gaji/service/domain/studyMate/entity/StudyMate.java index e08c1a44..54e52349 100644 --- a/src/main/java/gaji/service/domain/studyMate/entity/StudyMate.java +++ b/src/main/java/gaji/service/domain/studyMate/entity/StudyMate.java @@ -3,10 +3,10 @@ import gaji.service.domain.enums.Role; import gaji.service.domain.room.entity.Room; import gaji.service.domain.room.entity.RoomNotice; -import gaji.service.domain.roomBoard.entity.RoomTroublePostBookmark; -import gaji.service.domain.roomBoard.entity.RoomTroublePostLike; -import gaji.service.domain.roomBoard.entity.RoomInfoPost; -import gaji.service.domain.roomBoard.entity.RoomTroublePost; +import gaji.service.domain.roomBoard.entity.RoomTrouble.RoomTroublePostBookmark; +import gaji.service.domain.roomBoard.entity.RoomTrouble.RoomTroublePostLike; +import gaji.service.domain.roomBoard.entity.RoomInfo.RoomInfoPost; +import gaji.service.domain.roomBoard.entity.RoomTrouble.RoomTroublePost; import gaji.service.domain.user.entity.User; import jakarta.persistence.*; import lombok.AccessLevel; diff --git a/src/main/java/gaji/service/domain/user/entity/User.java b/src/main/java/gaji/service/domain/user/entity/User.java index ad2f7f17..9eb9107f 100644 --- a/src/main/java/gaji/service/domain/user/entity/User.java +++ b/src/main/java/gaji/service/domain/user/entity/User.java @@ -13,8 +13,7 @@ import gaji.service.domain.room.entity.Room; import gaji.service.domain.room.entity.RoomEvent; import gaji.service.domain.room.entity.VoiceChatUser; -import gaji.service.domain.roomBoard.entity.*; -import gaji.service.domain.roomBoard.entity.common.*; +import gaji.service.domain.roomBoard.entity.RoomPost.*; import gaji.service.domain.studyMate.entity.*; import gaji.service.oauth2.dto.TransferUserDTO; import jakarta.persistence.*; From 7e9cd8669c2c4442d6ab30442aa1b1d097d7a371 Mon Sep 17 00:00:00 2001 From: mmingoo Date: Fri, 16 Aug 2024 14:30:13 +0900 Subject: [PATCH 02/24] =?UTF-8?q?=F0=9F=94=A7=20=EC=8A=A4=ED=84=B0?= =?UTF-8?q?=EB=94=94=EB=A3=B8=20=ED=8C=8C=EC=9D=BC=20=EA=B5=AC=EC=A1=B0=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 스터디룸 게시글, 스터디룸 트러블슈팅 게시글, 스터디룸 정보나눔 게시판 각각의 service, repository들을 패키지로 분류 --- .../repository/{ => RoomInfo}/RoomInfoPostRepository.java | 2 +- .../{ => RoomPost}/RoomPostCommentRepository.java | 2 +- .../{ => RoomPost}/RoomPostQueryRepository.java | 2 +- .../repository/{ => RoomPost}/RoomPostRepository.java | 2 +- .../RoomTroublePostBookmarkRepository.java | 2 +- .../{ => RoomTrouble}/RoomTroublePostLikeRepository.java | 2 +- .../{ => RoomTrouble}/RoomTroublePostRepository.java | 2 +- .../{ => RoomTrouble}/TroublePostCommentRepository.java | 2 +- .../{ => RoomInfo}/RoomInfoPostCommandService.java | 2 +- .../{ => RoomInfo}/RoomInfoPostCommandServiceImpl.java | 6 +++--- .../service/{ => RoomPost}/RoomPostCommandService.java | 2 +- .../{ => RoomPost}/RoomPostCommandServiceImpl.java | 4 ++-- .../service/{ => RoomPost}/RoomPostQueryService.java | 2 +- .../service/{ => RoomPost}/RoomPostQueryServiceImpl.java | 6 +++--- .../{ => RoomTrouble}/RoomTroublePostCommandService.java | 2 +- .../RoomTroublePostCommandServiceImpl.java | 8 +++++++- .../roomBoard/web/controller/RoomInfoPostController.java | 3 +-- .../web/controller/RoomTroublePostController.java | 4 ++-- 18 files changed, 30 insertions(+), 25 deletions(-) rename src/main/java/gaji/service/domain/roomBoard/repository/{ => RoomInfo}/RoomInfoPostRepository.java (82%) rename src/main/java/gaji/service/domain/roomBoard/repository/{ => RoomPost}/RoomPostCommentRepository.java (79%) rename src/main/java/gaji/service/domain/roomBoard/repository/{ => RoomPost}/RoomPostQueryRepository.java (95%) rename src/main/java/gaji/service/domain/roomBoard/repository/{ => RoomPost}/RoomPostRepository.java (81%) rename src/main/java/gaji/service/domain/roomBoard/repository/{ => RoomTrouble}/RoomTroublePostBookmarkRepository.java (90%) rename src/main/java/gaji/service/domain/roomBoard/repository/{ => RoomTrouble}/RoomTroublePostLikeRepository.java (89%) rename src/main/java/gaji/service/domain/roomBoard/repository/{ => RoomTrouble}/RoomTroublePostRepository.java (94%) rename src/main/java/gaji/service/domain/roomBoard/repository/{ => RoomTrouble}/TroublePostCommentRepository.java (82%) rename src/main/java/gaji/service/domain/roomBoard/service/{ => RoomInfo}/RoomInfoPostCommandService.java (85%) rename src/main/java/gaji/service/domain/roomBoard/service/{ => RoomInfo}/RoomInfoPostCommandServiceImpl.java (92%) rename src/main/java/gaji/service/domain/roomBoard/service/{ => RoomPost}/RoomPostCommandService.java (82%) rename src/main/java/gaji/service/domain/roomBoard/service/{ => RoomPost}/RoomPostCommandServiceImpl.java (94%) rename src/main/java/gaji/service/domain/roomBoard/service/{ => RoomPost}/RoomPostQueryService.java (88%) rename src/main/java/gaji/service/domain/roomBoard/service/{ => RoomPost}/RoomPostQueryServiceImpl.java (83%) rename src/main/java/gaji/service/domain/roomBoard/service/{ => RoomTrouble}/RoomTroublePostCommandService.java (96%) rename src/main/java/gaji/service/domain/roomBoard/service/{ => RoomTrouble}/RoomTroublePostCommandServiceImpl.java (95%) diff --git a/src/main/java/gaji/service/domain/roomBoard/repository/RoomInfoPostRepository.java b/src/main/java/gaji/service/domain/roomBoard/repository/RoomInfo/RoomInfoPostRepository.java similarity index 82% rename from src/main/java/gaji/service/domain/roomBoard/repository/RoomInfoPostRepository.java rename to src/main/java/gaji/service/domain/roomBoard/repository/RoomInfo/RoomInfoPostRepository.java index c49bad17..c68bbaff 100644 --- a/src/main/java/gaji/service/domain/roomBoard/repository/RoomInfoPostRepository.java +++ b/src/main/java/gaji/service/domain/roomBoard/repository/RoomInfo/RoomInfoPostRepository.java @@ -1,4 +1,4 @@ -package gaji.service.domain.roomBoard.repository; +package gaji.service.domain.roomBoard.repository.RoomInfo; import gaji.service.domain.roomBoard.entity.RoomInfo.RoomInfoPost; import org.springframework.data.jpa.repository.JpaRepository; diff --git a/src/main/java/gaji/service/domain/roomBoard/repository/RoomPostCommentRepository.java b/src/main/java/gaji/service/domain/roomBoard/repository/RoomPost/RoomPostCommentRepository.java similarity index 79% rename from src/main/java/gaji/service/domain/roomBoard/repository/RoomPostCommentRepository.java rename to src/main/java/gaji/service/domain/roomBoard/repository/RoomPost/RoomPostCommentRepository.java index 08a79131..a2373111 100644 --- a/src/main/java/gaji/service/domain/roomBoard/repository/RoomPostCommentRepository.java +++ b/src/main/java/gaji/service/domain/roomBoard/repository/RoomPost/RoomPostCommentRepository.java @@ -1,4 +1,4 @@ -package gaji.service.domain.roomBoard.repository; +package gaji.service.domain.roomBoard.repository.RoomPost; import gaji.service.domain.roomBoard.entity.RoomTrouble.TroublePostComment; diff --git a/src/main/java/gaji/service/domain/roomBoard/repository/RoomPostQueryRepository.java b/src/main/java/gaji/service/domain/roomBoard/repository/RoomPost/RoomPostQueryRepository.java similarity index 95% rename from src/main/java/gaji/service/domain/roomBoard/repository/RoomPostQueryRepository.java rename to src/main/java/gaji/service/domain/roomBoard/repository/RoomPost/RoomPostQueryRepository.java index 9e561799..abbac418 100644 --- a/src/main/java/gaji/service/domain/roomBoard/repository/RoomPostQueryRepository.java +++ b/src/main/java/gaji/service/domain/roomBoard/repository/RoomPost/RoomPostQueryRepository.java @@ -1,4 +1,4 @@ -package gaji.service.domain.roomBoard.repository; +package gaji.service.domain.roomBoard.repository.RoomPost; import gaji.service.domain.roomBoard.web.dto.RoomPostResponseDto; import jakarta.persistence.EntityManager; diff --git a/src/main/java/gaji/service/domain/roomBoard/repository/RoomPostRepository.java b/src/main/java/gaji/service/domain/roomBoard/repository/RoomPost/RoomPostRepository.java similarity index 81% rename from src/main/java/gaji/service/domain/roomBoard/repository/RoomPostRepository.java rename to src/main/java/gaji/service/domain/roomBoard/repository/RoomPost/RoomPostRepository.java index b0d67ff1..63a91775 100644 --- a/src/main/java/gaji/service/domain/roomBoard/repository/RoomPostRepository.java +++ b/src/main/java/gaji/service/domain/roomBoard/repository/RoomPost/RoomPostRepository.java @@ -1,4 +1,4 @@ -package gaji.service.domain.roomBoard.repository; +package gaji.service.domain.roomBoard.repository.RoomPost; import gaji.service.domain.roomBoard.entity.RoomPost.RoomPost; import org.springframework.data.jpa.repository.JpaRepository; diff --git a/src/main/java/gaji/service/domain/roomBoard/repository/RoomTroublePostBookmarkRepository.java b/src/main/java/gaji/service/domain/roomBoard/repository/RoomTrouble/RoomTroublePostBookmarkRepository.java similarity index 90% rename from src/main/java/gaji/service/domain/roomBoard/repository/RoomTroublePostBookmarkRepository.java rename to src/main/java/gaji/service/domain/roomBoard/repository/RoomTrouble/RoomTroublePostBookmarkRepository.java index aebeee06..c76bf37c 100644 --- a/src/main/java/gaji/service/domain/roomBoard/repository/RoomTroublePostBookmarkRepository.java +++ b/src/main/java/gaji/service/domain/roomBoard/repository/RoomTrouble/RoomTroublePostBookmarkRepository.java @@ -1,4 +1,4 @@ -package gaji.service.domain.roomBoard.repository; +package gaji.service.domain.roomBoard.repository.RoomTrouble; import gaji.service.domain.roomBoard.entity.RoomTrouble.RoomTroublePost; import gaji.service.domain.roomBoard.entity.RoomTrouble.RoomTroublePostBookmark; diff --git a/src/main/java/gaji/service/domain/roomBoard/repository/RoomTroublePostLikeRepository.java b/src/main/java/gaji/service/domain/roomBoard/repository/RoomTrouble/RoomTroublePostLikeRepository.java similarity index 89% rename from src/main/java/gaji/service/domain/roomBoard/repository/RoomTroublePostLikeRepository.java rename to src/main/java/gaji/service/domain/roomBoard/repository/RoomTrouble/RoomTroublePostLikeRepository.java index bede49e4..7826fad5 100644 --- a/src/main/java/gaji/service/domain/roomBoard/repository/RoomTroublePostLikeRepository.java +++ b/src/main/java/gaji/service/domain/roomBoard/repository/RoomTrouble/RoomTroublePostLikeRepository.java @@ -1,4 +1,4 @@ -package gaji.service.domain.roomBoard.repository; +package gaji.service.domain.roomBoard.repository.RoomTrouble; import gaji.service.domain.roomBoard.entity.RoomTrouble.RoomTroublePost; import gaji.service.domain.roomBoard.entity.RoomTrouble.RoomTroublePostLike; diff --git a/src/main/java/gaji/service/domain/roomBoard/repository/RoomTroublePostRepository.java b/src/main/java/gaji/service/domain/roomBoard/repository/RoomTrouble/RoomTroublePostRepository.java similarity index 94% rename from src/main/java/gaji/service/domain/roomBoard/repository/RoomTroublePostRepository.java rename to src/main/java/gaji/service/domain/roomBoard/repository/RoomTrouble/RoomTroublePostRepository.java index e4b64be1..5b5dbdb5 100644 --- a/src/main/java/gaji/service/domain/roomBoard/repository/RoomTroublePostRepository.java +++ b/src/main/java/gaji/service/domain/roomBoard/repository/RoomTrouble/RoomTroublePostRepository.java @@ -1,4 +1,4 @@ -package gaji.service.domain.roomBoard.repository; +package gaji.service.domain.roomBoard.repository.RoomTrouble; import gaji.service.domain.roomBoard.entity.RoomTrouble.RoomTroublePost; import gaji.service.domain.roomBoard.web.dto.RoomPostResponseDto; diff --git a/src/main/java/gaji/service/domain/roomBoard/repository/TroublePostCommentRepository.java b/src/main/java/gaji/service/domain/roomBoard/repository/RoomTrouble/TroublePostCommentRepository.java similarity index 82% rename from src/main/java/gaji/service/domain/roomBoard/repository/TroublePostCommentRepository.java rename to src/main/java/gaji/service/domain/roomBoard/repository/RoomTrouble/TroublePostCommentRepository.java index 8527eb19..55a77f03 100644 --- a/src/main/java/gaji/service/domain/roomBoard/repository/TroublePostCommentRepository.java +++ b/src/main/java/gaji/service/domain/roomBoard/repository/RoomTrouble/TroublePostCommentRepository.java @@ -1,4 +1,4 @@ -package gaji.service.domain.roomBoard.repository; +package gaji.service.domain.roomBoard.repository.RoomTrouble; import gaji.service.domain.roomBoard.entity.RoomTrouble.TroublePostComment; import org.springframework.data.jpa.repository.JpaRepository; diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomInfoPostCommandService.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandService.java similarity index 85% rename from src/main/java/gaji/service/domain/roomBoard/service/RoomInfoPostCommandService.java rename to src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandService.java index 6fde2757..368cf38f 100644 --- a/src/main/java/gaji/service/domain/roomBoard/service/RoomInfoPostCommandService.java +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandService.java @@ -1,4 +1,4 @@ -package gaji.service.domain.roomBoard.service; +package gaji.service.domain.roomBoard.service.RoomInfo; import gaji.service.domain.roomBoard.web.dto.RoomPostRequestDto; import gaji.service.domain.roomBoard.web.dto.RoomPostResponseDto; diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomInfoPostCommandServiceImpl.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandServiceImpl.java similarity index 92% rename from src/main/java/gaji/service/domain/roomBoard/service/RoomInfoPostCommandServiceImpl.java rename to src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandServiceImpl.java index f6f3ca8c..c1e27bc2 100644 --- a/src/main/java/gaji/service/domain/roomBoard/service/RoomInfoPostCommandServiceImpl.java +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandServiceImpl.java @@ -1,4 +1,4 @@ -package gaji.service.domain.roomBoard.service; +package gaji.service.domain.roomBoard.service.RoomInfo; import gaji.service.domain.enums.RoomPostType; import gaji.service.domain.room.entity.Room; @@ -7,8 +7,8 @@ import gaji.service.domain.roomBoard.entity.RoomInfo.RoomInfoPost; import gaji.service.domain.roomBoard.entity.RoomBoard; import gaji.service.domain.roomBoard.repository.RoomBoardRepository; -import gaji.service.domain.roomBoard.repository.RoomInfoPostRepository; -import gaji.service.domain.roomBoard.repository.RoomTroublePostRepository; +import gaji.service.domain.roomBoard.repository.RoomInfo.RoomInfoPostRepository; +import gaji.service.domain.roomBoard.repository.RoomTrouble.RoomTroublePostRepository; import gaji.service.domain.roomBoard.web.dto.RoomPostRequestDto; import gaji.service.domain.roomBoard.web.dto.RoomPostResponseDto; import gaji.service.domain.studyMate.entity.StudyMate; diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomPostCommandService.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandService.java similarity index 82% rename from src/main/java/gaji/service/domain/roomBoard/service/RoomPostCommandService.java rename to src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandService.java index 7e4da37b..9a041560 100644 --- a/src/main/java/gaji/service/domain/roomBoard/service/RoomPostCommandService.java +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandService.java @@ -1,4 +1,4 @@ -package gaji.service.domain.roomBoard.service; +package gaji.service.domain.roomBoard.service.RoomPost; import gaji.service.domain.roomBoard.entity.RoomPost.RoomPost; import gaji.service.domain.roomBoard.web.dto.RoomPostRequestDto; diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomPostCommandServiceImpl.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandServiceImpl.java similarity index 94% rename from src/main/java/gaji/service/domain/roomBoard/service/RoomPostCommandServiceImpl.java rename to src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandServiceImpl.java index acfbf44c..0e70945d 100644 --- a/src/main/java/gaji/service/domain/roomBoard/service/RoomPostCommandServiceImpl.java +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandServiceImpl.java @@ -1,4 +1,4 @@ -package gaji.service.domain.roomBoard.service; +package gaji.service.domain.roomBoard.service.RoomPost; import gaji.service.domain.room.entity.Room; import gaji.service.domain.room.service.RoomQueryService; @@ -6,7 +6,7 @@ import gaji.service.domain.roomBoard.entity.RoomBoard; import gaji.service.domain.roomBoard.entity.RoomPost.RoomPost; import gaji.service.domain.roomBoard.repository.RoomBoardRepository; -import gaji.service.domain.roomBoard.repository.RoomPostRepository; +import gaji.service.domain.roomBoard.repository.RoomPost.RoomPostRepository; import gaji.service.domain.roomBoard.web.dto.RoomPostRequestDto; import gaji.service.domain.studyMate.repository.StudyMateRepository; import gaji.service.domain.studyMate.service.StudyMateQueryService; diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomPostQueryService.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostQueryService.java similarity index 88% rename from src/main/java/gaji/service/domain/roomBoard/service/RoomPostQueryService.java rename to src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostQueryService.java index c8b6cbea..483f64b5 100644 --- a/src/main/java/gaji/service/domain/roomBoard/service/RoomPostQueryService.java +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostQueryService.java @@ -1,4 +1,4 @@ -package gaji.service.domain.roomBoard.service; +package gaji.service.domain.roomBoard.service.RoomPost; import gaji.service.domain.roomBoard.web.dto.RoomPostResponseDto; diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomPostQueryServiceImpl.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostQueryServiceImpl.java similarity index 83% rename from src/main/java/gaji/service/domain/roomBoard/service/RoomPostQueryServiceImpl.java rename to src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostQueryServiceImpl.java index 7e07c8ff..98119f77 100644 --- a/src/main/java/gaji/service/domain/roomBoard/service/RoomPostQueryServiceImpl.java +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostQueryServiceImpl.java @@ -1,7 +1,7 @@ -package gaji.service.domain.roomBoard.service; +package gaji.service.domain.roomBoard.service.RoomPost; -import gaji.service.domain.roomBoard.repository.RoomPostQueryRepository; -import gaji.service.domain.roomBoard.repository.RoomTroublePostRepository; +import gaji.service.domain.roomBoard.repository.RoomPost.RoomPostQueryRepository; +import gaji.service.domain.roomBoard.repository.RoomTrouble.RoomTroublePostRepository; import gaji.service.domain.roomBoard.web.dto.RoomPostResponseDto; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.PageRequest; diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomTroublePostCommandService.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomTrouble/RoomTroublePostCommandService.java similarity index 96% rename from src/main/java/gaji/service/domain/roomBoard/service/RoomTroublePostCommandService.java rename to src/main/java/gaji/service/domain/roomBoard/service/RoomTrouble/RoomTroublePostCommandService.java index 39d253d3..ec4ac68a 100644 --- a/src/main/java/gaji/service/domain/roomBoard/service/RoomTroublePostCommandService.java +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomTrouble/RoomTroublePostCommandService.java @@ -1,4 +1,4 @@ -package gaji.service.domain.roomBoard.service; +package gaji.service.domain.roomBoard.service.RoomTrouble; import gaji.service.domain.roomBoard.entity.RoomTrouble.RoomTroublePost; import gaji.service.domain.roomBoard.entity.RoomTrouble.TroublePostComment; diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomTroublePostCommandServiceImpl.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomTrouble/RoomTroublePostCommandServiceImpl.java similarity index 95% rename from src/main/java/gaji/service/domain/roomBoard/service/RoomTroublePostCommandServiceImpl.java rename to src/main/java/gaji/service/domain/roomBoard/service/RoomTrouble/RoomTroublePostCommandServiceImpl.java index 33102b7e..9c8b6e44 100644 --- a/src/main/java/gaji/service/domain/roomBoard/service/RoomTroublePostCommandServiceImpl.java +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomTrouble/RoomTroublePostCommandServiceImpl.java @@ -1,4 +1,4 @@ -package gaji.service.domain.roomBoard.service; +package gaji.service.domain.roomBoard.service.RoomTrouble; import gaji.service.domain.enums.RoomPostType; import gaji.service.domain.room.entity.Room; @@ -11,6 +11,12 @@ import gaji.service.domain.roomBoard.entity.RoomTrouble.TroublePostComment; import gaji.service.domain.roomBoard.entity.RoomBoard; import gaji.service.domain.roomBoard.repository.*; +import gaji.service.domain.roomBoard.repository.RoomPost.RoomPostCommentRepository; +import gaji.service.domain.roomBoard.repository.RoomPost.RoomPostRepository; +import gaji.service.domain.roomBoard.repository.RoomTrouble.RoomTroublePostBookmarkRepository; +import gaji.service.domain.roomBoard.repository.RoomTrouble.RoomTroublePostLikeRepository; +import gaji.service.domain.roomBoard.repository.RoomTrouble.RoomTroublePostRepository; +import gaji.service.domain.roomBoard.repository.RoomTrouble.TroublePostCommentRepository; import gaji.service.domain.roomBoard.web.dto.RoomPostRequestDto; import gaji.service.domain.roomBoard.web.dto.RoomPostResponseDto; import gaji.service.domain.studyMate.entity.StudyMate; diff --git a/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomInfoPostController.java b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomInfoPostController.java index 26395970..399d10c6 100644 --- a/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomInfoPostController.java +++ b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomInfoPostController.java @@ -1,7 +1,6 @@ package gaji.service.domain.roomBoard.web.controller; -import gaji.service.domain.roomBoard.service.RoomInfoPostCommandService; -import gaji.service.domain.roomBoard.service.RoomTroublePostCommandService; +import gaji.service.domain.roomBoard.service.RoomInfo.RoomInfoPostCommandService; import gaji.service.domain.roomBoard.web.dto.RoomPostRequestDto; import gaji.service.domain.roomBoard.web.dto.RoomPostResponseDto; import gaji.service.global.base.BaseResponse; diff --git a/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomTroublePostController.java b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomTroublePostController.java index ed990825..75eb30b3 100644 --- a/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomTroublePostController.java +++ b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomTroublePostController.java @@ -2,8 +2,8 @@ import gaji.service.domain.roomBoard.converter.RoomPostConverter; import gaji.service.domain.roomBoard.entity.RoomTrouble.TroublePostComment; -import gaji.service.domain.roomBoard.service.RoomPostQueryService; -import gaji.service.domain.roomBoard.service.RoomTroublePostCommandService; +import gaji.service.domain.roomBoard.service.RoomPost.RoomPostQueryService; +import gaji.service.domain.roomBoard.service.RoomTrouble.RoomTroublePostCommandService; import gaji.service.domain.roomBoard.web.dto.RoomPostRequestDto; import gaji.service.domain.roomBoard.web.dto.RoomPostResponseDto; import gaji.service.global.base.BaseResponse; From e684f1a037e83eb91c8bf05c7bfa0c81508a3c8e Mon Sep 17 00:00:00 2001 From: mmingoo Date: Fri, 16 Aug 2024 16:30:48 +0900 Subject: [PATCH 03/24] =?UTF-8?q?=E2=9C=A8=20=20=EC=8A=A4=ED=84=B0?= =?UTF-8?q?=EB=94=94=EB=A6=84=20=EA=B2=8C=EC=8B=9C=EA=B8=80=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../converter/RoomPostConverter.java | 2 +- .../roomBoard/entity/RoomPost/RoomPost.java | 5 +-- .../RoomInfoPostCommandServiceImpl.java | 3 -- .../RoomPost/RoomPostCommandService.java | 4 +-- .../RoomPost/RoomPostCommandServiceImpl.java | 23 ++++++++---- .../web/controller/RoomPostController.java | 35 +++++++++++++++++++ .../web/dto/RoomPostResponseDto.java | 8 +++++ .../domain/studyMate/entity/StudyMate.java | 11 ++++-- .../gaji/service/domain/user/entity/User.java | 3 -- 9 files changed, 74 insertions(+), 20 deletions(-) create mode 100644 src/main/java/gaji/service/domain/roomBoard/web/controller/RoomPostController.java diff --git a/src/main/java/gaji/service/domain/roomBoard/converter/RoomPostConverter.java b/src/main/java/gaji/service/domain/roomBoard/converter/RoomPostConverter.java index 0321bffe..6aeee6be 100644 --- a/src/main/java/gaji/service/domain/roomBoard/converter/RoomPostConverter.java +++ b/src/main/java/gaji/service/domain/roomBoard/converter/RoomPostConverter.java @@ -14,7 +14,7 @@ public class RoomPostConverter { - public static RoomPost toRoomPost(RoomPostRequestDto.RoomPostDto requestDto, User user, RoomBoard roomBoard) { + public static RoomPost toRoomPost(RoomPostRequestDto.RoomPostDto requestDto, StudyMate studyMate, RoomBoard roomBoard) { RoomPost roomPost = RoomPost.builder() .user(user) .title(requestDto.getTitle()) diff --git a/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPost.java b/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPost.java index f44f65ec..73ae9060 100644 --- a/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPost.java +++ b/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPost.java @@ -1,6 +1,7 @@ package gaji.service.domain.roomBoard.entity.RoomPost; import gaji.service.domain.roomBoard.entity.RoomBoard; +import gaji.service.domain.studyMate.entity.StudyMate; import gaji.service.domain.user.entity.User; import jakarta.persistence.*; import lombok.*; @@ -20,8 +21,8 @@ public class RoomPost { private Long id; @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "user_id") - private User user; + @JoinColumn(name = "studyMate_id") + private StudyMate studyMate; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "board_id") diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandServiceImpl.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandServiceImpl.java index c1e27bc2..bf73ca93 100644 --- a/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandServiceImpl.java +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandServiceImpl.java @@ -48,9 +48,6 @@ public RoomPostResponseDto.toCreateRoomInfoPostIdDTO createRoomInfoPostIdDTO(Lon return roomBoardRepository.save(newRoomBoard); }); -// RoomTro roomPost = RoomPostConverter.toRoomPost(requestDto, user, roomBoard); -// roomPost = roomPostRepository.save(roomPost); - RoomInfoPost roomInfoPost = RoomPostConverter.toRoomInfoPost(requestDto, studyMate,roomBoard); roomInfoPostRepository.save(roomInfoPost); diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandService.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandService.java index 9a041560..d4ae2781 100644 --- a/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandService.java +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandService.java @@ -2,8 +2,8 @@ import gaji.service.domain.roomBoard.entity.RoomPost.RoomPost; import gaji.service.domain.roomBoard.web.dto.RoomPostRequestDto; +import gaji.service.domain.roomBoard.web.dto.RoomPostResponseDto; public interface RoomPostCommandService { - RoomPost createRoomPost(Long roomId, Long userId, RoomPostRequestDto.RoomPostDto requestDto); - + RoomPostResponseDto.toCreateRoomPostIdDTO createRoomePost(Long roomId, Long userId, RoomPostRequestDto.RoomPostDto requestDto); } diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandServiceImpl.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandServiceImpl.java index 0e70945d..333cbc56 100644 --- a/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandServiceImpl.java +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandServiceImpl.java @@ -1,13 +1,17 @@ package gaji.service.domain.roomBoard.service.RoomPost; +import gaji.service.domain.enums.RoomPostType; import gaji.service.domain.room.entity.Room; import gaji.service.domain.room.service.RoomQueryService; import gaji.service.domain.roomBoard.converter.RoomPostConverter; import gaji.service.domain.roomBoard.entity.RoomBoard; import gaji.service.domain.roomBoard.entity.RoomPost.RoomPost; +import gaji.service.domain.roomBoard.entity.RoomTrouble.RoomTroublePost; import gaji.service.domain.roomBoard.repository.RoomBoardRepository; import gaji.service.domain.roomBoard.repository.RoomPost.RoomPostRepository; import gaji.service.domain.roomBoard.web.dto.RoomPostRequestDto; +import gaji.service.domain.roomBoard.web.dto.RoomPostResponseDto; +import gaji.service.domain.studyMate.entity.StudyMate; import gaji.service.domain.studyMate.repository.StudyMateRepository; import gaji.service.domain.studyMate.service.StudyMateQueryService; import gaji.service.domain.user.entity.User; @@ -28,10 +32,10 @@ public class RoomPostCommandServiceImpl implements RoomPostCommandService { private final StudyMateQueryService studyMateQueryService; @Override - public RoomPost createRoomPost(Long roomId, Long userId, RoomPostRequestDto.RoomPostDto requestDto) { + public RoomPostResponseDto.toCreateRoomPostIdDTO createRoomPost(Long roomId, Long userId, RoomPostRequestDto.RoomPostDto requestDto) { User user = userQueryService.findUserById(userId); Room room = roomQueryService.findRoomById(roomId); - studyMateQueryService.findByUserIdAndRoomId(user.getId(), roomId); + StudyMate studyMate = studyMateQueryService.findByUserIdAndRoomId(user.getId(), roomId); // 스터디룸 게시판 확인 또는 생성 RoomBoard roomBoard = roomBoardRepository.findByRoomId(roomId) @@ -39,19 +43,24 @@ public RoomPost createRoomPost(Long roomId, Long userId, RoomPostRequestDto.Room RoomBoard newRoomBoard = RoomBoard.builder() .room(room) .name(room.getName()) + .roomPostType(RoomPostType.ROOM_POST) .build(); return roomBoardRepository.save(newRoomBoard); }); // RoomPost 생성 및 저장 - RoomPost roomPost = RoomPostConverter.toRoomPost(requestDto, user, roomBoard); - roomPost = roomPostRepository.save(roomPost); + RoomPost roomPost = RoomPostConverter.toRoomPost(requestDto, studyMate, roomBoard); + roomPostRepository.save(roomPost); + + RoomTroublePost roomTroublePost = RoomPostConverter.toRoomTroublePost(requestDto, studyMate,roomBoard); + roomTroublePostRepository.save(roomTroublePost); + + return RoomPostConverter.troublePostIdDto(roomTroublePost.getId()); - // RoomBoard에 새로운 RoomPost 추가 - roomBoard.addRoomPost(roomPost); - roomBoardRepository.save(roomBoard); return roomPost; } + + } diff --git a/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomPostController.java b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomPostController.java new file mode 100644 index 00000000..b582c4b2 --- /dev/null +++ b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomPostController.java @@ -0,0 +1,35 @@ +package gaji.service.domain.roomBoard.web.controller; + +import gaji.service.domain.roomBoard.entity.RoomPost.RoomPost; +import gaji.service.domain.roomBoard.service.RoomPost.RoomPostCommandService; +import gaji.service.domain.roomBoard.web.dto.RoomPostRequestDto; +import gaji.service.domain.roomBoard.web.dto.RoomPostResponseDto; +import gaji.service.global.base.BaseResponse; +import gaji.service.jwt.service.TokenProviderService; +import io.swagger.v3.oas.annotations.Operation; +import lombok.RequiredArgsConstructor; +import org.hibernate.validator.constraints.ParameterScriptAssert; +import org.springframework.web.bind.annotation.*; + +@RestController +@RequiredArgsConstructor +@RequestMapping("/api/study-rooms") +public class RoomPostController { + + private final TokenProviderService tokenProviderService; + private final RoomPostCommandService roomPostCommandService; + + @PostMapping("/room-Post/{roomId}") + @Operation(summary = "스터디룸 게시글 등록 API") + public BaseResponse createRoomPostController( + @RequestHeader("Authorization") String authorization, + @PathVariable("roomId") Long roomId, + @RequestBody RoomPostRequestDto.RoomPostDto requestDto + ){ + Long userId = tokenProviderService.getUserIdFromToken(authorization); + RoomPostResponseDto.toCreateRoomPostIdDTO toCreateRoomPostIdDTO = roomPostCommandService.createRoomePost(roomId, userId, requestDto); + return BaseResponse.onSuccess(toCreateRoomPostIdDTO); + + } + +} diff --git a/src/main/java/gaji/service/domain/roomBoard/web/dto/RoomPostResponseDto.java b/src/main/java/gaji/service/domain/roomBoard/web/dto/RoomPostResponseDto.java index ac70a040..9d3625a8 100644 --- a/src/main/java/gaji/service/domain/roomBoard/web/dto/RoomPostResponseDto.java +++ b/src/main/java/gaji/service/domain/roomBoard/web/dto/RoomPostResponseDto.java @@ -54,6 +54,14 @@ public static class toCreateRoomInfoPostIdDTO { Long infoPostId; } + @Builder + @Getter + @NoArgsConstructor + @AllArgsConstructor + public static class toCreateRoomPostIdDTO { + Long roomPostId; + } + @Getter public static class TroublePostSummaryDto { diff --git a/src/main/java/gaji/service/domain/studyMate/entity/StudyMate.java b/src/main/java/gaji/service/domain/studyMate/entity/StudyMate.java index 54e52349..f8eda1a1 100644 --- a/src/main/java/gaji/service/domain/studyMate/entity/StudyMate.java +++ b/src/main/java/gaji/service/domain/studyMate/entity/StudyMate.java @@ -3,6 +3,7 @@ import gaji.service.domain.enums.Role; import gaji.service.domain.room.entity.Room; import gaji.service.domain.room.entity.RoomNotice; +import gaji.service.domain.roomBoard.entity.RoomPost.RoomPost; import gaji.service.domain.roomBoard.entity.RoomTrouble.RoomTroublePostBookmark; import gaji.service.domain.roomBoard.entity.RoomTrouble.RoomTroublePostLike; import gaji.service.domain.roomBoard.entity.RoomInfo.RoomInfoPost; @@ -38,21 +39,27 @@ public class StudyMate { @OneToMany(mappedBy = "studyMate", cascade = CascadeType.ALL) private List roomNoticeList = new ArrayList<>(); + + // 트러블 슈팅 @OneToMany(mappedBy = "studyMate", cascade = CascadeType.ALL) private List roomTroublePostLikeList = new ArrayList<>(); @OneToMany(mappedBy = "studyMate", cascade = CascadeType.ALL) private List roomTroublePostBookmarkList = new ArrayList<>(); - - @OneToMany(mappedBy = "studyMate", cascade = CascadeType.ALL) private List roomTroublePostList = new ArrayList<>(); + //정보나눔 @OneToMany(mappedBy = "studyMate", cascade = CascadeType.ALL) private List roomInfoPostList = new ArrayList<>(); + + //게시글 + @OneToMany(mappedBy = "studyMate", cascade = CascadeType.ALL) + private List roomPostList = new ArrayList<>(); + @Enumerated(EnumType.STRING) private Role role; diff --git a/src/main/java/gaji/service/domain/user/entity/User.java b/src/main/java/gaji/service/domain/user/entity/User.java index 9eb9107f..1a4d6f1c 100644 --- a/src/main/java/gaji/service/domain/user/entity/User.java +++ b/src/main/java/gaji/service/domain/user/entity/User.java @@ -57,9 +57,6 @@ public class User extends BaseEntity { private List roomPostLikesList = new ArrayList<>(); - @OneToMany(mappedBy = "user", cascade = CascadeType.ALL) - private final List roomPostList = new ArrayList<>(); - @OneToMany(mappedBy = "user",cascade = CascadeType.ALL ) private List roomPostBookmarkList = new ArrayList<>(); From 9db61f99330417654c18bd3e3624f3f81c9c5e65 Mon Sep 17 00:00:00 2001 From: mmingoo Date: Fri, 16 Aug 2024 16:36:19 +0900 Subject: [PATCH 04/24] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20=20converter=20Error?= =?UTF-8?q?=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/roomBoard/converter/RoomPostConverter.java | 10 +++++++++- .../service/RoomPost/RoomPostCommandService.java | 2 +- .../service/RoomPost/RoomPostCommandServiceImpl.java | 9 +-------- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/main/java/gaji/service/domain/roomBoard/converter/RoomPostConverter.java b/src/main/java/gaji/service/domain/roomBoard/converter/RoomPostConverter.java index 6aeee6be..f1989f49 100644 --- a/src/main/java/gaji/service/domain/roomBoard/converter/RoomPostConverter.java +++ b/src/main/java/gaji/service/domain/roomBoard/converter/RoomPostConverter.java @@ -16,7 +16,7 @@ public class RoomPostConverter { public static RoomPost toRoomPost(RoomPostRequestDto.RoomPostDto requestDto, StudyMate studyMate, RoomBoard roomBoard) { RoomPost roomPost = RoomPost.builder() - .user(user) + .studyMate(studyMate) .title(requestDto.getTitle()) .body(requestDto.getBody()) .postTime(LocalDateTime.now()) @@ -34,12 +34,20 @@ public static RoomTroublePost toRoomTroublePost(RoomPostRequestDto.RoomTroubloeP .roomBoard(roomBoard) .build(); } + + //트러블 슈팅 게시판 id 반환 dto public static RoomPostResponseDto.toCreateRoomTroublePostIdDTO troublePostIdDto(Long id){ return RoomPostResponseDto.toCreateRoomTroublePostIdDTO.builder() .troublePostId(id) .build(); } + public static RoomPostResponseDto.toCreateRoomPostIdDTO postIdDto(Long id){ + return RoomPostResponseDto.toCreateRoomPostIdDTO.builder() + .roomPostId(id) + .build(); + } + public static RoomInfoPost toRoomInfoPost(RoomPostRequestDto.RoomInfoPostDto requestDto, StudyMate studyMate, RoomBoard roomBoard) { return RoomInfoPost.builder() .studyMate(studyMate) diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandService.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandService.java index d4ae2781..42bd6458 100644 --- a/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandService.java +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandService.java @@ -5,5 +5,5 @@ import gaji.service.domain.roomBoard.web.dto.RoomPostResponseDto; public interface RoomPostCommandService { - RoomPostResponseDto.toCreateRoomPostIdDTO createRoomePost(Long roomId, Long userId, RoomPostRequestDto.RoomPostDto requestDto); + RoomPostResponseDto.toCreateRoomPostIdDTO createRoomPost(Long roomId, Long userId, RoomPostRequestDto.RoomPostDto requestDto); } diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandServiceImpl.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandServiceImpl.java index 333cbc56..24981712 100644 --- a/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandServiceImpl.java +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandServiceImpl.java @@ -6,7 +6,6 @@ import gaji.service.domain.roomBoard.converter.RoomPostConverter; import gaji.service.domain.roomBoard.entity.RoomBoard; import gaji.service.domain.roomBoard.entity.RoomPost.RoomPost; -import gaji.service.domain.roomBoard.entity.RoomTrouble.RoomTroublePost; import gaji.service.domain.roomBoard.repository.RoomBoardRepository; import gaji.service.domain.roomBoard.repository.RoomPost.RoomPostRepository; import gaji.service.domain.roomBoard.web.dto.RoomPostRequestDto; @@ -52,13 +51,7 @@ public RoomPostResponseDto.toCreateRoomPostIdDTO createRoomPost(Long roomId, Lon RoomPost roomPost = RoomPostConverter.toRoomPost(requestDto, studyMate, roomBoard); roomPostRepository.save(roomPost); - RoomTroublePost roomTroublePost = RoomPostConverter.toRoomTroublePost(requestDto, studyMate,roomBoard); - roomTroublePostRepository.save(roomTroublePost); - - return RoomPostConverter.troublePostIdDto(roomTroublePost.getId()); - - - return roomPost; + return RoomPostConverter.postIdDto(roomPost.getId()); } From 8315f3eac78c9782758c1f602d5892c9a0b4e93a Mon Sep 17 00:00:00 2001 From: mmingoo Date: Sat, 17 Aug 2024 10:04:22 +0900 Subject: [PATCH 05/24] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20=EC=8A=A4=ED=84=B0?= =?UTF-8?q?=EB=94=94=EB=A3=B8=20=EA=B2=8C=EC=8B=9C=EA=B8=80=20=EC=BB=A8?= =?UTF-8?q?=ED=8A=B8=EB=A1=A4=EB=9F=AC=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/domain/roomBoard/converter/RoomPostConverter.java | 3 +-- .../domain/roomBoard/web/controller/RoomPostController.java | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/gaji/service/domain/roomBoard/converter/RoomPostConverter.java b/src/main/java/gaji/service/domain/roomBoard/converter/RoomPostConverter.java index f1989f49..0ccea595 100644 --- a/src/main/java/gaji/service/domain/roomBoard/converter/RoomPostConverter.java +++ b/src/main/java/gaji/service/domain/roomBoard/converter/RoomPostConverter.java @@ -15,14 +15,13 @@ public class RoomPostConverter { public static RoomPost toRoomPost(RoomPostRequestDto.RoomPostDto requestDto, StudyMate studyMate, RoomBoard roomBoard) { - RoomPost roomPost = RoomPost.builder() + return RoomPost.builder() .studyMate(studyMate) .title(requestDto.getTitle()) .body(requestDto.getBody()) .postTime(LocalDateTime.now()) .roomBoard(roomBoard) .build(); - return roomPost; } public static RoomTroublePost toRoomTroublePost(RoomPostRequestDto.RoomTroubloePostDto requestDto, StudyMate studyMate, RoomBoard roomBoard) { diff --git a/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomPostController.java b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomPostController.java index b582c4b2..1bfabff2 100644 --- a/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomPostController.java +++ b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomPostController.java @@ -27,7 +27,7 @@ public BaseResponse createRoomPostCon @RequestBody RoomPostRequestDto.RoomPostDto requestDto ){ Long userId = tokenProviderService.getUserIdFromToken(authorization); - RoomPostResponseDto.toCreateRoomPostIdDTO toCreateRoomPostIdDTO = roomPostCommandService.createRoomePost(roomId, userId, requestDto); + RoomPostResponseDto.toCreateRoomPostIdDTO toCreateRoomPostIdDTO = roomPostCommandService.createRoomPost(roomId, userId, requestDto); return BaseResponse.onSuccess(toCreateRoomPostIdDTO); } From e83ff06ad9b6500bd9e896c7b31e56e2b00ca548 Mon Sep 17 00:00:00 2001 From: mmingoo Date: Sat, 17 Aug 2024 10:36:02 +0900 Subject: [PATCH 06/24] =?UTF-8?q?=E2=9C=A8=20=20=EC=8A=A4=ED=84=B0?= =?UTF-8?q?=EB=94=94=EB=A6=84=20=EA=B2=8C=EC=8B=9C=EA=B8=80,=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=EB=82=98=EB=88=94=20=EA=B2=8C=EC=8B=9C=EA=B8=80=20?= =?UTF-8?q?=EC=97=85=EB=8D=B0=EC=9D=B4=ED=8A=B8=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 --- .../roomBoard/code/RoomPostErrorStatus.java | 18 ++++++++------ .../entity/RoomInfo/RoomInfoPost.java | 9 +++++++ .../roomBoard/entity/RoomPost/RoomPost.java | 9 +++++++ .../RoomInfo/RoomInfoPostCommandService.java | 2 ++ .../RoomInfoPostCommandServiceImpl.java | 19 +++++++++++++++ .../RoomPost/RoomPostCommandService.java | 1 + .../RoomPost/RoomPostCommandServiceImpl.java | 14 +++++++++++ .../RoomTroublePostCommandServiceImpl.java | 24 +++++++++---------- .../controller/RoomInfoPostController.java | 12 ++++++++++ .../web/controller/RoomPostController.java | 12 ++++++++++ 10 files changed, 101 insertions(+), 19 deletions(-) diff --git a/src/main/java/gaji/service/domain/roomBoard/code/RoomPostErrorStatus.java b/src/main/java/gaji/service/domain/roomBoard/code/RoomPostErrorStatus.java index 51b06511..11aa2a84 100644 --- a/src/main/java/gaji/service/domain/roomBoard/code/RoomPostErrorStatus.java +++ b/src/main/java/gaji/service/domain/roomBoard/code/RoomPostErrorStatus.java @@ -10,21 +10,25 @@ @Getter @AllArgsConstructor public enum RoomPostErrorStatus implements BaseErrorCodeInterface { - // 스터디룸 게시판 _ROOM_BOARD_NOT_FOUND(HttpStatus.BAD_REQUEST, "ROOM_4001", "존재하지 않는 게시판입니다."), - _TROUBLE_POST_NOT_FOUND(HttpStatus.BAD_REQUEST, "TROUBLE_4001", "존재하지 않는 게시글입니다."), - _TROUBLE_POST_ALREADY_LIKED(HttpStatus.BAD_REQUEST, "TROUBLE_4002", "이미 좋아요를 누른 게시글입니다."), - _TROUBLE_POST_LIKE_NOT_FOUND(HttpStatus.BAD_REQUEST, "TROUBLE_4003", "게시글에 좋아요를 누르지 않은 상태입니다."), - _TROUBLE_POST_ALREADY_BOOKMARKED(HttpStatus.BAD_REQUEST, "TROUBLE_4004", "이미 북마크를 누른 게시글입니다."), - _TROUBLE_POST_BOOKMARKED_NOT_FOUND(HttpStatus.BAD_REQUEST, "TROUBLE_4005", "북마크를 누르지 않은 상태입니다."), + //권한 _USER_NOT_DELETE_AUTH(HttpStatus.BAD_REQUEST, "AUTH_4001", "게시글을 삭제할 권한이 없습니다."), _USER_NOT_UPDATE_AUTH(HttpStatus.BAD_REQUEST, "AUTH_4002", "게시글을 수정할 권한이 없습니다."), + + //댓글 _USER_NOT_COMMENT_UPDATE_AUTH(HttpStatus.BAD_REQUEST, "AUTH_4003", "댓글을 수정할 권한이 없습니다."), _USER_NOT_COMMENT_DELETE_AUTH(HttpStatus.BAD_REQUEST, "AUTH_4004", "댓글을 삭제할 권한이 없습니다."), + _NOT_FOUND_COMMENT(HttpStatus.BAD_REQUEST, "COMMENT_4001", "존재하지 않는 댓글입니다."), + + // 게시글 관련 에러 + _POST_NOT_FOUND(HttpStatus.BAD_REQUEST, "POST_4001", "존재하지 않는 게시글입니다."), + _POST_ALREADY_LIKED(HttpStatus.BAD_REQUEST, "POST_4002", "이미 좋아요를 누른 게시글입니다."), + _POST_LIKE_NOT_FOUND(HttpStatus.BAD_REQUEST, "POST_4003", "게시글에 좋아요를 누르지 않은 상태입니다."), + _POST_ALREADY_BOOKMARKED(HttpStatus.BAD_REQUEST, "POST_4004", "이미 북마크를 누른 게시글입니다."), + _POST_BOOKMARKED_NOT_FOUND(HttpStatus.BAD_REQUEST, "POST_4005", "북마크를 누르지 않은 상태입니다."); - _NOT_FOUND_COMMENT(HttpStatus.BAD_REQUEST, "COMMENT_4001", "존재하지 않는 댓글입니다."); diff --git a/src/main/java/gaji/service/domain/roomBoard/entity/RoomInfo/RoomInfoPost.java b/src/main/java/gaji/service/domain/roomBoard/entity/RoomInfo/RoomInfoPost.java index cf8eabc3..2f1cea75 100644 --- a/src/main/java/gaji/service/domain/roomBoard/entity/RoomInfo/RoomInfoPost.java +++ b/src/main/java/gaji/service/domain/roomBoard/entity/RoomInfo/RoomInfoPost.java @@ -38,4 +38,13 @@ public void prePersist() { this.likeCount = 0; this.bookmarkCount = 0; } + + public boolean isAuthor(Long userId){ + return this.studyMate.getUser().getId().equals(userId); + } + + public void update(String title, String body) { + this.title = title; + this.body = body; + } } diff --git a/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPost.java b/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPost.java index 73ae9060..f688b39f 100644 --- a/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPost.java +++ b/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPost.java @@ -62,4 +62,13 @@ public void prePersist() { public void setRoomBoard(RoomBoard roomBoard) { this.roomBoard = roomBoard; } + + public boolean isAuthor(Long userId){ + return this.studyMate.getUser().getId().equals(userId); + } + + public void update(String title, String body) { + this.title = title; + this.body = body; + } } diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandService.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandService.java index 368cf38f..f82de593 100644 --- a/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandService.java +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandService.java @@ -5,4 +5,6 @@ public interface RoomInfoPostCommandService { RoomPostResponseDto.toCreateRoomInfoPostIdDTO createRoomInfoPostIdDTO(Long roomId, Long userId, RoomPostRequestDto.RoomInfoPostDto requestDto); + + void updateInfoPost(Long postId, Long userId, RoomPostRequestDto.RoomInfoPostDto requestDto); } diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandServiceImpl.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandServiceImpl.java index bf73ca93..e0cac4f7 100644 --- a/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandServiceImpl.java +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandServiceImpl.java @@ -3,11 +3,13 @@ import gaji.service.domain.enums.RoomPostType; import gaji.service.domain.room.entity.Room; import gaji.service.domain.room.service.RoomQueryService; +import gaji.service.domain.roomBoard.code.RoomPostErrorStatus; import gaji.service.domain.roomBoard.converter.RoomPostConverter; import gaji.service.domain.roomBoard.entity.RoomInfo.RoomInfoPost; import gaji.service.domain.roomBoard.entity.RoomBoard; import gaji.service.domain.roomBoard.repository.RoomBoardRepository; import gaji.service.domain.roomBoard.repository.RoomInfo.RoomInfoPostRepository; +import gaji.service.domain.roomBoard.repository.RoomPost.RoomPostRepository; import gaji.service.domain.roomBoard.repository.RoomTrouble.RoomTroublePostRepository; import gaji.service.domain.roomBoard.web.dto.RoomPostRequestDto; import gaji.service.domain.roomBoard.web.dto.RoomPostResponseDto; @@ -15,6 +17,7 @@ import gaji.service.domain.studyMate.service.StudyMateQueryService; import gaji.service.domain.user.entity.User; import gaji.service.domain.user.service.UserQueryService; +import gaji.service.global.exception.RestApiException; import jakarta.transaction.Transactional; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -29,6 +32,7 @@ public class RoomInfoPostCommandServiceImpl implements RoomInfoPostCommandServic private final RoomQueryService roomQueryService; private final StudyMateQueryService studyMateQueryService; private final RoomTroublePostRepository roomTroublePostRepository; + private final RoomPostRepository roomPostRepository; @Override @@ -54,4 +58,19 @@ public RoomPostResponseDto.toCreateRoomInfoPostIdDTO createRoomInfoPostIdDTO(Lon return RoomPostConverter.infoPostIdDto(roomInfoPost.getId()); } + + @Override + public void updateInfoPost(Long postId, Long userId, RoomPostRequestDto.RoomInfoPostDto requestDto) { + RoomInfoPost post = roomInfoPostRepository.findById(postId) + .orElseThrow(() -> new RestApiException(RoomPostErrorStatus._POST_NOT_FOUND)); + + if (!post.isAuthor(userId)) { + throw new RestApiException(RoomPostErrorStatus._USER_NOT_UPDATE_AUTH); + } + + post.update(requestDto.getTitle(), requestDto.getBody()); + } + + + } \ No newline at end of file diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandService.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandService.java index 42bd6458..9e23b4c6 100644 --- a/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandService.java +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandService.java @@ -6,4 +6,5 @@ public interface RoomPostCommandService { RoomPostResponseDto.toCreateRoomPostIdDTO createRoomPost(Long roomId, Long userId, RoomPostRequestDto.RoomPostDto requestDto); + void updatePost(Long postId, Long userId, RoomPostRequestDto.RoomPostDto requestDto); } diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandServiceImpl.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandServiceImpl.java index 24981712..72e5ae70 100644 --- a/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandServiceImpl.java +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandServiceImpl.java @@ -3,6 +3,7 @@ import gaji.service.domain.enums.RoomPostType; import gaji.service.domain.room.entity.Room; import gaji.service.domain.room.service.RoomQueryService; +import gaji.service.domain.roomBoard.code.RoomPostErrorStatus; import gaji.service.domain.roomBoard.converter.RoomPostConverter; import gaji.service.domain.roomBoard.entity.RoomBoard; import gaji.service.domain.roomBoard.entity.RoomPost.RoomPost; @@ -15,6 +16,7 @@ import gaji.service.domain.studyMate.service.StudyMateQueryService; import gaji.service.domain.user.entity.User; import gaji.service.domain.user.service.UserQueryService; +import gaji.service.global.exception.RestApiException; import jakarta.transaction.Transactional; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -54,6 +56,18 @@ public RoomPostResponseDto.toCreateRoomPostIdDTO createRoomPost(Long roomId, Lon return RoomPostConverter.postIdDto(roomPost.getId()); } + @Override + public void updatePost(Long postId, Long userId, RoomPostRequestDto.RoomPostDto requestDto) { + RoomPost post = roomPostRepository.findById(postId) + .orElseThrow(() -> new RestApiException(RoomPostErrorStatus._POST_NOT_FOUND)); + + if (!post.isAuthor(userId)) { + throw new RestApiException(RoomPostErrorStatus._USER_NOT_UPDATE_AUTH); + } + + post.update(requestDto.getTitle(), requestDto.getBody()); + } + } diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomTrouble/RoomTroublePostCommandServiceImpl.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomTrouble/RoomTroublePostCommandServiceImpl.java index 9c8b6e44..9bb10c2e 100644 --- a/src/main/java/gaji/service/domain/roomBoard/service/RoomTrouble/RoomTroublePostCommandServiceImpl.java +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomTrouble/RoomTroublePostCommandServiceImpl.java @@ -92,21 +92,21 @@ public RoomPostResponseDto.toCreateRoomTroublePostIdDTO createRoomTroublePost(Lo @Override public RoomTroublePost findTroublePostById(Long postId){ return roomTroublePostRepository.findById(postId) - .orElseThrow(() -> new RestApiException(RoomPostErrorStatus._TROUBLE_POST_NOT_FOUND)); + .orElseThrow(() -> new RestApiException(RoomPostErrorStatus._POST_NOT_FOUND)); } @Override public void addLike(Long postId, Long userId, Long roomId) { RoomTroublePost post = roomTroublePostRepository.findById(postId) - .orElseThrow(() -> new RestApiException(RoomPostErrorStatus._TROUBLE_POST_NOT_FOUND)); + .orElseThrow(() -> new RestApiException(RoomPostErrorStatus._POST_NOT_FOUND)); StudyMate studyMate = studyMateQueryService.findByUserIdAndRoomId(userId, roomId); Optional likeOptional = roomTroublePostLikeRepository .findByRoomTroublePostAndStudyMate(post, studyMate); if (likeOptional.isPresent()) { - throw new RestApiException(RoomPostErrorStatus._TROUBLE_POST_ALREADY_LIKED); + throw new RestApiException(RoomPostErrorStatus._POST_ALREADY_LIKED); } RoomTroublePostLike newLike = RoomTroublePostLike.builder() @@ -121,12 +121,12 @@ public void addLike(Long postId, Long userId, Long roomId) { @Override public void removeLike(Long postId, Long userId, Long roomId) { RoomTroublePost post = roomTroublePostRepository.findById(postId) - .orElseThrow(() -> new RestApiException(RoomPostErrorStatus._TROUBLE_POST_NOT_FOUND)); + .orElseThrow(() -> new RestApiException(RoomPostErrorStatus._POST_NOT_FOUND)); StudyMate studyMate = studyMateQueryService.findByUserIdAndRoomId(userId, roomId); RoomTroublePostLike like = roomTroublePostLikeRepository .findByRoomTroublePostAndStudyMate(post, studyMate) - .orElseThrow(() -> new RestApiException(RoomPostErrorStatus. _TROUBLE_POST_LIKE_NOT_FOUND)); + .orElseThrow(() -> new RestApiException(RoomPostErrorStatus. _POST_LIKE_NOT_FOUND)); post.removeLike(like); roomTroublePostLikeRepository.delete(like); @@ -135,11 +135,11 @@ public void removeLike(Long postId, Long userId, Long roomId) { @Override public void addBookmark(Long postId, Long userId, Long roomId) { RoomTroublePost post = roomTroublePostRepository.findById(postId) - .orElseThrow(() -> new RestApiException(RoomPostErrorStatus._TROUBLE_POST_NOT_FOUND)); + .orElseThrow(() -> new RestApiException(RoomPostErrorStatus._POST_NOT_FOUND)); StudyMate studyMate = studyMateQueryService.findByUserIdAndRoomId(userId, roomId); if (roomTroublePostBookmarkRepository.findByRoomTroublePostAndStudyMate(post, studyMate).isPresent()) { - throw new RestApiException(RoomPostErrorStatus._TROUBLE_POST_ALREADY_BOOKMARKED); + throw new RestApiException(RoomPostErrorStatus._POST_ALREADY_BOOKMARKED); } RoomTroublePostBookmark newBookmark = RoomTroublePostBookmark.builder() @@ -154,12 +154,12 @@ public void addBookmark(Long postId, Long userId, Long roomId) { @Override public void removeBookmark(Long postId, Long userId, Long roomId) { RoomTroublePost post = roomTroublePostRepository.findById(postId) - .orElseThrow(() -> new RestApiException(RoomPostErrorStatus._TROUBLE_POST_NOT_FOUND)); + .orElseThrow(() -> new RestApiException(RoomPostErrorStatus._POST_NOT_FOUND)); StudyMate studyMate = studyMateQueryService.findByUserIdAndRoomId(userId, roomId); RoomTroublePostBookmark bookmark = roomTroublePostBookmarkRepository .findByRoomTroublePostAndStudyMate(post, studyMate) - .orElseThrow(() -> new RestApiException(RoomPostErrorStatus._TROUBLE_POST_BOOKMARKED_NOT_FOUND)); + .orElseThrow(() -> new RestApiException(RoomPostErrorStatus._POST_BOOKMARKED_NOT_FOUND)); post.removeBookmark(bookmark); roomTroublePostBookmarkRepository.delete(bookmark); @@ -168,9 +168,9 @@ public void removeBookmark(Long postId, Long userId, Long roomId) { @Override public void deletePost(Long postId, Long userId) { RoomTroublePost post = roomTroublePostRepository.findById(postId) - .orElseThrow(() -> new RestApiException(RoomPostErrorStatus._TROUBLE_POST_NOT_FOUND)); + .orElseThrow(() -> new RestApiException(RoomPostErrorStatus._POST_NOT_FOUND)); if (!post.isAuthor(userId)) { - throw new RestApiException(RoomPostErrorStatus._TROUBLE_POST_NOT_FOUND); + throw new RestApiException(RoomPostErrorStatus._POST_NOT_FOUND); } roomTroublePostRepository.delete(post); } @@ -178,7 +178,7 @@ public void deletePost(Long postId, Long userId) { @Override public void updatePost(Long postId, Long userId, RoomPostRequestDto.RoomTroubloePostDto requestDto) { RoomTroublePost post = roomTroublePostRepository.findById(postId) - .orElseThrow(() -> new RestApiException(RoomPostErrorStatus._TROUBLE_POST_NOT_FOUND)); + .orElseThrow(() -> new RestApiException(RoomPostErrorStatus._POST_NOT_FOUND)); if (!post.isAuthor(userId)) { throw new RestApiException(RoomPostErrorStatus._USER_NOT_UPDATE_AUTH); diff --git a/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomInfoPostController.java b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomInfoPostController.java index 399d10c6..a2891a42 100644 --- a/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomInfoPostController.java +++ b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomInfoPostController.java @@ -29,4 +29,16 @@ public BaseResponse StudyRoomInfo RoomPostResponseDto.toCreateRoomInfoPostIdDTO roomInfoPostIdDTO = roomInfoPostCommandService.createRoomInfoPostIdDTO(roomId, userId, requestDto); return BaseResponse.onSuccess(roomInfoPostIdDTO); } + + @PutMapping("/info/{postId}") + @Operation(summary = "스터디룸 정보나눔 게시글 업데이트 API") + public BaseResponse updatePost( + @RequestHeader("Authorization") String authorization, + @RequestBody RoomPostRequestDto.RoomInfoPostDto requestDto, + @PathVariable Long postId + ) { + Long userId = tokenProviderService.getUserIdFromToken(authorization); + roomInfoPostCommandService.updateInfoPost(postId, userId,requestDto); + return BaseResponse.onSuccess( "게시글이 성공적으로 업데이트되었습니다."); + } } diff --git a/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomPostController.java b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomPostController.java index 1bfabff2..25f7bab2 100644 --- a/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomPostController.java +++ b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomPostController.java @@ -32,4 +32,16 @@ public BaseResponse createRoomPostCon } + @PutMapping("/trouble/{postId}") + @Operation(summary = "스터디룸 트러블슈팅 게시글 업데이트 API") + public BaseResponse updatePost( + @RequestHeader("Authorization") String authorization, + @RequestBody RoomPostRequestDto.RoomPostDto requestDto, + @PathVariable Long postId + ) { + Long userId = tokenProviderService.getUserIdFromToken(authorization); + roomPostCommandService.updatePost(postId, userId,requestDto); + return BaseResponse.onSuccess( "게시글이 성공적으로 업데이트되었습니다."); + } + } From 8e6bc71decc350aa2f1261f9b0435966ee8646a3 Mon Sep 17 00:00:00 2001 From: mmingoo Date: Sat, 17 Aug 2024 10:40:03 +0900 Subject: [PATCH 07/24] =?UTF-8?q?=E2=9C=A8=20=20=EC=8A=A4=ED=84=B0?= =?UTF-8?q?=EB=94=94=EB=A6=84=20=EA=B2=8C=EC=8B=9C=EA=B8=80,=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=EB=82=98=EB=88=94=20=EA=B2=8C=EC=8B=9C=EA=B8=80=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/RoomInfo/RoomInfoPostCommandService.java | 2 ++ .../RoomInfo/RoomInfoPostCommandServiceImpl.java | 9 +++++++++ .../service/RoomPost/RoomPostCommandService.java | 2 ++ .../service/RoomPost/RoomPostCommandServiceImpl.java | 10 ++++++++++ .../web/controller/RoomInfoPostController.java | 11 +++++++++++ .../roomBoard/web/controller/RoomPostController.java | 10 ++++++++++ 6 files changed, 44 insertions(+) diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandService.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandService.java index f82de593..8e0ee1ad 100644 --- a/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandService.java +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandService.java @@ -7,4 +7,6 @@ public interface RoomInfoPostCommandService { RoomPostResponseDto.toCreateRoomInfoPostIdDTO createRoomInfoPostIdDTO(Long roomId, Long userId, RoomPostRequestDto.RoomInfoPostDto requestDto); void updateInfoPost(Long postId, Long userId, RoomPostRequestDto.RoomInfoPostDto requestDto); + + void deleteInfoPost(Long postId, Long userId); } diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandServiceImpl.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandServiceImpl.java index e0cac4f7..fbdda3a8 100644 --- a/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandServiceImpl.java +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandServiceImpl.java @@ -72,5 +72,14 @@ public void updateInfoPost(Long postId, Long userId, RoomPostRequestDto.RoomInfo } + @Override + public void deleteInfoPost(Long postId, Long userId) { + RoomInfoPost post = roomInfoPostRepository.findById(postId) + .orElseThrow(() -> new RestApiException(RoomPostErrorStatus._POST_NOT_FOUND)); + if (!post.isAuthor(userId)) { + throw new RestApiException(RoomPostErrorStatus._POST_NOT_FOUND); + } + roomInfoPostRepository.delete(post); + } } \ No newline at end of file diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandService.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandService.java index 9e23b4c6..dd744688 100644 --- a/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandService.java +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandService.java @@ -7,4 +7,6 @@ public interface RoomPostCommandService { RoomPostResponseDto.toCreateRoomPostIdDTO createRoomPost(Long roomId, Long userId, RoomPostRequestDto.RoomPostDto requestDto); void updatePost(Long postId, Long userId, RoomPostRequestDto.RoomPostDto requestDto); + + void deletePost(Long postId, Long userId); } diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandServiceImpl.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandServiceImpl.java index 72e5ae70..dc1b0626 100644 --- a/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandServiceImpl.java +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandServiceImpl.java @@ -69,5 +69,15 @@ public void updatePost(Long postId, Long userId, RoomPostRequestDto.RoomPostDto } + @Override + public void deletePost(Long postId, Long userId) { + RoomPost post = roomPostRepository.findById(postId) + .orElseThrow(() -> new RestApiException(RoomPostErrorStatus._POST_NOT_FOUND)); + if (!post.isAuthor(userId)) { + throw new RestApiException(RoomPostErrorStatus._POST_NOT_FOUND); + } + roomPostRepository.delete(post); + } + } diff --git a/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomInfoPostController.java b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomInfoPostController.java index a2891a42..f3d23bc6 100644 --- a/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomInfoPostController.java +++ b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomInfoPostController.java @@ -41,4 +41,15 @@ public BaseResponse updatePost( roomInfoPostCommandService.updateInfoPost(postId, userId,requestDto); return BaseResponse.onSuccess( "게시글이 성공적으로 업데이트되었습니다."); } + + @DeleteMapping("/trouble/{postId}") + @Operation(summary = "스터디룸 트러블슈팅 게시글 삭제 API") + public BaseResponse deletePost( + @RequestHeader("Authorization") String authorization, + @PathVariable Long postId + ) { + Long userId = tokenProviderService.getUserIdFromToken(authorization); + roomInfoPostCommandService.deleteInfoPost(postId, userId); + return BaseResponse.onSuccess( "게시글이 성공적으로 삭제되었습니다."); + } } diff --git a/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomPostController.java b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomPostController.java index 25f7bab2..ce5b1cf8 100644 --- a/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomPostController.java +++ b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomPostController.java @@ -44,4 +44,14 @@ public BaseResponse updatePost( return BaseResponse.onSuccess( "게시글이 성공적으로 업데이트되었습니다."); } + @DeleteMapping("/trouble/{postId}") + @Operation(summary = "스터디룸 트러블슈팅 게시글 삭제 API") + public BaseResponse deletePost( + @RequestHeader("Authorization") String authorization, + @PathVariable Long postId + ) { + Long userId = tokenProviderService.getUserIdFromToken(authorization); + roomPostCommandService.deletePost(postId, userId); + return BaseResponse.onSuccess( "게시글이 성공적으로 삭제되었습니다."); + } } From 3105b767cb21f561f48e6cb882a19e13ad6efb3a Mon Sep 17 00:00:00 2001 From: mmingoo Date: Sat, 17 Aug 2024 13:18:25 +0900 Subject: [PATCH 08/24] =?UTF-8?q?=E2=9C=A8=20=20=EC=8A=A4=ED=84=B0?= =?UTF-8?q?=EB=94=94=EB=A6=84=20=EA=B2=8C=EC=8B=9C=EA=B8=80,=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=EB=82=98=EB=88=94=20=EB=8C=93=EA=B8=80=20=EB=93=B1?= =?UTF-8?q?=EB=A1=9D=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../converter/RoomPostConverter.java | 13 ++++ .../entity/RoomInfo/InfoPostComment.java | 67 +++++++++++++++++++ .../entity/RoomPost/PostComment.java | 63 +++++++++++++++++ .../entity/RoomPost/RoomComment.java | 46 ------------- .../entity/RoomPost/RoomCommentLikes.java | 24 ------- .../roomBoard/entity/RoomPost/RoomPost.java | 4 +- .../RoomInfo/InfoPostCommentRepository.java | 9 +++ .../RoomPost/PostCommentRepository.java | 9 +++ .../RoomInfo/RoomInfoPostCommandService.java | 2 + .../RoomInfoPostCommandServiceImpl.java | 25 +++++-- .../RoomInfo/RoomInfoPostQueryService.java | 7 ++ .../RoomInfoPostQueryServiceImpl.java | 21 ++++++ .../RoomPost/RoomPostCommandService.java | 4 ++ .../RoomPost/RoomPostCommandServiceImpl.java | 19 ++++++ .../RoomPost/RoomPostQueryService.java | 8 +++ .../RoomPost/RoomPostQueryServiceImpl.java | 26 +++++++ .../RoomTroublePostCommandService.java | 8 +-- .../RoomTroublePostCommandServiceImpl.java | 22 ++---- .../RoomTroublePostQueryService.java | 9 +++ .../RoomTroublePostQueryServiceImpl.java | 26 +++++++ .../controller/RoomInfoPostController.java | 12 ++++ .../web/controller/RoomPostController.java | 13 ++++ .../controller/RoomTroublePostController.java | 5 +- .../gaji/service/domain/user/entity/User.java | 5 -- 24 files changed, 338 insertions(+), 109 deletions(-) create mode 100644 src/main/java/gaji/service/domain/roomBoard/entity/RoomInfo/InfoPostComment.java create mode 100644 src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/PostComment.java delete mode 100644 src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomComment.java delete mode 100644 src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomCommentLikes.java create mode 100644 src/main/java/gaji/service/domain/roomBoard/repository/RoomInfo/InfoPostCommentRepository.java create mode 100644 src/main/java/gaji/service/domain/roomBoard/repository/RoomPost/PostCommentRepository.java create mode 100644 src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostQueryService.java create mode 100644 src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostQueryServiceImpl.java create mode 100644 src/main/java/gaji/service/domain/roomBoard/service/RoomTrouble/RoomTroublePostQueryService.java create mode 100644 src/main/java/gaji/service/domain/roomBoard/service/RoomTrouble/RoomTroublePostQueryServiceImpl.java diff --git a/src/main/java/gaji/service/domain/roomBoard/converter/RoomPostConverter.java b/src/main/java/gaji/service/domain/roomBoard/converter/RoomPostConverter.java index 0ccea595..ab45d618 100644 --- a/src/main/java/gaji/service/domain/roomBoard/converter/RoomPostConverter.java +++ b/src/main/java/gaji/service/domain/roomBoard/converter/RoomPostConverter.java @@ -1,7 +1,9 @@ package gaji.service.domain.roomBoard.converter; +import gaji.service.domain.roomBoard.entity.RoomInfo.InfoPostComment; import gaji.service.domain.roomBoard.entity.RoomInfo.RoomInfoPost; import gaji.service.domain.roomBoard.entity.RoomBoard; +import gaji.service.domain.roomBoard.entity.RoomPost.PostComment; import gaji.service.domain.roomBoard.entity.RoomPost.RoomPost; import gaji.service.domain.roomBoard.entity.RoomTrouble.RoomTroublePost; import gaji.service.domain.roomBoard.entity.RoomTrouble.TroublePostComment; @@ -68,4 +70,15 @@ public static RoomPostResponseDto.toWriteCommentDto toWriteCommentDto(TroublePos .commentId(newComment.getId()) .build(); } + + public static RoomPostResponseDto.toWriteCommentDto toWritePostCommentDto(PostComment newComment) { + return RoomPostResponseDto.toWriteCommentDto.builder() + .commentId(newComment.getId()) + .build(); + } + public static RoomPostResponseDto.toWriteCommentDto toWriteInfoPostCommentDto(InfoPostComment newComment) { + return RoomPostResponseDto.toWriteCommentDto.builder() + .commentId(newComment.getId()) + .build(); + } } diff --git a/src/main/java/gaji/service/domain/roomBoard/entity/RoomInfo/InfoPostComment.java b/src/main/java/gaji/service/domain/roomBoard/entity/RoomInfo/InfoPostComment.java new file mode 100644 index 00000000..4980851b --- /dev/null +++ b/src/main/java/gaji/service/domain/roomBoard/entity/RoomInfo/InfoPostComment.java @@ -0,0 +1,67 @@ +package gaji.service.domain.roomBoard.entity.RoomInfo; + +import gaji.service.domain.roomBoard.entity.RoomPost.PostComment; +import gaji.service.domain.roomBoard.entity.RoomPost.RoomPost; +import gaji.service.domain.user.entity.User; +import jakarta.persistence.*; +import lombok.*; + +import java.util.ArrayList; +import java.util.List; + +@Entity +@Getter +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@Builder +@AllArgsConstructor +public class InfoPostComment { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "user_id") + private User user; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "post_id") + private RoomInfoPost roomInoPost; + + private String body; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "parent_comment_id") + private InfoPostComment parentComment; + + @OneToMany(mappedBy = "parentComment", cascade = CascadeType.ALL, orphanRemoval = true) + private List replies = new ArrayList<>(); + + @OneToMany(mappedBy = "roomPost",cascade = CascadeType.ALL) + private final List infoPostList = new ArrayList<>() ; + + private boolean isReply; + + public void updateComment(String body) { + this.body = body; + } + + public boolean isAuthor(Long userId) { + return this.user.getId().equals(userId); + } + + public void addReply(InfoPostComment reply) { + if (!this.isReply) { + this.replies.add(reply); + reply.setParentComment(this); + reply.setIsReply(true); + } + } + + public void setParentComment(InfoPostComment parentComment) { + this.parentComment = parentComment; + } + + public void setIsReply(boolean isReply) { + this.isReply = isReply; + } +} \ No newline at end of file diff --git a/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/PostComment.java b/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/PostComment.java new file mode 100644 index 00000000..0813fbb9 --- /dev/null +++ b/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/PostComment.java @@ -0,0 +1,63 @@ +package gaji.service.domain.roomBoard.entity.RoomPost; + +import gaji.service.domain.roomBoard.entity.RoomTrouble.RoomTroublePost; +import gaji.service.domain.user.entity.User; +import jakarta.persistence.*; +import lombok.*; + +import java.util.ArrayList; +import java.util.List; + +@Entity +@Getter +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@Builder +@AllArgsConstructor +public class PostComment { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "user_id") + private User user; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "post_id") + private RoomPost roomPost; + + private String body; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "parent_comment_id") + private PostComment parentComment; + + @OneToMany(mappedBy = "parentComment", cascade = CascadeType.ALL, orphanRemoval = true) + private List replies = new ArrayList<>(); + + private boolean isReply; + + public void updateComment(String body) { + this.body = body; + } + + public boolean isAuthor(Long userId) { + return this.user.getId().equals(userId); + } + + public void addReply(PostComment reply) { + if (!this.isReply) { + this.replies.add(reply); + reply.setParentComment(this); + reply.setIsReply(true); + } + } + + public void setParentComment(PostComment parentComment) { + this.parentComment = parentComment; + } + + public void setIsReply(boolean isReply) { + this.isReply = isReply; + } +} \ No newline at end of file diff --git a/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomComment.java b/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomComment.java deleted file mode 100644 index f8b892f6..00000000 --- a/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomComment.java +++ /dev/null @@ -1,46 +0,0 @@ -package gaji.service.domain.roomBoard.entity.RoomPost; - -import gaji.service.domain.enums.UserAlarmTypeEnum; -import gaji.service.domain.user.entity.User; -import jakarta.persistence.*; -import lombok.AccessLevel; -import lombok.Getter; -import lombok.NoArgsConstructor; - -import java.util.ArrayList; -import java.util.List; - -@Entity -@Getter -@NoArgsConstructor(access = AccessLevel.PROTECTED) -public class RoomComment { - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; - - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "user_id") - private User user; - - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "post_id") - private RoomPost roomPost; - - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "parent_id") - private RoomComment parent; - - @OneToMany(mappedBy = "parent", cascade = CascadeType.ALL, orphanRemoval = true) - private List replies = new ArrayList<>(); - - @OneToMany(mappedBy = "roomComment", cascade = CascadeType.ALL) - private List roomCommentLikesList = new ArrayList<>(); - - private String body; - private Integer commentOrder; - private Integer depth; - - @Enumerated(EnumType.STRING) - private UserAlarmTypeEnum status; -} diff --git a/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomCommentLikes.java b/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomCommentLikes.java deleted file mode 100644 index 2004bc7c..00000000 --- a/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomCommentLikes.java +++ /dev/null @@ -1,24 +0,0 @@ -package gaji.service.domain.roomBoard.entity.RoomPost; - -import gaji.service.domain.user.entity.User; -import jakarta.persistence.*; -import lombok.AccessLevel; -import lombok.Getter; -import lombok.NoArgsConstructor; - -@Entity -@Getter -@NoArgsConstructor(access = AccessLevel.PROTECTED) -public class RoomCommentLikes { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; - - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "comment_id") - private RoomComment roomComment; - - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "user_id") - private User user; -} diff --git a/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPost.java b/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPost.java index f688b39f..ba307167 100644 --- a/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPost.java +++ b/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPost.java @@ -41,10 +41,10 @@ public class RoomPost { private final List roomPostBookmarkList = new ArrayList<>() ; @OneToMany(mappedBy = "roomPost",cascade = CascadeType.ALL) - private final List roomCommentList = new ArrayList<>() ; + private final List roomPostFileList = new ArrayList<>() ; @OneToMany(mappedBy = "roomPost",cascade = CascadeType.ALL) - private final List roomPostFileList = new ArrayList<>() ; + private final List postCommentList = new ArrayList<>() ; //erd 설계에는 없지만 추가 private int viewCount; diff --git a/src/main/java/gaji/service/domain/roomBoard/repository/RoomInfo/InfoPostCommentRepository.java b/src/main/java/gaji/service/domain/roomBoard/repository/RoomInfo/InfoPostCommentRepository.java new file mode 100644 index 00000000..02bedd2e --- /dev/null +++ b/src/main/java/gaji/service/domain/roomBoard/repository/RoomInfo/InfoPostCommentRepository.java @@ -0,0 +1,9 @@ +package gaji.service.domain.roomBoard.repository.RoomInfo; + +import gaji.service.domain.roomBoard.entity.RoomInfo.InfoPostComment; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface InfoPostCommentRepository extends JpaRepository { +} diff --git a/src/main/java/gaji/service/domain/roomBoard/repository/RoomPost/PostCommentRepository.java b/src/main/java/gaji/service/domain/roomBoard/repository/RoomPost/PostCommentRepository.java new file mode 100644 index 00000000..d638714e --- /dev/null +++ b/src/main/java/gaji/service/domain/roomBoard/repository/RoomPost/PostCommentRepository.java @@ -0,0 +1,9 @@ +package gaji.service.domain.roomBoard.repository.RoomPost; + +import gaji.service.domain.roomBoard.entity.RoomPost.PostComment; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface PostCommentRepository extends JpaRepository { +} diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandService.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandService.java index 8e0ee1ad..f3f41733 100644 --- a/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandService.java +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandService.java @@ -9,4 +9,6 @@ public interface RoomInfoPostCommandService { void updateInfoPost(Long postId, Long userId, RoomPostRequestDto.RoomInfoPostDto requestDto); void deleteInfoPost(Long postId, Long userId); + + RoomPostResponseDto.toWriteCommentDto writeCommentOnInfoPost(Long userId, Long postId, RoomPostRequestDto.RoomTroubleCommentDto request); } diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandServiceImpl.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandServiceImpl.java index fbdda3a8..65beeecf 100644 --- a/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandServiceImpl.java +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandServiceImpl.java @@ -5,12 +5,12 @@ import gaji.service.domain.room.service.RoomQueryService; import gaji.service.domain.roomBoard.code.RoomPostErrorStatus; import gaji.service.domain.roomBoard.converter.RoomPostConverter; +import gaji.service.domain.roomBoard.entity.RoomInfo.InfoPostComment; import gaji.service.domain.roomBoard.entity.RoomInfo.RoomInfoPost; import gaji.service.domain.roomBoard.entity.RoomBoard; import gaji.service.domain.roomBoard.repository.RoomBoardRepository; +import gaji.service.domain.roomBoard.repository.RoomInfo.InfoPostCommentRepository; import gaji.service.domain.roomBoard.repository.RoomInfo.RoomInfoPostRepository; -import gaji.service.domain.roomBoard.repository.RoomPost.RoomPostRepository; -import gaji.service.domain.roomBoard.repository.RoomTrouble.RoomTroublePostRepository; import gaji.service.domain.roomBoard.web.dto.RoomPostRequestDto; import gaji.service.domain.roomBoard.web.dto.RoomPostResponseDto; import gaji.service.domain.studyMate.entity.StudyMate; @@ -31,10 +31,8 @@ public class RoomInfoPostCommandServiceImpl implements RoomInfoPostCommandServic private final UserQueryService userQueryService; private final RoomQueryService roomQueryService; private final StudyMateQueryService studyMateQueryService; - private final RoomTroublePostRepository roomTroublePostRepository; - private final RoomPostRepository roomPostRepository; - - + private final RoomInfoPostQueryService roomInfoPostQueryService; + private final InfoPostCommentRepository infoPostCommentRepository; @Override public RoomPostResponseDto.toCreateRoomInfoPostIdDTO createRoomInfoPostIdDTO(Long roomId, Long userId, RoomPostRequestDto.RoomInfoPostDto requestDto) { User user = userQueryService.findUserById(userId); @@ -82,4 +80,19 @@ public void deleteInfoPost(Long postId, Long userId) { roomInfoPostRepository.delete(post); } + @Override + public RoomPostResponseDto.toWriteCommentDto writeCommentOnInfoPost(Long userId, Long postId, RoomPostRequestDto.RoomTroubleCommentDto request) { + User user = userQueryService.findUserById(userId); + RoomInfoPost roomPost = roomInfoPostQueryService.findInfoPostById(postId); + + InfoPostComment postComment = InfoPostComment.builder() + .user(user) + .roomInoPost(roomPost) + .body(request.getBody()) + .build(); + infoPostCommentRepository.save(postComment); + + return RoomPostConverter.toWriteInfoPostCommentDto(postComment); + } + } \ No newline at end of file diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostQueryService.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostQueryService.java new file mode 100644 index 00000000..2aabec32 --- /dev/null +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostQueryService.java @@ -0,0 +1,7 @@ +package gaji.service.domain.roomBoard.service.RoomInfo; + +import gaji.service.domain.roomBoard.entity.RoomInfo.RoomInfoPost; + +public interface RoomInfoPostQueryService { + RoomInfoPost findInfoPostById(Long PostId); +} diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostQueryServiceImpl.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostQueryServiceImpl.java new file mode 100644 index 00000000..c46f7381 --- /dev/null +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostQueryServiceImpl.java @@ -0,0 +1,21 @@ +package gaji.service.domain.roomBoard.service.RoomInfo; + +import gaji.service.domain.roomBoard.code.RoomPostErrorStatus; +import gaji.service.domain.roomBoard.entity.RoomInfo.RoomInfoPost; +import gaji.service.domain.roomBoard.repository.RoomInfo.RoomInfoPostRepository; +import gaji.service.global.exception.RestApiException; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +@Service +@RequiredArgsConstructor +public class RoomInfoPostQueryServiceImpl implements RoomInfoPostQueryService{ + + private final RoomInfoPostRepository roomInfoPostRepository; + + @Override + public RoomInfoPost findInfoPostById(Long PostId){ + return roomInfoPostRepository.findById(PostId) + .orElseThrow(() ->new RestApiException( RoomPostErrorStatus._POST_NOT_FOUND)); + } +} diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandService.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandService.java index dd744688..23f9a531 100644 --- a/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandService.java +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandService.java @@ -1,5 +1,6 @@ package gaji.service.domain.roomBoard.service.RoomPost; +import gaji.service.domain.roomBoard.entity.RoomPost.PostComment; import gaji.service.domain.roomBoard.entity.RoomPost.RoomPost; import gaji.service.domain.roomBoard.web.dto.RoomPostRequestDto; import gaji.service.domain.roomBoard.web.dto.RoomPostResponseDto; @@ -9,4 +10,7 @@ public interface RoomPostCommandService { void updatePost(Long postId, Long userId, RoomPostRequestDto.RoomPostDto requestDto); void deletePost(Long postId, Long userId); + + RoomPostResponseDto.toWriteCommentDto writeCommentOnPost(Long userId, Long postId, RoomPostRequestDto.RoomTroubleCommentDto request); + } diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandServiceImpl.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandServiceImpl.java index dc1b0626..10c4a29a 100644 --- a/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandServiceImpl.java +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandServiceImpl.java @@ -6,8 +6,10 @@ import gaji.service.domain.roomBoard.code.RoomPostErrorStatus; import gaji.service.domain.roomBoard.converter.RoomPostConverter; import gaji.service.domain.roomBoard.entity.RoomBoard; +import gaji.service.domain.roomBoard.entity.RoomPost.PostComment; import gaji.service.domain.roomBoard.entity.RoomPost.RoomPost; import gaji.service.domain.roomBoard.repository.RoomBoardRepository; +import gaji.service.domain.roomBoard.repository.RoomPost.PostCommentRepository; import gaji.service.domain.roomBoard.repository.RoomPost.RoomPostRepository; import gaji.service.domain.roomBoard.web.dto.RoomPostRequestDto; import gaji.service.domain.roomBoard.web.dto.RoomPostResponseDto; @@ -31,6 +33,8 @@ public class RoomPostCommandServiceImpl implements RoomPostCommandService { private final UserQueryService userQueryService; private final RoomQueryService roomQueryService; private final StudyMateQueryService studyMateQueryService; + private final PostCommentRepository postCommentRepository; + private final RoomPostQueryService roomPostQueryService; @Override public RoomPostResponseDto.toCreateRoomPostIdDTO createRoomPost(Long roomId, Long userId, RoomPostRequestDto.RoomPostDto requestDto) { @@ -80,4 +84,19 @@ public void deletePost(Long postId, Long userId) { } + @Override + public RoomPostResponseDto.toWriteCommentDto writeCommentOnPost(Long userId, Long postId, RoomPostRequestDto.RoomTroubleCommentDto request) { + User user = userQueryService.findUserById(userId); + RoomPost roomPost = roomPostQueryService.findPostById(postId); + + PostComment postComment = PostComment.builder() + .user(user) + .roomPost(roomPost) + .body(request.getBody()) + .build(); + postCommentRepository.save(postComment); + + return RoomPostConverter.toWritePostCommentDto(postComment); + } + } diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostQueryService.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostQueryService.java index 483f64b5..6ed7905d 100644 --- a/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostQueryService.java +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostQueryService.java @@ -1,5 +1,7 @@ package gaji.service.domain.roomBoard.service.RoomPost; +import gaji.service.domain.roomBoard.entity.RoomPost.PostComment; +import gaji.service.domain.roomBoard.entity.RoomPost.RoomPost; import gaji.service.domain.roomBoard.web.dto.RoomPostResponseDto; import java.util.List; @@ -10,4 +12,10 @@ public interface RoomPostQueryService { // List getPaginatedTroublePosts(Long boardId, int page, int size); List getNextTroublePosts(Long boardId, Long lastPostId, int size); + + RoomPost findPostById(Long PostId); + + PostComment findCommentByCommentId(Long commentId); + + PostComment findPostCommentById(Long troublePostId); } diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostQueryServiceImpl.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostQueryServiceImpl.java index 98119f77..98f0bcf7 100644 --- a/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostQueryServiceImpl.java +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostQueryServiceImpl.java @@ -1,8 +1,14 @@ package gaji.service.domain.roomBoard.service.RoomPost; +import gaji.service.domain.roomBoard.code.RoomPostErrorStatus; +import gaji.service.domain.roomBoard.entity.RoomPost.PostComment; +import gaji.service.domain.roomBoard.entity.RoomPost.RoomPost; +import gaji.service.domain.roomBoard.repository.RoomPost.PostCommentRepository; import gaji.service.domain.roomBoard.repository.RoomPost.RoomPostQueryRepository; +import gaji.service.domain.roomBoard.repository.RoomPost.RoomPostRepository; import gaji.service.domain.roomBoard.repository.RoomTrouble.RoomTroublePostRepository; import gaji.service.domain.roomBoard.web.dto.RoomPostResponseDto; +import gaji.service.global.exception.RestApiException; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; @@ -17,6 +23,8 @@ public class RoomPostQueryServiceImpl implements RoomPostQueryService { private final RoomPostQueryRepository roomPostQueryRepository; private final RoomTroublePostRepository roomTroublePostRepository; + private final RoomPostRepository roomPostRepository; + private final PostCommentRepository postCommentRepository; @Override public List getTop3RecentPosts(Long roomId) { @@ -28,4 +36,22 @@ public List getNextTroublePosts(Long Pageable pageable = PageRequest.of(0, size, Sort.by(Sort.Direction.DESC, "createdAt")); return roomTroublePostRepository.findTroublePostSummariesForInfiniteScroll(boardId, lastPostId,pageable); } + + @Override + public RoomPost findPostById(Long PostId){ + return roomPostRepository.findById(PostId) + .orElseThrow(() ->new RestApiException( RoomPostErrorStatus._POST_NOT_FOUND)); + } + + @Override + public PostComment findCommentByCommentId(Long commentId){ + return postCommentRepository.findById(commentId) + .orElseThrow(() ->new RestApiException( RoomPostErrorStatus._NOT_FOUND_COMMENT)); + } + + @Override + public PostComment findPostCommentById(Long troublePostId) { + return postCommentRepository.findById(troublePostId) + .orElseThrow(() -> new RestApiException(RoomPostErrorStatus._NOT_FOUND_COMMENT)); + } } diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomTrouble/RoomTroublePostCommandService.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomTrouble/RoomTroublePostCommandService.java index ec4ac68a..ec503207 100644 --- a/src/main/java/gaji/service/domain/roomBoard/service/RoomTrouble/RoomTroublePostCommandService.java +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomTrouble/RoomTroublePostCommandService.java @@ -6,7 +6,7 @@ import gaji.service.domain.roomBoard.web.dto.RoomPostResponseDto; public interface RoomTroublePostCommandService { - TroublePostComment writeCommentOnTroublePost(Long userId, Long postId, RoomPostRequestDto.RoomTroubleCommentDto request); + RoomPostResponseDto.toWriteCommentDto writeCommentOnTroublePost(Long userId, Long postId, RoomPostRequestDto.RoomTroubleCommentDto request); RoomPostResponseDto.toCreateRoomTroublePostIdDTO createRoomTroublePost(Long roomId, Long userId, RoomPostRequestDto.RoomTroubloePostDto requestDto); @@ -20,14 +20,10 @@ public interface RoomTroublePostCommandService { void updatePost(Long postId, Long userId, RoomPostRequestDto.RoomTroubloePostDto requestDto); - void updateComment(Long postId, Long userId, RoomPostRequestDto.RoomTroubleCommentDto requestDto); - - TroublePostComment findCommentByCommentId(Long commentId); + void updateComment(Long commentId, Long userId, RoomPostRequestDto.RoomTroubleCommentDto requestDto); void deleteComment(Long commentId, Long userId); - TroublePostComment findTroublePostCommentById(Long troublePostId); - void addBookmark(Long postId, Long userId, Long roomId); void removeBookmark(Long postId, Long userId, Long roomId); diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomTrouble/RoomTroublePostCommandServiceImpl.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomTrouble/RoomTroublePostCommandServiceImpl.java index 9bb10c2e..90335ada 100644 --- a/src/main/java/gaji/service/domain/roomBoard/service/RoomTrouble/RoomTroublePostCommandServiceImpl.java +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomTrouble/RoomTroublePostCommandServiceImpl.java @@ -44,22 +44,21 @@ public class RoomTroublePostCommandServiceImpl implements RoomTroublePostCommand private final RoomTroublePostLikeRepository roomTroublePostLikeRepository; private final TroublePostCommentRepository troublePostCommentRepository; private final RoomTroublePostBookmarkRepository roomTroublePostBookmarkRepository; + private final RoomTroublePostQueryService roomTroublePostQueryService; @Override - public TroublePostComment writeCommentOnTroublePost(Long userId, Long postId, RoomPostRequestDto.RoomTroubleCommentDto request) { + public RoomPostResponseDto.toWriteCommentDto writeCommentOnTroublePost(Long userId, Long postId, RoomPostRequestDto.RoomTroubleCommentDto request) { User user = userQueryService.findUserById(userId); RoomTroublePost roomTroublePost = findTroublePostById(postId); - System.out.println("트러블 슈팅: " + roomTroublePost.getBody()); TroublePostComment troublePostComment = TroublePostComment.builder() .user(user) .roomTroublePost(roomTroublePost) .body(request.getBody()) .build(); - System.out.println(troublePostComment.getBody()); troublePostCommentRepository.save(troublePostComment); - return troublePostComment; + return RoomPostConverter.toWriteCommentDto(troublePostComment); } @Override @@ -189,7 +188,7 @@ public void updatePost(Long postId, Long userId, RoomPostRequestDto.RoomTroubloe @Override public void updateComment(Long commentId, Long userId, RoomPostRequestDto.RoomTroubleCommentDto requestDto) { - TroublePostComment comment = findCommentByCommentId(commentId); + TroublePostComment comment = roomTroublePostQueryService.findCommentByCommentId(commentId); if (!comment.isAuthor(userId)){ throw new RestApiException(RoomPostErrorStatus._USER_NOT_COMMENT_UPDATE_AUTH); } @@ -200,7 +199,7 @@ public void updateComment(Long commentId, Long userId, RoomPostRequestDto.RoomTr @Override public void deleteComment(Long commentId, Long userId) { - TroublePostComment comment = findTroublePostCommentById(commentId); + TroublePostComment comment = roomTroublePostQueryService.findTroublePostCommentById(commentId); if (!comment.isAuthor(userId)) { throw new RestApiException(RoomPostErrorStatus._USER_NOT_COMMENT_DELETE_AUTH); @@ -242,17 +241,6 @@ public TroublePostComment addReply(Long commentId, Long userId, RoomPostRequestD } - @Override - public TroublePostComment findCommentByCommentId(Long commentId){ - return troublePostCommentRepository.findById(commentId) - .orElseThrow(() ->new RestApiException( RoomPostErrorStatus._NOT_FOUND_COMMENT)); - } - - @Override - public TroublePostComment findTroublePostCommentById(Long troublePostId) { - return troublePostCommentRepository.findById(troublePostId) - .orElseThrow(() -> new RestApiException(RoomPostErrorStatus._NOT_FOUND_COMMENT)); - } private void deleteReply(TroublePostComment reply) { diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomTrouble/RoomTroublePostQueryService.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomTrouble/RoomTroublePostQueryService.java new file mode 100644 index 00000000..1aec4c73 --- /dev/null +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomTrouble/RoomTroublePostQueryService.java @@ -0,0 +1,9 @@ +package gaji.service.domain.roomBoard.service.RoomTrouble; + +import gaji.service.domain.roomBoard.entity.RoomTrouble.TroublePostComment; + +public interface RoomTroublePostQueryService { + TroublePostComment findCommentByCommentId(Long commentId); + + TroublePostComment findTroublePostCommentById(Long troublePostId); +} diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomTrouble/RoomTroublePostQueryServiceImpl.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomTrouble/RoomTroublePostQueryServiceImpl.java new file mode 100644 index 00000000..725d0cf9 --- /dev/null +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomTrouble/RoomTroublePostQueryServiceImpl.java @@ -0,0 +1,26 @@ +package gaji.service.domain.roomBoard.service.RoomTrouble; + +import gaji.service.domain.roomBoard.code.RoomPostErrorStatus; +import gaji.service.domain.roomBoard.entity.RoomTrouble.TroublePostComment; +import gaji.service.domain.roomBoard.repository.RoomTrouble.TroublePostCommentRepository; +import gaji.service.global.exception.RestApiException; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +@Service +@RequiredArgsConstructor +public class RoomTroublePostQueryServiceImpl implements RoomTroublePostQueryService { + + private final TroublePostCommentRepository troublePostCommentRepository; + @Override + public TroublePostComment findCommentByCommentId(Long commentId){ + return troublePostCommentRepository.findById(commentId) + .orElseThrow(() ->new RestApiException( RoomPostErrorStatus._NOT_FOUND_COMMENT)); + } + + @Override + public TroublePostComment findTroublePostCommentById(Long troublePostId) { + return troublePostCommentRepository.findById(troublePostId) + .orElseThrow(() -> new RestApiException(RoomPostErrorStatus._NOT_FOUND_COMMENT)); + } +} diff --git a/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomInfoPostController.java b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomInfoPostController.java index f3d23bc6..4a921709 100644 --- a/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomInfoPostController.java +++ b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomInfoPostController.java @@ -52,4 +52,16 @@ public BaseResponse deletePost( roomInfoPostCommandService.deleteInfoPost(postId, userId); return BaseResponse.onSuccess( "게시글이 성공적으로 삭제되었습니다."); } + + @PostMapping("/info/{postId}/comments") + @Operation(summary = "스터디룸 트러블슈팅 댓글 등록 API") + public BaseResponse writeCommentOnInfoPost( + @RequestHeader("Authorization") String authorization, + @RequestBody @Valid RoomPostRequestDto.RoomTroubleCommentDto requestDto, + @PathVariable Long postId + ){ + Long userId = tokenProviderService.getUserIdFromToken(authorization); + RoomPostResponseDto.toWriteCommentDto newComment = roomInfoPostCommandService.writeCommentOnInfoPost(userId, postId, requestDto); + return BaseResponse.onSuccess(newComment); + } } diff --git a/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomPostController.java b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomPostController.java index ce5b1cf8..dd92ffa6 100644 --- a/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomPostController.java +++ b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomPostController.java @@ -7,6 +7,7 @@ import gaji.service.global.base.BaseResponse; import gaji.service.jwt.service.TokenProviderService; import io.swagger.v3.oas.annotations.Operation; +import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; import org.hibernate.validator.constraints.ParameterScriptAssert; import org.springframework.web.bind.annotation.*; @@ -54,4 +55,16 @@ public BaseResponse deletePost( roomPostCommandService.deletePost(postId, userId); return BaseResponse.onSuccess( "게시글이 성공적으로 삭제되었습니다."); } + + @PostMapping("/post/{postId}/comments") + @Operation(summary = "스터디룸 트러블슈팅 댓글 등록 API") + public BaseResponse writeCommentOnPost( + @RequestHeader("Authorization") String authorization, + @RequestBody @Valid RoomPostRequestDto.RoomTroubleCommentDto requestDto, + @PathVariable Long postId + ){ + Long userId = tokenProviderService.getUserIdFromToken(authorization); + RoomPostResponseDto.toWriteCommentDto newComment = roomPostCommandService.writeCommentOnPost(userId, postId, requestDto); + return BaseResponse.onSuccess(newComment); + } } diff --git a/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomTroublePostController.java b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomTroublePostController.java index 75eb30b3..9317a1dc 100644 --- a/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomTroublePostController.java +++ b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomTroublePostController.java @@ -46,10 +46,9 @@ public BaseResponse writeCommentOnTrouble @RequestBody @Valid RoomPostRequestDto.RoomTroubleCommentDto requestDto, @PathVariable Long troublePostId ){ - System.out.println("댓글: " + requestDto.getBody()); Long userId = tokenProviderService.getUserIdFromToken(authorization); - TroublePostComment newComment = roomTroublePostCommandService.writeCommentOnTroublePost(userId, troublePostId, requestDto); - return BaseResponse.onSuccess(RoomPostConverter.toWriteCommentDto(newComment)); + RoomPostResponseDto.toWriteCommentDto newComment = roomTroublePostCommandService.writeCommentOnTroublePost(userId, troublePostId, requestDto); + return BaseResponse.onSuccess(newComment); } @PostMapping("/trouble/{roomId}/posts/{postId}/like") diff --git a/src/main/java/gaji/service/domain/user/entity/User.java b/src/main/java/gaji/service/domain/user/entity/User.java index 1a4d6f1c..dec4c640 100644 --- a/src/main/java/gaji/service/domain/user/entity/User.java +++ b/src/main/java/gaji/service/domain/user/entity/User.java @@ -115,11 +115,6 @@ public class User extends BaseEntity { @OneToMany(mappedBy = "user") private List chatMessageList = new ArrayList<>(); - @OneToMany(mappedBy = "user") - private List roomCommentLikesList = new ArrayList<>(); - - @OneToMany(mappedBy = "user") - private List roomCommentList = new ArrayList<>(); @OneToMany(mappedBy = "user", cascade = CascadeType.ALL) private List weeklyUserProgressList = new ArrayList<>(); From 07728b39fd5f73845ef0bfc57c90105a6c9eb7ec Mon Sep 17 00:00:00 2001 From: mmingoo Date: Sat, 17 Aug 2024 13:24:29 +0900 Subject: [PATCH 09/24] =?UTF-8?q?=E2=9C=A8=20=20=EC=8A=A4=ED=84=B0?= =?UTF-8?q?=EB=94=94=EB=A6=84=20=EA=B2=8C=EC=8B=9C=EA=B8=80,=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=EB=82=98=EB=88=94=20=EB=8C=93=EA=B8=80=20=EC=88=98?= =?UTF-8?q?=EC=A0=95=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RoomInfo/RoomInfoPostCommandService.java | 2 ++ .../RoomInfo/RoomInfoPostCommandServiceImpl.java | 9 +++++++++ .../RoomInfo/RoomInfoPostQueryService.java | 5 +++++ .../RoomInfo/RoomInfoPostQueryServiceImpl.java | 16 ++++++++++++++++ .../service/RoomPost/RoomPostCommandService.java | 1 + .../RoomPost/RoomPostCommandServiceImpl.java | 10 ++++++++++ .../web/controller/RoomInfoPostController.java | 12 ++++++++++++ .../web/controller/RoomPostController.java | 12 ++++++++++++ 8 files changed, 67 insertions(+) diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandService.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandService.java index f3f41733..abb1c7ac 100644 --- a/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandService.java +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandService.java @@ -11,4 +11,6 @@ public interface RoomInfoPostCommandService { void deleteInfoPost(Long postId, Long userId); RoomPostResponseDto.toWriteCommentDto writeCommentOnInfoPost(Long userId, Long postId, RoomPostRequestDto.RoomTroubleCommentDto request); + + void updateComment(Long commentId, Long userId, RoomPostRequestDto.RoomTroubleCommentDto requestDto); } diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandServiceImpl.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandServiceImpl.java index 65beeecf..7a6115eb 100644 --- a/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandServiceImpl.java +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandServiceImpl.java @@ -95,4 +95,13 @@ public RoomPostResponseDto.toWriteCommentDto writeCommentOnInfoPost(Long userId, return RoomPostConverter.toWriteInfoPostCommentDto(postComment); } + @Override + public void updateComment(Long commentId, Long userId, RoomPostRequestDto.RoomTroubleCommentDto requestDto) { + InfoPostComment comment = roomInfoPostQueryService.findCommentByCommentId(commentId); + if (!comment.isAuthor(userId)){ + throw new RestApiException(RoomPostErrorStatus._USER_NOT_COMMENT_UPDATE_AUTH); + } + comment.updateComment(requestDto.getBody()); + } + } \ No newline at end of file diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostQueryService.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostQueryService.java index 2aabec32..cabdbd6f 100644 --- a/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostQueryService.java +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostQueryService.java @@ -1,7 +1,12 @@ package gaji.service.domain.roomBoard.service.RoomInfo; +import gaji.service.domain.roomBoard.entity.RoomInfo.InfoPostComment; import gaji.service.domain.roomBoard.entity.RoomInfo.RoomInfoPost; public interface RoomInfoPostQueryService { RoomInfoPost findInfoPostById(Long PostId); + + InfoPostComment findCommentByCommentId(Long commentId); + + InfoPostComment findPostCommentById(Long troublePostId); } diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostQueryServiceImpl.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostQueryServiceImpl.java index c46f7381..8aa67210 100644 --- a/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostQueryServiceImpl.java +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostQueryServiceImpl.java @@ -1,7 +1,9 @@ package gaji.service.domain.roomBoard.service.RoomInfo; import gaji.service.domain.roomBoard.code.RoomPostErrorStatus; +import gaji.service.domain.roomBoard.entity.RoomInfo.InfoPostComment; import gaji.service.domain.roomBoard.entity.RoomInfo.RoomInfoPost; +import gaji.service.domain.roomBoard.repository.RoomInfo.InfoPostCommentRepository; import gaji.service.domain.roomBoard.repository.RoomInfo.RoomInfoPostRepository; import gaji.service.global.exception.RestApiException; import lombok.RequiredArgsConstructor; @@ -12,10 +14,24 @@ public class RoomInfoPostQueryServiceImpl implements RoomInfoPostQueryService{ private final RoomInfoPostRepository roomInfoPostRepository; + private final InfoPostCommentRepository infoPostCommentRepository; @Override public RoomInfoPost findInfoPostById(Long PostId){ return roomInfoPostRepository.findById(PostId) .orElseThrow(() ->new RestApiException( RoomPostErrorStatus._POST_NOT_FOUND)); } + + + @Override + public InfoPostComment findCommentByCommentId(Long commentId){ + return infoPostCommentRepository.findById(commentId) + .orElseThrow(() ->new RestApiException( RoomPostErrorStatus._NOT_FOUND_COMMENT)); + } + + @Override + public InfoPostComment findPostCommentById(Long troublePostId) { + return infoPostCommentRepository.findById(troublePostId) + .orElseThrow(() -> new RestApiException(RoomPostErrorStatus._NOT_FOUND_COMMENT)); + } } diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandService.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandService.java index 23f9a531..29a75e79 100644 --- a/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandService.java +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandService.java @@ -13,4 +13,5 @@ public interface RoomPostCommandService { RoomPostResponseDto.toWriteCommentDto writeCommentOnPost(Long userId, Long postId, RoomPostRequestDto.RoomTroubleCommentDto request); + void updateComment(Long commentId, Long userId, RoomPostRequestDto.RoomTroubleCommentDto requestDto); } diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandServiceImpl.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandServiceImpl.java index 10c4a29a..83945c3f 100644 --- a/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandServiceImpl.java +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandServiceImpl.java @@ -99,4 +99,14 @@ public RoomPostResponseDto.toWriteCommentDto writeCommentOnPost(Long userId, Lon return RoomPostConverter.toWritePostCommentDto(postComment); } + @Override + public void updateComment(Long commentId, Long userId, RoomPostRequestDto.RoomTroubleCommentDto requestDto) { + PostComment comment = roomPostQueryService.findCommentByCommentId(commentId); + if (!comment.isAuthor(userId)){ + throw new RestApiException(RoomPostErrorStatus._USER_NOT_COMMENT_UPDATE_AUTH); + } + + comment.updateComment(requestDto.getBody()); + } + } diff --git a/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomInfoPostController.java b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomInfoPostController.java index 4a921709..dcd4e9f4 100644 --- a/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomInfoPostController.java +++ b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomInfoPostController.java @@ -64,4 +64,16 @@ public BaseResponse writeCommentOnInfoPos RoomPostResponseDto.toWriteCommentDto newComment = roomInfoPostCommandService.writeCommentOnInfoPost(userId, postId, requestDto); return BaseResponse.onSuccess(newComment); } + + @PutMapping("/trouble/comments/{commentId}") + @Operation(summary = "스터디룸 트러블슈팅 댓글 업데이트 API") + public BaseResponse updateComment( + @RequestHeader("Authorization") String authorization, + @RequestBody RoomPostRequestDto.RoomTroubleCommentDto requestDto, + @PathVariable Long commentId + ) { + Long userId = tokenProviderService.getUserIdFromToken(authorization); + roomInfoPostCommandService.updateComment(commentId, userId,requestDto); + return BaseResponse.onSuccess( "댓글이 성공적으로 업데이트되었습니다."); + } } diff --git a/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomPostController.java b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomPostController.java index dd92ffa6..eb7a33f9 100644 --- a/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomPostController.java +++ b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomPostController.java @@ -67,4 +67,16 @@ public BaseResponse writeCommentOnPost( RoomPostResponseDto.toWriteCommentDto newComment = roomPostCommandService.writeCommentOnPost(userId, postId, requestDto); return BaseResponse.onSuccess(newComment); } + + @PutMapping("/trouble/comments/{commentId}") + @Operation(summary = "스터디룸 트러블슈팅 댓글 업데이트 API") + public BaseResponse updateComment( + @RequestHeader("Authorization") String authorization, + @RequestBody RoomPostRequestDto.RoomTroubleCommentDto requestDto, + @PathVariable Long commentId + ) { + Long userId = tokenProviderService.getUserIdFromToken(authorization); + roomPostCommandService.updateComment(commentId, userId,requestDto); + return BaseResponse.onSuccess( "댓글이 성공적으로 업데이트되었습니다."); + } } From c6d46fcb0249ca04cdfbfb0c985de235d993d625 Mon Sep 17 00:00:00 2001 From: mmingoo Date: Sat, 17 Aug 2024 14:30:45 +0900 Subject: [PATCH 10/24] =?UTF-8?q?=E2=9C=A8=20=20=EC=8A=A4=ED=84=B0?= =?UTF-8?q?=EB=94=94=EB=A6=84=20=EA=B2=8C=EC=8B=9C=EA=B8=80,=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=EB=82=98=EB=88=94=20=EB=8C=93=EA=B8=80=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RoomInfo/RoomInfoPostCommandService.java | 2 ++ .../RoomInfoPostCommandServiceImpl.java | 31 +++++++++++++++++++ .../RoomPost/RoomPostCommandService.java | 2 ++ .../RoomPost/RoomPostCommandServiceImpl.java | 31 +++++++++++++++++++ .../controller/RoomInfoPostController.java | 23 ++++++++++---- .../web/controller/RoomPostController.java | 27 +++++++++++----- 6 files changed, 102 insertions(+), 14 deletions(-) diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandService.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandService.java index abb1c7ac..86d3c680 100644 --- a/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandService.java +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandService.java @@ -13,4 +13,6 @@ public interface RoomInfoPostCommandService { RoomPostResponseDto.toWriteCommentDto writeCommentOnInfoPost(Long userId, Long postId, RoomPostRequestDto.RoomTroubleCommentDto request); void updateComment(Long commentId, Long userId, RoomPostRequestDto.RoomTroubleCommentDto requestDto); + + void deleteComment(Long commentId, Long userId); } diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandServiceImpl.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandServiceImpl.java index 7a6115eb..bbb93ad8 100644 --- a/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandServiceImpl.java +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandServiceImpl.java @@ -104,4 +104,35 @@ public void updateComment(Long commentId, Long userId, RoomPostRequestDto.RoomTr comment.updateComment(requestDto.getBody()); } + + @Override + public void deleteComment(Long commentId, Long userId) { + InfoPostComment comment = roomInfoPostQueryService.findPostCommentById(commentId); + + if (!comment.isAuthor(userId)) { + throw new RestApiException(RoomPostErrorStatus._USER_NOT_COMMENT_DELETE_AUTH); + } + + if (comment.isReply()) { + // 답글인 경우, 해당 답글만 삭제 + deleteReply(comment); + } else { + // 댓글인 경우, 댓글과 모든 관련 답글 삭제 + deleteCommentAndReplies(comment); + } + + + } + + private void deleteReply(InfoPostComment reply) { + InfoPostComment parentComment = reply.getParentComment(); + parentComment.getReplies().remove(reply); + infoPostCommentRepository.delete(reply); + } + + private void deleteCommentAndReplies(InfoPostComment comment) { + // CascadeType.ALL과 orphanRemoval = true 설정으로 인해 + // 댓글을 삭제하면 연관된 모든 답글도 자동으로 삭제됩니다. + infoPostCommentRepository.delete(comment); + } } \ No newline at end of file diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandService.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandService.java index 29a75e79..fc876c71 100644 --- a/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandService.java +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandService.java @@ -14,4 +14,6 @@ public interface RoomPostCommandService { RoomPostResponseDto.toWriteCommentDto writeCommentOnPost(Long userId, Long postId, RoomPostRequestDto.RoomTroubleCommentDto request); void updateComment(Long commentId, Long userId, RoomPostRequestDto.RoomTroubleCommentDto requestDto); + + void deleteComment(Long commentId, Long userId); } diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandServiceImpl.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandServiceImpl.java index 83945c3f..25df339e 100644 --- a/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandServiceImpl.java +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandServiceImpl.java @@ -109,4 +109,35 @@ public void updateComment(Long commentId, Long userId, RoomPostRequestDto.RoomTr comment.updateComment(requestDto.getBody()); } + @Override + public void deleteComment(Long commentId, Long userId) { + PostComment comment = roomPostQueryService.findPostCommentById(commentId); + + if (!comment.isAuthor(userId)) { + throw new RestApiException(RoomPostErrorStatus._USER_NOT_COMMENT_DELETE_AUTH); + } + + if (comment.isReply()) { + // 답글인 경우, 해당 답글만 삭제 + deleteReply(comment); + } else { + // 댓글인 경우, 댓글과 모든 관련 답글 삭제 + deleteCommentAndReplies(comment); + } + + + } + + private void deleteReply(PostComment reply) { + PostComment parentComment = reply.getParentComment(); + parentComment.getReplies().remove(reply); + postCommentRepository.delete(reply); + } + + private void deleteCommentAndReplies(PostComment comment) { + // CascadeType.ALL과 orphanRemoval = true 설정으로 인해 + // 댓글을 삭제하면 연관된 모든 답글도 자동으로 삭제됩니다. + postCommentRepository.delete(comment); + } + } diff --git a/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomInfoPostController.java b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomInfoPostController.java index dcd4e9f4..c204f684 100644 --- a/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomInfoPostController.java +++ b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomInfoPostController.java @@ -17,7 +17,7 @@ public class RoomInfoPostController { private final TokenProviderService tokenProviderService; private final RoomInfoPostCommandService roomInfoPostCommandService; - @PostMapping("/info-post/{roomId}") + @PostMapping("/info/{roomId}") @Operation(summary = "스터디룸 정보나눔 게시판 등록 API") public BaseResponse StudyRoomInfoPostController( @RequestHeader("Authorization") String authorization, @@ -42,8 +42,8 @@ public BaseResponse updatePost( return BaseResponse.onSuccess( "게시글이 성공적으로 업데이트되었습니다."); } - @DeleteMapping("/trouble/{postId}") - @Operation(summary = "스터디룸 트러블슈팅 게시글 삭제 API") + @DeleteMapping("/info/{postId}") + @Operation(summary = "스터디룸 정보나눔 게시글 삭제 API") public BaseResponse deletePost( @RequestHeader("Authorization") String authorization, @PathVariable Long postId @@ -54,7 +54,7 @@ public BaseResponse deletePost( } @PostMapping("/info/{postId}/comments") - @Operation(summary = "스터디룸 트러블슈팅 댓글 등록 API") + @Operation(summary = "스터디룸 정보나눔 댓글 등록 API") public BaseResponse writeCommentOnInfoPost( @RequestHeader("Authorization") String authorization, @RequestBody @Valid RoomPostRequestDto.RoomTroubleCommentDto requestDto, @@ -65,8 +65,8 @@ public BaseResponse writeCommentOnInfoPos return BaseResponse.onSuccess(newComment); } - @PutMapping("/trouble/comments/{commentId}") - @Operation(summary = "스터디룸 트러블슈팅 댓글 업데이트 API") + @PutMapping("/info/comments/{commentId}") + @Operation(summary = "스터디룸 정보나눔 댓글 업데이트 API") public BaseResponse updateComment( @RequestHeader("Authorization") String authorization, @RequestBody RoomPostRequestDto.RoomTroubleCommentDto requestDto, @@ -76,4 +76,15 @@ public BaseResponse updateComment( roomInfoPostCommandService.updateComment(commentId, userId,requestDto); return BaseResponse.onSuccess( "댓글이 성공적으로 업데이트되었습니다."); } + + @DeleteMapping("/info/comments/{commentId}") + @Operation(summary = "스터디룸 정보나눔 게시글 댓글 삭제 API") + public BaseResponse deleteComment( + @RequestHeader("Authorization") String authorization, + @PathVariable Long commentId + ) { + Long userId = tokenProviderService.getUserIdFromToken(authorization); + roomInfoPostCommandService.deleteComment(commentId, userId); + return BaseResponse.onSuccess( "댓글이 성공적으로 삭제되었습니다."); + } } diff --git a/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomPostController.java b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomPostController.java index eb7a33f9..25f6d70a 100644 --- a/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomPostController.java +++ b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomPostController.java @@ -20,7 +20,7 @@ public class RoomPostController { private final TokenProviderService tokenProviderService; private final RoomPostCommandService roomPostCommandService; - @PostMapping("/room-Post/{roomId}") + @PostMapping("/post/{roomId}") @Operation(summary = "스터디룸 게시글 등록 API") public BaseResponse createRoomPostController( @RequestHeader("Authorization") String authorization, @@ -33,8 +33,8 @@ public BaseResponse createRoomPostCon } - @PutMapping("/trouble/{postId}") - @Operation(summary = "스터디룸 트러블슈팅 게시글 업데이트 API") + @PutMapping("/post/{postId}") + @Operation(summary = "스터디룸 게시글 업데이트 API") public BaseResponse updatePost( @RequestHeader("Authorization") String authorization, @RequestBody RoomPostRequestDto.RoomPostDto requestDto, @@ -45,8 +45,8 @@ public BaseResponse updatePost( return BaseResponse.onSuccess( "게시글이 성공적으로 업데이트되었습니다."); } - @DeleteMapping("/trouble/{postId}") - @Operation(summary = "스터디룸 트러블슈팅 게시글 삭제 API") + @DeleteMapping("/post/{postId}") + @Operation(summary = "스터디룸 게시글 삭제 API") public BaseResponse deletePost( @RequestHeader("Authorization") String authorization, @PathVariable Long postId @@ -57,7 +57,7 @@ public BaseResponse deletePost( } @PostMapping("/post/{postId}/comments") - @Operation(summary = "스터디룸 트러블슈팅 댓글 등록 API") + @Operation(summary = "스터디룸 게시글 댓글 등록 API") public BaseResponse writeCommentOnPost( @RequestHeader("Authorization") String authorization, @RequestBody @Valid RoomPostRequestDto.RoomTroubleCommentDto requestDto, @@ -68,8 +68,8 @@ public BaseResponse writeCommentOnPost( return BaseResponse.onSuccess(newComment); } - @PutMapping("/trouble/comments/{commentId}") - @Operation(summary = "스터디룸 트러블슈팅 댓글 업데이트 API") + @PutMapping("/post/comments/{commentId}") + @Operation(summary = "스터디룸 게시글 댓글 업데이트 API") public BaseResponse updateComment( @RequestHeader("Authorization") String authorization, @RequestBody RoomPostRequestDto.RoomTroubleCommentDto requestDto, @@ -79,4 +79,15 @@ public BaseResponse updateComment( roomPostCommandService.updateComment(commentId, userId,requestDto); return BaseResponse.onSuccess( "댓글이 성공적으로 업데이트되었습니다."); } + + @DeleteMapping("/post/comments/{commentId}") + @Operation(summary = "스터디룸 게시글 댓글 삭제 API") + public BaseResponse deleteComment( + @RequestHeader("Authorization") String authorization, + @PathVariable Long commentId + ) { + Long userId = tokenProviderService.getUserIdFromToken(authorization); + roomPostCommandService.deleteComment(commentId, userId); + return BaseResponse.onSuccess( "댓글이 성공적으로 삭제되었습니다."); + } } From 0b2b511b06391eaa2885e13e30043e5396543bab Mon Sep 17 00:00:00 2001 From: mmingoo Date: Sat, 17 Aug 2024 14:59:55 +0900 Subject: [PATCH 11/24] =?UTF-8?q?=E2=9C=A8=20=20=EC=8A=A4=ED=84=B0?= =?UTF-8?q?=EB=94=94=EB=A6=84=20=EA=B2=8C=EC=8B=9C=EA=B8=80,=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=EB=82=98=EB=88=94=20=EB=8C=93=EA=B8=80=EC=97=90=20?= =?UTF-8?q?=EB=8B=B5=EA=B8=80=20=EC=9E=91=EC=84=B1=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 --- .../RoomInfo/RoomInfoPostCommandService.java | 3 +++ .../RoomInfoPostCommandServiceImpl.java | 22 ++++++++++++++++++ .../RoomPost/RoomPostCommandService.java | 2 ++ .../RoomPost/RoomPostCommandServiceImpl.java | 23 +++++++++++++++++++ .../RoomTroublePostCommandServiceImpl.java | 5 ---- .../controller/RoomInfoPostController.java | 15 ++++++++++++ .../web/controller/RoomPostController.java | 15 ++++++++++++ .../controller/RoomTroublePostController.java | 4 ++-- 8 files changed, 82 insertions(+), 7 deletions(-) diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandService.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandService.java index 86d3c680..8b2b9d6b 100644 --- a/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandService.java +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandService.java @@ -1,5 +1,6 @@ package gaji.service.domain.roomBoard.service.RoomInfo; +import gaji.service.domain.roomBoard.entity.RoomInfo.InfoPostComment; import gaji.service.domain.roomBoard.web.dto.RoomPostRequestDto; import gaji.service.domain.roomBoard.web.dto.RoomPostResponseDto; @@ -15,4 +16,6 @@ public interface RoomInfoPostCommandService { void updateComment(Long commentId, Long userId, RoomPostRequestDto.RoomTroubleCommentDto requestDto); void deleteComment(Long commentId, Long userId); + + InfoPostComment addReply(Long commentId, Long userId, RoomPostRequestDto.RoomTroubleCommentDto request); } diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandServiceImpl.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandServiceImpl.java index bbb93ad8..559c2434 100644 --- a/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandServiceImpl.java +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandServiceImpl.java @@ -135,4 +135,26 @@ private void deleteCommentAndReplies(InfoPostComment comment) { // 댓글을 삭제하면 연관된 모든 답글도 자동으로 삭제됩니다. infoPostCommentRepository.delete(comment); } + + @Override + public InfoPostComment addReply(Long commentId, Long userId, RoomPostRequestDto.RoomTroubleCommentDto request) { + InfoPostComment parentComment = infoPostCommentRepository.findById(commentId) + .orElseThrow(() -> new RestApiException(RoomPostErrorStatus._NOT_FOUND_COMMENT)); + + if (parentComment.isReply()) { + throw new IllegalStateException("답글에는 답글을 달 수 없습니다."); + } + + User user = userQueryService.findUserById(userId); + InfoPostComment reply = InfoPostComment.builder() + .user(user) + .roomInoPost(parentComment.getRoomInoPost()) + .body(request.getBody()) + .isReply(true) + .parentComment(parentComment) + .build(); + + parentComment.addReply(reply); + return infoPostCommentRepository.save(reply); + } } \ No newline at end of file diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandService.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandService.java index fc876c71..fcb1f95f 100644 --- a/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandService.java +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandService.java @@ -16,4 +16,6 @@ public interface RoomPostCommandService { void updateComment(Long commentId, Long userId, RoomPostRequestDto.RoomTroubleCommentDto requestDto); void deleteComment(Long commentId, Long userId); + + PostComment addReply(Long commentId, Long userId, RoomPostRequestDto.RoomTroubleCommentDto request); } diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandServiceImpl.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandServiceImpl.java index 25df339e..031f0dc7 100644 --- a/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandServiceImpl.java +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandServiceImpl.java @@ -140,4 +140,27 @@ private void deleteCommentAndReplies(PostComment comment) { postCommentRepository.delete(comment); } + @Override + public PostComment addReply(Long commentId, Long userId, RoomPostRequestDto.RoomTroubleCommentDto request) { + PostComment parentComment = postCommentRepository.findById(commentId) + .orElseThrow(() -> new RestApiException(RoomPostErrorStatus._NOT_FOUND_COMMENT)); + + if (parentComment.isReply()) { + throw new IllegalStateException("답글에는 답글을 달 수 없습니다."); + } + + User user = userQueryService.findUserById(userId); + PostComment reply = PostComment.builder() + .user(user) + .roomPost(parentComment.getRoomPost()) + .body(request.getBody()) + .isReply(true) + .parentComment(parentComment) + .build(); + + parentComment.addReply(reply); + return postCommentRepository.save(reply); + } + + } diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomTrouble/RoomTroublePostCommandServiceImpl.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomTrouble/RoomTroublePostCommandServiceImpl.java index 90335ada..9b5b4d44 100644 --- a/src/main/java/gaji/service/domain/roomBoard/service/RoomTrouble/RoomTroublePostCommandServiceImpl.java +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomTrouble/RoomTroublePostCommandServiceImpl.java @@ -215,9 +215,6 @@ public void deleteComment(Long commentId, Long userId) { } - - - @Override public TroublePostComment addReply(Long commentId, Long userId, RoomPostRequestDto.RoomTroubleCommentDto request) { TroublePostComment parentComment = troublePostCommentRepository.findById(commentId) @@ -241,8 +238,6 @@ public TroublePostComment addReply(Long commentId, Long userId, RoomPostRequestD } - - private void deleteReply(TroublePostComment reply) { TroublePostComment parentComment = reply.getParentComment(); parentComment.getReplies().remove(reply); diff --git a/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomInfoPostController.java b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomInfoPostController.java index c204f684..b410ec34 100644 --- a/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomInfoPostController.java +++ b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomInfoPostController.java @@ -1,5 +1,8 @@ package gaji.service.domain.roomBoard.web.controller; +import gaji.service.domain.roomBoard.converter.RoomPostConverter; +import gaji.service.domain.roomBoard.entity.RoomInfo.InfoPostComment; +import gaji.service.domain.roomBoard.entity.RoomPost.PostComment; import gaji.service.domain.roomBoard.service.RoomInfo.RoomInfoPostCommandService; import gaji.service.domain.roomBoard.web.dto.RoomPostRequestDto; import gaji.service.domain.roomBoard.web.dto.RoomPostResponseDto; @@ -87,4 +90,16 @@ public BaseResponse deleteComment( roomInfoPostCommandService.deleteComment(commentId, userId); return BaseResponse.onSuccess( "댓글이 성공적으로 삭제되었습니다."); } + + @PostMapping("/info/comments/{commentId}/replies") + @Operation(summary = "정보나눔 게시글 댓글의 답글 작성 API") + public BaseResponse addReply( + @RequestHeader("Authorization") String authorization, + @PathVariable Long commentId, + @RequestBody @Valid RoomPostRequestDto.RoomTroubleCommentDto requestDto + ) { + Long userId = tokenProviderService.getUserIdFromToken(authorization); + InfoPostComment replyComment = roomInfoPostCommandService.addReply(commentId, userId, requestDto); + return BaseResponse.onSuccess(RoomPostConverter.toWriteInfoPostCommentDto(replyComment)); + } } diff --git a/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomPostController.java b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomPostController.java index 25f6d70a..14323f0e 100644 --- a/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomPostController.java +++ b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomPostController.java @@ -1,6 +1,9 @@ package gaji.service.domain.roomBoard.web.controller; +import gaji.service.domain.roomBoard.converter.RoomPostConverter; +import gaji.service.domain.roomBoard.entity.RoomPost.PostComment; import gaji.service.domain.roomBoard.entity.RoomPost.RoomPost; +import gaji.service.domain.roomBoard.entity.RoomTrouble.TroublePostComment; import gaji.service.domain.roomBoard.service.RoomPost.RoomPostCommandService; import gaji.service.domain.roomBoard.web.dto.RoomPostRequestDto; import gaji.service.domain.roomBoard.web.dto.RoomPostResponseDto; @@ -90,4 +93,16 @@ public BaseResponse deleteComment( roomPostCommandService.deleteComment(commentId, userId); return BaseResponse.onSuccess( "댓글이 성공적으로 삭제되었습니다."); } + + @PostMapping("/post/comments/{commentId}/replies") + @Operation(summary = "게시글 댓글의 답글 작성 API") + public BaseResponse addReply( + @RequestHeader("Authorization") String authorization, + @PathVariable Long commentId, + @RequestBody @Valid RoomPostRequestDto.RoomTroubleCommentDto requestDto + ) { + Long userId = tokenProviderService.getUserIdFromToken(authorization); + PostComment replyComment = roomPostCommandService.addReply(commentId, userId, requestDto); + return BaseResponse.onSuccess(RoomPostConverter.toWritePostCommentDto(replyComment)); + } } diff --git a/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomTroublePostController.java b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomTroublePostController.java index 9317a1dc..692aa1dc 100644 --- a/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomTroublePostController.java +++ b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomTroublePostController.java @@ -146,7 +146,7 @@ public BaseResponse removeBookmark( return BaseResponse.onSuccess( "북마크가 성공적으로 삭제되었습니다."); } - @PostMapping("/comments/{commentId}/replies") + @PostMapping("/trouble/comments/{commentId}/replies") @Operation(summary = "트러블 슈팅 게시글 댓글의 답글 작성 API") public BaseResponse addReply( @RequestHeader("Authorization") String authorization, @@ -158,7 +158,7 @@ public BaseResponse addReply( return BaseResponse.onSuccess(RoomPostConverter.toWriteCommentDto(replyComment)); } - @GetMapping("/{boardId}/trouble-posts") + @GetMapping("/{boardId}/trouble") @Operation(summary = "트러블 슈팅 게시글 무한 스크롤 조회", description = "트러블 슈팅 게시글을 무한 스크롤 방식으로 조회합니다.") @ApiResponse(responseCode = "200", description = "조회 성공") public BaseResponse> getNextTroublePosts( From 0f9e1fc828d1aac160c3282310c6db79b28255d7 Mon Sep 17 00:00:00 2001 From: mmingoo Date: Sat, 17 Aug 2024 15:07:49 +0900 Subject: [PATCH 12/24] =?UTF-8?q?Revert=20"=E2=9C=A8=20=20=EC=8A=A4?= =?UTF-8?q?=ED=84=B0=EB=94=94=EB=A6=84=20=EA=B2=8C=EC=8B=9C=EA=B8=80,?= =?UTF-8?q?=EC=A0=95=EB=B3=B4=EB=82=98=EB=88=94=20=EB=8C=93=EA=B8=80?= =?UTF-8?q?=EC=97=90=20=EB=8B=B5=EA=B8=80=20=EC=9E=91=EC=84=B1=20=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5=20=EA=B5=AC=ED=98=84"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 0b2b511b06391eaa2885e13e30043e5396543bab. --- .../RoomInfo/RoomInfoPostCommandService.java | 3 --- .../RoomInfoPostCommandServiceImpl.java | 22 ------------------ .../RoomPost/RoomPostCommandService.java | 2 -- .../RoomPost/RoomPostCommandServiceImpl.java | 23 ------------------- .../RoomTroublePostCommandServiceImpl.java | 5 ++++ .../controller/RoomInfoPostController.java | 15 ------------ .../web/controller/RoomPostController.java | 15 ------------ .../controller/RoomTroublePostController.java | 4 ++-- 8 files changed, 7 insertions(+), 82 deletions(-) diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandService.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandService.java index 8b2b9d6b..86d3c680 100644 --- a/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandService.java +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandService.java @@ -1,6 +1,5 @@ package gaji.service.domain.roomBoard.service.RoomInfo; -import gaji.service.domain.roomBoard.entity.RoomInfo.InfoPostComment; import gaji.service.domain.roomBoard.web.dto.RoomPostRequestDto; import gaji.service.domain.roomBoard.web.dto.RoomPostResponseDto; @@ -16,6 +15,4 @@ public interface RoomInfoPostCommandService { void updateComment(Long commentId, Long userId, RoomPostRequestDto.RoomTroubleCommentDto requestDto); void deleteComment(Long commentId, Long userId); - - InfoPostComment addReply(Long commentId, Long userId, RoomPostRequestDto.RoomTroubleCommentDto request); } diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandServiceImpl.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandServiceImpl.java index 559c2434..bbb93ad8 100644 --- a/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandServiceImpl.java +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandServiceImpl.java @@ -135,26 +135,4 @@ private void deleteCommentAndReplies(InfoPostComment comment) { // 댓글을 삭제하면 연관된 모든 답글도 자동으로 삭제됩니다. infoPostCommentRepository.delete(comment); } - - @Override - public InfoPostComment addReply(Long commentId, Long userId, RoomPostRequestDto.RoomTroubleCommentDto request) { - InfoPostComment parentComment = infoPostCommentRepository.findById(commentId) - .orElseThrow(() -> new RestApiException(RoomPostErrorStatus._NOT_FOUND_COMMENT)); - - if (parentComment.isReply()) { - throw new IllegalStateException("답글에는 답글을 달 수 없습니다."); - } - - User user = userQueryService.findUserById(userId); - InfoPostComment reply = InfoPostComment.builder() - .user(user) - .roomInoPost(parentComment.getRoomInoPost()) - .body(request.getBody()) - .isReply(true) - .parentComment(parentComment) - .build(); - - parentComment.addReply(reply); - return infoPostCommentRepository.save(reply); - } } \ No newline at end of file diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandService.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandService.java index fcb1f95f..fc876c71 100644 --- a/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandService.java +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandService.java @@ -16,6 +16,4 @@ public interface RoomPostCommandService { void updateComment(Long commentId, Long userId, RoomPostRequestDto.RoomTroubleCommentDto requestDto); void deleteComment(Long commentId, Long userId); - - PostComment addReply(Long commentId, Long userId, RoomPostRequestDto.RoomTroubleCommentDto request); } diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandServiceImpl.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandServiceImpl.java index 031f0dc7..25df339e 100644 --- a/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandServiceImpl.java +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandServiceImpl.java @@ -140,27 +140,4 @@ private void deleteCommentAndReplies(PostComment comment) { postCommentRepository.delete(comment); } - @Override - public PostComment addReply(Long commentId, Long userId, RoomPostRequestDto.RoomTroubleCommentDto request) { - PostComment parentComment = postCommentRepository.findById(commentId) - .orElseThrow(() -> new RestApiException(RoomPostErrorStatus._NOT_FOUND_COMMENT)); - - if (parentComment.isReply()) { - throw new IllegalStateException("답글에는 답글을 달 수 없습니다."); - } - - User user = userQueryService.findUserById(userId); - PostComment reply = PostComment.builder() - .user(user) - .roomPost(parentComment.getRoomPost()) - .body(request.getBody()) - .isReply(true) - .parentComment(parentComment) - .build(); - - parentComment.addReply(reply); - return postCommentRepository.save(reply); - } - - } diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomTrouble/RoomTroublePostCommandServiceImpl.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomTrouble/RoomTroublePostCommandServiceImpl.java index 9b5b4d44..90335ada 100644 --- a/src/main/java/gaji/service/domain/roomBoard/service/RoomTrouble/RoomTroublePostCommandServiceImpl.java +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomTrouble/RoomTroublePostCommandServiceImpl.java @@ -215,6 +215,9 @@ public void deleteComment(Long commentId, Long userId) { } + + + @Override public TroublePostComment addReply(Long commentId, Long userId, RoomPostRequestDto.RoomTroubleCommentDto request) { TroublePostComment parentComment = troublePostCommentRepository.findById(commentId) @@ -238,6 +241,8 @@ public TroublePostComment addReply(Long commentId, Long userId, RoomPostRequestD } + + private void deleteReply(TroublePostComment reply) { TroublePostComment parentComment = reply.getParentComment(); parentComment.getReplies().remove(reply); diff --git a/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomInfoPostController.java b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomInfoPostController.java index b410ec34..c204f684 100644 --- a/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomInfoPostController.java +++ b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomInfoPostController.java @@ -1,8 +1,5 @@ package gaji.service.domain.roomBoard.web.controller; -import gaji.service.domain.roomBoard.converter.RoomPostConverter; -import gaji.service.domain.roomBoard.entity.RoomInfo.InfoPostComment; -import gaji.service.domain.roomBoard.entity.RoomPost.PostComment; import gaji.service.domain.roomBoard.service.RoomInfo.RoomInfoPostCommandService; import gaji.service.domain.roomBoard.web.dto.RoomPostRequestDto; import gaji.service.domain.roomBoard.web.dto.RoomPostResponseDto; @@ -90,16 +87,4 @@ public BaseResponse deleteComment( roomInfoPostCommandService.deleteComment(commentId, userId); return BaseResponse.onSuccess( "댓글이 성공적으로 삭제되었습니다."); } - - @PostMapping("/info/comments/{commentId}/replies") - @Operation(summary = "정보나눔 게시글 댓글의 답글 작성 API") - public BaseResponse addReply( - @RequestHeader("Authorization") String authorization, - @PathVariable Long commentId, - @RequestBody @Valid RoomPostRequestDto.RoomTroubleCommentDto requestDto - ) { - Long userId = tokenProviderService.getUserIdFromToken(authorization); - InfoPostComment replyComment = roomInfoPostCommandService.addReply(commentId, userId, requestDto); - return BaseResponse.onSuccess(RoomPostConverter.toWriteInfoPostCommentDto(replyComment)); - } } diff --git a/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomPostController.java b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomPostController.java index 14323f0e..25f6d70a 100644 --- a/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomPostController.java +++ b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomPostController.java @@ -1,9 +1,6 @@ package gaji.service.domain.roomBoard.web.controller; -import gaji.service.domain.roomBoard.converter.RoomPostConverter; -import gaji.service.domain.roomBoard.entity.RoomPost.PostComment; import gaji.service.domain.roomBoard.entity.RoomPost.RoomPost; -import gaji.service.domain.roomBoard.entity.RoomTrouble.TroublePostComment; import gaji.service.domain.roomBoard.service.RoomPost.RoomPostCommandService; import gaji.service.domain.roomBoard.web.dto.RoomPostRequestDto; import gaji.service.domain.roomBoard.web.dto.RoomPostResponseDto; @@ -93,16 +90,4 @@ public BaseResponse deleteComment( roomPostCommandService.deleteComment(commentId, userId); return BaseResponse.onSuccess( "댓글이 성공적으로 삭제되었습니다."); } - - @PostMapping("/post/comments/{commentId}/replies") - @Operation(summary = "게시글 댓글의 답글 작성 API") - public BaseResponse addReply( - @RequestHeader("Authorization") String authorization, - @PathVariable Long commentId, - @RequestBody @Valid RoomPostRequestDto.RoomTroubleCommentDto requestDto - ) { - Long userId = tokenProviderService.getUserIdFromToken(authorization); - PostComment replyComment = roomPostCommandService.addReply(commentId, userId, requestDto); - return BaseResponse.onSuccess(RoomPostConverter.toWritePostCommentDto(replyComment)); - } } diff --git a/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomTroublePostController.java b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomTroublePostController.java index 692aa1dc..9317a1dc 100644 --- a/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomTroublePostController.java +++ b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomTroublePostController.java @@ -146,7 +146,7 @@ public BaseResponse removeBookmark( return BaseResponse.onSuccess( "북마크가 성공적으로 삭제되었습니다."); } - @PostMapping("/trouble/comments/{commentId}/replies") + @PostMapping("/comments/{commentId}/replies") @Operation(summary = "트러블 슈팅 게시글 댓글의 답글 작성 API") public BaseResponse addReply( @RequestHeader("Authorization") String authorization, @@ -158,7 +158,7 @@ public BaseResponse addReply( return BaseResponse.onSuccess(RoomPostConverter.toWriteCommentDto(replyComment)); } - @GetMapping("/{boardId}/trouble") + @GetMapping("/{boardId}/trouble-posts") @Operation(summary = "트러블 슈팅 게시글 무한 스크롤 조회", description = "트러블 슈팅 게시글을 무한 스크롤 방식으로 조회합니다.") @ApiResponse(responseCode = "200", description = "조회 성공") public BaseResponse> getNextTroublePosts( From 5246748f5bb1cb660cfb0f18635751d9167d2ead Mon Sep 17 00:00:00 2001 From: mmingoo Date: Sat, 17 Aug 2024 17:02:00 +0900 Subject: [PATCH 13/24] =?UTF-8?q?=E2=9C=A8=20=20=EC=8A=A4=ED=84=B0?= =?UTF-8?q?=EB=94=94=EB=A6=84=20=EA=B2=8C=EC=8B=9C=EA=B8=80,=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=EB=82=98=EB=88=94=20=EA=B2=8C=EC=8B=9C=EA=B8=80=20?= =?UTF-8?q?=EC=A2=8B=EC=95=84=EC=9A=94,=20=EC=A2=8B=EC=95=84=EC=9A=94=20?= =?UTF-8?q?=EC=B7=A8=EC=86=8C=20=EA=B8=B0=EB=8A=A5=20=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entity/RoomInfo/RoomInfoPost.java | 18 ++++++++ .../entity/RoomInfo/RoomInfoPostLikes.java | 25 +++++++++++ .../roomBoard/entity/RoomPost/RoomPost.java | 12 +++++ .../entity/RoomPost/RoomPostLikes.java | 9 ++-- .../RoomInfo/RoomInfoPostLikesRepository.java | 14 ++++++ .../RoomPost/RoomPostLikesRepository.java | 16 +++++++ .../RoomInfo/RoomInfoPostCommandService.java | 4 ++ .../RoomInfoPostCommandServiceImpl.java | 44 +++++++++++++++++++ .../RoomPost/RoomPostCommandService.java | 4 ++ .../RoomPost/RoomPostCommandServiceImpl.java | 42 ++++++++++++++++++ .../controller/RoomInfoPostController.java | 24 ++++++++++ .../web/controller/RoomPostController.java | 24 ++++++++++ .../domain/studyMate/entity/StudyMate.java | 4 ++ .../gaji/service/domain/user/entity/User.java | 5 --- 14 files changed, 236 insertions(+), 9 deletions(-) create mode 100644 src/main/java/gaji/service/domain/roomBoard/entity/RoomInfo/RoomInfoPostLikes.java create mode 100644 src/main/java/gaji/service/domain/roomBoard/repository/RoomInfo/RoomInfoPostLikesRepository.java create mode 100644 src/main/java/gaji/service/domain/roomBoard/repository/RoomPost/RoomPostLikesRepository.java diff --git a/src/main/java/gaji/service/domain/roomBoard/entity/RoomInfo/RoomInfoPost.java b/src/main/java/gaji/service/domain/roomBoard/entity/RoomInfo/RoomInfoPost.java index 2f1cea75..9208aadf 100644 --- a/src/main/java/gaji/service/domain/roomBoard/entity/RoomInfo/RoomInfoPost.java +++ b/src/main/java/gaji/service/domain/roomBoard/entity/RoomInfo/RoomInfoPost.java @@ -1,11 +1,14 @@ package gaji.service.domain.roomBoard.entity.RoomInfo; import gaji.service.domain.roomBoard.entity.RoomBoard; +import gaji.service.domain.roomBoard.entity.RoomTrouble.RoomTroublePostLike; import gaji.service.domain.studyMate.entity.StudyMate; import jakarta.persistence.*; import lombok.*; import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; @Entity @Getter @@ -32,6 +35,9 @@ public class RoomInfoPost { @JoinColumn(name = "study_mate_id") private StudyMate studyMate; + @OneToMany(mappedBy = "roomInfoPost", cascade = CascadeType.ALL) + private List roomInfoPostLikesList = new ArrayList<>(); + @PrePersist public void prePersist() { this.viewCount = 0; @@ -47,4 +53,16 @@ public void update(String title, String body) { this.title = title; this.body = body; } + + public void addLike(RoomInfoPostLikes like) { + this.roomInfoPostLikesList.add(like); + this.likeCount++; + } + + public void removeLike(RoomInfoPostLikes like) { + this.roomInfoPostLikesList.remove(like); + this.likeCount = Math.max(0, this.likeCount - 1); + + } + } diff --git a/src/main/java/gaji/service/domain/roomBoard/entity/RoomInfo/RoomInfoPostLikes.java b/src/main/java/gaji/service/domain/roomBoard/entity/RoomInfo/RoomInfoPostLikes.java new file mode 100644 index 00000000..84f954fb --- /dev/null +++ b/src/main/java/gaji/service/domain/roomBoard/entity/RoomInfo/RoomInfoPostLikes.java @@ -0,0 +1,25 @@ +package gaji.service.domain.roomBoard.entity.RoomInfo; + +import gaji.service.domain.roomBoard.entity.RoomPost.RoomPost; +import gaji.service.domain.studyMate.entity.StudyMate; +import jakarta.persistence.*; +import lombok.*; + +@Entity +@Getter +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@Builder +@AllArgsConstructor +public class RoomInfoPostLikes { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "user_id") + private StudyMate studyMate; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "post_id") + private RoomInfoPost roomInfoPost; +} diff --git a/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPost.java b/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPost.java index ba307167..515746ca 100644 --- a/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPost.java +++ b/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPost.java @@ -1,6 +1,7 @@ package gaji.service.domain.roomBoard.entity.RoomPost; import gaji.service.domain.roomBoard.entity.RoomBoard; +import gaji.service.domain.roomBoard.entity.RoomTrouble.RoomTroublePostLike; import gaji.service.domain.studyMate.entity.StudyMate; import gaji.service.domain.user.entity.User; import jakarta.persistence.*; @@ -71,4 +72,15 @@ public void update(String title, String body) { this.title = title; this.body = body; } + + public void addLike(RoomPostLikes like) { + this.roomPostLikesList.add(like); + this.likeCount++; + } + + public void removeLike(RoomPostLikes like) { + this.roomPostLikesList.remove(like); + this.likeCount = Math.max(0, this.likeCount - 1); + + } } diff --git a/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPostLikes.java b/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPostLikes.java index 82d49126..59c52a9b 100644 --- a/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPostLikes.java +++ b/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPostLikes.java @@ -1,14 +1,15 @@ package gaji.service.domain.roomBoard.entity.RoomPost; +import gaji.service.domain.studyMate.entity.StudyMate; import gaji.service.domain.user.entity.User; import jakarta.persistence.*; -import lombok.AccessLevel; -import lombok.Getter; -import lombok.NoArgsConstructor; +import lombok.*; @Entity @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) +@Builder +@AllArgsConstructor public class RoomPostLikes { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @@ -16,7 +17,7 @@ public class RoomPostLikes { @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "user_id") - private User user; + private StudyMate studyMate; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "post_id") diff --git a/src/main/java/gaji/service/domain/roomBoard/repository/RoomInfo/RoomInfoPostLikesRepository.java b/src/main/java/gaji/service/domain/roomBoard/repository/RoomInfo/RoomInfoPostLikesRepository.java new file mode 100644 index 00000000..576e3fd6 --- /dev/null +++ b/src/main/java/gaji/service/domain/roomBoard/repository/RoomInfo/RoomInfoPostLikesRepository.java @@ -0,0 +1,14 @@ +package gaji.service.domain.roomBoard.repository.RoomInfo; + +import gaji.service.domain.roomBoard.entity.RoomInfo.RoomInfoPost; +import gaji.service.domain.roomBoard.entity.RoomInfo.RoomInfoPostLikes; +import gaji.service.domain.studyMate.entity.StudyMate; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import java.util.Optional; + +@Repository +public interface RoomInfoPostLikesRepository extends JpaRepository { + Optional findByRoomInfoPostAndStudyMate(RoomInfoPost post, StudyMate studyMate); +} diff --git a/src/main/java/gaji/service/domain/roomBoard/repository/RoomPost/RoomPostLikesRepository.java b/src/main/java/gaji/service/domain/roomBoard/repository/RoomPost/RoomPostLikesRepository.java new file mode 100644 index 00000000..3d191053 --- /dev/null +++ b/src/main/java/gaji/service/domain/roomBoard/repository/RoomPost/RoomPostLikesRepository.java @@ -0,0 +1,16 @@ +package gaji.service.domain.roomBoard.repository.RoomPost; + +import gaji.service.domain.roomBoard.entity.RoomInfo.RoomInfoPost; +import gaji.service.domain.roomBoard.entity.RoomPost.RoomPost; +import gaji.service.domain.roomBoard.entity.RoomPost.RoomPostLikes; +import gaji.service.domain.roomBoard.entity.RoomTrouble.RoomTroublePostLike; +import gaji.service.domain.studyMate.entity.StudyMate; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import java.util.Optional; + +@Repository +public interface RoomPostLikesRepository extends JpaRepository { + Optional findByRoomPostAndStudyMate(RoomPost post, StudyMate studyMate); +} diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandService.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandService.java index 86d3c680..7ca99a79 100644 --- a/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandService.java +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandService.java @@ -15,4 +15,8 @@ public interface RoomInfoPostCommandService { void updateComment(Long commentId, Long userId, RoomPostRequestDto.RoomTroubleCommentDto requestDto); void deleteComment(Long commentId, Long userId); + + void addLike(Long postId, Long userId, Long roomId); + + void removeLike(Long postId, Long userId, Long roomId); } diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandServiceImpl.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandServiceImpl.java index bbb93ad8..db2f43df 100644 --- a/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandServiceImpl.java +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandServiceImpl.java @@ -8,9 +8,12 @@ import gaji.service.domain.roomBoard.entity.RoomInfo.InfoPostComment; import gaji.service.domain.roomBoard.entity.RoomInfo.RoomInfoPost; import gaji.service.domain.roomBoard.entity.RoomBoard; +import gaji.service.domain.roomBoard.entity.RoomInfo.RoomInfoPostLikes; import gaji.service.domain.roomBoard.repository.RoomBoardRepository; import gaji.service.domain.roomBoard.repository.RoomInfo.InfoPostCommentRepository; +import gaji.service.domain.roomBoard.repository.RoomInfo.RoomInfoPostLikesRepository; import gaji.service.domain.roomBoard.repository.RoomInfo.RoomInfoPostRepository; +import gaji.service.domain.roomBoard.repository.RoomPost.RoomPostLikesRepository; import gaji.service.domain.roomBoard.web.dto.RoomPostRequestDto; import gaji.service.domain.roomBoard.web.dto.RoomPostResponseDto; import gaji.service.domain.studyMate.entity.StudyMate; @@ -22,6 +25,8 @@ import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; +import java.util.Optional; + @Service @RequiredArgsConstructor @Transactional @@ -33,6 +38,9 @@ public class RoomInfoPostCommandServiceImpl implements RoomInfoPostCommandServic private final StudyMateQueryService studyMateQueryService; private final RoomInfoPostQueryService roomInfoPostQueryService; private final InfoPostCommentRepository infoPostCommentRepository; + private final RoomPostLikesRepository roomPostLikesRepository; + private final RoomInfoPostLikesRepository roomInfoPostLikesRepository; + @Override public RoomPostResponseDto.toCreateRoomInfoPostIdDTO createRoomInfoPostIdDTO(Long roomId, Long userId, RoomPostRequestDto.RoomInfoPostDto requestDto) { User user = userQueryService.findUserById(userId); @@ -135,4 +143,40 @@ private void deleteCommentAndReplies(InfoPostComment comment) { // 댓글을 삭제하면 연관된 모든 답글도 자동으로 삭제됩니다. infoPostCommentRepository.delete(comment); } + + @Override + public void addLike(Long postId, Long userId, Long roomId) { + RoomInfoPost post = roomInfoPostRepository.findById(postId) + .orElseThrow(() -> new RestApiException(RoomPostErrorStatus._POST_NOT_FOUND)); + StudyMate studyMate = studyMateQueryService.findByUserIdAndRoomId(userId, roomId); + + Optional likeOptional = roomInfoPostLikesRepository + .findByRoomInfoPostAndStudyMate(post, studyMate); + + if (likeOptional.isPresent()) { + throw new RestApiException(RoomPostErrorStatus._POST_ALREADY_LIKED); + } + + RoomInfoPostLikes newLike = RoomInfoPostLikes.builder() + .roomInfoPost(post) + .studyMate(studyMate) + .build(); + + post.addLike(newLike); + roomInfoPostLikesRepository.save(newLike); + } + + @Override + public void removeLike(Long postId, Long userId, Long roomId) { + RoomInfoPost post = roomInfoPostRepository.findById(postId) + .orElseThrow(() -> new RestApiException(RoomPostErrorStatus._POST_NOT_FOUND)); + StudyMate studyMate = studyMateQueryService.findByUserIdAndRoomId(userId, roomId); + + RoomInfoPostLikes like = roomInfoPostLikesRepository + .findByRoomInfoPostAndStudyMate(post, studyMate) + .orElseThrow(() -> new RestApiException(RoomPostErrorStatus. _POST_LIKE_NOT_FOUND)); + + post.removeLike(like); + roomInfoPostLikesRepository.delete(like); + } } \ No newline at end of file diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandService.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandService.java index fc876c71..3e901bad 100644 --- a/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandService.java +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandService.java @@ -16,4 +16,8 @@ public interface RoomPostCommandService { void updateComment(Long commentId, Long userId, RoomPostRequestDto.RoomTroubleCommentDto requestDto); void deleteComment(Long commentId, Long userId); + + void addLike(Long postId, Long userId, Long roomId); + + void removeLike(Long postId, Long userId, Long roomId); } diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandServiceImpl.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandServiceImpl.java index 25df339e..43b61538 100644 --- a/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandServiceImpl.java +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandServiceImpl.java @@ -8,8 +8,10 @@ import gaji.service.domain.roomBoard.entity.RoomBoard; import gaji.service.domain.roomBoard.entity.RoomPost.PostComment; import gaji.service.domain.roomBoard.entity.RoomPost.RoomPost; +import gaji.service.domain.roomBoard.entity.RoomPost.RoomPostLikes; import gaji.service.domain.roomBoard.repository.RoomBoardRepository; import gaji.service.domain.roomBoard.repository.RoomPost.PostCommentRepository; +import gaji.service.domain.roomBoard.repository.RoomPost.RoomPostLikesRepository; import gaji.service.domain.roomBoard.repository.RoomPost.RoomPostRepository; import gaji.service.domain.roomBoard.web.dto.RoomPostRequestDto; import gaji.service.domain.roomBoard.web.dto.RoomPostResponseDto; @@ -23,6 +25,8 @@ import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; +import java.util.Optional; + @Service @RequiredArgsConstructor @Transactional @@ -35,6 +39,7 @@ public class RoomPostCommandServiceImpl implements RoomPostCommandService { private final StudyMateQueryService studyMateQueryService; private final PostCommentRepository postCommentRepository; private final RoomPostQueryService roomPostQueryService; + private final RoomPostLikesRepository roomPostLikesRepository; @Override public RoomPostResponseDto.toCreateRoomPostIdDTO createRoomPost(Long roomId, Long userId, RoomPostRequestDto.RoomPostDto requestDto) { @@ -140,4 +145,41 @@ private void deleteCommentAndReplies(PostComment comment) { postCommentRepository.delete(comment); } + @Override + public void addLike(Long postId, Long userId, Long roomId) { + RoomPost post = roomPostRepository.findById(postId) + .orElseThrow(() -> new RestApiException(RoomPostErrorStatus._POST_NOT_FOUND)); + StudyMate studyMate = studyMateQueryService.findByUserIdAndRoomId(userId, roomId); + + Optional likeOptional = roomPostLikesRepository + .findByRoomPostAndStudyMate(post, studyMate) + ; + + if (likeOptional.isPresent()) { + throw new RestApiException(RoomPostErrorStatus._POST_ALREADY_LIKED); + } + + RoomPostLikes newLike = RoomPostLikes.builder() + .roomPost(post) + .studyMate(studyMate) + .build(); + + post.addLike(newLike); + roomPostLikesRepository.save(newLike); + } + + @Override + public void removeLike(Long postId, Long userId, Long roomId) { + RoomPost post = roomPostRepository.findById(postId) + .orElseThrow(() -> new RestApiException(RoomPostErrorStatus._POST_NOT_FOUND)); + StudyMate studyMate = studyMateQueryService.findByUserIdAndRoomId(userId, roomId); + + RoomPostLikes like = roomPostLikesRepository + .findByRoomPostAndStudyMate(post, studyMate) + .orElseThrow(() -> new RestApiException(RoomPostErrorStatus. _POST_LIKE_NOT_FOUND)); + + post.removeLike(like); + roomPostLikesRepository.delete(like); + } + } diff --git a/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomInfoPostController.java b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomInfoPostController.java index c204f684..1615cc8b 100644 --- a/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomInfoPostController.java +++ b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomInfoPostController.java @@ -87,4 +87,28 @@ public BaseResponse deleteComment( roomInfoPostCommandService.deleteComment(commentId, userId); return BaseResponse.onSuccess( "댓글이 성공적으로 삭제되었습니다."); } + + @PostMapping("/info/{roomId}/posts/{postId}/like") + @Operation(summary = "스터디룸 정보나눔 게시글 좋아요 API") + public BaseResponse postLike( + @RequestHeader("Authorization") String authorization, + @PathVariable Long postId, + @PathVariable Long roomId + ) { + Long userId = tokenProviderService.getUserIdFromToken(authorization); + roomInfoPostCommandService.addLike(postId, userId, roomId); + return BaseResponse.onSuccess("LIKE"); + } + + @DeleteMapping("/info/{roomId}/posts/{postId}/unlike") + @Operation(summary = "스터디룸 정보나눔 게시글 좋아요 취소 API") + public BaseResponse postUnlike( + @RequestHeader("Authorization") String authorization, + @PathVariable Long postId, + @PathVariable Long roomId + ) { + Long userId = tokenProviderService.getUserIdFromToken(authorization); + roomInfoPostCommandService.removeLike(postId, userId, roomId); + return BaseResponse.onSuccess("UNLIKE"); + } } diff --git a/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomPostController.java b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomPostController.java index 25f6d70a..72c2626a 100644 --- a/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomPostController.java +++ b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomPostController.java @@ -90,4 +90,28 @@ public BaseResponse deleteComment( roomPostCommandService.deleteComment(commentId, userId); return BaseResponse.onSuccess( "댓글이 성공적으로 삭제되었습니다."); } + + @PostMapping("/post/{roomId}/posts/{postId}/like") + @Operation(summary = "스터디룸 게시글 좋아요 API") + public BaseResponse postLike( + @RequestHeader("Authorization") String authorization, + @PathVariable Long postId, + @PathVariable Long roomId + ) { + Long userId = tokenProviderService.getUserIdFromToken(authorization); + roomPostCommandService.addLike(postId, userId, roomId); + return BaseResponse.onSuccess("LIKE"); + } + + @DeleteMapping("/post/{roomId}/posts/{postId}/unlike") + @Operation(summary = "스터디룸 게시글 좋아요 취소 API") + public BaseResponse postUnlike( + @RequestHeader("Authorization") String authorization, + @PathVariable Long postId, + @PathVariable Long roomId + ) { + Long userId = tokenProviderService.getUserIdFromToken(authorization); + roomPostCommandService.removeLike(postId, userId, roomId); + return BaseResponse.onSuccess("UNLIKE"); + } } diff --git a/src/main/java/gaji/service/domain/studyMate/entity/StudyMate.java b/src/main/java/gaji/service/domain/studyMate/entity/StudyMate.java index f8eda1a1..8a4d82e1 100644 --- a/src/main/java/gaji/service/domain/studyMate/entity/StudyMate.java +++ b/src/main/java/gaji/service/domain/studyMate/entity/StudyMate.java @@ -4,6 +4,7 @@ import gaji.service.domain.room.entity.Room; import gaji.service.domain.room.entity.RoomNotice; import gaji.service.domain.roomBoard.entity.RoomPost.RoomPost; +import gaji.service.domain.roomBoard.entity.RoomPost.RoomPostLikes; import gaji.service.domain.roomBoard.entity.RoomTrouble.RoomTroublePostBookmark; import gaji.service.domain.roomBoard.entity.RoomTrouble.RoomTroublePostLike; import gaji.service.domain.roomBoard.entity.RoomInfo.RoomInfoPost; @@ -60,6 +61,9 @@ public class StudyMate { @OneToMany(mappedBy = "studyMate", cascade = CascadeType.ALL) private List roomPostList = new ArrayList<>(); + @OneToMany(mappedBy = "studyMate", cascade = CascadeType.ALL) + private List roomPostLikesList = new ArrayList<>(); + @Enumerated(EnumType.STRING) private Role role; diff --git a/src/main/java/gaji/service/domain/user/entity/User.java b/src/main/java/gaji/service/domain/user/entity/User.java index dec4c640..e5054607 100644 --- a/src/main/java/gaji/service/domain/user/entity/User.java +++ b/src/main/java/gaji/service/domain/user/entity/User.java @@ -52,11 +52,6 @@ public class User extends BaseEntity { @OneToMany(mappedBy = "user",cascade = CascadeType.ALL ) private List studyMateList; - - @OneToMany(mappedBy = "user", cascade = CascadeType.ALL) - private List roomPostLikesList = new ArrayList<>(); - - @OneToMany(mappedBy = "user",cascade = CascadeType.ALL ) private List roomPostBookmarkList = new ArrayList<>(); From 45acbd0ecdbb082f8d18717022e59c3c640e50e0 Mon Sep 17 00:00:00 2001 From: mmingoo Date: Sat, 17 Aug 2024 18:04:17 +0900 Subject: [PATCH 14/24] =?UTF-8?q?=E2=9C=A8=20=20=EC=8A=A4=ED=84=B0?= =?UTF-8?q?=EB=94=94=EB=A6=84=20=EA=B2=8C=EC=8B=9C=EA=B8=80,=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=EB=82=98=EB=88=94=20=EB=B6=81=EB=A7=88=ED=81=AC,=20?= =?UTF-8?q?=20=EB=B6=81=EB=A7=88=ED=81=AC=20=EC=B7=A8=EC=86=8C=20=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5=20=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entity/RoomInfo/RoomInfoPost.java | 18 +++++++++ .../entity/RoomInfo/RoomInfoPostBookmark.java | 25 ++++++++++++ .../roomBoard/entity/RoomPost/RoomPost.java | 12 ++++++ .../entity/RoomPost/RoomPostBookmark.java | 14 ++++--- .../RoomInfoPostBookmarkRepository.java | 14 +++++++ .../RoomPost/RoomPostBookmarkRepository.java | 14 +++++++ .../RoomPost/RoomPostRepository.java | 3 ++ .../RoomInfo/RoomInfoPostCommandService.java | 4 ++ .../RoomInfoPostCommandServiceImpl.java | 38 ++++++++++++++++++- .../RoomPost/RoomPostCommandService.java | 4 ++ .../RoomPost/RoomPostCommandServiceImpl.java | 35 +++++++++++++++++ .../controller/RoomInfoPostController.java | 24 ++++++++++++ .../web/controller/RoomPostController.java | 25 ++++++++++++ 13 files changed, 223 insertions(+), 7 deletions(-) create mode 100644 src/main/java/gaji/service/domain/roomBoard/entity/RoomInfo/RoomInfoPostBookmark.java create mode 100644 src/main/java/gaji/service/domain/roomBoard/repository/RoomInfo/RoomInfoPostBookmarkRepository.java create mode 100644 src/main/java/gaji/service/domain/roomBoard/repository/RoomPost/RoomPostBookmarkRepository.java diff --git a/src/main/java/gaji/service/domain/roomBoard/entity/RoomInfo/RoomInfoPost.java b/src/main/java/gaji/service/domain/roomBoard/entity/RoomInfo/RoomInfoPost.java index 9208aadf..ec8b4bae 100644 --- a/src/main/java/gaji/service/domain/roomBoard/entity/RoomInfo/RoomInfoPost.java +++ b/src/main/java/gaji/service/domain/roomBoard/entity/RoomInfo/RoomInfoPost.java @@ -1,6 +1,8 @@ package gaji.service.domain.roomBoard.entity.RoomInfo; import gaji.service.domain.roomBoard.entity.RoomBoard; +import gaji.service.domain.roomBoard.entity.RoomPost.RoomPostBookmark; +import gaji.service.domain.roomBoard.entity.RoomTrouble.RoomTroublePostBookmark; import gaji.service.domain.roomBoard.entity.RoomTrouble.RoomTroublePostLike; import gaji.service.domain.studyMate.entity.StudyMate; import jakarta.persistence.*; @@ -38,6 +40,11 @@ public class RoomInfoPost { @OneToMany(mappedBy = "roomInfoPost", cascade = CascadeType.ALL) private List roomInfoPostLikesList = new ArrayList<>(); + + @OneToMany(mappedBy = "roomInfoPost", cascade = CascadeType.ALL) + private List roomInfoPostBookmarkList = new ArrayList<>(); + + @PrePersist public void prePersist() { this.viewCount = 0; @@ -65,4 +72,15 @@ public void removeLike(RoomInfoPostLikes like) { } + public void addBookmark(RoomInfoPostBookmark bookmark) { + this.roomInfoPostBookmarkList.add(bookmark); + this.bookmarkCount++; + } + + public void removeBookmark(RoomInfoPostBookmark bookmark) { + this.roomInfoPostBookmarkList.remove(bookmark); + this. bookmarkCount = Math.max(0, this.bookmarkCount - 1); + + } + } diff --git a/src/main/java/gaji/service/domain/roomBoard/entity/RoomInfo/RoomInfoPostBookmark.java b/src/main/java/gaji/service/domain/roomBoard/entity/RoomInfo/RoomInfoPostBookmark.java new file mode 100644 index 00000000..ffbf4b3c --- /dev/null +++ b/src/main/java/gaji/service/domain/roomBoard/entity/RoomInfo/RoomInfoPostBookmark.java @@ -0,0 +1,25 @@ +package gaji.service.domain.roomBoard.entity.RoomInfo; + +import gaji.service.domain.roomBoard.entity.RoomTrouble.RoomTroublePost; +import gaji.service.domain.studyMate.entity.StudyMate; +import jakarta.persistence.*; +import lombok.*; + +@Entity +@Getter +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@AllArgsConstructor +@Builder +public class RoomInfoPostBookmark { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "study_mate_id") + private StudyMate studyMate; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "post_id") + private RoomInfoPost roomInfoPost; +} diff --git a/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPost.java b/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPost.java index 515746ca..3a354ca9 100644 --- a/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPost.java +++ b/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPost.java @@ -1,6 +1,7 @@ package gaji.service.domain.roomBoard.entity.RoomPost; import gaji.service.domain.roomBoard.entity.RoomBoard; +import gaji.service.domain.roomBoard.entity.RoomTrouble.RoomTroublePostBookmark; import gaji.service.domain.roomBoard.entity.RoomTrouble.RoomTroublePostLike; import gaji.service.domain.studyMate.entity.StudyMate; import gaji.service.domain.user.entity.User; @@ -83,4 +84,15 @@ public void removeLike(RoomPostLikes like) { this.likeCount = Math.max(0, this.likeCount - 1); } + public void addBookmark(RoomPostBookmark bookmark) { + this.roomPostBookmarkList.add(bookmark); + this.bookmarkCount++; + } + + public void removeBookmark(RoomPostBookmark bookmark) { + this.roomPostBookmarkList.remove(bookmark); + this. bookmarkCount = Math.max(0, this.bookmarkCount - 1); + + } + } diff --git a/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPostBookmark.java b/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPostBookmark.java index 75aec6e4..045d1591 100644 --- a/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPostBookmark.java +++ b/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPostBookmark.java @@ -1,14 +1,16 @@ package gaji.service.domain.roomBoard.entity.RoomPost; +import gaji.service.domain.roomBoard.entity.RoomTrouble.RoomTroublePost; +import gaji.service.domain.studyMate.entity.StudyMate; import gaji.service.domain.user.entity.User; import jakarta.persistence.*; -import lombok.AccessLevel; -import lombok.Getter; -import lombok.NoArgsConstructor; +import lombok.*; @Entity @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) +@AllArgsConstructor +@Builder public class RoomPostBookmark { @Id @@ -16,10 +18,10 @@ public class RoomPostBookmark { private Long id; @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "user_id") - private User user; + @JoinColumn(name = "study_mate_id") + private StudyMate studyMate; @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "room_id") + @JoinColumn(name = "post_id") private RoomPost roomPost; } diff --git a/src/main/java/gaji/service/domain/roomBoard/repository/RoomInfo/RoomInfoPostBookmarkRepository.java b/src/main/java/gaji/service/domain/roomBoard/repository/RoomInfo/RoomInfoPostBookmarkRepository.java new file mode 100644 index 00000000..9d50d8fe --- /dev/null +++ b/src/main/java/gaji/service/domain/roomBoard/repository/RoomInfo/RoomInfoPostBookmarkRepository.java @@ -0,0 +1,14 @@ +package gaji.service.domain.roomBoard.repository.RoomInfo; + +import gaji.service.domain.roomBoard.entity.RoomInfo.RoomInfoPost; +import gaji.service.domain.roomBoard.entity.RoomInfo.RoomInfoPostBookmark; +import gaji.service.domain.studyMate.entity.StudyMate; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import java.util.Optional; + +@Repository +public interface RoomInfoPostBookmarkRepository extends JpaRepository { + Optional findByRoomInfoPostAndStudyMate(RoomInfoPost post, StudyMate studyMate); +} diff --git a/src/main/java/gaji/service/domain/roomBoard/repository/RoomPost/RoomPostBookmarkRepository.java b/src/main/java/gaji/service/domain/roomBoard/repository/RoomPost/RoomPostBookmarkRepository.java new file mode 100644 index 00000000..9f629772 --- /dev/null +++ b/src/main/java/gaji/service/domain/roomBoard/repository/RoomPost/RoomPostBookmarkRepository.java @@ -0,0 +1,14 @@ +package gaji.service.domain.roomBoard.repository.RoomPost; + +import gaji.service.domain.roomBoard.entity.RoomPost.RoomPost; +import gaji.service.domain.roomBoard.entity.RoomPost.RoomPostBookmark; +import gaji.service.domain.studyMate.entity.StudyMate; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import java.util.Optional; + +@Repository +public interface RoomPostBookmarkRepository extends JpaRepository { + Optional findByRoomPostAndStudyMate(RoomPost post, StudyMate studyMate); +} diff --git a/src/main/java/gaji/service/domain/roomBoard/repository/RoomPost/RoomPostRepository.java b/src/main/java/gaji/service/domain/roomBoard/repository/RoomPost/RoomPostRepository.java index 63a91775..e56bb072 100644 --- a/src/main/java/gaji/service/domain/roomBoard/repository/RoomPost/RoomPostRepository.java +++ b/src/main/java/gaji/service/domain/roomBoard/repository/RoomPost/RoomPostRepository.java @@ -1,9 +1,12 @@ package gaji.service.domain.roomBoard.repository.RoomPost; import gaji.service.domain.roomBoard.entity.RoomPost.RoomPost; +import gaji.service.domain.studyMate.entity.StudyMate; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; +import java.util.Optional; + @Repository public interface RoomPostRepository extends JpaRepository { } diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandService.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandService.java index 7ca99a79..076779a0 100644 --- a/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandService.java +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandService.java @@ -19,4 +19,8 @@ public interface RoomInfoPostCommandService { void addLike(Long postId, Long userId, Long roomId); void removeLike(Long postId, Long userId, Long roomId); + + void addBookmark(Long postId, Long userId, Long roomId); + + void removeBookmark(Long postId, Long userId, Long roomId); } diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandServiceImpl.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandServiceImpl.java index db2f43df..d81f6aef 100644 --- a/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandServiceImpl.java +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandServiceImpl.java @@ -8,9 +8,11 @@ import gaji.service.domain.roomBoard.entity.RoomInfo.InfoPostComment; import gaji.service.domain.roomBoard.entity.RoomInfo.RoomInfoPost; import gaji.service.domain.roomBoard.entity.RoomBoard; +import gaji.service.domain.roomBoard.entity.RoomInfo.RoomInfoPostBookmark; import gaji.service.domain.roomBoard.entity.RoomInfo.RoomInfoPostLikes; import gaji.service.domain.roomBoard.repository.RoomBoardRepository; import gaji.service.domain.roomBoard.repository.RoomInfo.InfoPostCommentRepository; +import gaji.service.domain.roomBoard.repository.RoomInfo.RoomInfoPostBookmarkRepository; import gaji.service.domain.roomBoard.repository.RoomInfo.RoomInfoPostLikesRepository; import gaji.service.domain.roomBoard.repository.RoomInfo.RoomInfoPostRepository; import gaji.service.domain.roomBoard.repository.RoomPost.RoomPostLikesRepository; @@ -40,6 +42,7 @@ public class RoomInfoPostCommandServiceImpl implements RoomInfoPostCommandServic private final InfoPostCommentRepository infoPostCommentRepository; private final RoomPostLikesRepository roomPostLikesRepository; private final RoomInfoPostLikesRepository roomInfoPostLikesRepository; + private final RoomInfoPostBookmarkRepository roomInfoPostBookmarkRepository; @Override public RoomPostResponseDto.toCreateRoomInfoPostIdDTO createRoomInfoPostIdDTO(Long roomId, Long userId, RoomPostRequestDto.RoomInfoPostDto requestDto) { @@ -179,4 +182,37 @@ public void removeLike(Long postId, Long userId, Long roomId) { post.removeLike(like); roomInfoPostLikesRepository.delete(like); } -} \ No newline at end of file + @Override + public void addBookmark(Long postId, Long userId, Long roomId) { + RoomInfoPost post = roomInfoPostRepository.findById(postId) + .orElseThrow(() -> new RestApiException(RoomPostErrorStatus._POST_NOT_FOUND)); + StudyMate studyMate = studyMateQueryService.findByUserIdAndRoomId(userId, roomId); + + if (roomInfoPostBookmarkRepository.findByRoomInfoPostAndStudyMate(post, studyMate).isPresent()) { + throw new RestApiException(RoomPostErrorStatus._POST_ALREADY_BOOKMARKED); + } + + RoomInfoPostBookmark newBookmark = RoomInfoPostBookmark.builder() + .roomInfoPost(post) + .studyMate(studyMate) + .build(); + post.addBookmark(newBookmark); + roomInfoPostBookmarkRepository.save(newBookmark); + + } + + @Override + public void removeBookmark(Long postId, Long userId, Long roomId) { + RoomInfoPost post = roomInfoPostRepository.findById(postId) + .orElseThrow(() -> new RestApiException(RoomPostErrorStatus._POST_NOT_FOUND)); + StudyMate studyMate = studyMateQueryService.findByUserIdAndRoomId(userId, roomId); + + RoomInfoPostBookmark bookmark = roomInfoPostBookmarkRepository + .findByRoomInfoPostAndStudyMate(post, studyMate) + .orElseThrow(() -> new RestApiException(RoomPostErrorStatus._POST_BOOKMARKED_NOT_FOUND)); + + post.removeBookmark(bookmark); + roomInfoPostBookmarkRepository.delete(bookmark); + } +} + diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandService.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandService.java index 3e901bad..13daed4b 100644 --- a/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandService.java +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandService.java @@ -20,4 +20,8 @@ public interface RoomPostCommandService { void addLike(Long postId, Long userId, Long roomId); void removeLike(Long postId, Long userId, Long roomId); + + void addBookmark(Long postId, Long userId, Long roomId); + + void removeBookmark(Long postId, Long userId, Long roomId); } diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandServiceImpl.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandServiceImpl.java index 43b61538..10f9eecc 100644 --- a/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandServiceImpl.java +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandServiceImpl.java @@ -8,9 +8,11 @@ import gaji.service.domain.roomBoard.entity.RoomBoard; import gaji.service.domain.roomBoard.entity.RoomPost.PostComment; import gaji.service.domain.roomBoard.entity.RoomPost.RoomPost; +import gaji.service.domain.roomBoard.entity.RoomPost.RoomPostBookmark; import gaji.service.domain.roomBoard.entity.RoomPost.RoomPostLikes; import gaji.service.domain.roomBoard.repository.RoomBoardRepository; import gaji.service.domain.roomBoard.repository.RoomPost.PostCommentRepository; +import gaji.service.domain.roomBoard.repository.RoomPost.RoomPostBookmarkRepository; import gaji.service.domain.roomBoard.repository.RoomPost.RoomPostLikesRepository; import gaji.service.domain.roomBoard.repository.RoomPost.RoomPostRepository; import gaji.service.domain.roomBoard.web.dto.RoomPostRequestDto; @@ -40,6 +42,7 @@ public class RoomPostCommandServiceImpl implements RoomPostCommandService { private final PostCommentRepository postCommentRepository; private final RoomPostQueryService roomPostQueryService; private final RoomPostLikesRepository roomPostLikesRepository; + private final RoomPostBookmarkRepository roomPostBookmarkRepository; @Override public RoomPostResponseDto.toCreateRoomPostIdDTO createRoomPost(Long roomId, Long userId, RoomPostRequestDto.RoomPostDto requestDto) { @@ -182,4 +185,36 @@ public void removeLike(Long postId, Long userId, Long roomId) { roomPostLikesRepository.delete(like); } + @Override + public void addBookmark(Long postId, Long userId, Long roomId) { + RoomPost post = roomPostRepository.findById(postId) + .orElseThrow(() -> new RestApiException(RoomPostErrorStatus._POST_NOT_FOUND)); + StudyMate studyMate = studyMateQueryService.findByUserIdAndRoomId(userId, roomId); + + if (roomPostBookmarkRepository.findByRoomPostAndStudyMate(post, studyMate).isPresent()) { + throw new RestApiException(RoomPostErrorStatus._POST_ALREADY_BOOKMARKED); + } + + RoomPostBookmark newBookmark = RoomPostBookmark.builder() + .roomPost(post) + .studyMate(studyMate) + .build(); + post.addBookmark(newBookmark); + roomPostBookmarkRepository.save(newBookmark); + + } + + @Override + public void removeBookmark(Long postId, Long userId, Long roomId) { + RoomPost post = roomPostRepository.findById(postId) + .orElseThrow(() -> new RestApiException(RoomPostErrorStatus._POST_NOT_FOUND)); + StudyMate studyMate = studyMateQueryService.findByUserIdAndRoomId(userId, roomId); + + RoomPostBookmark bookmark = roomPostBookmarkRepository + .findByRoomPostAndStudyMate(post, studyMate) + .orElseThrow(() -> new RestApiException(RoomPostErrorStatus._POST_BOOKMARKED_NOT_FOUND)); + + post.removeBookmark(bookmark); + roomPostBookmarkRepository.delete(bookmark); + } } diff --git a/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomInfoPostController.java b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomInfoPostController.java index 1615cc8b..887eed0e 100644 --- a/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomInfoPostController.java +++ b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomInfoPostController.java @@ -111,4 +111,28 @@ public BaseResponse postUnlike( roomInfoPostCommandService.removeLike(postId, userId, roomId); return BaseResponse.onSuccess("UNLIKE"); } + + @PostMapping("/info/{roomId}/{postId}/bookmark-add") + @Operation(summary = "정보나눔 게시글 북마크 추가 API") + public BaseResponse addBookmark( + @RequestHeader("Authorization") String authorization, + @PathVariable Long roomId, + @PathVariable Long postId + ) { + Long userId = tokenProviderService.getUserIdFromToken(authorization); + roomInfoPostCommandService.addBookmark(postId, userId, roomId); + return BaseResponse.onSuccess( "북마크가 성공적으로 업데이트 되었습니다."); + } + + @DeleteMapping("/info/{roomId}/{postId}/bookmark-remove") + @Operation(summary = "정보나눔 게시글 북마크 제거 API") + public BaseResponse removeBookmark( + @RequestHeader("Authorization") String authorization, + @PathVariable Long roomId, + @PathVariable Long postId + ) { + Long userId = tokenProviderService.getUserIdFromToken(authorization); + roomInfoPostCommandService.removeBookmark(postId, userId, roomId); + return BaseResponse.onSuccess( "북마크가 성공적으로 삭제되었습니다."); + } } diff --git a/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomPostController.java b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomPostController.java index 72c2626a..36bc8c33 100644 --- a/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomPostController.java +++ b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomPostController.java @@ -114,4 +114,29 @@ public BaseResponse postUnlike( roomPostCommandService.removeLike(postId, userId, roomId); return BaseResponse.onSuccess("UNLIKE"); } + + @PostMapping("/post/{roomId}/{postId}/bookmark-add") + @Operation(summary = "게시글 북마크 추가 API") + public BaseResponse addBookmark( + @RequestHeader("Authorization") String authorization, + @PathVariable Long roomId, + @PathVariable Long postId + ) { + Long userId = tokenProviderService.getUserIdFromToken(authorization); + roomPostCommandService.addBookmark(postId, userId, roomId); + return BaseResponse.onSuccess( "북마크가 성공적으로 업데이트 되었습니다."); + } + + @DeleteMapping("/post/{roomId}/{postId}/bookmark-remove") + @Operation(summary = "게시글 북마크 제거 API") + public BaseResponse removeBookmark( + @RequestHeader("Authorization") String authorization, + @PathVariable Long roomId, + @PathVariable Long postId + ) { + Long userId = tokenProviderService.getUserIdFromToken(authorization); + roomPostCommandService.removeBookmark(postId, userId, roomId); + return BaseResponse.onSuccess( "북마크가 성공적으로 삭제되었습니다."); + } + } From 814cbd57a34abb656b85465b51a968f9784f86a2 Mon Sep 17 00:00:00 2001 From: mmingoo Date: Sun, 18 Aug 2024 00:24:32 +0900 Subject: [PATCH 15/24] =?UTF-8?q?=F0=9F=90=9B=20=EB=B2=84=EA=B7=B8=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/gaji/service/domain/alram/Alarm.java | 2 +- .../domain/common/annotation/CheckPage.java | 2 +- .../SelectCategoryQueryDslRepositoryImpl.java | 2 +- .../repository/SelectCategoryRepository.java | 1 - .../SelectHashtagQueryDslRepositoryImpl.java | 2 +- .../common/service/CategoryServiceImpl.java | 2 +- .../message/converter/MessageConverter.java | 1 - .../domain/message/entity/MessageBody.java | 1 - .../service/MessageCommandServiceImpl.java | 2 +- .../web/controller/MessageRestController.java | 2 +- .../service/domain/myRepeat/MyRepeat.java | 1 - .../domain/myRepeat/RepeatException.java | 1 - .../domain/post/code/PostErrorStatus.java | 2 +- .../repository/PostQueryDslRepository.java | 2 +- .../PostQueryDslRepositoryImpl.java | 3 +-- .../post/service/CommentServiceImpl.java | 2 -- .../post/service/PostBookMarkServiceImpl.java | 1 - .../post/service/PostCommandServiceImpl.java | 5 +---- .../domain/post/service/PostLikesService.java | 1 - .../post/service/PostLikesServiceImpl.java | 1 - .../domain/post/service/PostQueryService.java | 2 +- .../post/service/PostQueryServiceImpl.java | 5 +---- .../validation/PostTypeExistValidator.java | 2 -- .../web/controller/PostRestController.java | 2 +- .../domain/post/web/dto/PostRequestDTO.java | 2 +- .../recruit/converter/RecruitConverter.java | 4 +--- .../domain/recruit/entity/StudyComment.java | 2 +- .../repository/RecruitCustomRepository.java | 5 ----- .../RecruitCustomRepositoryImpl.java | 2 +- .../service/RecruitCommandService.java | 1 - .../service/RecruitCommandServiceImpl.java | 2 +- .../service/RecruitQueryServiceImpl.java | 7 ++++--- .../service/StudyCommentQueryService.java | 4 ---- .../recruit/web/dto/RecruitResponseDTO.java | 5 ++++- .../gaji/service/domain/room/entity/Room.java | 2 +- .../repository/RoomCustomRepositoryImpl.java | 1 - .../WeeklyUserProgressRepository.java | 1 - .../room/service/RoomCommandServiceImpl.java | 10 +++++----- .../domain/room/service/RoomQueryService.java | 3 --- .../room/service/RoomQueryServiceImpl.java | 6 ++---- .../web/controller/RoomMainController.java | 3 --- .../converter/RoomPostConverter.java | 3 +-- .../entity/RoomInfo/InfoPostComment.java | 10 +++++----- .../entity/RoomInfo/RoomInfoPost.java | 9 ++++++--- .../entity/RoomInfo/RoomInfoPostBookmark.java | 1 - .../entity/RoomInfo/RoomInfoPostLikes.java | 1 - .../entity/RoomPost/PostComment.java | 1 - .../roomBoard/entity/RoomPost/RoomPost.java | 3 --- .../entity/RoomPost/RoomPostBookmark.java | 2 -- .../entity/RoomPost/RoomPostLikes.java | 1 - .../entity/RoomPost/RoomPostReport.java | 2 +- .../RoomPost/RoomPostLikesRepository.java | 2 -- .../RoomPost/RoomPostRepository.java | 3 --- .../RoomInfoPostCommandServiceImpl.java | 4 ++-- .../RoomPost/RoomPostCommandService.java | 2 -- .../RoomTroublePostCommandServiceImpl.java | 4 ++-- .../web/controller/RoomPostController.java | 2 -- .../studyMate/entity/StudyApplicant.java | 2 +- .../domain/studyMate/entity/StudyMate.java | 4 ++-- .../studyMate/entity/UserAssignment.java | 3 --- .../studyMate/entity/WeeklyUserProgress.java | 1 - .../service/StudyMateQueryServiceImpl.java | 2 +- .../domain/studyMate/web/dto/ResponseDto.java | 5 ----- .../domain/user/code/UserErrorStatus.java | 2 +- .../gaji/service/domain/user/entity/User.java | 20 ++++++++++++------- .../user/validation/UserExistValidator.java | 1 - .../domain/user/web/dto/UserRequestDTO.java | 1 - 67 files changed, 70 insertions(+), 128 deletions(-) diff --git a/src/main/java/gaji/service/domain/alram/Alarm.java b/src/main/java/gaji/service/domain/alram/Alarm.java index 9f863b53..bdf2d57c 100644 --- a/src/main/java/gaji/service/domain/alram/Alarm.java +++ b/src/main/java/gaji/service/domain/alram/Alarm.java @@ -1,7 +1,7 @@ package gaji.service.domain.alram; -import gaji.service.domain.user.entity.User; import gaji.service.domain.enums.IsConfirmed; +import gaji.service.domain.user.entity.User; import jakarta.persistence.*; import lombok.AccessLevel; import lombok.Getter; diff --git a/src/main/java/gaji/service/domain/common/annotation/CheckPage.java b/src/main/java/gaji/service/domain/common/annotation/CheckPage.java index da951170..0e18c3e4 100644 --- a/src/main/java/gaji/service/domain/common/annotation/CheckPage.java +++ b/src/main/java/gaji/service/domain/common/annotation/CheckPage.java @@ -1,8 +1,8 @@ package gaji.service.domain.common.annotation; import gaji.service.domain.common.validation.PageNumberValidator; -import jakarta.validation.Payload; import jakarta.validation.Constraint; +import jakarta.validation.Payload; import java.lang.annotation.*; diff --git a/src/main/java/gaji/service/domain/common/repository/SelectCategoryQueryDslRepositoryImpl.java b/src/main/java/gaji/service/domain/common/repository/SelectCategoryQueryDslRepositoryImpl.java index 05545ea5..40a502f2 100644 --- a/src/main/java/gaji/service/domain/common/repository/SelectCategoryQueryDslRepositoryImpl.java +++ b/src/main/java/gaji/service/domain/common/repository/SelectCategoryQueryDslRepositoryImpl.java @@ -10,8 +10,8 @@ import java.util.List; -import static gaji.service.domain.common.entity.QSelectCategory.selectCategory; import static gaji.service.domain.common.entity.QCategory.category1; +import static gaji.service.domain.common.entity.QSelectCategory.selectCategory; @Repository diff --git a/src/main/java/gaji/service/domain/common/repository/SelectCategoryRepository.java b/src/main/java/gaji/service/domain/common/repository/SelectCategoryRepository.java index 94590829..ad2164cc 100644 --- a/src/main/java/gaji/service/domain/common/repository/SelectCategoryRepository.java +++ b/src/main/java/gaji/service/domain/common/repository/SelectCategoryRepository.java @@ -1,7 +1,6 @@ package gaji.service.domain.common.repository; import gaji.service.domain.common.entity.SelectCategory; -import gaji.service.domain.common.repository.SelectCategoryQueryDslRepository; import gaji.service.domain.enums.PostTypeEnum; import org.springframework.data.jpa.repository.JpaRepository; diff --git a/src/main/java/gaji/service/domain/common/repository/SelectHashtagQueryDslRepositoryImpl.java b/src/main/java/gaji/service/domain/common/repository/SelectHashtagQueryDslRepositoryImpl.java index 0f2ff759..71da7d80 100644 --- a/src/main/java/gaji/service/domain/common/repository/SelectHashtagQueryDslRepositoryImpl.java +++ b/src/main/java/gaji/service/domain/common/repository/SelectHashtagQueryDslRepositoryImpl.java @@ -8,8 +8,8 @@ import java.util.List; -import static gaji.service.domain.common.entity.QSelectHashtag.selectHashtag; import static gaji.service.domain.common.entity.QHashtag.hashtag; +import static gaji.service.domain.common.entity.QSelectHashtag.selectHashtag; @Repository diff --git a/src/main/java/gaji/service/domain/common/service/CategoryServiceImpl.java b/src/main/java/gaji/service/domain/common/service/CategoryServiceImpl.java index d2eb3ee3..d434057d 100644 --- a/src/main/java/gaji/service/domain/common/service/CategoryServiceImpl.java +++ b/src/main/java/gaji/service/domain/common/service/CategoryServiceImpl.java @@ -4,10 +4,10 @@ import gaji.service.domain.common.entity.Category; import gaji.service.domain.common.entity.SelectCategory; import gaji.service.domain.common.repository.CategoryRepository; +import gaji.service.domain.common.repository.SelectCategoryRepository; import gaji.service.domain.common.web.dto.CategoryResponseDTO; import gaji.service.domain.enums.CategoryEnum; import gaji.service.domain.enums.PostTypeEnum; -import gaji.service.domain.common.repository.SelectCategoryRepository; import gaji.service.global.exception.RestApiException; import gaji.service.global.exception.code.status.GlobalErrorStatus; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/gaji/service/domain/message/converter/MessageConverter.java b/src/main/java/gaji/service/domain/message/converter/MessageConverter.java index e18d3b60..8f1ac84b 100644 --- a/src/main/java/gaji/service/domain/message/converter/MessageConverter.java +++ b/src/main/java/gaji/service/domain/message/converter/MessageConverter.java @@ -2,7 +2,6 @@ import gaji.service.domain.message.entity.Message; import gaji.service.domain.message.enums.MessageTypeEnum; -import gaji.service.domain.message.web.dto.MessageRequestDTO; import gaji.service.domain.message.web.dto.MessageResponseDTO; import gaji.service.domain.user.entity.User; diff --git a/src/main/java/gaji/service/domain/message/entity/MessageBody.java b/src/main/java/gaji/service/domain/message/entity/MessageBody.java index 867844dd..69d4844b 100644 --- a/src/main/java/gaji/service/domain/message/entity/MessageBody.java +++ b/src/main/java/gaji/service/domain/message/entity/MessageBody.java @@ -1,6 +1,5 @@ package gaji.service.domain.message.entity; -import gaji.service.domain.user.entity.User; import jakarta.persistence.*; import lombok.AccessLevel; import lombok.Builder; diff --git a/src/main/java/gaji/service/domain/message/service/MessageCommandServiceImpl.java b/src/main/java/gaji/service/domain/message/service/MessageCommandServiceImpl.java index 9d331f66..0e31f1bc 100644 --- a/src/main/java/gaji/service/domain/message/service/MessageCommandServiceImpl.java +++ b/src/main/java/gaji/service/domain/message/service/MessageCommandServiceImpl.java @@ -1,8 +1,8 @@ package gaji.service.domain.message.service; import gaji.service.domain.message.converter.MessageBodyConverter; -import gaji.service.domain.message.entity.Message; import gaji.service.domain.message.converter.MessageConverter; +import gaji.service.domain.message.entity.Message; import gaji.service.domain.message.entity.MessageBody; import gaji.service.domain.message.repository.MessageBodyRepository; import gaji.service.domain.message.repository.MessageRepository; diff --git a/src/main/java/gaji/service/domain/message/web/controller/MessageRestController.java b/src/main/java/gaji/service/domain/message/web/controller/MessageRestController.java index bd49ffea..f35c17ff 100644 --- a/src/main/java/gaji/service/domain/message/web/controller/MessageRestController.java +++ b/src/main/java/gaji/service/domain/message/web/controller/MessageRestController.java @@ -1,7 +1,7 @@ package gaji.service.domain.message.web.controller; -import gaji.service.domain.message.entity.Message; import gaji.service.domain.message.converter.MessageConverter; +import gaji.service.domain.message.entity.Message; import gaji.service.domain.message.service.MessageCommandService; import gaji.service.domain.message.service.MessageQueryService; import gaji.service.domain.message.web.dto.MessageRequestDTO; diff --git a/src/main/java/gaji/service/domain/myRepeat/MyRepeat.java b/src/main/java/gaji/service/domain/myRepeat/MyRepeat.java index 6852f794..2dd04fd0 100644 --- a/src/main/java/gaji/service/domain/myRepeat/MyRepeat.java +++ b/src/main/java/gaji/service/domain/myRepeat/MyRepeat.java @@ -1,6 +1,5 @@ package gaji.service.domain.myRepeat; -import gaji.service.domain.room.entity.RoomEvent; import gaji.service.domain.enums.Frequency; import jakarta.persistence.*; import lombok.AccessLevel; diff --git a/src/main/java/gaji/service/domain/myRepeat/RepeatException.java b/src/main/java/gaji/service/domain/myRepeat/RepeatException.java index 78bdf322..bea14d81 100644 --- a/src/main/java/gaji/service/domain/myRepeat/RepeatException.java +++ b/src/main/java/gaji/service/domain/myRepeat/RepeatException.java @@ -1,6 +1,5 @@ package gaji.service.domain.myRepeat; -import gaji.service.domain.room.entity.RoomEvent; import jakarta.persistence.*; import lombok.AccessLevel; import lombok.Getter; diff --git a/src/main/java/gaji/service/domain/post/code/PostErrorStatus.java b/src/main/java/gaji/service/domain/post/code/PostErrorStatus.java index 65da7077..751169c3 100644 --- a/src/main/java/gaji/service/domain/post/code/PostErrorStatus.java +++ b/src/main/java/gaji/service/domain/post/code/PostErrorStatus.java @@ -27,7 +27,7 @@ public enum PostErrorStatus implements BaseErrorCodeInterface { @Override public BaseCodeDto getErrorCode() { - return gaji.service.global.exception.code.BaseCodeDto.builder() + return BaseCodeDto.builder() .httpStatus(httpStatus) .isSuccess(isSuccess) .code(code) diff --git a/src/main/java/gaji/service/domain/post/repository/PostQueryDslRepository.java b/src/main/java/gaji/service/domain/post/repository/PostQueryDslRepository.java index dc2ebda5..dccaae74 100644 --- a/src/main/java/gaji/service/domain/post/repository/PostQueryDslRepository.java +++ b/src/main/java/gaji/service/domain/post/repository/PostQueryDslRepository.java @@ -1,9 +1,9 @@ package gaji.service.domain.post.repository; import com.querydsl.core.Tuple; -import gaji.service.domain.enums.SortType; import gaji.service.domain.enums.PostStatusEnum; import gaji.service.domain.enums.PostTypeEnum; +import gaji.service.domain.enums.SortType; import gaji.service.domain.post.entity.Post; import gaji.service.domain.user.entity.User; import org.springframework.data.domain.Pageable; diff --git a/src/main/java/gaji/service/domain/post/repository/PostQueryDslRepositoryImpl.java b/src/main/java/gaji/service/domain/post/repository/PostQueryDslRepositoryImpl.java index 3e833679..3dc03004 100644 --- a/src/main/java/gaji/service/domain/post/repository/PostQueryDslRepositoryImpl.java +++ b/src/main/java/gaji/service/domain/post/repository/PostQueryDslRepositoryImpl.java @@ -4,11 +4,10 @@ import com.querydsl.core.types.OrderSpecifier; import com.querydsl.core.types.dsl.BooleanExpression; import com.querydsl.jpa.impl.JPAQueryFactory; -import gaji.service.domain.common.entity.Category; import gaji.service.domain.common.service.CategoryService; -import gaji.service.domain.enums.SortType; import gaji.service.domain.enums.PostStatusEnum; import gaji.service.domain.enums.PostTypeEnum; +import gaji.service.domain.enums.SortType; import gaji.service.domain.post.entity.Post; import gaji.service.domain.user.entity.User; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/gaji/service/domain/post/service/CommentServiceImpl.java b/src/main/java/gaji/service/domain/post/service/CommentServiceImpl.java index 3bf9f562..211d3913 100644 --- a/src/main/java/gaji/service/domain/post/service/CommentServiceImpl.java +++ b/src/main/java/gaji/service/domain/post/service/CommentServiceImpl.java @@ -11,8 +11,6 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import java.util.List; - @Service @RequiredArgsConstructor @Transactional(readOnly = true) diff --git a/src/main/java/gaji/service/domain/post/service/PostBookMarkServiceImpl.java b/src/main/java/gaji/service/domain/post/service/PostBookMarkServiceImpl.java index d8678fc5..b153ce14 100644 --- a/src/main/java/gaji/service/domain/post/service/PostBookMarkServiceImpl.java +++ b/src/main/java/gaji/service/domain/post/service/PostBookMarkServiceImpl.java @@ -2,7 +2,6 @@ import gaji.service.domain.post.entity.Post; import gaji.service.domain.post.repository.PostBookmarkRepository; -import gaji.service.domain.user.entity.User; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; diff --git a/src/main/java/gaji/service/domain/post/service/PostCommandServiceImpl.java b/src/main/java/gaji/service/domain/post/service/PostCommandServiceImpl.java index d0b71b88..301ff01e 100644 --- a/src/main/java/gaji/service/domain/post/service/PostCommandServiceImpl.java +++ b/src/main/java/gaji/service/domain/post/service/PostCommandServiceImpl.java @@ -15,14 +15,11 @@ import gaji.service.domain.post.entity.PostBookmark; import gaji.service.domain.post.entity.PostLikes; import gaji.service.domain.post.repository.PostBookmarkRepository; -import gaji.service.domain.post.repository.PostLikesRepository; import gaji.service.domain.post.repository.PostJpaRepository; +import gaji.service.domain.post.repository.PostLikesRepository; import gaji.service.domain.post.web.dto.PostRequestDTO; -import gaji.service.domain.user.code.UserErrorStatus; import gaji.service.domain.user.entity.User; -import gaji.service.domain.user.repository.UserRepository; import gaji.service.domain.user.service.UserQueryService; -import gaji.service.global.exception.RestApiException; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; diff --git a/src/main/java/gaji/service/domain/post/service/PostLikesService.java b/src/main/java/gaji/service/domain/post/service/PostLikesService.java index e6c41f34..dd47cc07 100644 --- a/src/main/java/gaji/service/domain/post/service/PostLikesService.java +++ b/src/main/java/gaji/service/domain/post/service/PostLikesService.java @@ -1,7 +1,6 @@ package gaji.service.domain.post.service; import gaji.service.domain.post.entity.Post; -import gaji.service.domain.user.entity.User; public interface PostLikesService { boolean existsByUserAndPost(Long userId, Post post); diff --git a/src/main/java/gaji/service/domain/post/service/PostLikesServiceImpl.java b/src/main/java/gaji/service/domain/post/service/PostLikesServiceImpl.java index 4f8355f6..4541b5da 100644 --- a/src/main/java/gaji/service/domain/post/service/PostLikesServiceImpl.java +++ b/src/main/java/gaji/service/domain/post/service/PostLikesServiceImpl.java @@ -2,7 +2,6 @@ import gaji.service.domain.post.entity.Post; import gaji.service.domain.post.repository.PostLikesRepository; -import gaji.service.domain.user.entity.User; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; diff --git a/src/main/java/gaji/service/domain/post/service/PostQueryService.java b/src/main/java/gaji/service/domain/post/service/PostQueryService.java index 53473eb3..9f46a553 100644 --- a/src/main/java/gaji/service/domain/post/service/PostQueryService.java +++ b/src/main/java/gaji/service/domain/post/service/PostQueryService.java @@ -1,8 +1,8 @@ package gaji.service.domain.post.service; -import gaji.service.domain.enums.SortType; import gaji.service.domain.enums.PostStatusEnum; import gaji.service.domain.enums.PostTypeEnum; +import gaji.service.domain.enums.SortType; import gaji.service.domain.post.entity.Post; import org.springframework.data.domain.Slice; diff --git a/src/main/java/gaji/service/domain/post/service/PostQueryServiceImpl.java b/src/main/java/gaji/service/domain/post/service/PostQueryServiceImpl.java index 2f2b7e13..0396c6a2 100644 --- a/src/main/java/gaji/service/domain/post/service/PostQueryServiceImpl.java +++ b/src/main/java/gaji/service/domain/post/service/PostQueryServiceImpl.java @@ -1,10 +1,9 @@ package gaji.service.domain.post.service; -import gaji.service.domain.common.entity.Category; import gaji.service.domain.common.service.CategoryService; -import gaji.service.domain.enums.SortType; import gaji.service.domain.enums.PostStatusEnum; import gaji.service.domain.enums.PostTypeEnum; +import gaji.service.domain.enums.SortType; import gaji.service.domain.post.code.PostErrorStatus; import gaji.service.domain.post.entity.Post; import gaji.service.domain.post.repository.PostJpaRepository; @@ -15,8 +14,6 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import java.util.List; - @Service @RequiredArgsConstructor @Transactional(readOnly = true) diff --git a/src/main/java/gaji/service/domain/post/validation/PostTypeExistValidator.java b/src/main/java/gaji/service/domain/post/validation/PostTypeExistValidator.java index 9100341c..3392717f 100644 --- a/src/main/java/gaji/service/domain/post/validation/PostTypeExistValidator.java +++ b/src/main/java/gaji/service/domain/post/validation/PostTypeExistValidator.java @@ -7,8 +7,6 @@ import jakarta.validation.ConstraintValidatorContext; import org.springframework.stereotype.Component; -import java.util.Arrays; - @Component public class PostTypeExistValidator implements ConstraintValidator { diff --git a/src/main/java/gaji/service/domain/post/web/controller/PostRestController.java b/src/main/java/gaji/service/domain/post/web/controller/PostRestController.java index 5e97379a..2dc7b563 100644 --- a/src/main/java/gaji/service/domain/post/web/controller/PostRestController.java +++ b/src/main/java/gaji/service/domain/post/web/controller/PostRestController.java @@ -1,8 +1,8 @@ package gaji.service.domain.post.web.controller; -import gaji.service.domain.enums.SortType; import gaji.service.domain.enums.PostStatusEnum; import gaji.service.domain.enums.PostTypeEnum; +import gaji.service.domain.enums.SortType; import gaji.service.domain.post.converter.CommentConverter; import gaji.service.domain.post.converter.PostConverter; import gaji.service.domain.post.entity.Comment; diff --git a/src/main/java/gaji/service/domain/post/web/dto/PostRequestDTO.java b/src/main/java/gaji/service/domain/post/web/dto/PostRequestDTO.java index 75a267ac..1aab2bbf 100644 --- a/src/main/java/gaji/service/domain/post/web/dto/PostRequestDTO.java +++ b/src/main/java/gaji/service/domain/post/web/dto/PostRequestDTO.java @@ -1,7 +1,7 @@ package gaji.service.domain.post.web.dto; -import gaji.service.domain.common.annotation.ExistsCategory; import gaji.service.domain.common.annotation.CheckHashtagListElement; +import gaji.service.domain.common.annotation.ExistsCategory; import gaji.service.domain.enums.PostTypeEnum; import gaji.service.domain.post.annotation.ExistPostType; import io.swagger.v3.oas.annotations.media.Schema; diff --git a/src/main/java/gaji/service/domain/recruit/converter/RecruitConverter.java b/src/main/java/gaji/service/domain/recruit/converter/RecruitConverter.java index 2fc7aad6..45710aa8 100644 --- a/src/main/java/gaji/service/domain/recruit/converter/RecruitConverter.java +++ b/src/main/java/gaji/service/domain/recruit/converter/RecruitConverter.java @@ -3,7 +3,6 @@ import gaji.service.domain.common.entity.Category; import gaji.service.domain.common.entity.SelectCategory; import gaji.service.domain.enums.CategoryEnum; -import gaji.service.domain.user.entity.User; import gaji.service.domain.enums.Role; import gaji.service.domain.recruit.entity.StudyComment; import gaji.service.domain.recruit.web.dto.RecruitRequestDTO; @@ -11,11 +10,10 @@ import gaji.service.domain.room.entity.Material; import gaji.service.domain.room.entity.Room; import gaji.service.domain.studyMate.entity.StudyMate; +import gaji.service.domain.user.entity.User; import gaji.service.global.converter.DateConverter; -import java.time.Duration; import java.time.LocalDate; -import java.time.LocalDateTime; import java.time.temporal.ChronoUnit; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/gaji/service/domain/recruit/entity/StudyComment.java b/src/main/java/gaji/service/domain/recruit/entity/StudyComment.java index f6c2be8a..f5aa5bf9 100644 --- a/src/main/java/gaji/service/domain/recruit/entity/StudyComment.java +++ b/src/main/java/gaji/service/domain/recruit/entity/StudyComment.java @@ -1,9 +1,9 @@ package gaji.service.domain.recruit.entity; -import gaji.service.domain.user.entity.User; import gaji.service.domain.common.entity.BaseEntity; import gaji.service.domain.enums.CommentStatus; import gaji.service.domain.room.entity.Room; +import gaji.service.domain.user.entity.User; import jakarta.persistence.*; import lombok.AccessLevel; import lombok.Getter; diff --git a/src/main/java/gaji/service/domain/recruit/repository/RecruitCustomRepository.java b/src/main/java/gaji/service/domain/recruit/repository/RecruitCustomRepository.java index 9c36c4d0..4ea94d33 100644 --- a/src/main/java/gaji/service/domain/recruit/repository/RecruitCustomRepository.java +++ b/src/main/java/gaji/service/domain/recruit/repository/RecruitCustomRepository.java @@ -4,13 +4,8 @@ import gaji.service.domain.enums.PreviewFilter; import gaji.service.domain.enums.SortType; import gaji.service.domain.recruit.web.dto.RecruitResponseDTO; -import gaji.service.domain.room.entity.Room; -import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; -import java.time.LocalDateTime; -import java.util.List; - public interface RecruitCustomRepository { RecruitResponseDTO.PreviewListDTO findByCategoryOrderBySortType( diff --git a/src/main/java/gaji/service/domain/recruit/repository/RecruitCustomRepositoryImpl.java b/src/main/java/gaji/service/domain/recruit/repository/RecruitCustomRepositoryImpl.java index 4d0bc2ea..d57331fd 100644 --- a/src/main/java/gaji/service/domain/recruit/repository/RecruitCustomRepositoryImpl.java +++ b/src/main/java/gaji/service/domain/recruit/repository/RecruitCustomRepositoryImpl.java @@ -15,8 +15,8 @@ import java.util.List; -import static gaji.service.domain.room.entity.QRoom.room; import static gaji.service.domain.common.entity.QSelectCategory.selectCategory; +import static gaji.service.domain.room.entity.QRoom.room; @RequiredArgsConstructor @Repository diff --git a/src/main/java/gaji/service/domain/recruit/service/RecruitCommandService.java b/src/main/java/gaji/service/domain/recruit/service/RecruitCommandService.java index 8aed2575..1f03a1a6 100644 --- a/src/main/java/gaji/service/domain/recruit/service/RecruitCommandService.java +++ b/src/main/java/gaji/service/domain/recruit/service/RecruitCommandService.java @@ -2,7 +2,6 @@ import gaji.service.domain.recruit.web.dto.RecruitRequestDTO; import gaji.service.domain.recruit.web.dto.RecruitResponseDTO; -import gaji.service.domain.room.entity.Room; public interface RecruitCommandService { diff --git a/src/main/java/gaji/service/domain/recruit/service/RecruitCommandServiceImpl.java b/src/main/java/gaji/service/domain/recruit/service/RecruitCommandServiceImpl.java index 112ce437..ba0c176d 100644 --- a/src/main/java/gaji/service/domain/recruit/service/RecruitCommandServiceImpl.java +++ b/src/main/java/gaji/service/domain/recruit/service/RecruitCommandServiceImpl.java @@ -3,10 +3,10 @@ import gaji.service.domain.common.entity.Category; import gaji.service.domain.common.entity.SelectCategory; import gaji.service.domain.common.repository.CategoryRepository; +import gaji.service.domain.common.repository.SelectCategoryRepository; import gaji.service.domain.enums.CategoryEnum; import gaji.service.domain.enums.PostTypeEnum; import gaji.service.domain.recruit.converter.RecruitConverter; -import gaji.service.domain.common.repository.SelectCategoryRepository; import gaji.service.domain.recruit.web.dto.RecruitRequestDTO; import gaji.service.domain.recruit.web.dto.RecruitResponseDTO; import gaji.service.domain.room.entity.Material; diff --git a/src/main/java/gaji/service/domain/recruit/service/RecruitQueryServiceImpl.java b/src/main/java/gaji/service/domain/recruit/service/RecruitQueryServiceImpl.java index a2550afe..1ce333af 100644 --- a/src/main/java/gaji/service/domain/recruit/service/RecruitQueryServiceImpl.java +++ b/src/main/java/gaji/service/domain/recruit/service/RecruitQueryServiceImpl.java @@ -1,24 +1,25 @@ package gaji.service.domain.recruit.service; import gaji.service.domain.common.entity.SelectCategory; +import gaji.service.domain.common.repository.SelectCategoryRepository; import gaji.service.domain.enums.CategoryEnum; import gaji.service.domain.enums.PostTypeEnum; import gaji.service.domain.enums.PreviewFilter; import gaji.service.domain.enums.SortType; import gaji.service.domain.recruit.converter.RecruitConverter; import gaji.service.domain.recruit.repository.RecruitRepository; -import gaji.service.domain.common.repository.SelectCategoryRepository; +import gaji.service.domain.recruit.web.dto.RecruitResponseDTO; +import gaji.service.domain.room.entity.Room; import gaji.service.domain.room.service.RoomCommandService; import gaji.service.domain.room.service.RoomQueryService; import gaji.service.domain.user.entity.User; -import gaji.service.domain.recruit.web.dto.RecruitResponseDTO; -import gaji.service.domain.room.entity.Room; import gaji.service.domain.user.service.UserQueryService; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; + import java.util.ArrayList; import java.util.Arrays; import java.util.List; diff --git a/src/main/java/gaji/service/domain/recruit/service/StudyCommentQueryService.java b/src/main/java/gaji/service/domain/recruit/service/StudyCommentQueryService.java index 345ada0b..2855576e 100644 --- a/src/main/java/gaji/service/domain/recruit/service/StudyCommentQueryService.java +++ b/src/main/java/gaji/service/domain/recruit/service/StudyCommentQueryService.java @@ -1,10 +1,6 @@ package gaji.service.domain.recruit.service; -import gaji.service.domain.recruit.entity.StudyComment; import gaji.service.domain.recruit.web.dto.RecruitResponseDTO; -import gaji.service.domain.room.entity.Room; - -import java.util.List; public interface StudyCommentQueryService { diff --git a/src/main/java/gaji/service/domain/recruit/web/dto/RecruitResponseDTO.java b/src/main/java/gaji/service/domain/recruit/web/dto/RecruitResponseDTO.java index c050ed71..a7c09377 100644 --- a/src/main/java/gaji/service/domain/recruit/web/dto/RecruitResponseDTO.java +++ b/src/main/java/gaji/service/domain/recruit/web/dto/RecruitResponseDTO.java @@ -3,7 +3,10 @@ import gaji.service.domain.enums.CategoryEnum; import gaji.service.domain.enums.RecruitPostTypeEnum; import gaji.service.domain.enums.UserActive; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; import java.time.LocalDate; import java.time.LocalDateTime; diff --git a/src/main/java/gaji/service/domain/room/entity/Room.java b/src/main/java/gaji/service/domain/room/entity/Room.java index 770a3186..c8c1b9ca 100644 --- a/src/main/java/gaji/service/domain/room/entity/Room.java +++ b/src/main/java/gaji/service/domain/room/entity/Room.java @@ -2,7 +2,6 @@ import gaji.service.domain.common.entity.BaseEntity; import gaji.service.domain.curriculum.Curriculum; -import gaji.service.domain.user.entity.User; import gaji.service.domain.enums.RecruitPostTypeEnum; import gaji.service.domain.recruit.entity.RecruitPostBookmark; import gaji.service.domain.recruit.entity.RecruitPostLikes; @@ -10,6 +9,7 @@ import gaji.service.domain.studyMate.entity.Chat; import gaji.service.domain.studyMate.entity.StudyApplicant; import gaji.service.domain.studyMate.entity.StudyMate; +import gaji.service.domain.user.entity.User; import jakarta.persistence.*; import lombok.AccessLevel; import lombok.Builder; diff --git a/src/main/java/gaji/service/domain/room/repository/RoomCustomRepositoryImpl.java b/src/main/java/gaji/service/domain/room/repository/RoomCustomRepositoryImpl.java index 379eecac..34bca482 100644 --- a/src/main/java/gaji/service/domain/room/repository/RoomCustomRepositoryImpl.java +++ b/src/main/java/gaji/service/domain/room/repository/RoomCustomRepositoryImpl.java @@ -7,7 +7,6 @@ import gaji.service.domain.studyMate.entity.QStudyMate; import gaji.service.domain.user.entity.User; import lombok.AllArgsConstructor; - import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Slice; import org.springframework.data.domain.SliceImpl; diff --git a/src/main/java/gaji/service/domain/room/repository/WeeklyUserProgressRepository.java b/src/main/java/gaji/service/domain/room/repository/WeeklyUserProgressRepository.java index 8c9f8575..31d7cbf6 100644 --- a/src/main/java/gaji/service/domain/room/repository/WeeklyUserProgressRepository.java +++ b/src/main/java/gaji/service/domain/room/repository/WeeklyUserProgressRepository.java @@ -1,7 +1,6 @@ package gaji.service.domain.room.repository; import gaji.service.domain.room.entity.RoomEvent; -import gaji.service.domain.room.web.dto.RoomResponseDto; import gaji.service.domain.studyMate.entity.WeeklyUserProgress; import gaji.service.domain.user.entity.User; import org.springframework.data.jpa.repository.JpaRepository; diff --git a/src/main/java/gaji/service/domain/room/service/RoomCommandServiceImpl.java b/src/main/java/gaji/service/domain/room/service/RoomCommandServiceImpl.java index 67cf1a89..1c16ef68 100644 --- a/src/main/java/gaji/service/domain/room/service/RoomCommandServiceImpl.java +++ b/src/main/java/gaji/service/domain/room/service/RoomCommandServiceImpl.java @@ -1,22 +1,22 @@ package gaji.service.domain.room.service; -import gaji.service.domain.room.repository.*; -import gaji.service.domain.room.web.dto.RoomResponseDto; -import gaji.service.domain.studyMate.entity.WeeklyUserProgress; -import gaji.service.domain.user.entity.User; import gaji.service.domain.enums.Role; import gaji.service.domain.room.code.RoomErrorStatus; import gaji.service.domain.room.entity.NoticeConfirmation; import gaji.service.domain.room.entity.Room; import gaji.service.domain.room.entity.RoomEvent; import gaji.service.domain.room.entity.RoomNotice; +import gaji.service.domain.room.repository.*; import gaji.service.domain.room.web.dto.RoomRequestDto; +import gaji.service.domain.room.web.dto.RoomResponseDto; +import gaji.service.domain.studyMate.code.StudyMateErrorStatus; import gaji.service.domain.studyMate.entity.Assignment; import gaji.service.domain.studyMate.entity.StudyMate; import gaji.service.domain.studyMate.entity.UserAssignment; -import gaji.service.domain.studyMate.code.StudyMateErrorStatus; +import gaji.service.domain.studyMate.entity.WeeklyUserProgress; import gaji.service.domain.studyMate.repository.StudyMateRepository; import gaji.service.domain.studyMate.service.StudyMateQueryService; +import gaji.service.domain.user.entity.User; import gaji.service.domain.user.service.UserQueryServiceImpl; import gaji.service.global.exception.RestApiException; import jakarta.transaction.Transactional; diff --git a/src/main/java/gaji/service/domain/room/service/RoomQueryService.java b/src/main/java/gaji/service/domain/room/service/RoomQueryService.java index cf7ca7ba..b558b5d6 100644 --- a/src/main/java/gaji/service/domain/room/service/RoomQueryService.java +++ b/src/main/java/gaji/service/domain/room/service/RoomQueryService.java @@ -1,9 +1,6 @@ package gaji.service.domain.room.service; import gaji.service.domain.room.entity.Room; -import gaji.service.domain.room.web.dto.RoomResponseDto; - -import java.util.List; import gaji.service.domain.room.entity.RoomEvent; import gaji.service.domain.room.web.dto.RoomResponseDto; import org.springframework.transaction.annotation.Transactional; diff --git a/src/main/java/gaji/service/domain/room/service/RoomQueryServiceImpl.java b/src/main/java/gaji/service/domain/room/service/RoomQueryServiceImpl.java index 9e677074..9b8dcc2d 100644 --- a/src/main/java/gaji/service/domain/room/service/RoomQueryServiceImpl.java +++ b/src/main/java/gaji/service/domain/room/service/RoomQueryServiceImpl.java @@ -3,15 +3,13 @@ import gaji.service.domain.room.code.RoomErrorStatus; import gaji.service.domain.room.entity.Room; -import gaji.service.domain.room.repository.RoomQueryRepository; import gaji.service.domain.room.entity.RoomEvent; import gaji.service.domain.room.repository.RoomEventRepository; +import gaji.service.domain.room.repository.RoomQueryRepository; import gaji.service.domain.room.repository.RoomRepository; -import gaji.service.domain.room.web.dto.RoomResponseDto; import gaji.service.domain.room.repository.WeeklyUserProgressRepository; +import gaji.service.domain.room.web.dto.RoomResponseDto; import gaji.service.global.exception.RestApiException; -import jakarta.persistence.EntityManager; -import jakarta.persistence.PersistenceContext; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; diff --git a/src/main/java/gaji/service/domain/room/web/controller/RoomMainController.java b/src/main/java/gaji/service/domain/room/web/controller/RoomMainController.java index aafb6a68..5d5fac97 100644 --- a/src/main/java/gaji/service/domain/room/web/controller/RoomMainController.java +++ b/src/main/java/gaji/service/domain/room/web/controller/RoomMainController.java @@ -1,14 +1,11 @@ package gaji.service.domain.room.web.controller; -import gaji.service.domain.room.converter.RoomConverter; import gaji.service.domain.room.entity.RoomEvent; -import gaji.service.domain.room.entity.RoomNotice; import gaji.service.domain.room.service.RoomCommandService; import gaji.service.domain.room.service.RoomQueryService; import gaji.service.domain.room.web.dto.RoomRequestDto; import gaji.service.domain.room.web.dto.RoomResponseDto; import gaji.service.domain.studyMate.entity.Assignment; -import gaji.service.domain.studyMate.web.dto.ResponseDto; import gaji.service.global.base.BaseResponse; import gaji.service.jwt.service.TokenProviderService; import io.swagger.v3.oas.annotations.Operation; diff --git a/src/main/java/gaji/service/domain/roomBoard/converter/RoomPostConverter.java b/src/main/java/gaji/service/domain/roomBoard/converter/RoomPostConverter.java index ab45d618..c4ff872d 100644 --- a/src/main/java/gaji/service/domain/roomBoard/converter/RoomPostConverter.java +++ b/src/main/java/gaji/service/domain/roomBoard/converter/RoomPostConverter.java @@ -1,8 +1,8 @@ package gaji.service.domain.roomBoard.converter; +import gaji.service.domain.roomBoard.entity.RoomBoard; import gaji.service.domain.roomBoard.entity.RoomInfo.InfoPostComment; import gaji.service.domain.roomBoard.entity.RoomInfo.RoomInfoPost; -import gaji.service.domain.roomBoard.entity.RoomBoard; import gaji.service.domain.roomBoard.entity.RoomPost.PostComment; import gaji.service.domain.roomBoard.entity.RoomPost.RoomPost; import gaji.service.domain.roomBoard.entity.RoomTrouble.RoomTroublePost; @@ -10,7 +10,6 @@ import gaji.service.domain.roomBoard.web.dto.RoomPostRequestDto; import gaji.service.domain.roomBoard.web.dto.RoomPostResponseDto; import gaji.service.domain.studyMate.entity.StudyMate; -import gaji.service.domain.user.entity.User; import java.time.LocalDateTime; diff --git a/src/main/java/gaji/service/domain/roomBoard/entity/RoomInfo/InfoPostComment.java b/src/main/java/gaji/service/domain/roomBoard/entity/RoomInfo/InfoPostComment.java index 4980851b..a82e06c8 100644 --- a/src/main/java/gaji/service/domain/roomBoard/entity/RoomInfo/InfoPostComment.java +++ b/src/main/java/gaji/service/domain/roomBoard/entity/RoomInfo/InfoPostComment.java @@ -1,7 +1,5 @@ package gaji.service.domain.roomBoard.entity.RoomInfo; -import gaji.service.domain.roomBoard.entity.RoomPost.PostComment; -import gaji.service.domain.roomBoard.entity.RoomPost.RoomPost; import gaji.service.domain.user.entity.User; import jakarta.persistence.*; import lombok.*; @@ -23,9 +21,13 @@ public class InfoPostComment { @JoinColumn(name = "user_id") private User user; +// @ManyToOne(fetch = FetchType.LAZY) +// @JoinColumn(name = "post_id") +// private RoomInfoPost roomInfoPost; + @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "post_id") - private RoomInfoPost roomInoPost; + private RoomInfoPost roomInfoPost; private String body; @@ -36,8 +38,6 @@ public class InfoPostComment { @OneToMany(mappedBy = "parentComment", cascade = CascadeType.ALL, orphanRemoval = true) private List replies = new ArrayList<>(); - @OneToMany(mappedBy = "roomPost",cascade = CascadeType.ALL) - private final List infoPostList = new ArrayList<>() ; private boolean isReply; diff --git a/src/main/java/gaji/service/domain/roomBoard/entity/RoomInfo/RoomInfoPost.java b/src/main/java/gaji/service/domain/roomBoard/entity/RoomInfo/RoomInfoPost.java index ec8b4bae..4be1f8d2 100644 --- a/src/main/java/gaji/service/domain/roomBoard/entity/RoomInfo/RoomInfoPost.java +++ b/src/main/java/gaji/service/domain/roomBoard/entity/RoomInfo/RoomInfoPost.java @@ -1,9 +1,6 @@ package gaji.service.domain.roomBoard.entity.RoomInfo; import gaji.service.domain.roomBoard.entity.RoomBoard; -import gaji.service.domain.roomBoard.entity.RoomPost.RoomPostBookmark; -import gaji.service.domain.roomBoard.entity.RoomTrouble.RoomTroublePostBookmark; -import gaji.service.domain.roomBoard.entity.RoomTrouble.RoomTroublePostLike; import gaji.service.domain.studyMate.entity.StudyMate; import jakarta.persistence.*; import lombok.*; @@ -44,6 +41,12 @@ public class RoomInfoPost { @OneToMany(mappedBy = "roomInfoPost", cascade = CascadeType.ALL) private List roomInfoPostBookmarkList = new ArrayList<>(); + @OneToMany(mappedBy = "roomInfoPost", cascade = CascadeType.ALL) + private List infoPostCommentList = new ArrayList<>(); + +// @OneToMany(mappedBy = "roomInfoPost", cascade = CascadeType.ALL) +// private List infoPostCommentList = new ArrayList<>(); + @PrePersist public void prePersist() { diff --git a/src/main/java/gaji/service/domain/roomBoard/entity/RoomInfo/RoomInfoPostBookmark.java b/src/main/java/gaji/service/domain/roomBoard/entity/RoomInfo/RoomInfoPostBookmark.java index ffbf4b3c..5ec8152e 100644 --- a/src/main/java/gaji/service/domain/roomBoard/entity/RoomInfo/RoomInfoPostBookmark.java +++ b/src/main/java/gaji/service/domain/roomBoard/entity/RoomInfo/RoomInfoPostBookmark.java @@ -1,6 +1,5 @@ package gaji.service.domain.roomBoard.entity.RoomInfo; -import gaji.service.domain.roomBoard.entity.RoomTrouble.RoomTroublePost; import gaji.service.domain.studyMate.entity.StudyMate; import jakarta.persistence.*; import lombok.*; diff --git a/src/main/java/gaji/service/domain/roomBoard/entity/RoomInfo/RoomInfoPostLikes.java b/src/main/java/gaji/service/domain/roomBoard/entity/RoomInfo/RoomInfoPostLikes.java index 84f954fb..fac1b528 100644 --- a/src/main/java/gaji/service/domain/roomBoard/entity/RoomInfo/RoomInfoPostLikes.java +++ b/src/main/java/gaji/service/domain/roomBoard/entity/RoomInfo/RoomInfoPostLikes.java @@ -1,6 +1,5 @@ package gaji.service.domain.roomBoard.entity.RoomInfo; -import gaji.service.domain.roomBoard.entity.RoomPost.RoomPost; import gaji.service.domain.studyMate.entity.StudyMate; import jakarta.persistence.*; import lombok.*; diff --git a/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/PostComment.java b/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/PostComment.java index 0813fbb9..ac6c8d53 100644 --- a/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/PostComment.java +++ b/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/PostComment.java @@ -1,6 +1,5 @@ package gaji.service.domain.roomBoard.entity.RoomPost; -import gaji.service.domain.roomBoard.entity.RoomTrouble.RoomTroublePost; import gaji.service.domain.user.entity.User; import jakarta.persistence.*; import lombok.*; diff --git a/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPost.java b/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPost.java index 3a354ca9..6d672497 100644 --- a/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPost.java +++ b/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPost.java @@ -1,10 +1,7 @@ package gaji.service.domain.roomBoard.entity.RoomPost; import gaji.service.domain.roomBoard.entity.RoomBoard; -import gaji.service.domain.roomBoard.entity.RoomTrouble.RoomTroublePostBookmark; -import gaji.service.domain.roomBoard.entity.RoomTrouble.RoomTroublePostLike; import gaji.service.domain.studyMate.entity.StudyMate; -import gaji.service.domain.user.entity.User; import jakarta.persistence.*; import lombok.*; diff --git a/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPostBookmark.java b/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPostBookmark.java index 045d1591..18e1722a 100644 --- a/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPostBookmark.java +++ b/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPostBookmark.java @@ -1,8 +1,6 @@ package gaji.service.domain.roomBoard.entity.RoomPost; -import gaji.service.domain.roomBoard.entity.RoomTrouble.RoomTroublePost; import gaji.service.domain.studyMate.entity.StudyMate; -import gaji.service.domain.user.entity.User; import jakarta.persistence.*; import lombok.*; diff --git a/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPostLikes.java b/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPostLikes.java index 59c52a9b..55209dad 100644 --- a/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPostLikes.java +++ b/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPostLikes.java @@ -1,7 +1,6 @@ package gaji.service.domain.roomBoard.entity.RoomPost; import gaji.service.domain.studyMate.entity.StudyMate; -import gaji.service.domain.user.entity.User; import jakarta.persistence.*; import lombok.*; diff --git a/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPostReport.java b/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPostReport.java index 39ba829e..6e022184 100644 --- a/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPostReport.java +++ b/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPostReport.java @@ -1,7 +1,7 @@ package gaji.service.domain.roomBoard.entity.RoomPost; -import gaji.service.domain.user.entity.User; import gaji.service.domain.enums.ReportPostTypeEnum; +import gaji.service.domain.user.entity.User; import jakarta.persistence.*; import lombok.AccessLevel; import lombok.Getter; diff --git a/src/main/java/gaji/service/domain/roomBoard/repository/RoomPost/RoomPostLikesRepository.java b/src/main/java/gaji/service/domain/roomBoard/repository/RoomPost/RoomPostLikesRepository.java index 3d191053..1fd0f0be 100644 --- a/src/main/java/gaji/service/domain/roomBoard/repository/RoomPost/RoomPostLikesRepository.java +++ b/src/main/java/gaji/service/domain/roomBoard/repository/RoomPost/RoomPostLikesRepository.java @@ -1,9 +1,7 @@ package gaji.service.domain.roomBoard.repository.RoomPost; -import gaji.service.domain.roomBoard.entity.RoomInfo.RoomInfoPost; import gaji.service.domain.roomBoard.entity.RoomPost.RoomPost; import gaji.service.domain.roomBoard.entity.RoomPost.RoomPostLikes; -import gaji.service.domain.roomBoard.entity.RoomTrouble.RoomTroublePostLike; import gaji.service.domain.studyMate.entity.StudyMate; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; diff --git a/src/main/java/gaji/service/domain/roomBoard/repository/RoomPost/RoomPostRepository.java b/src/main/java/gaji/service/domain/roomBoard/repository/RoomPost/RoomPostRepository.java index e56bb072..63a91775 100644 --- a/src/main/java/gaji/service/domain/roomBoard/repository/RoomPost/RoomPostRepository.java +++ b/src/main/java/gaji/service/domain/roomBoard/repository/RoomPost/RoomPostRepository.java @@ -1,12 +1,9 @@ package gaji.service.domain.roomBoard.repository.RoomPost; import gaji.service.domain.roomBoard.entity.RoomPost.RoomPost; -import gaji.service.domain.studyMate.entity.StudyMate; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; -import java.util.Optional; - @Repository public interface RoomPostRepository extends JpaRepository { } diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandServiceImpl.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandServiceImpl.java index d81f6aef..76026611 100644 --- a/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandServiceImpl.java +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandServiceImpl.java @@ -5,9 +5,9 @@ import gaji.service.domain.room.service.RoomQueryService; import gaji.service.domain.roomBoard.code.RoomPostErrorStatus; import gaji.service.domain.roomBoard.converter.RoomPostConverter; +import gaji.service.domain.roomBoard.entity.RoomBoard; import gaji.service.domain.roomBoard.entity.RoomInfo.InfoPostComment; import gaji.service.domain.roomBoard.entity.RoomInfo.RoomInfoPost; -import gaji.service.domain.roomBoard.entity.RoomBoard; import gaji.service.domain.roomBoard.entity.RoomInfo.RoomInfoPostBookmark; import gaji.service.domain.roomBoard.entity.RoomInfo.RoomInfoPostLikes; import gaji.service.domain.roomBoard.repository.RoomBoardRepository; @@ -98,7 +98,7 @@ public RoomPostResponseDto.toWriteCommentDto writeCommentOnInfoPost(Long userId, InfoPostComment postComment = InfoPostComment.builder() .user(user) - .roomInoPost(roomPost) + .roomInfoPost(roomPost) .body(request.getBody()) .build(); infoPostCommentRepository.save(postComment); diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandService.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandService.java index 13daed4b..6f1282b8 100644 --- a/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandService.java +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandService.java @@ -1,7 +1,5 @@ package gaji.service.domain.roomBoard.service.RoomPost; -import gaji.service.domain.roomBoard.entity.RoomPost.PostComment; -import gaji.service.domain.roomBoard.entity.RoomPost.RoomPost; import gaji.service.domain.roomBoard.web.dto.RoomPostRequestDto; import gaji.service.domain.roomBoard.web.dto.RoomPostResponseDto; diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomTrouble/RoomTroublePostCommandServiceImpl.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomTrouble/RoomTroublePostCommandServiceImpl.java index 90335ada..5b3f74e1 100644 --- a/src/main/java/gaji/service/domain/roomBoard/service/RoomTrouble/RoomTroublePostCommandServiceImpl.java +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomTrouble/RoomTroublePostCommandServiceImpl.java @@ -5,12 +5,12 @@ import gaji.service.domain.room.service.RoomQueryService; import gaji.service.domain.roomBoard.code.RoomPostErrorStatus; import gaji.service.domain.roomBoard.converter.RoomPostConverter; +import gaji.service.domain.roomBoard.entity.RoomBoard; import gaji.service.domain.roomBoard.entity.RoomTrouble.RoomTroublePost; import gaji.service.domain.roomBoard.entity.RoomTrouble.RoomTroublePostBookmark; import gaji.service.domain.roomBoard.entity.RoomTrouble.RoomTroublePostLike; import gaji.service.domain.roomBoard.entity.RoomTrouble.TroublePostComment; -import gaji.service.domain.roomBoard.entity.RoomBoard; -import gaji.service.domain.roomBoard.repository.*; +import gaji.service.domain.roomBoard.repository.RoomBoardRepository; import gaji.service.domain.roomBoard.repository.RoomPost.RoomPostCommentRepository; import gaji.service.domain.roomBoard.repository.RoomPost.RoomPostRepository; import gaji.service.domain.roomBoard.repository.RoomTrouble.RoomTroublePostBookmarkRepository; diff --git a/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomPostController.java b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomPostController.java index 36bc8c33..df051867 100644 --- a/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomPostController.java +++ b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomPostController.java @@ -1,6 +1,5 @@ package gaji.service.domain.roomBoard.web.controller; -import gaji.service.domain.roomBoard.entity.RoomPost.RoomPost; import gaji.service.domain.roomBoard.service.RoomPost.RoomPostCommandService; import gaji.service.domain.roomBoard.web.dto.RoomPostRequestDto; import gaji.service.domain.roomBoard.web.dto.RoomPostResponseDto; @@ -9,7 +8,6 @@ import io.swagger.v3.oas.annotations.Operation; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; -import org.hibernate.validator.constraints.ParameterScriptAssert; import org.springframework.web.bind.annotation.*; @RestController diff --git a/src/main/java/gaji/service/domain/studyMate/entity/StudyApplicant.java b/src/main/java/gaji/service/domain/studyMate/entity/StudyApplicant.java index 1375d099..9dfa4da4 100644 --- a/src/main/java/gaji/service/domain/studyMate/entity/StudyApplicant.java +++ b/src/main/java/gaji/service/domain/studyMate/entity/StudyApplicant.java @@ -1,8 +1,8 @@ package gaji.service.domain.studyMate.entity; -import gaji.service.domain.user.entity.User; import gaji.service.domain.enums.ApplicantStatus; import gaji.service.domain.room.entity.Room; +import gaji.service.domain.user.entity.User; import jakarta.persistence.*; import lombok.AccessLevel; import lombok.Getter; diff --git a/src/main/java/gaji/service/domain/studyMate/entity/StudyMate.java b/src/main/java/gaji/service/domain/studyMate/entity/StudyMate.java index 8a4d82e1..8e36f2c2 100644 --- a/src/main/java/gaji/service/domain/studyMate/entity/StudyMate.java +++ b/src/main/java/gaji/service/domain/studyMate/entity/StudyMate.java @@ -3,12 +3,12 @@ import gaji.service.domain.enums.Role; import gaji.service.domain.room.entity.Room; import gaji.service.domain.room.entity.RoomNotice; +import gaji.service.domain.roomBoard.entity.RoomInfo.RoomInfoPost; import gaji.service.domain.roomBoard.entity.RoomPost.RoomPost; import gaji.service.domain.roomBoard.entity.RoomPost.RoomPostLikes; +import gaji.service.domain.roomBoard.entity.RoomTrouble.RoomTroublePost; import gaji.service.domain.roomBoard.entity.RoomTrouble.RoomTroublePostBookmark; import gaji.service.domain.roomBoard.entity.RoomTrouble.RoomTroublePostLike; -import gaji.service.domain.roomBoard.entity.RoomInfo.RoomInfoPost; -import gaji.service.domain.roomBoard.entity.RoomTrouble.RoomTroublePost; import gaji.service.domain.user.entity.User; import jakarta.persistence.*; import lombok.AccessLevel; diff --git a/src/main/java/gaji/service/domain/studyMate/entity/UserAssignment.java b/src/main/java/gaji/service/domain/studyMate/entity/UserAssignment.java index 08cb146d..7705616f 100644 --- a/src/main/java/gaji/service/domain/studyMate/entity/UserAssignment.java +++ b/src/main/java/gaji/service/domain/studyMate/entity/UserAssignment.java @@ -4,9 +4,6 @@ import jakarta.persistence.*; import lombok.*; -import java.util.ArrayList; -import java.util.List; - @Entity @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) diff --git a/src/main/java/gaji/service/domain/studyMate/entity/WeeklyUserProgress.java b/src/main/java/gaji/service/domain/studyMate/entity/WeeklyUserProgress.java index 315ce3b4..2ebe8c36 100644 --- a/src/main/java/gaji/service/domain/studyMate/entity/WeeklyUserProgress.java +++ b/src/main/java/gaji/service/domain/studyMate/entity/WeeklyUserProgress.java @@ -2,7 +2,6 @@ import gaji.service.domain.room.entity.RoomEvent; import gaji.service.domain.user.entity.User; -import gaji.service.domain.room.entity.Room; import jakarta.persistence.*; import lombok.*; diff --git a/src/main/java/gaji/service/domain/studyMate/service/StudyMateQueryServiceImpl.java b/src/main/java/gaji/service/domain/studyMate/service/StudyMateQueryServiceImpl.java index d948c473..155adc7e 100644 --- a/src/main/java/gaji/service/domain/studyMate/service/StudyMateQueryServiceImpl.java +++ b/src/main/java/gaji/service/domain/studyMate/service/StudyMateQueryServiceImpl.java @@ -1,7 +1,7 @@ package gaji.service.domain.studyMate.service; -import gaji.service.domain.studyMate.entity.StudyMate; import gaji.service.domain.studyMate.code.StudyMateErrorStatus; +import gaji.service.domain.studyMate.entity.StudyMate; import gaji.service.domain.studyMate.repository.StudyMateRepository; import gaji.service.global.exception.RestApiException; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/gaji/service/domain/studyMate/web/dto/ResponseDto.java b/src/main/java/gaji/service/domain/studyMate/web/dto/ResponseDto.java index 54ffb312..82951f96 100644 --- a/src/main/java/gaji/service/domain/studyMate/web/dto/ResponseDto.java +++ b/src/main/java/gaji/service/domain/studyMate/web/dto/ResponseDto.java @@ -1,9 +1,4 @@ package gaji.service.domain.studyMate.web.dto; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; - public class ResponseDto { } diff --git a/src/main/java/gaji/service/domain/user/code/UserErrorStatus.java b/src/main/java/gaji/service/domain/user/code/UserErrorStatus.java index cd0337bf..55492347 100644 --- a/src/main/java/gaji/service/domain/user/code/UserErrorStatus.java +++ b/src/main/java/gaji/service/domain/user/code/UserErrorStatus.java @@ -24,7 +24,7 @@ public enum UserErrorStatus implements BaseErrorCodeInterface { @Override public BaseCodeDto getErrorCode() { - return gaji.service.global.exception.code.BaseCodeDto.builder() + return BaseCodeDto.builder() .httpStatus(httpStatus) .isSuccess(isSuccess) .code(code) diff --git a/src/main/java/gaji/service/domain/user/entity/User.java b/src/main/java/gaji/service/domain/user/entity/User.java index e5054607..4811dffe 100644 --- a/src/main/java/gaji/service/domain/user/entity/User.java +++ b/src/main/java/gaji/service/domain/user/entity/User.java @@ -4,16 +4,22 @@ import gaji.service.domain.Report; import gaji.service.domain.alram.Alarm; import gaji.service.domain.common.entity.BaseEntity; -import gaji.service.domain.enums.*; +import gaji.service.domain.enums.Gender; +import gaji.service.domain.enums.ServiceRole; +import gaji.service.domain.enums.SocialType; +import gaji.service.domain.enums.UserActive; import gaji.service.domain.message.entity.Message; -import gaji.service.domain.post.entity.*; +import gaji.service.domain.post.entity.Comment; +import gaji.service.domain.post.entity.Post; +import gaji.service.domain.post.entity.PostFile; +import gaji.service.domain.post.entity.PostLikes; import gaji.service.domain.recruit.entity.RecruitPostBookmark; import gaji.service.domain.recruit.entity.RecruitPostLikes; import gaji.service.domain.recruit.entity.SearchKeyword; import gaji.service.domain.room.entity.Room; import gaji.service.domain.room.entity.RoomEvent; import gaji.service.domain.room.entity.VoiceChatUser; -import gaji.service.domain.roomBoard.entity.RoomPost.*; +import gaji.service.domain.roomBoard.entity.RoomPost.RoomPostFile; import gaji.service.domain.studyMate.entity.*; import gaji.service.oauth2.dto.TransferUserDTO; import jakarta.persistence.*; @@ -52,8 +58,8 @@ public class User extends BaseEntity { @OneToMany(mappedBy = "user",cascade = CascadeType.ALL ) private List studyMateList; - @OneToMany(mappedBy = "user",cascade = CascadeType.ALL ) - private List roomPostBookmarkList = new ArrayList<>(); +// @OneToMany(mappedBy = "user",cascade = CascadeType.ALL ) +// private List roomPostBookmarkList = new ArrayList<>(); @OneToMany(mappedBy = "user",cascade = CascadeType.ALL ) private List recruitPostList = new ArrayList<>(); @@ -89,8 +95,8 @@ public class User extends BaseEntity { @OneToMany(mappedBy = "user") private List postList = new ArrayList<>(); - @OneToMany(mappedBy = "user") - private List postBookmarkList = new ArrayList<>(); +// @OneToMany(mappedBy = "user") +// private List postBookmarkList = new ArrayList<>(); @OneToMany(mappedBy = "user") private List postFileList = new ArrayList<>(); diff --git a/src/main/java/gaji/service/domain/user/validation/UserExistValidator.java b/src/main/java/gaji/service/domain/user/validation/UserExistValidator.java index 15457f0f..0ed3283c 100644 --- a/src/main/java/gaji/service/domain/user/validation/UserExistValidator.java +++ b/src/main/java/gaji/service/domain/user/validation/UserExistValidator.java @@ -1,7 +1,6 @@ package gaji.service.domain.user.validation; import gaji.service.domain.user.annotation.ExistUser; -import gaji.service.domain.post.code.PostErrorStatus; import gaji.service.domain.user.code.UserErrorStatus; import gaji.service.domain.user.service.UserQueryService; import jakarta.validation.ConstraintValidator; diff --git a/src/main/java/gaji/service/domain/user/web/dto/UserRequestDTO.java b/src/main/java/gaji/service/domain/user/web/dto/UserRequestDTO.java index d7bbeb21..afc3d270 100644 --- a/src/main/java/gaji/service/domain/user/web/dto/UserRequestDTO.java +++ b/src/main/java/gaji/service/domain/user/web/dto/UserRequestDTO.java @@ -1,6 +1,5 @@ package gaji.service.domain.user.web.dto; -import gaji.service.domain.enums.PostTypeEnum; import jakarta.validation.constraints.NotBlank; import lombok.Getter; import lombok.RequiredArgsConstructor; From d13021fa40c9e92c16dec647f5da25f7ea4cf859 Mon Sep 17 00:00:00 2001 From: mmingoo Date: Sun, 18 Aug 2024 14:26:01 +0900 Subject: [PATCH 16/24] =?UTF-8?q?=E2=9C=A8=20=20=EC=8A=A4=ED=84=B0?= =?UTF-8?q?=EB=94=94=EB=A6=84=20=EA=B2=8C=EC=8B=9C=EA=B8=80,=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=EB=82=98=EB=88=94=20=EB=AA=A9=EB=A1=9D=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RoomInfo/RoomInfoPostRepository.java | 15 ++++++++ .../RoomPost/RoomPostRepository.java | 17 ++++++++- .../RoomInfo/RoomInfoPostQueryService.java | 5 +++ .../RoomInfoPostQueryServiceImpl.java | 12 ++++++ .../RoomPost/RoomPostQueryService.java | 2 +- .../RoomPost/RoomPostQueryServiceImpl.java | 6 +-- .../RoomTroublePostQueryService.java | 5 +++ .../RoomTroublePostQueryServiceImpl.java | 14 +++++++ .../controller/RoomInfoPostController.java | 20 ++++++++++ .../web/controller/RoomPostController.java | 20 ++++++++++ .../controller/RoomTroublePostController.java | 9 +++-- .../web/dto/RoomPostResponseDto.java | 38 +++++++++++++++++++ 12 files changed, 153 insertions(+), 10 deletions(-) diff --git a/src/main/java/gaji/service/domain/roomBoard/repository/RoomInfo/RoomInfoPostRepository.java b/src/main/java/gaji/service/domain/roomBoard/repository/RoomInfo/RoomInfoPostRepository.java index c68bbaff..d22d76af 100644 --- a/src/main/java/gaji/service/domain/roomBoard/repository/RoomInfo/RoomInfoPostRepository.java +++ b/src/main/java/gaji/service/domain/roomBoard/repository/RoomInfo/RoomInfoPostRepository.java @@ -1,9 +1,24 @@ package gaji.service.domain.roomBoard.repository.RoomInfo; import gaji.service.domain.roomBoard.entity.RoomInfo.RoomInfoPost; +import gaji.service.domain.roomBoard.web.dto.RoomPostResponseDto; +import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; +import java.util.List; + @Repository public interface RoomInfoPostRepository extends JpaRepository { + @Query("SELECT new gaji.service.domain.roomBoard.web.dto.RoomPostResponseDto$InfoPostSummaryDto(" + + "r.id, r.title, r.studyMate.user.nickname, r.postTime, r.viewCount, SIZE(r.infoPostCommentList)) " + + "FROM RoomInfoPost r " + + "WHERE r.roomBoard.id = :boardId AND r.id < :lastPostId " + + "ORDER BY r.postTime DESC") + List findInfoPostSummariesForInfiniteScroll( + @Param("boardId") Long boardId, + @Param("lastPostId") Long lastPostId, + Pageable pageable); } diff --git a/src/main/java/gaji/service/domain/roomBoard/repository/RoomPost/RoomPostRepository.java b/src/main/java/gaji/service/domain/roomBoard/repository/RoomPost/RoomPostRepository.java index 63a91775..d25e548e 100644 --- a/src/main/java/gaji/service/domain/roomBoard/repository/RoomPost/RoomPostRepository.java +++ b/src/main/java/gaji/service/domain/roomBoard/repository/RoomPost/RoomPostRepository.java @@ -1,9 +1,24 @@ package gaji.service.domain.roomBoard.repository.RoomPost; - +import gaji.service.domain.roomBoard.web.dto.RoomPostResponseDto; +import gaji.service.domain.roomBoard.web.dto.RoomPostResponseDto.*; import gaji.service.domain.roomBoard.entity.RoomPost.RoomPost; +import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; +import java.util.List; + @Repository public interface RoomPostRepository extends JpaRepository { + @Query("SELECT new gaji.service.domain.roomBoard.web.dto.RoomPostResponseDto$PostSummaryDto(" + + "r.id, r.title, r.studyMate.user.nickname, r.postTime, r.viewCount, SIZE(r.postCommentList)) " + + "FROM RoomPost r " + + "WHERE r.roomBoard.id = :boardId AND r.id < :lastPostId " + + "ORDER BY r.postTime DESC") + List findPostSummariesForInfiniteScroll( + @Param("boardId") Long boardId, + @Param("lastPostId") Long lastPostId, + Pageable pageable); } diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostQueryService.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostQueryService.java index cabdbd6f..251d7b58 100644 --- a/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostQueryService.java +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostQueryService.java @@ -2,6 +2,9 @@ import gaji.service.domain.roomBoard.entity.RoomInfo.InfoPostComment; import gaji.service.domain.roomBoard.entity.RoomInfo.RoomInfoPost; +import gaji.service.domain.roomBoard.web.dto.RoomPostResponseDto; + +import java.util.List; public interface RoomInfoPostQueryService { RoomInfoPost findInfoPostById(Long PostId); @@ -9,4 +12,6 @@ public interface RoomInfoPostQueryService { InfoPostComment findCommentByCommentId(Long commentId); InfoPostComment findPostCommentById(Long troublePostId); + + List getNextPosts(Long boardId, Long lastPostId, int size); } diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostQueryServiceImpl.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostQueryServiceImpl.java index 8aa67210..4e07fe39 100644 --- a/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostQueryServiceImpl.java +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostQueryServiceImpl.java @@ -5,10 +5,16 @@ import gaji.service.domain.roomBoard.entity.RoomInfo.RoomInfoPost; import gaji.service.domain.roomBoard.repository.RoomInfo.InfoPostCommentRepository; import gaji.service.domain.roomBoard.repository.RoomInfo.RoomInfoPostRepository; +import gaji.service.domain.roomBoard.web.dto.RoomPostResponseDto; import gaji.service.global.exception.RestApiException; import lombok.RequiredArgsConstructor; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; import org.springframework.stereotype.Service; +import java.util.List; + @Service @RequiredArgsConstructor public class RoomInfoPostQueryServiceImpl implements RoomInfoPostQueryService{ @@ -34,4 +40,10 @@ public InfoPostComment findPostCommentById(Long troublePostId) { return infoPostCommentRepository.findById(troublePostId) .orElseThrow(() -> new RestApiException(RoomPostErrorStatus._NOT_FOUND_COMMENT)); } + + @Override + public List getNextPosts(Long boardId, Long lastPostId, int size) { + Pageable pageable = PageRequest.of(0, size, Sort.by(Sort.Direction.DESC, "createdAt")); + return roomInfoPostRepository.findInfoPostSummariesForInfiniteScroll(boardId, lastPostId,pageable); + } } diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostQueryService.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostQueryService.java index 6ed7905d..cad80f2b 100644 --- a/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostQueryService.java +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostQueryService.java @@ -11,7 +11,7 @@ public interface RoomPostQueryService { // List getPaginatedTroublePosts(Long boardId, int page, int size); - List getNextTroublePosts(Long boardId, Long lastPostId, int size); + List getNextPosts(Long boardId, Long lastPostId, int size); RoomPost findPostById(Long PostId); diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostQueryServiceImpl.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostQueryServiceImpl.java index 98f0bcf7..e0b91233 100644 --- a/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostQueryServiceImpl.java +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostQueryServiceImpl.java @@ -6,7 +6,6 @@ import gaji.service.domain.roomBoard.repository.RoomPost.PostCommentRepository; import gaji.service.domain.roomBoard.repository.RoomPost.RoomPostQueryRepository; import gaji.service.domain.roomBoard.repository.RoomPost.RoomPostRepository; -import gaji.service.domain.roomBoard.repository.RoomTrouble.RoomTroublePostRepository; import gaji.service.domain.roomBoard.web.dto.RoomPostResponseDto; import gaji.service.global.exception.RestApiException; import lombok.RequiredArgsConstructor; @@ -22,7 +21,6 @@ public class RoomPostQueryServiceImpl implements RoomPostQueryService { private final RoomPostQueryRepository roomPostQueryRepository; - private final RoomTroublePostRepository roomTroublePostRepository; private final RoomPostRepository roomPostRepository; private final PostCommentRepository postCommentRepository; @@ -32,9 +30,9 @@ public List getTop3RecentPosts(Long roomId) { } @Override - public List getNextTroublePosts(Long boardId, Long lastPostId, int size) { + public List getNextPosts(Long boardId, Long lastPostId, int size) { Pageable pageable = PageRequest.of(0, size, Sort.by(Sort.Direction.DESC, "createdAt")); - return roomTroublePostRepository.findTroublePostSummariesForInfiniteScroll(boardId, lastPostId,pageable); + return roomPostRepository.findPostSummariesForInfiniteScroll(boardId, lastPostId,pageable); } @Override diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomTrouble/RoomTroublePostQueryService.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomTrouble/RoomTroublePostQueryService.java index 1aec4c73..24adeec9 100644 --- a/src/main/java/gaji/service/domain/roomBoard/service/RoomTrouble/RoomTroublePostQueryService.java +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomTrouble/RoomTroublePostQueryService.java @@ -1,9 +1,14 @@ package gaji.service.domain.roomBoard.service.RoomTrouble; import gaji.service.domain.roomBoard.entity.RoomTrouble.TroublePostComment; +import gaji.service.domain.roomBoard.web.dto.RoomPostResponseDto; + +import java.util.List; public interface RoomTroublePostQueryService { TroublePostComment findCommentByCommentId(Long commentId); TroublePostComment findTroublePostCommentById(Long troublePostId); + + List getNextTroublePosts(Long boardId, Long lastPostId, int size); } diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomTrouble/RoomTroublePostQueryServiceImpl.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomTrouble/RoomTroublePostQueryServiceImpl.java index 725d0cf9..c2c4f77d 100644 --- a/src/main/java/gaji/service/domain/roomBoard/service/RoomTrouble/RoomTroublePostQueryServiceImpl.java +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomTrouble/RoomTroublePostQueryServiceImpl.java @@ -2,16 +2,24 @@ import gaji.service.domain.roomBoard.code.RoomPostErrorStatus; import gaji.service.domain.roomBoard.entity.RoomTrouble.TroublePostComment; +import gaji.service.domain.roomBoard.repository.RoomTrouble.RoomTroublePostRepository; import gaji.service.domain.roomBoard.repository.RoomTrouble.TroublePostCommentRepository; +import gaji.service.domain.roomBoard.web.dto.RoomPostResponseDto; import gaji.service.global.exception.RestApiException; import lombok.RequiredArgsConstructor; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; import org.springframework.stereotype.Service; +import java.util.List; + @Service @RequiredArgsConstructor public class RoomTroublePostQueryServiceImpl implements RoomTroublePostQueryService { private final TroublePostCommentRepository troublePostCommentRepository; + private final RoomTroublePostRepository roomTroublePostRepository; @Override public TroublePostComment findCommentByCommentId(Long commentId){ return troublePostCommentRepository.findById(commentId) @@ -23,4 +31,10 @@ public TroublePostComment findTroublePostCommentById(Long troublePostId) { return troublePostCommentRepository.findById(troublePostId) .orElseThrow(() -> new RestApiException(RoomPostErrorStatus._NOT_FOUND_COMMENT)); } + + @Override + public List getNextTroublePosts(Long boardId, Long lastPostId, int size) { + Pageable pageable = PageRequest.of(0, size, Sort.by(Sort.Direction.DESC, "createdAt")); + return roomTroublePostRepository.findTroublePostSummariesForInfiniteScroll(boardId, lastPostId,pageable); + } } diff --git a/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomInfoPostController.java b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomInfoPostController.java index 887eed0e..0d14e55a 100644 --- a/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomInfoPostController.java +++ b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomInfoPostController.java @@ -1,21 +1,27 @@ package gaji.service.domain.roomBoard.web.controller; import gaji.service.domain.roomBoard.service.RoomInfo.RoomInfoPostCommandService; +import gaji.service.domain.roomBoard.service.RoomInfo.RoomInfoPostQueryService; import gaji.service.domain.roomBoard.web.dto.RoomPostRequestDto; import gaji.service.domain.roomBoard.web.dto.RoomPostResponseDto; import gaji.service.global.base.BaseResponse; import gaji.service.jwt.service.TokenProviderService; import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.responses.ApiResponse; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.*; +import java.util.List; + @RestController @RequiredArgsConstructor @RequestMapping("/api/study-rooms") public class RoomInfoPostController { private final TokenProviderService tokenProviderService; private final RoomInfoPostCommandService roomInfoPostCommandService; + private final RoomInfoPostQueryService roomInfoPostQueryService; @PostMapping("/info/{roomId}") @Operation(summary = "스터디룸 정보나눔 게시판 등록 API") @@ -135,4 +141,18 @@ public BaseResponse removeBookmark( roomInfoPostCommandService.removeBookmark(postId, userId, roomId); return BaseResponse.onSuccess( "북마크가 성공적으로 삭제되었습니다."); } + + @GetMapping("/{boardId}/info") + @Operation(summary = "게시글 무한 스크롤 조회", description = "게시글을 무한 스크롤 방식으로 조회합니다.") + @ApiResponse(responseCode = "200", description = "조회 성공") + public BaseResponse> getNextTroublePosts( + @PathVariable @Parameter(description = "게시판 ID") Long boardId, + @RequestParam @Parameter(description = "마지막으로 로드된 게시글 ID") Long lastPostId, + @RequestParam(defaultValue = "10") @Parameter(description = "조회할 게시글 수") int size) { + + List posts = + roomInfoPostQueryService.getNextPosts(boardId, lastPostId, size); + + return BaseResponse.onSuccess(posts); + } } diff --git a/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomPostController.java b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomPostController.java index df051867..32ae91d8 100644 --- a/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomPostController.java +++ b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomPostController.java @@ -1,15 +1,20 @@ package gaji.service.domain.roomBoard.web.controller; import gaji.service.domain.roomBoard.service.RoomPost.RoomPostCommandService; +import gaji.service.domain.roomBoard.service.RoomPost.RoomPostQueryService; import gaji.service.domain.roomBoard.web.dto.RoomPostRequestDto; import gaji.service.domain.roomBoard.web.dto.RoomPostResponseDto; import gaji.service.global.base.BaseResponse; import gaji.service.jwt.service.TokenProviderService; import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.responses.ApiResponse; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.*; +import java.util.List; + @RestController @RequiredArgsConstructor @RequestMapping("/api/study-rooms") @@ -17,6 +22,7 @@ public class RoomPostController { private final TokenProviderService tokenProviderService; private final RoomPostCommandService roomPostCommandService; + private final RoomPostQueryService roomPostQueryService; @PostMapping("/post/{roomId}") @Operation(summary = "스터디룸 게시글 등록 API") @@ -137,4 +143,18 @@ public BaseResponse removeBookmark( return BaseResponse.onSuccess( "북마크가 성공적으로 삭제되었습니다."); } + @GetMapping("/{boardId}/post") + @Operation(summary = "게시글 무한 스크롤 조회", description = "게시글을 무한 스크롤 방식으로 조회합니다.") + @ApiResponse(responseCode = "200", description = "조회 성공") + public BaseResponse> getNextPosts( + @PathVariable @Parameter(description = "게시판 ID") Long boardId, + @RequestParam @Parameter(description = "마지막으로 로드된 게시글 ID") Long lastPostId, + @RequestParam(defaultValue = "10") @Parameter(description = "조회할 게시글 수") int size) { + + List posts = + roomPostQueryService.getNextPosts(boardId, lastPostId, size); + + return BaseResponse.onSuccess(posts); + } + } diff --git a/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomTroublePostController.java b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomTroublePostController.java index 9317a1dc..16f6596a 100644 --- a/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomTroublePostController.java +++ b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomTroublePostController.java @@ -4,6 +4,8 @@ import gaji.service.domain.roomBoard.entity.RoomTrouble.TroublePostComment; import gaji.service.domain.roomBoard.service.RoomPost.RoomPostQueryService; import gaji.service.domain.roomBoard.service.RoomTrouble.RoomTroublePostCommandService; +import gaji.service.domain.roomBoard.service.RoomTrouble.RoomTroublePostQueryService; +import gaji.service.domain.roomBoard.service.RoomTrouble.RoomTroublePostQueryServiceImpl; import gaji.service.domain.roomBoard.web.dto.RoomPostRequestDto; import gaji.service.domain.roomBoard.web.dto.RoomPostResponseDto; import gaji.service.global.base.BaseResponse; @@ -24,8 +26,7 @@ public class RoomTroublePostController { private final TokenProviderService tokenProviderService; private final RoomTroublePostCommandService roomTroublePostCommandService; - private final RoomPostQueryService roomPostQueryService; - + private final RoomTroublePostQueryService roomTroublePostQueryService; @PostMapping("/trouble/{roomId}") @Operation(summary = "스터디룸 트러블슈팅 게시판 등록 API") public BaseResponse TroublePostController( @@ -158,7 +159,7 @@ public BaseResponse addReply( return BaseResponse.onSuccess(RoomPostConverter.toWriteCommentDto(replyComment)); } - @GetMapping("/{boardId}/trouble-posts") + @GetMapping("/{boardId}/trouble") @Operation(summary = "트러블 슈팅 게시글 무한 스크롤 조회", description = "트러블 슈팅 게시글을 무한 스크롤 방식으로 조회합니다.") @ApiResponse(responseCode = "200", description = "조회 성공") public BaseResponse> getNextTroublePosts( @@ -167,7 +168,7 @@ public BaseResponse> getNextTrou @RequestParam(defaultValue = "10") @Parameter(description = "조회할 게시글 수") int size) { List posts = - roomPostQueryService.getNextTroublePosts(boardId, lastPostId, size); + roomTroublePostQueryService.getNextTroublePosts(boardId, lastPostId, size); return BaseResponse.onSuccess(posts); } diff --git a/src/main/java/gaji/service/domain/roomBoard/web/dto/RoomPostResponseDto.java b/src/main/java/gaji/service/domain/roomBoard/web/dto/RoomPostResponseDto.java index 9d3625a8..38d2e9c0 100644 --- a/src/main/java/gaji/service/domain/roomBoard/web/dto/RoomPostResponseDto.java +++ b/src/main/java/gaji/service/domain/roomBoard/web/dto/RoomPostResponseDto.java @@ -82,4 +82,42 @@ public TroublePostSummaryDto(Long id, String title, String nickname, LocalDateTi } } + @Getter + public static class PostSummaryDto { + private final Long id; + private final String title; + private final String nickname; + private final String createdAt; + private final int viewCount; + private final int commentCount; + + public PostSummaryDto(Long id, String title, String nickname, LocalDateTime createdAt, int viewCount, int commentCount) { + this.id = id; + this.title = title; + this.nickname = nickname; + this.createdAt = DateConverter.convertToRelativeTimeFormat(createdAt); + this.viewCount = viewCount; + this.commentCount = commentCount; + } + } + + @Getter + public static class InfoPostSummaryDto { + private final Long id; + private final String title; + private final String nickname; + private final String createdAt; + private final int viewCount; + private final int commentCount; + + public InfoPostSummaryDto(Long id, String title, String nickname, LocalDateTime createdAt, int viewCount, int commentCount) { + this.id = id; + this.title = title; + this.nickname = nickname; + this.createdAt = DateConverter.convertToRelativeTimeFormat(createdAt); + this.viewCount = viewCount; + this.commentCount = commentCount; + } + } + } From 607aa62b2ace3c4acdd199a9b265eabb6131c74d Mon Sep 17 00:00:00 2001 From: mmingoo Date: Sun, 18 Aug 2024 16:26:23 +0900 Subject: [PATCH 17/24] =?UTF-8?q?=E2=9C=A8=20=20=EC=8A=A4=ED=84=B0?= =?UTF-8?q?=EB=94=94=EB=A6=84=20=EA=B2=8C=EC=8B=9C=EA=B8=80,=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=EB=82=98=EB=88=94=20=EB=8C=93=EA=B8=80=EC=9D=98=20?= =?UTF-8?q?=EB=8B=B5=EA=B8=80=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RoomInfo/RoomInfoPostCommandService.java | 3 +++ .../RoomInfoPostCommandServiceImpl.java | 22 +++++++++++++++++ .../RoomPost/RoomPostCommandService.java | 3 +++ .../RoomPost/RoomPostCommandServiceImpl.java | 24 +++++++++++++++++++ .../controller/RoomInfoPostController.java | 15 ++++++++++++ .../web/controller/RoomPostController.java | 14 +++++++++++ .../controller/RoomTroublePostController.java | 2 +- 7 files changed, 82 insertions(+), 1 deletion(-) diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandService.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandService.java index 076779a0..8f4d70d0 100644 --- a/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandService.java +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandService.java @@ -1,5 +1,6 @@ package gaji.service.domain.roomBoard.service.RoomInfo; +import gaji.service.domain.roomBoard.entity.RoomInfo.InfoPostComment; import gaji.service.domain.roomBoard.web.dto.RoomPostRequestDto; import gaji.service.domain.roomBoard.web.dto.RoomPostResponseDto; @@ -23,4 +24,6 @@ public interface RoomInfoPostCommandService { void addBookmark(Long postId, Long userId, Long roomId); void removeBookmark(Long postId, Long userId, Long roomId); + + InfoPostComment addReply(Long commentId, Long userId, RoomPostRequestDto.RoomTroubleCommentDto request); } diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandServiceImpl.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandServiceImpl.java index 76026611..93e984ff 100644 --- a/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandServiceImpl.java +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomInfo/RoomInfoPostCommandServiceImpl.java @@ -214,5 +214,27 @@ public void removeBookmark(Long postId, Long userId, Long roomId) { post.removeBookmark(bookmark); roomInfoPostBookmarkRepository.delete(bookmark); } + + @Override + public InfoPostComment addReply(Long commentId, Long userId, RoomPostRequestDto.RoomTroubleCommentDto request) { + InfoPostComment parentComment = infoPostCommentRepository.findById(commentId) + .orElseThrow(() -> new RestApiException(RoomPostErrorStatus._NOT_FOUND_COMMENT)); + + if (parentComment.isReply()) { + throw new IllegalStateException("답글에는 답글을 달 수 없습니다."); + } + + User user = userQueryService.findUserById(userId); + InfoPostComment reply = InfoPostComment.builder() + .user(user) + .roomInfoPost(parentComment.getRoomInfoPost()) + .body(request.getBody()) + .isReply(true) + .parentComment(parentComment) + .build(); + + parentComment.addReply(reply); + return infoPostCommentRepository.save(reply); + } } diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandService.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandService.java index 6f1282b8..99bd579a 100644 --- a/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandService.java +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandService.java @@ -1,5 +1,6 @@ package gaji.service.domain.roomBoard.service.RoomPost; +import gaji.service.domain.roomBoard.entity.RoomPost.PostComment; import gaji.service.domain.roomBoard.web.dto.RoomPostRequestDto; import gaji.service.domain.roomBoard.web.dto.RoomPostResponseDto; @@ -22,4 +23,6 @@ public interface RoomPostCommandService { void addBookmark(Long postId, Long userId, Long roomId); void removeBookmark(Long postId, Long userId, Long roomId); + + PostComment addReply(Long commentId, Long userId, RoomPostRequestDto.RoomTroubleCommentDto request); } diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandServiceImpl.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandServiceImpl.java index 10f9eecc..1355b4e3 100644 --- a/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandServiceImpl.java +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandServiceImpl.java @@ -10,6 +10,7 @@ import gaji.service.domain.roomBoard.entity.RoomPost.RoomPost; import gaji.service.domain.roomBoard.entity.RoomPost.RoomPostBookmark; import gaji.service.domain.roomBoard.entity.RoomPost.RoomPostLikes; +import gaji.service.domain.roomBoard.entity.RoomTrouble.TroublePostComment; import gaji.service.domain.roomBoard.repository.RoomBoardRepository; import gaji.service.domain.roomBoard.repository.RoomPost.PostCommentRepository; import gaji.service.domain.roomBoard.repository.RoomPost.RoomPostBookmarkRepository; @@ -217,4 +218,27 @@ public void removeBookmark(Long postId, Long userId, Long roomId) { post.removeBookmark(bookmark); roomPostBookmarkRepository.delete(bookmark); } + + @Override + public PostComment addReply(Long commentId, Long userId, RoomPostRequestDto.RoomTroubleCommentDto request) { + PostComment parentComment = postCommentRepository.findById(commentId) + .orElseThrow(() -> new RestApiException(RoomPostErrorStatus._NOT_FOUND_COMMENT)); + + if (parentComment.isReply()) { + throw new IllegalStateException("답글에는 답글을 달 수 없습니다."); + } + + User user = userQueryService.findUserById(userId); + PostComment reply = PostComment.builder() + .user(user) + .roomPost(parentComment.getRoomPost()) + .body(request.getBody()) + .isReply(true) + .parentComment(parentComment) + .build(); + + parentComment.addReply(reply); + return postCommentRepository.save(reply); + } + } diff --git a/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomInfoPostController.java b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomInfoPostController.java index 0d14e55a..371121af 100644 --- a/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomInfoPostController.java +++ b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomInfoPostController.java @@ -1,5 +1,8 @@ package gaji.service.domain.roomBoard.web.controller; +import gaji.service.domain.roomBoard.converter.RoomPostConverter; +import gaji.service.domain.roomBoard.entity.RoomInfo.InfoPostComment; +import gaji.service.domain.roomBoard.entity.RoomPost.PostComment; import gaji.service.domain.roomBoard.service.RoomInfo.RoomInfoPostCommandService; import gaji.service.domain.roomBoard.service.RoomInfo.RoomInfoPostQueryService; import gaji.service.domain.roomBoard.web.dto.RoomPostRequestDto; @@ -155,4 +158,16 @@ public BaseResponse> getNextTrouble return BaseResponse.onSuccess(posts); } + + @PostMapping("/info/comments/{commentId}/replies") + @Operation(summary = "게시글 댓글의 답글 작성 API") + public BaseResponse addReply( + @RequestHeader("Authorization") String authorization, + @PathVariable Long commentId, + @RequestBody @Valid RoomPostRequestDto.RoomTroubleCommentDto requestDto + ) { + Long userId = tokenProviderService.getUserIdFromToken(authorization); + InfoPostComment replyComment = roomInfoPostCommandService.addReply(commentId, userId, requestDto); + return BaseResponse.onSuccess(RoomPostConverter.toWriteInfoPostCommentDto(replyComment)); + } } diff --git a/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomPostController.java b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomPostController.java index 32ae91d8..36e74bf1 100644 --- a/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomPostController.java +++ b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomPostController.java @@ -1,5 +1,8 @@ package gaji.service.domain.roomBoard.web.controller; +import gaji.service.domain.roomBoard.converter.RoomPostConverter; +import gaji.service.domain.roomBoard.entity.RoomPost.PostComment; +import gaji.service.domain.roomBoard.entity.RoomTrouble.TroublePostComment; import gaji.service.domain.roomBoard.service.RoomPost.RoomPostCommandService; import gaji.service.domain.roomBoard.service.RoomPost.RoomPostQueryService; import gaji.service.domain.roomBoard.web.dto.RoomPostRequestDto; @@ -157,4 +160,15 @@ public BaseResponse> getNextPosts( return BaseResponse.onSuccess(posts); } + @PostMapping("/post/comments/{commentId}/replies") + @Operation(summary = "게시글 댓글의 답글 작성 API") + public BaseResponse addReply( + @RequestHeader("Authorization") String authorization, + @PathVariable Long commentId, + @RequestBody @Valid RoomPostRequestDto.RoomTroubleCommentDto requestDto + ) { + Long userId = tokenProviderService.getUserIdFromToken(authorization); + PostComment replyComment = roomPostCommandService.addReply(commentId, userId, requestDto); + return BaseResponse.onSuccess(RoomPostConverter.toWritePostCommentDto(replyComment)); + } } diff --git a/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomTroublePostController.java b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomTroublePostController.java index 16f6596a..7579c5ac 100644 --- a/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomTroublePostController.java +++ b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomTroublePostController.java @@ -147,7 +147,7 @@ public BaseResponse removeBookmark( return BaseResponse.onSuccess( "북마크가 성공적으로 삭제되었습니다."); } - @PostMapping("/comments/{commentId}/replies") + @PostMapping("/trouble/comments/{commentId}/replies") @Operation(summary = "트러블 슈팅 게시글 댓글의 답글 작성 API") public BaseResponse addReply( @RequestHeader("Authorization") String authorization, From 7978600213ce876941e03238a483200362213804 Mon Sep 17 00:00:00 2001 From: mmingoo Date: Sun, 18 Aug 2024 16:52:54 +0900 Subject: [PATCH 18/24] =?UTF-8?q?=E2=9C=A8=20=20=EC=8A=A4=ED=84=B0?= =?UTF-8?q?=EB=94=94=EB=A6=84=20=EA=B2=8C=EC=8B=9C=EA=B8=80=20=EB=AA=A9?= =?UTF-8?q?=EB=A1=9D=EC=A1=B0=ED=9A=8C=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/controller/RoomInfoPostController.java | 1 + .../web/controller/RoomPostController.java | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomInfoPostController.java b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomInfoPostController.java index 371121af..3b1626be 100644 --- a/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomInfoPostController.java +++ b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomInfoPostController.java @@ -170,4 +170,5 @@ public BaseResponse addReply( InfoPostComment replyComment = roomInfoPostCommandService.addReply(commentId, userId, requestDto); return BaseResponse.onSuccess(RoomPostConverter.toWriteInfoPostCommentDto(replyComment)); } + } diff --git a/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomPostController.java b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomPostController.java index 36e74bf1..9f0eebb4 100644 --- a/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomPostController.java +++ b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomPostController.java @@ -171,4 +171,18 @@ public BaseResponse addReply( PostComment replyComment = roomPostCommandService.addReply(commentId, userId, requestDto); return BaseResponse.onSuccess(RoomPostConverter.toWritePostCommentDto(replyComment)); } + + @GetMapping("/{boardId}/post") + @Operation(summary = "게시글 무한 스크롤 조회", description = "게시글을 무한 스크롤 방식으로 조회합니다.") + @ApiResponse(responseCode = "200", description = "조회 성공") + public BaseResponse> getNextTroublePosts( + @PathVariable @Parameter(description = "게시판 ID") Long boardId, + @RequestParam @Parameter(description = "마지막으로 로드된 게시글 ID") Long lastPostId, + @RequestParam(defaultValue = "10") @Parameter(description = "조회할 게시글 수") int size) { + + List posts = + roomPostQueryService.getNextPosts(boardId, lastPostId, size); + + return BaseResponse.onSuccess(posts); + } } From dcbfe26cb9fa85bfa6abfc42ab70097ef4891cb9 Mon Sep 17 00:00:00 2001 From: mmingoo Date: Sun, 18 Aug 2024 17:05:57 +0900 Subject: [PATCH 19/24] =?UTF-8?q?=F0=9F=94=A5=20=EC=8A=A4=ED=84=B0?= =?UTF-8?q?=EB=94=94=EB=A6=84=20=EA=B2=8C=EC=8B=9C=EA=B8=80=20=EB=AA=A9?= =?UTF-8?q?=EB=A1=9D=EC=A1=B0=ED=9A=8C=20=EC=A4=91=EB=B3=B5=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/controller/RoomPostController.java | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomPostController.java b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomPostController.java index 9f0eebb4..db30589b 100644 --- a/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomPostController.java +++ b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomPostController.java @@ -172,17 +172,4 @@ public BaseResponse addReply( return BaseResponse.onSuccess(RoomPostConverter.toWritePostCommentDto(replyComment)); } - @GetMapping("/{boardId}/post") - @Operation(summary = "게시글 무한 스크롤 조회", description = "게시글을 무한 스크롤 방식으로 조회합니다.") - @ApiResponse(responseCode = "200", description = "조회 성공") - public BaseResponse> getNextTroublePosts( - @PathVariable @Parameter(description = "게시판 ID") Long boardId, - @RequestParam @Parameter(description = "마지막으로 로드된 게시글 ID") Long lastPostId, - @RequestParam(defaultValue = "10") @Parameter(description = "조회할 게시글 수") int size) { - - List posts = - roomPostQueryService.getNextPosts(boardId, lastPostId, size); - - return BaseResponse.onSuccess(posts); - } } From 663dd65e5e0509e6ec66788551c3de036dde8ba7 Mon Sep 17 00:00:00 2001 From: mmingoo Date: Sun, 18 Aug 2024 17:09:40 +0900 Subject: [PATCH 20/24] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20=EA=B2=8C=EC=8B=9C?= =?UTF-8?q?=EA=B8=80=20=EC=97=94=ED=8B=B0=ED=8B=B0=EC=97=90=EC=84=9C=20pos?= =?UTF-8?q?tTime=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/roomBoard/converter/RoomPostConverter.java | 3 --- .../domain/roomBoard/entity/RoomInfo/RoomInfoPost.java | 4 ++-- .../service/domain/roomBoard/entity/RoomPost/RoomPost.java | 5 ++--- .../domain/roomBoard/entity/RoomTrouble/RoomTroublePost.java | 1 - 4 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/main/java/gaji/service/domain/roomBoard/converter/RoomPostConverter.java b/src/main/java/gaji/service/domain/roomBoard/converter/RoomPostConverter.java index c4ff872d..e3f79e95 100644 --- a/src/main/java/gaji/service/domain/roomBoard/converter/RoomPostConverter.java +++ b/src/main/java/gaji/service/domain/roomBoard/converter/RoomPostConverter.java @@ -20,7 +20,6 @@ public static RoomPost toRoomPost(RoomPostRequestDto.RoomPostDto requestDto, Stu .studyMate(studyMate) .title(requestDto.getTitle()) .body(requestDto.getBody()) - .postTime(LocalDateTime.now()) .roomBoard(roomBoard) .build(); } @@ -30,7 +29,6 @@ public static RoomTroublePost toRoomTroublePost(RoomPostRequestDto.RoomTroubloeP .studyMate(studyMate) .title(requestDto.getTitle()) .body(requestDto.getBody()) - .postTime(LocalDateTime.now()) .roomBoard(roomBoard) .build(); } @@ -53,7 +51,6 @@ public static RoomInfoPost toRoomInfoPost(RoomPostRequestDto.RoomInfoPostDto req .studyMate(studyMate) .title(requestDto.getTitle()) .body(requestDto.getBody()) - .postTime(LocalDateTime.now()) .roomBoard(roomBoard) .build(); } diff --git a/src/main/java/gaji/service/domain/roomBoard/entity/RoomInfo/RoomInfoPost.java b/src/main/java/gaji/service/domain/roomBoard/entity/RoomInfo/RoomInfoPost.java index 4be1f8d2..9989830b 100644 --- a/src/main/java/gaji/service/domain/roomBoard/entity/RoomInfo/RoomInfoPost.java +++ b/src/main/java/gaji/service/domain/roomBoard/entity/RoomInfo/RoomInfoPost.java @@ -1,5 +1,6 @@ package gaji.service.domain.roomBoard.entity.RoomInfo; +import gaji.service.domain.common.entity.BaseEntity; import gaji.service.domain.roomBoard.entity.RoomBoard; import gaji.service.domain.studyMate.entity.StudyMate; import jakarta.persistence.*; @@ -14,7 +15,7 @@ @NoArgsConstructor(access = AccessLevel.PROTECTED) @AllArgsConstructor @Builder -public class RoomInfoPost { +public class RoomInfoPost extends BaseEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; @@ -24,7 +25,6 @@ public class RoomInfoPost { private int viewCount; private int likeCount; private int bookmarkCount; - private LocalDateTime postTime; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "board_id") diff --git a/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPost.java b/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPost.java index 6d672497..503b9bb9 100644 --- a/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPost.java +++ b/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPost.java @@ -1,5 +1,6 @@ package gaji.service.domain.roomBoard.entity.RoomPost; +import gaji.service.domain.common.entity.BaseEntity; import gaji.service.domain.roomBoard.entity.RoomBoard; import gaji.service.domain.studyMate.entity.StudyMate; import jakarta.persistence.*; @@ -14,7 +15,7 @@ @NoArgsConstructor(access = AccessLevel.PROTECTED) @AllArgsConstructor @Builder -public class RoomPost { +public class RoomPost extends BaseEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; @@ -50,8 +51,6 @@ public class RoomPost { private int likeCount; private int bookmarkCount; - private LocalDateTime postTime; - @PrePersist public void prePersist() { this.viewCount = 0; diff --git a/src/main/java/gaji/service/domain/roomBoard/entity/RoomTrouble/RoomTroublePost.java b/src/main/java/gaji/service/domain/roomBoard/entity/RoomTrouble/RoomTroublePost.java index ca2d1b1c..90cbb7a9 100644 --- a/src/main/java/gaji/service/domain/roomBoard/entity/RoomTrouble/RoomTroublePost.java +++ b/src/main/java/gaji/service/domain/roomBoard/entity/RoomTrouble/RoomTroublePost.java @@ -25,7 +25,6 @@ public class RoomTroublePost extends BaseEntity { private int viewCount; private int likeCount; private int bookmarkCount; - private LocalDateTime postTime; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "board_id") From 50113f528aeda2502bfbf2bfdf0e940ed78bf3a9 Mon Sep 17 00:00:00 2001 From: mmingoo Date: Sun, 18 Aug 2024 17:36:33 +0900 Subject: [PATCH 21/24] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20RoomPostLike?= =?UTF-8?q?=EC=97=90=EC=84=9C=20=EB=A7=A4=ED=95=91=20=EC=97=90=EB=9F=AC=20?= =?UTF-8?q?=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../roomBoard/entity/RoomPost/RoomPostLikes.java | 2 +- .../repository/RoomInfo/RoomInfoPostRepository.java | 4 ++-- .../repository/RoomPost/RoomPostRepository.java | 4 ++-- .../service/domain/studyMate/entity/StudyMate.java | 12 ++++++++++++ 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPostLikes.java b/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPostLikes.java index 55209dad..01ee16b7 100644 --- a/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPostLikes.java +++ b/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPostLikes.java @@ -15,7 +15,7 @@ public class RoomPostLikes { private Long id; @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "user_id") + @JoinColumn(name = "study_mate_id") private StudyMate studyMate; @ManyToOne(fetch = FetchType.LAZY) diff --git a/src/main/java/gaji/service/domain/roomBoard/repository/RoomInfo/RoomInfoPostRepository.java b/src/main/java/gaji/service/domain/roomBoard/repository/RoomInfo/RoomInfoPostRepository.java index d22d76af..e7bd5f9a 100644 --- a/src/main/java/gaji/service/domain/roomBoard/repository/RoomInfo/RoomInfoPostRepository.java +++ b/src/main/java/gaji/service/domain/roomBoard/repository/RoomInfo/RoomInfoPostRepository.java @@ -13,10 +13,10 @@ @Repository public interface RoomInfoPostRepository extends JpaRepository { @Query("SELECT new gaji.service.domain.roomBoard.web.dto.RoomPostResponseDto$InfoPostSummaryDto(" + - "r.id, r.title, r.studyMate.user.nickname, r.postTime, r.viewCount, SIZE(r.infoPostCommentList)) " + + "r.id, r.title, r.studyMate.user.nickname, r.createdAt, r.viewCount, SIZE(r.infoPostCommentList)) " + "FROM RoomInfoPost r " + "WHERE r.roomBoard.id = :boardId AND r.id < :lastPostId " + - "ORDER BY r.postTime DESC") + "ORDER BY r.createdAt DESC") List findInfoPostSummariesForInfiniteScroll( @Param("boardId") Long boardId, @Param("lastPostId") Long lastPostId, diff --git a/src/main/java/gaji/service/domain/roomBoard/repository/RoomPost/RoomPostRepository.java b/src/main/java/gaji/service/domain/roomBoard/repository/RoomPost/RoomPostRepository.java index d25e548e..703e8184 100644 --- a/src/main/java/gaji/service/domain/roomBoard/repository/RoomPost/RoomPostRepository.java +++ b/src/main/java/gaji/service/domain/roomBoard/repository/RoomPost/RoomPostRepository.java @@ -13,10 +13,10 @@ @Repository public interface RoomPostRepository extends JpaRepository { @Query("SELECT new gaji.service.domain.roomBoard.web.dto.RoomPostResponseDto$PostSummaryDto(" + - "r.id, r.title, r.studyMate.user.nickname, r.postTime, r.viewCount, SIZE(r.postCommentList)) " + + "r.id, r.title, r.studyMate.user.nickname, r.createdAt, r.viewCount, SIZE(r.postCommentList)) " + "FROM RoomPost r " + "WHERE r.roomBoard.id = :boardId AND r.id < :lastPostId " + - "ORDER BY r.postTime DESC") + "ORDER BY r.createdAt DESC") List findPostSummariesForInfiniteScroll( @Param("boardId") Long boardId, @Param("lastPostId") Long lastPostId, diff --git a/src/main/java/gaji/service/domain/studyMate/entity/StudyMate.java b/src/main/java/gaji/service/domain/studyMate/entity/StudyMate.java index 8e36f2c2..2a796f18 100644 --- a/src/main/java/gaji/service/domain/studyMate/entity/StudyMate.java +++ b/src/main/java/gaji/service/domain/studyMate/entity/StudyMate.java @@ -4,7 +4,10 @@ import gaji.service.domain.room.entity.Room; import gaji.service.domain.room.entity.RoomNotice; import gaji.service.domain.roomBoard.entity.RoomInfo.RoomInfoPost; +import gaji.service.domain.roomBoard.entity.RoomInfo.RoomInfoPostBookmark; +import gaji.service.domain.roomBoard.entity.RoomInfo.RoomInfoPostLikes; import gaji.service.domain.roomBoard.entity.RoomPost.RoomPost; +import gaji.service.domain.roomBoard.entity.RoomPost.RoomPostBookmark; import gaji.service.domain.roomBoard.entity.RoomPost.RoomPostLikes; import gaji.service.domain.roomBoard.entity.RoomTrouble.RoomTroublePost; import gaji.service.domain.roomBoard.entity.RoomTrouble.RoomTroublePostBookmark; @@ -56,6 +59,12 @@ public class StudyMate { @OneToMany(mappedBy = "studyMate", cascade = CascadeType.ALL) private List roomInfoPostList = new ArrayList<>(); + @OneToMany(mappedBy = "studyMate", cascade = CascadeType.ALL) + private List roomInfoPostLikesList = new ArrayList<>(); + + @OneToMany(mappedBy = "studyMate", cascade = CascadeType.ALL) + private List roomInfoPostBookmarkList = new ArrayList<>(); + //게시글 @OneToMany(mappedBy = "studyMate", cascade = CascadeType.ALL) @@ -64,6 +73,9 @@ public class StudyMate { @OneToMany(mappedBy = "studyMate", cascade = CascadeType.ALL) private List roomPostLikesList = new ArrayList<>(); + @OneToMany(mappedBy = "studyMate", cascade = CascadeType.ALL) + private List roomPostBookmarkList = new ArrayList<>(); + @Enumerated(EnumType.STRING) private Role role; From 91cc645ae4ba84ee876300cb98d82d3c44aa7359 Mon Sep 17 00:00:00 2001 From: mmingoo Date: Sun, 18 Aug 2024 18:41:25 +0900 Subject: [PATCH 22/24] =?UTF-8?q?Revert=20"=E2=99=BB=EF=B8=8F=20RoomPostLi?= =?UTF-8?q?ke=EC=97=90=EC=84=9C=20=EB=A7=A4=ED=95=91=20=EC=97=90=EB=9F=AC?= =?UTF-8?q?=20=ED=95=B4=EA=B2=B0"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 50113f528aeda2502bfbf2bfdf0e940ed78bf3a9. --- .../roomBoard/entity/RoomPost/RoomPostLikes.java | 2 +- .../repository/RoomInfo/RoomInfoPostRepository.java | 4 ++-- .../repository/RoomPost/RoomPostRepository.java | 4 ++-- .../service/domain/studyMate/entity/StudyMate.java | 12 ------------ 4 files changed, 5 insertions(+), 17 deletions(-) diff --git a/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPostLikes.java b/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPostLikes.java index 01ee16b7..55209dad 100644 --- a/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPostLikes.java +++ b/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPostLikes.java @@ -15,7 +15,7 @@ public class RoomPostLikes { private Long id; @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "study_mate_id") + @JoinColumn(name = "user_id") private StudyMate studyMate; @ManyToOne(fetch = FetchType.LAZY) diff --git a/src/main/java/gaji/service/domain/roomBoard/repository/RoomInfo/RoomInfoPostRepository.java b/src/main/java/gaji/service/domain/roomBoard/repository/RoomInfo/RoomInfoPostRepository.java index e7bd5f9a..d22d76af 100644 --- a/src/main/java/gaji/service/domain/roomBoard/repository/RoomInfo/RoomInfoPostRepository.java +++ b/src/main/java/gaji/service/domain/roomBoard/repository/RoomInfo/RoomInfoPostRepository.java @@ -13,10 +13,10 @@ @Repository public interface RoomInfoPostRepository extends JpaRepository { @Query("SELECT new gaji.service.domain.roomBoard.web.dto.RoomPostResponseDto$InfoPostSummaryDto(" + - "r.id, r.title, r.studyMate.user.nickname, r.createdAt, r.viewCount, SIZE(r.infoPostCommentList)) " + + "r.id, r.title, r.studyMate.user.nickname, r.postTime, r.viewCount, SIZE(r.infoPostCommentList)) " + "FROM RoomInfoPost r " + "WHERE r.roomBoard.id = :boardId AND r.id < :lastPostId " + - "ORDER BY r.createdAt DESC") + "ORDER BY r.postTime DESC") List findInfoPostSummariesForInfiniteScroll( @Param("boardId") Long boardId, @Param("lastPostId") Long lastPostId, diff --git a/src/main/java/gaji/service/domain/roomBoard/repository/RoomPost/RoomPostRepository.java b/src/main/java/gaji/service/domain/roomBoard/repository/RoomPost/RoomPostRepository.java index 703e8184..d25e548e 100644 --- a/src/main/java/gaji/service/domain/roomBoard/repository/RoomPost/RoomPostRepository.java +++ b/src/main/java/gaji/service/domain/roomBoard/repository/RoomPost/RoomPostRepository.java @@ -13,10 +13,10 @@ @Repository public interface RoomPostRepository extends JpaRepository { @Query("SELECT new gaji.service.domain.roomBoard.web.dto.RoomPostResponseDto$PostSummaryDto(" + - "r.id, r.title, r.studyMate.user.nickname, r.createdAt, r.viewCount, SIZE(r.postCommentList)) " + + "r.id, r.title, r.studyMate.user.nickname, r.postTime, r.viewCount, SIZE(r.postCommentList)) " + "FROM RoomPost r " + "WHERE r.roomBoard.id = :boardId AND r.id < :lastPostId " + - "ORDER BY r.createdAt DESC") + "ORDER BY r.postTime DESC") List findPostSummariesForInfiniteScroll( @Param("boardId") Long boardId, @Param("lastPostId") Long lastPostId, diff --git a/src/main/java/gaji/service/domain/studyMate/entity/StudyMate.java b/src/main/java/gaji/service/domain/studyMate/entity/StudyMate.java index 2a796f18..8e36f2c2 100644 --- a/src/main/java/gaji/service/domain/studyMate/entity/StudyMate.java +++ b/src/main/java/gaji/service/domain/studyMate/entity/StudyMate.java @@ -4,10 +4,7 @@ import gaji.service.domain.room.entity.Room; import gaji.service.domain.room.entity.RoomNotice; import gaji.service.domain.roomBoard.entity.RoomInfo.RoomInfoPost; -import gaji.service.domain.roomBoard.entity.RoomInfo.RoomInfoPostBookmark; -import gaji.service.domain.roomBoard.entity.RoomInfo.RoomInfoPostLikes; import gaji.service.domain.roomBoard.entity.RoomPost.RoomPost; -import gaji.service.domain.roomBoard.entity.RoomPost.RoomPostBookmark; import gaji.service.domain.roomBoard.entity.RoomPost.RoomPostLikes; import gaji.service.domain.roomBoard.entity.RoomTrouble.RoomTroublePost; import gaji.service.domain.roomBoard.entity.RoomTrouble.RoomTroublePostBookmark; @@ -59,12 +56,6 @@ public class StudyMate { @OneToMany(mappedBy = "studyMate", cascade = CascadeType.ALL) private List roomInfoPostList = new ArrayList<>(); - @OneToMany(mappedBy = "studyMate", cascade = CascadeType.ALL) - private List roomInfoPostLikesList = new ArrayList<>(); - - @OneToMany(mappedBy = "studyMate", cascade = CascadeType.ALL) - private List roomInfoPostBookmarkList = new ArrayList<>(); - //게시글 @OneToMany(mappedBy = "studyMate", cascade = CascadeType.ALL) @@ -73,9 +64,6 @@ public class StudyMate { @OneToMany(mappedBy = "studyMate", cascade = CascadeType.ALL) private List roomPostLikesList = new ArrayList<>(); - @OneToMany(mappedBy = "studyMate", cascade = CascadeType.ALL) - private List roomPostBookmarkList = new ArrayList<>(); - @Enumerated(EnumType.STRING) private Role role; From dbddf88fe4071d0ea7ad9eb823ed3e9255ade7af Mon Sep 17 00:00:00 2001 From: mmingoo Date: Sun, 18 Aug 2024 18:48:30 +0900 Subject: [PATCH 23/24] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20conflict=20=ED=95=B4?= =?UTF-8?q?=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/post/converter/CommunityPostConverter.java | 4 ++-- .../domain/post/repository/CommentQueryDslRepository.java | 2 +- .../post/repository/CommentQueryDslRepositoryImpl.java | 2 +- .../post/repository/CommunityPostQueryDslRepository.java | 2 +- .../repository/CommunityPostQueryDslRepositoryImpl.java | 2 +- .../domain/post/service/CommunityPostCommandService.java | 2 +- .../post/service/CommunityPostCommandServiceImpl.java | 4 ++-- .../domain/post/service/CommunityPostQueryService.java | 2 +- .../domain/post/service/CommunityPostQueryServiceImpl.java | 2 +- .../post/web/controller/CommunityPostRestController.java | 6 +++--- .../gaji/service/domain/post/web/dto/PostRequestDTO.java | 3 +-- 11 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/main/java/gaji/service/domain/post/converter/CommunityPostConverter.java b/src/main/java/gaji/service/domain/post/converter/CommunityPostConverter.java index ffa11300..7c35cc03 100644 --- a/src/main/java/gaji/service/domain/post/converter/CommunityPostConverter.java +++ b/src/main/java/gaji/service/domain/post/converter/CommunityPostConverter.java @@ -6,14 +6,14 @@ import gaji.service.domain.common.web.dto.HashtagResponseDTO; import gaji.service.domain.enums.PostStatusEnum; import gaji.service.domain.enums.PostTypeEnum; -import gaji.service.domain.post.entity.CommunityComment; import gaji.service.domain.post.entity.CommnuityPost; +import gaji.service.domain.post.entity.CommunityComment; import gaji.service.domain.post.entity.PostBookmark; import gaji.service.domain.post.entity.PostLikes; import gaji.service.domain.post.service.CommunityPostBookMarkService; import gaji.service.domain.post.service.CommunityPostLikesService; -import gaji.service.domain.post.web.dto.PostRequestDTO; import gaji.service.domain.post.web.dto.CommunityPostResponseDTO; +import gaji.service.domain.post.web.dto.PostRequestDTO; import gaji.service.domain.user.entity.User; import gaji.service.global.converter.DateConverter; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/gaji/service/domain/post/repository/CommentQueryDslRepository.java b/src/main/java/gaji/service/domain/post/repository/CommentQueryDslRepository.java index c41516d1..ed4d66d3 100644 --- a/src/main/java/gaji/service/domain/post/repository/CommentQueryDslRepository.java +++ b/src/main/java/gaji/service/domain/post/repository/CommentQueryDslRepository.java @@ -1,7 +1,7 @@ package gaji.service.domain.post.repository; -import gaji.service.domain.post.entity.CommunityComment; import gaji.service.domain.post.entity.CommnuityPost; +import gaji.service.domain.post.entity.CommunityComment; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Slice; diff --git a/src/main/java/gaji/service/domain/post/repository/CommentQueryDslRepositoryImpl.java b/src/main/java/gaji/service/domain/post/repository/CommentQueryDslRepositoryImpl.java index 8d54c6a1..4626924c 100644 --- a/src/main/java/gaji/service/domain/post/repository/CommentQueryDslRepositoryImpl.java +++ b/src/main/java/gaji/service/domain/post/repository/CommentQueryDslRepositoryImpl.java @@ -3,8 +3,8 @@ import com.querydsl.core.types.OrderSpecifier; import com.querydsl.core.types.dsl.BooleanExpression; import com.querydsl.jpa.impl.JPAQueryFactory; -import gaji.service.domain.post.entity.CommunityComment; import gaji.service.domain.post.entity.CommnuityPost; +import gaji.service.domain.post.entity.CommunityComment; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Slice; diff --git a/src/main/java/gaji/service/domain/post/repository/CommunityPostQueryDslRepository.java b/src/main/java/gaji/service/domain/post/repository/CommunityPostQueryDslRepository.java index ab8deddb..b074160f 100644 --- a/src/main/java/gaji/service/domain/post/repository/CommunityPostQueryDslRepository.java +++ b/src/main/java/gaji/service/domain/post/repository/CommunityPostQueryDslRepository.java @@ -1,9 +1,9 @@ package gaji.service.domain.post.repository; import com.querydsl.core.Tuple; -import gaji.service.domain.enums.SortType; import gaji.service.domain.enums.PostStatusEnum; import gaji.service.domain.enums.PostTypeEnum; +import gaji.service.domain.enums.SortType; import gaji.service.domain.post.entity.CommnuityPost; import gaji.service.domain.user.entity.User; import org.springframework.data.domain.Pageable; diff --git a/src/main/java/gaji/service/domain/post/repository/CommunityPostQueryDslRepositoryImpl.java b/src/main/java/gaji/service/domain/post/repository/CommunityPostQueryDslRepositoryImpl.java index d0675c8f..36deb533 100644 --- a/src/main/java/gaji/service/domain/post/repository/CommunityPostQueryDslRepositoryImpl.java +++ b/src/main/java/gaji/service/domain/post/repository/CommunityPostQueryDslRepositoryImpl.java @@ -5,9 +5,9 @@ import com.querydsl.core.types.dsl.BooleanExpression; import com.querydsl.jpa.impl.JPAQueryFactory; import gaji.service.domain.common.service.CategoryService; -import gaji.service.domain.enums.SortType; import gaji.service.domain.enums.PostStatusEnum; import gaji.service.domain.enums.PostTypeEnum; +import gaji.service.domain.enums.SortType; import gaji.service.domain.post.entity.CommnuityPost; import gaji.service.domain.user.entity.User; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/gaji/service/domain/post/service/CommunityPostCommandService.java b/src/main/java/gaji/service/domain/post/service/CommunityPostCommandService.java index 3ed481d6..5f653338 100644 --- a/src/main/java/gaji/service/domain/post/service/CommunityPostCommandService.java +++ b/src/main/java/gaji/service/domain/post/service/CommunityPostCommandService.java @@ -1,7 +1,7 @@ package gaji.service.domain.post.service; -import gaji.service.domain.post.entity.CommunityComment; import gaji.service.domain.post.entity.CommnuityPost; +import gaji.service.domain.post.entity.CommunityComment; import gaji.service.domain.post.entity.PostBookmark; import gaji.service.domain.post.entity.PostLikes; import gaji.service.domain.post.web.dto.PostRequestDTO; diff --git a/src/main/java/gaji/service/domain/post/service/CommunityPostCommandServiceImpl.java b/src/main/java/gaji/service/domain/post/service/CommunityPostCommandServiceImpl.java index 31e9db7d..1a1deb98 100644 --- a/src/main/java/gaji/service/domain/post/service/CommunityPostCommandServiceImpl.java +++ b/src/main/java/gaji/service/domain/post/service/CommunityPostCommandServiceImpl.java @@ -9,13 +9,13 @@ import gaji.service.domain.common.service.CategoryService; import gaji.service.domain.common.service.HashtagService; import gaji.service.domain.post.converter.CommunityPostConverter; -import gaji.service.domain.post.entity.CommunityComment; import gaji.service.domain.post.entity.CommnuityPost; +import gaji.service.domain.post.entity.CommunityComment; import gaji.service.domain.post.entity.PostBookmark; import gaji.service.domain.post.entity.PostLikes; import gaji.service.domain.post.repository.CommunityPostBookmarkRepository; -import gaji.service.domain.post.repository.CommunityPostLikesRepository; import gaji.service.domain.post.repository.CommunityPostJpaRepository; +import gaji.service.domain.post.repository.CommunityPostLikesRepository; import gaji.service.domain.post.web.dto.PostRequestDTO; import gaji.service.domain.user.entity.User; import gaji.service.domain.user.service.UserQueryService; diff --git a/src/main/java/gaji/service/domain/post/service/CommunityPostQueryService.java b/src/main/java/gaji/service/domain/post/service/CommunityPostQueryService.java index d43c21c1..fb000603 100644 --- a/src/main/java/gaji/service/domain/post/service/CommunityPostQueryService.java +++ b/src/main/java/gaji/service/domain/post/service/CommunityPostQueryService.java @@ -1,8 +1,8 @@ package gaji.service.domain.post.service; -import gaji.service.domain.enums.SortType; import gaji.service.domain.enums.PostStatusEnum; import gaji.service.domain.enums.PostTypeEnum; +import gaji.service.domain.enums.SortType; import gaji.service.domain.post.entity.CommnuityPost; import org.springframework.data.domain.Slice; diff --git a/src/main/java/gaji/service/domain/post/service/CommunityPostQueryServiceImpl.java b/src/main/java/gaji/service/domain/post/service/CommunityPostQueryServiceImpl.java index a073ec29..275b48dd 100644 --- a/src/main/java/gaji/service/domain/post/service/CommunityPostQueryServiceImpl.java +++ b/src/main/java/gaji/service/domain/post/service/CommunityPostQueryServiceImpl.java @@ -1,8 +1,8 @@ package gaji.service.domain.post.service; -import gaji.service.domain.enums.SortType; import gaji.service.domain.enums.PostStatusEnum; import gaji.service.domain.enums.PostTypeEnum; +import gaji.service.domain.enums.SortType; import gaji.service.domain.post.code.CommunityPostErrorStatus; import gaji.service.domain.post.entity.CommnuityPost; import gaji.service.domain.post.repository.CommunityPostBookmarkRepository; diff --git a/src/main/java/gaji/service/domain/post/web/controller/CommunityPostRestController.java b/src/main/java/gaji/service/domain/post/web/controller/CommunityPostRestController.java index d60faec8..42fb4b60 100644 --- a/src/main/java/gaji/service/domain/post/web/controller/CommunityPostRestController.java +++ b/src/main/java/gaji/service/domain/post/web/controller/CommunityPostRestController.java @@ -1,20 +1,20 @@ package gaji.service.domain.post.web.controller; -import gaji.service.domain.enums.SortType; import gaji.service.domain.enums.PostStatusEnum; import gaji.service.domain.enums.PostTypeEnum; +import gaji.service.domain.enums.SortType; import gaji.service.domain.post.converter.CommunityCommentConverter; import gaji.service.domain.post.converter.CommunityPostConverter; -import gaji.service.domain.post.entity.CommunityComment; import gaji.service.domain.post.entity.CommnuityPost; +import gaji.service.domain.post.entity.CommunityComment; import gaji.service.domain.post.entity.PostBookmark; import gaji.service.domain.post.entity.PostLikes; import gaji.service.domain.post.service.CommunityCommentService; import gaji.service.domain.post.service.CommunityPostCommandService; import gaji.service.domain.post.service.CommunityPostQueryService; import gaji.service.domain.post.web.dto.CommunityPostCommentResponseDTO; -import gaji.service.domain.post.web.dto.PostRequestDTO; import gaji.service.domain.post.web.dto.CommunityPostResponseDTO; +import gaji.service.domain.post.web.dto.PostRequestDTO; import gaji.service.global.base.BaseResponse; import gaji.service.jwt.service.TokenProviderService; import io.swagger.v3.oas.annotations.Operation; diff --git a/src/main/java/gaji/service/domain/post/web/dto/PostRequestDTO.java b/src/main/java/gaji/service/domain/post/web/dto/PostRequestDTO.java index e80e0798..ef938b35 100644 --- a/src/main/java/gaji/service/domain/post/web/dto/PostRequestDTO.java +++ b/src/main/java/gaji/service/domain/post/web/dto/PostRequestDTO.java @@ -1,8 +1,7 @@ package gaji.service.domain.post.web.dto; -import gaji.service.domain.common.annotation.CheckHashtagLength; -import gaji.service.domain.common.annotation.ExistsCategory; import gaji.service.domain.common.annotation.CheckHashtagBlank; +import gaji.service.domain.common.annotation.CheckHashtagLength; import gaji.service.domain.enums.PostTypeEnum; import gaji.service.domain.post.annotation.ExistPostType; import io.swagger.v3.oas.annotations.media.Schema; From 33bc0588b3f07f9a8539ebdae9c498fb0a1d762b Mon Sep 17 00:00:00 2001 From: mmingoo Date: Sun, 18 Aug 2024 19:01:22 +0900 Subject: [PATCH 24/24] =?UTF-8?q?=F0=9F=90=9B=20pull=20origin=20develop=20?= =?UTF-8?q?=ED=9B=84=20=EC=83=9D=EA=B8=B0=EB=8A=94=20=EB=B2=84=EA=B7=B8=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/repository/SelectCategoryRepository.java | 2 -- .../domain/common/service/CategoryServiceImpl.java | 1 - .../common/validation/HashtagLengthValidator.java | 1 - .../domain/recruit/converter/RecruitConverter.java | 4 ++-- .../repository/StudyCommentCustomRepositoryImpl.java | 1 + .../recruit/service/RecruitQueryServiceImpl.java | 5 +++-- .../recruit/web/controller/RecruitController.java | 1 - .../room/web/controller/RoomNoticeController.java | 1 - .../domain/roomBoard/converter/RoomPostConverter.java | 2 -- .../domain/roomBoard/entity/RoomInfo/RoomInfoPost.java | 1 - .../domain/roomBoard/entity/RoomPost/RoomPost.java | 1 - .../roomBoard/entity/RoomPost/RoomPostLikes.java | 2 +- .../roomBoard/entity/RoomTrouble/RoomTroublePost.java | 1 - .../repository/RoomInfo/RoomInfoPostRepository.java | 4 ++-- .../repository/RoomPost/RoomPostRepository.java | 10 +++++----- .../service/RoomPost/RoomPostCommandServiceImpl.java | 1 - .../web/controller/RoomInfoPostController.java | 1 - .../roomBoard/web/controller/RoomPostController.java | 1 - .../web/controller/RoomTroublePostController.java | 10 +++------- .../java/gaji/service/domain/user/entity/User.java | 4 ++-- 20 files changed, 19 insertions(+), 35 deletions(-) diff --git a/src/main/java/gaji/service/domain/common/repository/SelectCategoryRepository.java b/src/main/java/gaji/service/domain/common/repository/SelectCategoryRepository.java index 07479778..16af3119 100644 --- a/src/main/java/gaji/service/domain/common/repository/SelectCategoryRepository.java +++ b/src/main/java/gaji/service/domain/common/repository/SelectCategoryRepository.java @@ -4,8 +4,6 @@ import gaji.service.domain.enums.PostTypeEnum; import org.springframework.data.jpa.repository.JpaRepository; -import java.util.List; - public interface SelectCategoryRepository extends JpaRepository, SelectCategoryQueryDslRepository { SelectCategory findByEntityIdAndType(Long entityId, PostTypeEnum type); diff --git a/src/main/java/gaji/service/domain/common/service/CategoryServiceImpl.java b/src/main/java/gaji/service/domain/common/service/CategoryServiceImpl.java index 40d392eb..d0a3a561 100644 --- a/src/main/java/gaji/service/domain/common/service/CategoryServiceImpl.java +++ b/src/main/java/gaji/service/domain/common/service/CategoryServiceImpl.java @@ -15,7 +15,6 @@ import org.springframework.transaction.annotation.Transactional; import java.util.List; -import java.util.stream.Collectors; @Service @RequiredArgsConstructor diff --git a/src/main/java/gaji/service/domain/common/validation/HashtagLengthValidator.java b/src/main/java/gaji/service/domain/common/validation/HashtagLengthValidator.java index 074312d8..3b8e4b71 100644 --- a/src/main/java/gaji/service/domain/common/validation/HashtagLengthValidator.java +++ b/src/main/java/gaji/service/domain/common/validation/HashtagLengthValidator.java @@ -1,6 +1,5 @@ package gaji.service.domain.common.validation; -import gaji.service.domain.common.annotation.CheckHashtagBlank; import gaji.service.domain.common.annotation.CheckHashtagLength; import gaji.service.global.exception.code.status.GlobalErrorStatus; import jakarta.validation.ConstraintValidator; diff --git a/src/main/java/gaji/service/domain/recruit/converter/RecruitConverter.java b/src/main/java/gaji/service/domain/recruit/converter/RecruitConverter.java index 3f7c1b7a..8729e132 100644 --- a/src/main/java/gaji/service/domain/recruit/converter/RecruitConverter.java +++ b/src/main/java/gaji/service/domain/recruit/converter/RecruitConverter.java @@ -2,16 +2,16 @@ import gaji.service.domain.common.entity.SelectCategory; import gaji.service.domain.enums.CategoryEnum; +import gaji.service.domain.enums.Role; import gaji.service.domain.recruit.entity.RecruitPostBookmark; import gaji.service.domain.recruit.entity.RecruitPostLikes; -import gaji.service.domain.user.entity.User; -import gaji.service.domain.enums.Role; import gaji.service.domain.recruit.entity.StudyComment; import gaji.service.domain.recruit.web.dto.RecruitRequestDTO; import gaji.service.domain.recruit.web.dto.RecruitResponseDTO; import gaji.service.domain.room.entity.Material; import gaji.service.domain.room.entity.Room; import gaji.service.domain.studyMate.entity.StudyMate; +import gaji.service.domain.user.entity.User; import gaji.service.global.converter.DateConverter; import org.springframework.data.domain.Slice; import org.springframework.stereotype.Component; diff --git a/src/main/java/gaji/service/domain/recruit/repository/StudyCommentCustomRepositoryImpl.java b/src/main/java/gaji/service/domain/recruit/repository/StudyCommentCustomRepositoryImpl.java index f085045f..2c592510 100644 --- a/src/main/java/gaji/service/domain/recruit/repository/StudyCommentCustomRepositoryImpl.java +++ b/src/main/java/gaji/service/domain/recruit/repository/StudyCommentCustomRepositoryImpl.java @@ -10,6 +10,7 @@ import org.springframework.data.domain.Slice; import org.springframework.data.domain.SliceImpl; import org.springframework.stereotype.Repository; + import java.util.List; import static gaji.service.domain.recruit.entity.QStudyComment.studyComment; diff --git a/src/main/java/gaji/service/domain/recruit/service/RecruitQueryServiceImpl.java b/src/main/java/gaji/service/domain/recruit/service/RecruitQueryServiceImpl.java index e3dc137e..4e19bdcd 100644 --- a/src/main/java/gaji/service/domain/recruit/service/RecruitQueryServiceImpl.java +++ b/src/main/java/gaji/service/domain/recruit/service/RecruitQueryServiceImpl.java @@ -9,11 +9,11 @@ import gaji.service.domain.recruit.code.RecruitErrorStatus; import gaji.service.domain.recruit.converter.RecruitConverter; import gaji.service.domain.recruit.repository.RecruitRepository; +import gaji.service.domain.recruit.web.dto.RecruitResponseDTO; +import gaji.service.domain.room.entity.Room; import gaji.service.domain.room.service.RoomCommandService; import gaji.service.domain.room.service.RoomQueryService; import gaji.service.domain.user.entity.User; -import gaji.service.domain.recruit.web.dto.RecruitResponseDTO; -import gaji.service.domain.room.entity.Room; import gaji.service.domain.user.service.UserQueryService; import gaji.service.global.exception.RestApiException; import lombok.RequiredArgsConstructor; @@ -21,6 +21,7 @@ import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; + import java.util.ArrayList; import java.util.Arrays; import java.util.List; diff --git a/src/main/java/gaji/service/domain/recruit/web/controller/RecruitController.java b/src/main/java/gaji/service/domain/recruit/web/controller/RecruitController.java index 447838e1..66c9f4fb 100644 --- a/src/main/java/gaji/service/domain/recruit/web/controller/RecruitController.java +++ b/src/main/java/gaji/service/domain/recruit/web/controller/RecruitController.java @@ -12,7 +12,6 @@ import gaji.service.global.base.BaseResponse; import gaji.service.jwt.service.TokenProviderService; import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.responses.ApiResponse; import jakarta.validation.Valid; import jakarta.validation.constraints.Min; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/gaji/service/domain/room/web/controller/RoomNoticeController.java b/src/main/java/gaji/service/domain/room/web/controller/RoomNoticeController.java index b9a76a29..b418b018 100644 --- a/src/main/java/gaji/service/domain/room/web/controller/RoomNoticeController.java +++ b/src/main/java/gaji/service/domain/room/web/controller/RoomNoticeController.java @@ -11,7 +11,6 @@ import io.swagger.v3.oas.annotations.Operation; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; -import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; import java.util.List; diff --git a/src/main/java/gaji/service/domain/roomBoard/converter/RoomPostConverter.java b/src/main/java/gaji/service/domain/roomBoard/converter/RoomPostConverter.java index e3f79e95..9607d4b0 100644 --- a/src/main/java/gaji/service/domain/roomBoard/converter/RoomPostConverter.java +++ b/src/main/java/gaji/service/domain/roomBoard/converter/RoomPostConverter.java @@ -11,8 +11,6 @@ import gaji.service.domain.roomBoard.web.dto.RoomPostResponseDto; import gaji.service.domain.studyMate.entity.StudyMate; -import java.time.LocalDateTime; - public class RoomPostConverter { public static RoomPost toRoomPost(RoomPostRequestDto.RoomPostDto requestDto, StudyMate studyMate, RoomBoard roomBoard) { diff --git a/src/main/java/gaji/service/domain/roomBoard/entity/RoomInfo/RoomInfoPost.java b/src/main/java/gaji/service/domain/roomBoard/entity/RoomInfo/RoomInfoPost.java index 9989830b..af23abcf 100644 --- a/src/main/java/gaji/service/domain/roomBoard/entity/RoomInfo/RoomInfoPost.java +++ b/src/main/java/gaji/service/domain/roomBoard/entity/RoomInfo/RoomInfoPost.java @@ -6,7 +6,6 @@ import jakarta.persistence.*; import lombok.*; -import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPost.java b/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPost.java index 503b9bb9..8182064c 100644 --- a/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPost.java +++ b/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPost.java @@ -6,7 +6,6 @@ import jakarta.persistence.*; import lombok.*; -import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPostLikes.java b/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPostLikes.java index 55209dad..01ee16b7 100644 --- a/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPostLikes.java +++ b/src/main/java/gaji/service/domain/roomBoard/entity/RoomPost/RoomPostLikes.java @@ -15,7 +15,7 @@ public class RoomPostLikes { private Long id; @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "user_id") + @JoinColumn(name = "study_mate_id") private StudyMate studyMate; @ManyToOne(fetch = FetchType.LAZY) diff --git a/src/main/java/gaji/service/domain/roomBoard/entity/RoomTrouble/RoomTroublePost.java b/src/main/java/gaji/service/domain/roomBoard/entity/RoomTrouble/RoomTroublePost.java index 90cbb7a9..e1e7df4f 100644 --- a/src/main/java/gaji/service/domain/roomBoard/entity/RoomTrouble/RoomTroublePost.java +++ b/src/main/java/gaji/service/domain/roomBoard/entity/RoomTrouble/RoomTroublePost.java @@ -6,7 +6,6 @@ import jakarta.persistence.*; import lombok.*; -import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/gaji/service/domain/roomBoard/repository/RoomInfo/RoomInfoPostRepository.java b/src/main/java/gaji/service/domain/roomBoard/repository/RoomInfo/RoomInfoPostRepository.java index d22d76af..e7bd5f9a 100644 --- a/src/main/java/gaji/service/domain/roomBoard/repository/RoomInfo/RoomInfoPostRepository.java +++ b/src/main/java/gaji/service/domain/roomBoard/repository/RoomInfo/RoomInfoPostRepository.java @@ -13,10 +13,10 @@ @Repository public interface RoomInfoPostRepository extends JpaRepository { @Query("SELECT new gaji.service.domain.roomBoard.web.dto.RoomPostResponseDto$InfoPostSummaryDto(" + - "r.id, r.title, r.studyMate.user.nickname, r.postTime, r.viewCount, SIZE(r.infoPostCommentList)) " + + "r.id, r.title, r.studyMate.user.nickname, r.createdAt, r.viewCount, SIZE(r.infoPostCommentList)) " + "FROM RoomInfoPost r " + "WHERE r.roomBoard.id = :boardId AND r.id < :lastPostId " + - "ORDER BY r.postTime DESC") + "ORDER BY r.createdAt DESC") List findInfoPostSummariesForInfiniteScroll( @Param("boardId") Long boardId, @Param("lastPostId") Long lastPostId, diff --git a/src/main/java/gaji/service/domain/roomBoard/repository/RoomPost/RoomPostRepository.java b/src/main/java/gaji/service/domain/roomBoard/repository/RoomPost/RoomPostRepository.java index d25e548e..b7167798 100644 --- a/src/main/java/gaji/service/domain/roomBoard/repository/RoomPost/RoomPostRepository.java +++ b/src/main/java/gaji/service/domain/roomBoard/repository/RoomPost/RoomPostRepository.java @@ -1,7 +1,7 @@ package gaji.service.domain.roomBoard.repository.RoomPost; -import gaji.service.domain.roomBoard.web.dto.RoomPostResponseDto; -import gaji.service.domain.roomBoard.web.dto.RoomPostResponseDto.*; + import gaji.service.domain.roomBoard.entity.RoomPost.RoomPost; +import gaji.service.domain.roomBoard.web.dto.RoomPostResponseDto.PostSummaryDto; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; @@ -13,11 +13,11 @@ @Repository public interface RoomPostRepository extends JpaRepository { @Query("SELECT new gaji.service.domain.roomBoard.web.dto.RoomPostResponseDto$PostSummaryDto(" + - "r.id, r.title, r.studyMate.user.nickname, r.postTime, r.viewCount, SIZE(r.postCommentList)) " + + "r.id, r.title, r.studyMate.user.nickname, r.createdAt, r.viewCount, SIZE(r.postCommentList)) " + "FROM RoomPost r " + "WHERE r.roomBoard.id = :boardId AND r.id < :lastPostId " + - "ORDER BY r.postTime DESC") - List findPostSummariesForInfiniteScroll( + "ORDER BY r.createdAt DESC") + List findPostSummariesForInfiniteScroll( @Param("boardId") Long boardId, @Param("lastPostId") Long lastPostId, Pageable pageable); diff --git a/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandServiceImpl.java b/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandServiceImpl.java index 1355b4e3..3be8b1c0 100644 --- a/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandServiceImpl.java +++ b/src/main/java/gaji/service/domain/roomBoard/service/RoomPost/RoomPostCommandServiceImpl.java @@ -10,7 +10,6 @@ import gaji.service.domain.roomBoard.entity.RoomPost.RoomPost; import gaji.service.domain.roomBoard.entity.RoomPost.RoomPostBookmark; import gaji.service.domain.roomBoard.entity.RoomPost.RoomPostLikes; -import gaji.service.domain.roomBoard.entity.RoomTrouble.TroublePostComment; import gaji.service.domain.roomBoard.repository.RoomBoardRepository; import gaji.service.domain.roomBoard.repository.RoomPost.PostCommentRepository; import gaji.service.domain.roomBoard.repository.RoomPost.RoomPostBookmarkRepository; diff --git a/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomInfoPostController.java b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomInfoPostController.java index 3b1626be..7db04d09 100644 --- a/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomInfoPostController.java +++ b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomInfoPostController.java @@ -2,7 +2,6 @@ import gaji.service.domain.roomBoard.converter.RoomPostConverter; import gaji.service.domain.roomBoard.entity.RoomInfo.InfoPostComment; -import gaji.service.domain.roomBoard.entity.RoomPost.PostComment; import gaji.service.domain.roomBoard.service.RoomInfo.RoomInfoPostCommandService; import gaji.service.domain.roomBoard.service.RoomInfo.RoomInfoPostQueryService; import gaji.service.domain.roomBoard.web.dto.RoomPostRequestDto; diff --git a/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomPostController.java b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomPostController.java index db30589b..10674759 100644 --- a/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomPostController.java +++ b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomPostController.java @@ -2,7 +2,6 @@ import gaji.service.domain.roomBoard.converter.RoomPostConverter; import gaji.service.domain.roomBoard.entity.RoomPost.PostComment; -import gaji.service.domain.roomBoard.entity.RoomTrouble.TroublePostComment; import gaji.service.domain.roomBoard.service.RoomPost.RoomPostCommandService; import gaji.service.domain.roomBoard.service.RoomPost.RoomPostQueryService; import gaji.service.domain.roomBoard.web.dto.RoomPostRequestDto; diff --git a/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomTroublePostController.java b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomTroublePostController.java index bc14765a..6e078207 100644 --- a/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomTroublePostController.java +++ b/src/main/java/gaji/service/domain/roomBoard/web/controller/RoomTroublePostController.java @@ -2,10 +2,8 @@ import gaji.service.domain.roomBoard.converter.RoomPostConverter; import gaji.service.domain.roomBoard.entity.RoomTrouble.TroublePostComment; -import gaji.service.domain.roomBoard.service.RoomPost.RoomPostQueryService; import gaji.service.domain.roomBoard.service.RoomTrouble.RoomTroublePostCommandService; import gaji.service.domain.roomBoard.service.RoomTrouble.RoomTroublePostQueryService; -import gaji.service.domain.roomBoard.service.RoomTrouble.RoomTroublePostQueryServiceImpl; import gaji.service.domain.roomBoard.web.dto.RoomPostRequestDto; import gaji.service.domain.roomBoard.web.dto.RoomPostResponseDto; import gaji.service.global.base.BaseResponse; @@ -28,7 +26,7 @@ public class RoomTroublePostController { private final RoomTroublePostCommandService roomTroublePostCommandService; private final RoomTroublePostQueryService roomTroublePostQueryService; @PostMapping("/trouble/{roomId}") - @Operation(summary = "스터디룸 트러블슈팅 게시판 게시글 등록 API") + @Operation(summary = "스터디룸 트러블슈팅 게시판 등록 API") public BaseResponse TroublePostController( @RequestHeader("Authorization") String authorization, @RequestBody @Valid RoomPostRequestDto.RoomTroubloePostDto requestDto, @@ -162,7 +160,7 @@ public BaseResponse addReply( @GetMapping("/{boardId}/trouble") @Operation(summary = "트러블 슈팅 게시글 무한 스크롤 조회", description = "트러블 슈팅 게시글을 무한 스크롤 방식으로 조회합니다.") @ApiResponse(responseCode = "200", description = "조회 성공") - public BaseResponse getNextTroublePosts( + public BaseResponse> getNextTroublePosts( @PathVariable @Parameter(description = "게시판 ID") Long boardId, @RequestParam @Parameter(description = "마지막으로 로드된 게시글 ID") Long lastPostId, @RequestParam(defaultValue = "10") @Parameter(description = "조회할 게시글 수") int size) { @@ -170,9 +168,7 @@ public BaseResponse getNextTroubl List posts = roomTroublePostQueryService.getNextTroublePosts(boardId, lastPostId, size); - return BaseResponse.onSuccess( - new RoomPostResponseDto.TroublePostSummaryListDto(posts) - ); + return BaseResponse.onSuccess(posts); } } diff --git a/src/main/java/gaji/service/domain/user/entity/User.java b/src/main/java/gaji/service/domain/user/entity/User.java index ce74fa35..129d6f56 100644 --- a/src/main/java/gaji/service/domain/user/entity/User.java +++ b/src/main/java/gaji/service/domain/user/entity/User.java @@ -9,8 +9,8 @@ import gaji.service.domain.enums.SocialType; import gaji.service.domain.enums.UserActive; import gaji.service.domain.message.entity.Message; -import gaji.service.domain.post.entity.Comment; -import gaji.service.domain.post.entity.Post; +import gaji.service.domain.post.entity.CommnuityPost; +import gaji.service.domain.post.entity.CommunityComment; import gaji.service.domain.post.entity.PostFile; import gaji.service.domain.post.entity.PostLikes; import gaji.service.domain.recruit.entity.RecruitPostBookmark;