Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 이전글 다음 글 isDelete,isPrivate 조건 추가 #151

Merged
merged 5 commits into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading