Skip to content

Commit

Permalink
fix: 이전글 다음 글 isDelete,isPrivate 조건 추가 (#151)
Browse files Browse the repository at this point in the history
* fix: 이전글 다음 글 isDelete 추가

* fix: ktlint 수정

---------

Co-authored-by: 우혁준 (HyukJoon Woo) <whjoon0225@naver.com>
Co-authored-by: Junhyeong Kim <indiv0227@snu.ac.kr>
  • Loading branch information
3 people authored Sep 22, 2023
1 parent 3ad4b91 commit 5f6b6f3
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,13 @@ import java.time.LocalDateTime
interface NewsRepository : JpaRepository<NewsEntity, Long>, CustomNewsRepository {
fun findAllByIsPrivateFalseAndIsImportantTrueAndIsDeletedFalse(): List<NewsEntity>
fun findAllByIsImportantTrueAndIsDeletedFalse(): List<NewsEntity>
fun findFirstByCreatedAtLessThanOrderByCreatedAtDesc(timestamp: LocalDateTime): NewsEntity?
fun findFirstByCreatedAtGreaterThanOrderByCreatedAtAsc(timestamp: LocalDateTime): NewsEntity?
fun findFirstByIsDeletedFalseAndIsPrivateFalseAndCreatedAtLessThanOrderByCreatedAtDesc(
timestamp: LocalDateTime
): NewsEntity?

fun findFirstByIsDeletedFalseAndIsPrivateFalseAndCreatedAtGreaterThanOrderByCreatedAtAsc(
timestamp: LocalDateTime
): NewsEntity?
}

interface CustomNewsRepository {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,13 @@ import java.time.LocalDateTime
interface NoticeRepository : JpaRepository<NoticeEntity, Long>, CustomNoticeRepository {
fun findAllByIsPrivateFalseAndIsImportantTrueAndIsDeletedFalse(): List<NoticeEntity>
fun findAllByIsImportantTrueAndIsDeletedFalse(): List<NoticeEntity>
fun findFirstByCreatedAtLessThanOrderByCreatedAtDesc(timestamp: LocalDateTime): NoticeEntity?
fun findFirstByCreatedAtGreaterThanOrderByCreatedAtAsc(timestamp: LocalDateTime): NoticeEntity?
fun findFirstByIsDeletedFalseAndIsPrivateFalseAndCreatedAtLessThanOrderByCreatedAtDesc(
timestamp: LocalDateTime
): NoticeEntity?

fun findFirstByIsDeletedFalseAndIsPrivateFalseAndCreatedAtGreaterThanOrderByCreatedAtAsc(
timestamp: LocalDateTime
): NoticeEntity?
}

interface CustomNoticeRepository {
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@ import java.time.LocalDateTime
interface SeminarRepository : JpaRepository<SeminarEntity, Long>, CustomSeminarRepository {
fun findAllByIsPrivateFalseAndIsImportantTrueAndIsDeletedFalse(): List<SeminarEntity>
fun findAllByIsImportantTrueAndIsDeletedFalse(): List<SeminarEntity>
fun findFirstByCreatedAtLessThanAndIsPrivateFalseOrderByCreatedAtDesc(timestamp: LocalDateTime): SeminarEntity?
fun findFirstByCreatedAtGreaterThanAndIsPrivateFalseOrderByCreatedAtAsc(timestamp: LocalDateTime): SeminarEntity?
fun findFirstByIsDeletedFalseAndIsPrivateFalseAndCreatedAtLessThanOrderByCreatedAtDesc(
timestamp: LocalDateTime
): SeminarEntity?
fun findFirstByIsDeletedFalseAndIsPrivateFalseAndCreatedAtGreaterThanOrderByCreatedAtAsc(
timestamp: LocalDateTime
): SeminarEntity?
}

interface CustomSeminarRepository {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 5f6b6f3

Please sign in to comment.