From 5f6b6f342742e27d39442477162bc069d66c3243 Mon Sep 17 00:00:00 2001 From: Jo Seonggyu Date: Fri, 22 Sep 2023 14:37:56 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EC=9D=B4=EC=A0=84=EA=B8=80=20=EB=8B=A4?= =?UTF-8?q?=EC=9D=8C=20=EA=B8=80=20isDelete,isPrivate=20=EC=A1=B0=EA=B1=B4?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80=20(#151)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: 이전글 다음 글 isDelete 추가 * fix: ktlint 수정 --------- Co-authored-by: 우혁준 (HyukJoon Woo) Co-authored-by: Junhyeong Kim --- .../csereal/core/news/database/NewsRepository.kt | 9 +++++++-- .../csereal/core/news/service/NewsService.kt | 10 ++++++++-- .../csereal/core/notice/database/NoticeRepository.kt | 12 ++++++++---- .../csereal/core/notice/service/NoticeService.kt | 8 ++++++-- .../core/seminar/database/SeminarRepository.kt | 8 ++++++-- .../csereal/core/seminar/service/SeminarService.kt | 8 ++++++-- 6 files changed, 41 insertions(+), 14 deletions(-) diff --git a/src/main/kotlin/com/wafflestudio/csereal/core/news/database/NewsRepository.kt b/src/main/kotlin/com/wafflestudio/csereal/core/news/database/NewsRepository.kt index 43da67ea..964e8273 100644 --- a/src/main/kotlin/com/wafflestudio/csereal/core/news/database/NewsRepository.kt +++ b/src/main/kotlin/com/wafflestudio/csereal/core/news/database/NewsRepository.kt @@ -24,8 +24,13 @@ import java.time.LocalDateTime interface NewsRepository : JpaRepository, CustomNewsRepository { fun findAllByIsPrivateFalseAndIsImportantTrueAndIsDeletedFalse(): List fun findAllByIsImportantTrueAndIsDeletedFalse(): List - fun findFirstByCreatedAtLessThanOrderByCreatedAtDesc(timestamp: LocalDateTime): NewsEntity? - fun findFirstByCreatedAtGreaterThanOrderByCreatedAtAsc(timestamp: LocalDateTime): NewsEntity? + fun findFirstByIsDeletedFalseAndIsPrivateFalseAndCreatedAtLessThanOrderByCreatedAtDesc( + timestamp: LocalDateTime + ): NewsEntity? + + fun findFirstByIsDeletedFalseAndIsPrivateFalseAndCreatedAtGreaterThanOrderByCreatedAtAsc( + timestamp: LocalDateTime + ): NewsEntity? } interface CustomNewsRepository { diff --git a/src/main/kotlin/com/wafflestudio/csereal/core/news/service/NewsService.kt b/src/main/kotlin/com/wafflestudio/csereal/core/news/service/NewsService.kt index 8bd1448c..9bddd8e3 100644 --- a/src/main/kotlin/com/wafflestudio/csereal/core/news/service/NewsService.kt +++ b/src/main/kotlin/com/wafflestudio/csereal/core/news/service/NewsService.kt @@ -80,8 +80,14 @@ class NewsServiceImpl( val imageURL = mainImageService.createImageURL(news.mainImage) val attachmentResponses = attachmentService.createAttachmentResponses(news.attachments) - val prevNews = newsRepository.findFirstByCreatedAtLessThanOrderByCreatedAtDesc(news.createdAt!!) - val nextNews = newsRepository.findFirstByCreatedAtGreaterThanOrderByCreatedAtAsc(news.createdAt!!) + val prevNews = + newsRepository.findFirstByIsDeletedFalseAndIsPrivateFalseAndCreatedAtLessThanOrderByCreatedAtDesc( + news.createdAt!! + ) + val nextNews = + newsRepository.findFirstByIsDeletedFalseAndIsPrivateFalseAndCreatedAtGreaterThanOrderByCreatedAtAsc( + news.createdAt!! + ) return NewsDto.of(news, imageURL, attachmentResponses, prevNews, nextNews) } diff --git a/src/main/kotlin/com/wafflestudio/csereal/core/notice/database/NoticeRepository.kt b/src/main/kotlin/com/wafflestudio/csereal/core/notice/database/NoticeRepository.kt index a4a531dd..ec4acfa5 100644 --- a/src/main/kotlin/com/wafflestudio/csereal/core/notice/database/NoticeRepository.kt +++ b/src/main/kotlin/com/wafflestudio/csereal/core/notice/database/NoticeRepository.kt @@ -19,8 +19,13 @@ import java.time.LocalDateTime interface NoticeRepository : JpaRepository, CustomNoticeRepository { fun findAllByIsPrivateFalseAndIsImportantTrueAndIsDeletedFalse(): List fun findAllByIsImportantTrueAndIsDeletedFalse(): List - fun findFirstByCreatedAtLessThanOrderByCreatedAtDesc(timestamp: LocalDateTime): NoticeEntity? - fun findFirstByCreatedAtGreaterThanOrderByCreatedAtAsc(timestamp: LocalDateTime): NoticeEntity? + fun findFirstByIsDeletedFalseAndIsPrivateFalseAndCreatedAtLessThanOrderByCreatedAtDesc( + timestamp: LocalDateTime + ): NoticeEntity? + + fun findFirstByIsDeletedFalseAndIsPrivateFalseAndCreatedAtGreaterThanOrderByCreatedAtAsc( + timestamp: LocalDateTime + ): NoticeEntity? } interface CustomNoticeRepository { @@ -123,8 +128,7 @@ class NoticeRepositoryImpl( noticeEntity.attachments.isNotEmpty, noticeEntity.isPrivate ) - ) - .from(noticeEntity) + ).from(noticeEntity) .leftJoin(noticeTagEntity).on(noticeTagEntity.notice.eq(noticeEntity)) .where(noticeEntity.isDeleted.eq(false)) .where(keywordBooleanBuilder, tagsBooleanBuilder, isPrivateBooleanBuilder) diff --git a/src/main/kotlin/com/wafflestudio/csereal/core/notice/service/NoticeService.kt b/src/main/kotlin/com/wafflestudio/csereal/core/notice/service/NoticeService.kt index 59b62670..85ab88af 100644 --- a/src/main/kotlin/com/wafflestudio/csereal/core/notice/service/NoticeService.kt +++ b/src/main/kotlin/com/wafflestudio/csereal/core/notice/service/NoticeService.kt @@ -75,9 +75,13 @@ class NoticeServiceImpl( val attachmentResponses = attachmentService.createAttachmentResponses(notice.attachments) val prevNotice = - noticeRepository.findFirstByCreatedAtLessThanOrderByCreatedAtDesc(notice.createdAt!!) + noticeRepository.findFirstByIsDeletedFalseAndIsPrivateFalseAndCreatedAtLessThanOrderByCreatedAtDesc( + notice.createdAt!! + ) val nextNotice = - noticeRepository.findFirstByCreatedAtGreaterThanOrderByCreatedAtAsc(notice.createdAt!!) + noticeRepository.findFirstByIsDeletedFalseAndIsPrivateFalseAndCreatedAtGreaterThanOrderByCreatedAtAsc( + notice.createdAt!! + ) return NoticeDto.of(notice, attachmentResponses, prevNotice, nextNotice) } diff --git a/src/main/kotlin/com/wafflestudio/csereal/core/seminar/database/SeminarRepository.kt b/src/main/kotlin/com/wafflestudio/csereal/core/seminar/database/SeminarRepository.kt index 54c8145d..f7431267 100644 --- a/src/main/kotlin/com/wafflestudio/csereal/core/seminar/database/SeminarRepository.kt +++ b/src/main/kotlin/com/wafflestudio/csereal/core/seminar/database/SeminarRepository.kt @@ -16,8 +16,12 @@ import java.time.LocalDateTime interface SeminarRepository : JpaRepository, CustomSeminarRepository { fun findAllByIsPrivateFalseAndIsImportantTrueAndIsDeletedFalse(): List fun findAllByIsImportantTrueAndIsDeletedFalse(): List - fun findFirstByCreatedAtLessThanAndIsPrivateFalseOrderByCreatedAtDesc(timestamp: LocalDateTime): SeminarEntity? - fun findFirstByCreatedAtGreaterThanAndIsPrivateFalseOrderByCreatedAtAsc(timestamp: LocalDateTime): SeminarEntity? + fun findFirstByIsDeletedFalseAndIsPrivateFalseAndCreatedAtLessThanOrderByCreatedAtDesc( + timestamp: LocalDateTime + ): SeminarEntity? + fun findFirstByIsDeletedFalseAndIsPrivateFalseAndCreatedAtGreaterThanOrderByCreatedAtAsc( + timestamp: LocalDateTime + ): SeminarEntity? } interface CustomSeminarRepository { diff --git a/src/main/kotlin/com/wafflestudio/csereal/core/seminar/service/SeminarService.kt b/src/main/kotlin/com/wafflestudio/csereal/core/seminar/service/SeminarService.kt index d8348849..1d78991e 100644 --- a/src/main/kotlin/com/wafflestudio/csereal/core/seminar/service/SeminarService.kt +++ b/src/main/kotlin/com/wafflestudio/csereal/core/seminar/service/SeminarService.kt @@ -83,9 +83,13 @@ class SeminarServiceImpl( val attachmentResponses = attachmentService.createAttachmentResponses(seminar.attachments) val prevSeminar = - seminarRepository.findFirstByCreatedAtLessThanAndIsPrivateFalseOrderByCreatedAtDesc(seminar.createdAt!!) + seminarRepository.findFirstByIsDeletedFalseAndIsPrivateFalseAndCreatedAtLessThanOrderByCreatedAtDesc( + seminar.createdAt!! + ) val nextSeminar = - seminarRepository.findFirstByCreatedAtGreaterThanAndIsPrivateFalseOrderByCreatedAtAsc(seminar.createdAt!!) + seminarRepository.findFirstByIsDeletedFalseAndIsPrivateFalseAndCreatedAtGreaterThanOrderByCreatedAtAsc( + seminar.createdAt!! + ) return SeminarDto.of(seminar, imageURL, attachmentResponses, prevSeminar, nextSeminar) }