Compare commits
No commits in common. "b7610641e544493e38bc42c7ecc8b801d2642417" and "04f2ac6815c9a121336704cfef9dfe772c981c96" have entirely different histories.
b7610641e5
...
04f2ac6815
|
@ -6,11 +6,11 @@ import kr.co.vividnext.sodalive.content.main.banner.GetAudioContentBannerRespons
|
||||||
import kr.co.vividnext.sodalive.content.series.GetSeriesListResponse
|
import kr.co.vividnext.sodalive.content.series.GetSeriesListResponse
|
||||||
import kr.co.vividnext.sodalive.event.GetEventResponse
|
import kr.co.vividnext.sodalive.event.GetEventResponse
|
||||||
import kr.co.vividnext.sodalive.explorer.GetExplorerSectionResponse
|
import kr.co.vividnext.sodalive.explorer.GetExplorerSectionResponse
|
||||||
import kr.co.vividnext.sodalive.notice.NoticeItem
|
import kr.co.vividnext.sodalive.notice.NoticeTitleItem
|
||||||
|
|
||||||
data class GetContentMainTabHomeResponse(
|
data class GetContentMainTabHomeResponse(
|
||||||
val tabId: Long = 1,
|
val tabId: Long = 1,
|
||||||
val latestNotice: NoticeItem?,
|
val latestNotice: NoticeTitleItem?,
|
||||||
val bannerList: List<GetAudioContentBannerResponse>,
|
val bannerList: List<GetAudioContentBannerResponse>,
|
||||||
val rankCreatorList: GetExplorerSectionResponse,
|
val rankCreatorList: GetExplorerSectionResponse,
|
||||||
val rankSeriesList: List<GetSeriesListResponse.SeriesListItem>,
|
val rankSeriesList: List<GetSeriesListResponse.SeriesListItem>,
|
||||||
|
|
|
@ -7,9 +7,14 @@ data class GetNoticeResponse(
|
||||||
val noticeList: List<NoticeItem>
|
val noticeList: List<NoticeItem>
|
||||||
)
|
)
|
||||||
|
|
||||||
data class NoticeItem @QueryProjection constructor(
|
data class NoticeItem(
|
||||||
val id: Long,
|
val id: Long,
|
||||||
val title: String,
|
val title: String,
|
||||||
val content: String,
|
val content: String,
|
||||||
val date: String
|
val date: String
|
||||||
)
|
)
|
||||||
|
|
||||||
|
data class NoticeTitleItem @QueryProjection constructor(
|
||||||
|
val id: Long,
|
||||||
|
val title: String
|
||||||
|
)
|
||||||
|
|
|
@ -5,6 +5,8 @@ import org.springframework.data.domain.Pageable
|
||||||
import org.springframework.data.repository.findByIdOrNull
|
import org.springframework.data.repository.findByIdOrNull
|
||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
import org.springframework.transaction.annotation.Transactional
|
import org.springframework.transaction.annotation.Transactional
|
||||||
|
import java.time.ZoneId
|
||||||
|
import java.time.format.DateTimeFormatter
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
|
@ -44,11 +46,25 @@ class ServiceNoticeService(private val repository: ServiceServiceNoticeRepositor
|
||||||
fun getNoticeList(pageable: Pageable, timezone: String): GetNoticeResponse {
|
fun getNoticeList(pageable: Pageable, timezone: String): GetNoticeResponse {
|
||||||
val totalCount = repository.getNoticeTotalCount()
|
val totalCount = repository.getNoticeTotalCount()
|
||||||
val noticeList = repository.getNoticeList(pageable)
|
val noticeList = repository.getNoticeList(pageable)
|
||||||
|
.asSequence()
|
||||||
|
.map {
|
||||||
|
val createdAt = it.createdAt!!
|
||||||
|
.atZone(ZoneId.of("UTC"))
|
||||||
|
.withZoneSameInstant(ZoneId.of(timezone))
|
||||||
|
|
||||||
|
NoticeItem(
|
||||||
|
it.id!!,
|
||||||
|
it.title,
|
||||||
|
it.content,
|
||||||
|
createdAt.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))
|
||||||
|
)
|
||||||
|
}
|
||||||
|
.toList()
|
||||||
|
|
||||||
return GetNoticeResponse(totalCount, noticeList)
|
return GetNoticeResponse(totalCount, noticeList)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getLatestNotice(): NoticeItem? {
|
fun getLatestNotice(): NoticeTitleItem? {
|
||||||
return repository.getLatestNotice()
|
return repository.getLatestNotice()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,22 +1,18 @@
|
||||||
package kr.co.vividnext.sodalive.notice
|
package kr.co.vividnext.sodalive.notice
|
||||||
|
|
||||||
import com.querydsl.core.types.dsl.DateTimePath
|
|
||||||
import com.querydsl.core.types.dsl.Expressions
|
|
||||||
import com.querydsl.core.types.dsl.StringTemplate
|
|
||||||
import com.querydsl.jpa.impl.JPAQueryFactory
|
import com.querydsl.jpa.impl.JPAQueryFactory
|
||||||
import kr.co.vividnext.sodalive.notice.QServiceNotice.serviceNotice
|
import kr.co.vividnext.sodalive.notice.QServiceNotice.serviceNotice
|
||||||
import org.springframework.data.domain.Pageable
|
import org.springframework.data.domain.Pageable
|
||||||
import org.springframework.data.jpa.repository.JpaRepository
|
import org.springframework.data.jpa.repository.JpaRepository
|
||||||
import org.springframework.stereotype.Repository
|
import org.springframework.stereotype.Repository
|
||||||
import java.time.LocalDateTime
|
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
interface ServiceServiceNoticeRepository : JpaRepository<ServiceNotice, Long>, ServiceNoticeQueryRepository
|
interface ServiceServiceNoticeRepository : JpaRepository<ServiceNotice, Long>, ServiceNoticeQueryRepository
|
||||||
|
|
||||||
interface ServiceNoticeQueryRepository {
|
interface ServiceNoticeQueryRepository {
|
||||||
fun getNoticeTotalCount(): Int
|
fun getNoticeTotalCount(): Int
|
||||||
fun getNoticeList(pageable: Pageable): List<NoticeItem>
|
fun getNoticeList(pageable: Pageable): List<ServiceNotice>
|
||||||
fun getLatestNotice(): NoticeItem?
|
fun getLatestNotice(): NoticeTitleItem?
|
||||||
}
|
}
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
|
@ -30,17 +26,9 @@ class ServiceNoticeQueryRepositoryImpl(private val queryFactory: JPAQueryFactory
|
||||||
.size
|
.size
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getNoticeList(pageable: Pageable): List<NoticeItem> {
|
override fun getNoticeList(pageable: Pageable): List<ServiceNotice> {
|
||||||
return queryFactory
|
return queryFactory
|
||||||
.select(
|
.selectFrom(serviceNotice)
|
||||||
QNoticeItem(
|
|
||||||
serviceNotice.id,
|
|
||||||
serviceNotice.title,
|
|
||||||
serviceNotice.content,
|
|
||||||
getFormattedDate(serviceNotice.createdAt)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
.from(serviceNotice)
|
|
||||||
.where(serviceNotice.isActive.isTrue)
|
.where(serviceNotice.isActive.isTrue)
|
||||||
.offset(pageable.offset)
|
.offset(pageable.offset)
|
||||||
.limit(pageable.pageSize.toLong())
|
.limit(pageable.pageSize.toLong())
|
||||||
|
@ -48,14 +36,12 @@ class ServiceNoticeQueryRepositoryImpl(private val queryFactory: JPAQueryFactory
|
||||||
.fetch()
|
.fetch()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getLatestNotice(): NoticeItem? {
|
override fun getLatestNotice(): NoticeTitleItem? {
|
||||||
return queryFactory
|
return queryFactory
|
||||||
.select(
|
.select(
|
||||||
QNoticeItem(
|
QNoticeTitleItem(
|
||||||
serviceNotice.id,
|
serviceNotice.id,
|
||||||
serviceNotice.title,
|
serviceNotice.title
|
||||||
serviceNotice.content,
|
|
||||||
getFormattedDate(serviceNotice.createdAt)
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.from(serviceNotice)
|
.from(serviceNotice)
|
||||||
|
@ -63,18 +49,4 @@ class ServiceNoticeQueryRepositoryImpl(private val queryFactory: JPAQueryFactory
|
||||||
.orderBy(serviceNotice.id.desc())
|
.orderBy(serviceNotice.id.desc())
|
||||||
.fetchFirst()
|
.fetchFirst()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getFormattedDate(dateTimePath: DateTimePath<LocalDateTime>): StringTemplate {
|
|
||||||
return Expressions.stringTemplate(
|
|
||||||
"DATE_FORMAT({0}, {1})",
|
|
||||||
Expressions.dateTimeTemplate(
|
|
||||||
LocalDateTime::class.java,
|
|
||||||
"CONVERT_TZ({0},{1},{2})",
|
|
||||||
dateTimePath,
|
|
||||||
"UTC",
|
|
||||||
"Asia/Seoul"
|
|
||||||
),
|
|
||||||
"%Y-%m-%d"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -347,7 +347,6 @@ class RankingRepository(
|
||||||
.and(audioContent.isActive.isTrue)
|
.and(audioContent.isActive.isTrue)
|
||||||
.and(audioContent.duration.isNotNull)
|
.and(audioContent.duration.isNotNull)
|
||||||
.and(audioContent.limited.isNull)
|
.and(audioContent.limited.isNull)
|
||||||
.and(audioContentTheme.isActive.isTrue)
|
|
||||||
.and(order.isActive.isTrue)
|
.and(order.isActive.isTrue)
|
||||||
.and(member.id.eq(creatorId))
|
.and(member.id.eq(creatorId))
|
||||||
|
|
||||||
|
@ -370,7 +369,6 @@ class RankingRepository(
|
||||||
)
|
)
|
||||||
.from(order)
|
.from(order)
|
||||||
.innerJoin(order.audioContent, audioContent)
|
.innerJoin(order.audioContent, audioContent)
|
||||||
.innerJoin(audioContent.theme, audioContentTheme)
|
|
||||||
.innerJoin(audioContent.member, member)
|
.innerJoin(audioContent.member, member)
|
||||||
.where(where)
|
.where(where)
|
||||||
.groupBy(audioContent.id)
|
.groupBy(audioContent.id)
|
||||||
|
@ -386,7 +384,6 @@ class RankingRepository(
|
||||||
.and(audioContent.isActive.isTrue)
|
.and(audioContent.isActive.isTrue)
|
||||||
.and(audioContent.duration.isNotNull)
|
.and(audioContent.duration.isNotNull)
|
||||||
.and(audioContent.limited.isNull)
|
.and(audioContent.limited.isNull)
|
||||||
.and(audioContentTheme.isActive.isTrue)
|
|
||||||
.and(order.isActive.isTrue)
|
.and(order.isActive.isTrue)
|
||||||
.and(member.id.eq(creatorId))
|
.and(member.id.eq(creatorId))
|
||||||
|
|
||||||
|
@ -409,7 +406,6 @@ class RankingRepository(
|
||||||
)
|
)
|
||||||
.from(order)
|
.from(order)
|
||||||
.innerJoin(order.audioContent, audioContent)
|
.innerJoin(order.audioContent, audioContent)
|
||||||
.innerJoin(audioContent.theme, audioContentTheme)
|
|
||||||
.innerJoin(audioContent.member, member)
|
.innerJoin(audioContent.member, member)
|
||||||
.where(where)
|
.where(where)
|
||||||
.groupBy(audioContent.id)
|
.groupBy(audioContent.id)
|
||||||
|
|
Loading…
Reference in New Issue