콘텐츠 메인
- 홈 탭 API
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package kr.co.vividnext.sodalive.notice
|
||||
|
||||
import com.querydsl.core.annotations.QueryProjection
|
||||
|
||||
data class GetNoticeResponse(
|
||||
val totalCount: Int,
|
||||
val noticeList: List<NoticeItem>
|
||||
@@ -11,3 +13,8 @@ data class NoticeItem(
|
||||
val content: String,
|
||||
val date: String
|
||||
)
|
||||
|
||||
data class NoticeTitleItem @QueryProjection constructor(
|
||||
val id: Long,
|
||||
val title: String
|
||||
)
|
||||
|
@@ -63,4 +63,8 @@ class ServiceNoticeService(private val repository: ServiceServiceNoticeRepositor
|
||||
|
||||
return GetNoticeResponse(totalCount, noticeList)
|
||||
}
|
||||
|
||||
fun getLatestNotice(): NoticeTitleItem? {
|
||||
return repository.getLatestNotice()
|
||||
}
|
||||
}
|
||||
|
@@ -12,6 +12,7 @@ interface ServiceServiceNoticeRepository : JpaRepository<ServiceNotice, Long>, S
|
||||
interface ServiceNoticeQueryRepository {
|
||||
fun getNoticeTotalCount(): Int
|
||||
fun getNoticeList(pageable: Pageable): List<ServiceNotice>
|
||||
fun getLatestNotice(): NoticeTitleItem?
|
||||
}
|
||||
|
||||
@Repository
|
||||
@@ -34,4 +35,18 @@ class ServiceNoticeQueryRepositoryImpl(private val queryFactory: JPAQueryFactory
|
||||
.orderBy(serviceNotice.id.desc())
|
||||
.fetch()
|
||||
}
|
||||
|
||||
override fun getLatestNotice(): NoticeTitleItem? {
|
||||
return queryFactory
|
||||
.select(
|
||||
QNoticeTitleItem(
|
||||
serviceNotice.id,
|
||||
serviceNotice.title
|
||||
)
|
||||
)
|
||||
.from(serviceNotice)
|
||||
.where(serviceNotice.isActive.isTrue)
|
||||
.orderBy(serviceNotice.id.desc())
|
||||
.fetchFirst()
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user