Skip to content

Commit

Permalink
Merge pull request #62 from PSR-Co/fix/#61-list-excep-null
Browse files Browse the repository at this point in the history
[fix] CS 도메인 예외 처리 및 Res 수정
  • Loading branch information
chaerlo127 authored Aug 5, 2023
2 parents dd2fcbe + cee53e2 commit 470f024
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/main/kotlin/com/psr/psr/cs/dto/assembler/CsAssembler.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class CsAssembler {

// 공지사항 메인
fun toNoticeListRes(noticeList: List<Notice>?): NoticeListRes {
if (noticeList == null) return NoticeListRes(null)
if (noticeList!!.isEmpty()) return NoticeListRes(null)
return NoticeListRes(noticeList.stream().map {
n -> NoticeRes(n.id, n.title, n.createdAt)
}.collect(Collectors.toList()))
Expand All @@ -27,7 +27,7 @@ class CsAssembler {

// 자주 묻는 질문 메인
fun toFaqListRes(faqList: List<Faq>?) : FaqListRes {
if(faqList == null) return FaqListRes(null)
if(faqList!!.isEmpty()) return FaqListRes(null)
return FaqListRes(faqList.stream().map {
f -> FaqRes(f.id, f.type.value, f.title)
}.collect(Collectors.toList()))
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/com/psr/psr/cs/repository/FaqRepository.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import org.springframework.stereotype.Repository

@Repository
interface FaqRepository: JpaRepository<Faq, Long> {
fun findByOrderByCreatedAtDesc(): List<Faq>
fun findByTypeOrderByCreatedAtDesc(type: FaqType): List<Faq>
fun findByStatusOrderByCreatedAtDesc(status: String): List<Faq>
fun findByTypeAndStatusOrderByCreatedAtDesc(type: FaqType, status: String): List<Faq>
fun findByIdAndStatus(id: Long, status: String) : Faq?
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ import org.springframework.stereotype.Repository

@Repository
interface NoticeRepository: JpaRepository<Notice, Long> {
fun findByOrderByCreatedAtDesc() : List<Notice>?
fun findByStatusOrderByCreatedAtDesc(status: String) : List<Notice>?
fun findByIdAndStatus(id: Long, status: String) : Notice?
}
6 changes: 3 additions & 3 deletions src/main/kotlin/com/psr/psr/cs/service/CsService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class CsService(
) {
// 공지사항 메인
fun getNotices() : NoticeListRes{
return csAssembler.toNoticeListRes(noticeRepository.findByOrderByCreatedAtDesc())
return csAssembler.toNoticeListRes(noticeRepository.findByStatusOrderByCreatedAtDesc(ACTIVE_STATUS))
}

// 공지사항 상세
Expand All @@ -33,9 +33,9 @@ class CsService(

// 자주 묻는 질문 메인
fun getFaqs(type: String?): FaqListRes {
return if(type == null) csAssembler.toFaqListRes(faqRepository.findByOrderByCreatedAtDesc())
return if(type == null) csAssembler.toFaqListRes(faqRepository.findByStatusOrderByCreatedAtDesc(ACTIVE_STATUS))
else{
csAssembler.toFaqListRes(faqRepository.findByTypeOrderByCreatedAtDesc(FaqType.getTypeByName(type)))
csAssembler.toFaqListRes(faqRepository.findByTypeAndStatusOrderByCreatedAtDesc(FaqType.getTypeByName(type), ACTIVE_STATUS))
}
}

Expand Down

0 comments on commit 470f024

Please sign in to comment.