parent
6ccdfab551
commit
df3f045209
|
@ -14,8 +14,6 @@ import org.springframework.cache.annotation.Cacheable
|
||||||
import org.springframework.data.domain.Pageable
|
import org.springframework.data.domain.Pageable
|
||||||
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
|
||||||
class AudioContentMainService(
|
class AudioContentMainService(
|
||||||
|
@ -93,7 +91,6 @@ class AudioContentMainService(
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
@Cacheable(cacheNames = ["default"], key = "'contentMainBannerList:' + #memberId + ':' + #isAdult")
|
|
||||||
fun getAudioContentMainBannerList(memberId: Long, isAdult: Boolean) =
|
fun getAudioContentMainBannerList(memberId: Long, isAdult: Boolean) =
|
||||||
repository.getAudioContentMainBannerList(isAdult = isAdult)
|
repository.getAudioContentMainBannerList(isAdult = isAdult)
|
||||||
.asSequence()
|
.asSequence()
|
||||||
|
@ -109,17 +106,6 @@ class AudioContentMainService(
|
||||||
type = it.type,
|
type = it.type,
|
||||||
thumbnailImageUrl = "$imageHost/${it.thumbnailImage}",
|
thumbnailImageUrl = "$imageHost/${it.thumbnailImage}",
|
||||||
eventItem = if (it.type == AudioContentBannerType.EVENT && it.event != null) {
|
eventItem = if (it.type == AudioContentBannerType.EVENT && it.event != null) {
|
||||||
val dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd")
|
|
||||||
val startDate = it.event!!.startDate
|
|
||||||
.atZone(ZoneId.of("UTC"))
|
|
||||||
.withZoneSameInstant(ZoneId.of("Asia/Seoul"))
|
|
||||||
.format(dateTimeFormatter)
|
|
||||||
|
|
||||||
val endDate = it.event!!.endDate
|
|
||||||
.atZone(ZoneId.of("UTC"))
|
|
||||||
.withZoneSameInstant(ZoneId.of("Asia/Seoul"))
|
|
||||||
.format(dateTimeFormatter)
|
|
||||||
|
|
||||||
EventItem(
|
EventItem(
|
||||||
id = it.event!!.id!!,
|
id = it.event!!.id!!,
|
||||||
thumbnailImageUrl = if (!it.event!!.thumbnailImage.startsWith("https://")) {
|
thumbnailImageUrl = if (!it.event!!.thumbnailImage.startsWith("https://")) {
|
||||||
|
@ -136,11 +122,7 @@ class AudioContentMainService(
|
||||||
it.event!!.detailImage
|
it.event!!.detailImage
|
||||||
},
|
},
|
||||||
popupImageUrl = null,
|
popupImageUrl = null,
|
||||||
startDate = startDate,
|
link = it.event!!.link
|
||||||
endDate = endDate,
|
|
||||||
link = it.event!!.link,
|
|
||||||
title = it.event!!.title,
|
|
||||||
isPopup = false
|
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
null
|
null
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
package kr.co.vividnext.sodalive.event
|
package kr.co.vividnext.sodalive.event
|
||||||
|
|
||||||
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.event.QEvent.event
|
import kr.co.vividnext.sodalive.event.QEvent.event
|
||||||
import org.springframework.data.jpa.repository.JpaRepository
|
import org.springframework.data.jpa.repository.JpaRepository
|
||||||
|
@ -43,15 +40,10 @@ class EventQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) : Even
|
||||||
.select(
|
.select(
|
||||||
QEventItem(
|
QEventItem(
|
||||||
event.id,
|
event.id,
|
||||||
event.title,
|
|
||||||
event.thumbnailImage,
|
event.thumbnailImage,
|
||||||
event.detailImage,
|
event.detailImage,
|
||||||
event.popupImage,
|
event.popupImage,
|
||||||
getFormattedDate(event.startDate),
|
event.link
|
||||||
getFormattedDate(event.endDate),
|
|
||||||
event.link,
|
|
||||||
event.isAdult,
|
|
||||||
event.isPopup
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.from(event)
|
.from(event)
|
||||||
|
@ -84,15 +76,10 @@ class EventQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) : Even
|
||||||
.select(
|
.select(
|
||||||
QEventItem(
|
QEventItem(
|
||||||
event.id,
|
event.id,
|
||||||
event.title,
|
|
||||||
event.thumbnailImage,
|
event.thumbnailImage,
|
||||||
event.detailImage,
|
event.detailImage,
|
||||||
event.popupImage,
|
event.popupImage,
|
||||||
getFormattedDate(event.startDate),
|
event.link
|
||||||
getFormattedDate(event.endDate),
|
|
||||||
event.link,
|
|
||||||
event.isAdult,
|
|
||||||
event.isPopup
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.from(event)
|
.from(event)
|
||||||
|
@ -100,18 +87,4 @@ class EventQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) : Even
|
||||||
.orderBy(event.id.desc())
|
.orderBy(event.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"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,13 +12,8 @@ data class GetEventResponse(
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
data class EventItem @QueryProjection constructor(
|
data class EventItem @QueryProjection constructor(
|
||||||
@JsonProperty("id") val id: Long,
|
@JsonProperty("id") val id: Long,
|
||||||
@JsonProperty("title") val title: String? = null,
|
|
||||||
@JsonProperty("thumbnailImageUrl") var thumbnailImageUrl: String,
|
@JsonProperty("thumbnailImageUrl") var thumbnailImageUrl: String,
|
||||||
@JsonProperty("detailImageUrl") var detailImageUrl: String? = null,
|
@JsonProperty("detailImageUrl") var detailImageUrl: String? = null,
|
||||||
@JsonProperty("popupImageUrl") var popupImageUrl: String? = null,
|
@JsonProperty("popupImageUrl") var popupImageUrl: String? = null,
|
||||||
@JsonProperty("startDate") var startDate: String,
|
@JsonProperty("link") val link: String? = null
|
||||||
@JsonProperty("endDate") var endDate: String,
|
|
||||||
@JsonProperty("link") val link: String? = null,
|
|
||||||
@JsonProperty("isAdult") val isAdult: Boolean? = null,
|
|
||||||
@JsonProperty("isPopup") val isPopup: Boolean
|
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue