Compare commits
No commits in common. "df3f045209b027a5857c9370bcd1b9afa138acb8" and "e3e41511878b0c9dd3102e0acc9c1edb2be8ddad" have entirely different histories.
df3f045209
...
e3e4151187
|
@ -1,4 +1,4 @@
|
||||||
package kr.co.vividnext.sodalive.admin.event.charge
|
package kr.co.vividnext.sodalive.admin.event
|
||||||
|
|
||||||
import kr.co.vividnext.sodalive.common.ApiResponse
|
import kr.co.vividnext.sodalive.common.ApiResponse
|
||||||
import org.springframework.security.access.prepost.PreAuthorize
|
import org.springframework.security.access.prepost.PreAuthorize
|
||||||
|
@ -11,20 +11,22 @@ import org.springframework.web.bind.annotation.RestController
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/event/charge")
|
@RequestMapping("/event/charge")
|
||||||
@PreAuthorize("hasRole('ADMIN')")
|
|
||||||
class AdminChargeEventController(private val service: AdminChargeEventService) {
|
class AdminChargeEventController(private val service: AdminChargeEventService) {
|
||||||
@PostMapping
|
@PostMapping
|
||||||
|
@PreAuthorize("hasRole('ADMIN')")
|
||||||
fun createChargeEvent(@RequestBody request: CreateChargeEventRequest): ApiResponse<Any> {
|
fun createChargeEvent(@RequestBody request: CreateChargeEventRequest): ApiResponse<Any> {
|
||||||
service.createChargeEvent(request)
|
service.createChargeEvent(request)
|
||||||
return ApiResponse.ok(null, "등록되었습니다.")
|
return ApiResponse.ok(null, "등록되었습니다.")
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping
|
@PutMapping
|
||||||
|
@PreAuthorize("hasRole('ADMIN')")
|
||||||
fun modifyChargeEvent(@RequestBody request: ModifyChargeEventRequest) = ApiResponse.ok(
|
fun modifyChargeEvent(@RequestBody request: ModifyChargeEventRequest) = ApiResponse.ok(
|
||||||
service.modifyChargeEvent(request),
|
service.modifyChargeEvent(request),
|
||||||
"수정되었습니다."
|
"수정되었습니다."
|
||||||
)
|
)
|
||||||
|
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
|
@PreAuthorize("hasRole('ADMIN')")
|
||||||
fun getChargeEventList() = ApiResponse.ok(service.getChargeEventList())
|
fun getChargeEventList() = ApiResponse.ok(service.getChargeEventList())
|
||||||
}
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
package kr.co.vividnext.sodalive.admin.event.charge
|
package kr.co.vividnext.sodalive.admin.event
|
||||||
|
|
||||||
import com.querydsl.jpa.impl.JPAQueryFactory
|
import com.querydsl.jpa.impl.JPAQueryFactory
|
||||||
import kr.co.vividnext.sodalive.admin.event.charge.QChargeEvent.chargeEvent
|
import kr.co.vividnext.sodalive.admin.event.QChargeEvent.chargeEvent
|
||||||
import org.springframework.data.jpa.repository.JpaRepository
|
import org.springframework.data.jpa.repository.JpaRepository
|
||||||
import org.springframework.stereotype.Repository
|
import org.springframework.stereotype.Repository
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package kr.co.vividnext.sodalive.admin.event.charge
|
package kr.co.vividnext.sodalive.admin.event
|
||||||
|
|
||||||
import kr.co.vividnext.sodalive.common.SodaException
|
import kr.co.vividnext.sodalive.common.SodaException
|
||||||
import org.springframework.data.repository.findByIdOrNull
|
import org.springframework.data.repository.findByIdOrNull
|
|
@ -1,4 +1,4 @@
|
||||||
package kr.co.vividnext.sodalive.admin.event.charge
|
package kr.co.vividnext.sodalive.admin.event
|
||||||
|
|
||||||
import kr.co.vividnext.sodalive.common.BaseEntity
|
import kr.co.vividnext.sodalive.common.BaseEntity
|
||||||
import java.time.LocalDateTime
|
import java.time.LocalDateTime
|
|
@ -1,4 +1,4 @@
|
||||||
package kr.co.vividnext.sodalive.admin.event.charge
|
package kr.co.vividnext.sodalive.admin.event
|
||||||
|
|
||||||
data class CreateChargeEventRequest(
|
data class CreateChargeEventRequest(
|
||||||
val title: String,
|
val title: String,
|
|
@ -1,4 +1,4 @@
|
||||||
package kr.co.vividnext.sodalive.admin.event.charge
|
package kr.co.vividnext.sodalive.admin.event
|
||||||
|
|
||||||
data class GetChargeEventListResponse(
|
data class GetChargeEventListResponse(
|
||||||
val id: Long,
|
val id: Long,
|
|
@ -1,4 +1,4 @@
|
||||||
package kr.co.vividnext.sodalive.admin.event.charge
|
package kr.co.vividnext.sodalive.admin.event
|
||||||
|
|
||||||
data class ModifyChargeEventRequest(
|
data class ModifyChargeEventRequest(
|
||||||
val id: Long,
|
val id: Long,
|
|
@ -1,57 +0,0 @@
|
||||||
package kr.co.vividnext.sodalive.admin.event.banner
|
|
||||||
|
|
||||||
import kr.co.vividnext.sodalive.common.ApiResponse
|
|
||||||
import org.springframework.security.access.prepost.PreAuthorize
|
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping
|
|
||||||
import org.springframework.web.bind.annotation.PutMapping
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping
|
|
||||||
import org.springframework.web.bind.annotation.RequestParam
|
|
||||||
import org.springframework.web.bind.annotation.RestController
|
|
||||||
import org.springframework.web.multipart.MultipartFile
|
|
||||||
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/admin/event/banner")
|
|
||||||
@PreAuthorize("hasRole('ADMIN')")
|
|
||||||
class AdminEventBannerController(private val service: AdminEventBannerService) {
|
|
||||||
@PostMapping
|
|
||||||
fun createEventBanner(
|
|
||||||
@RequestParam("thumbnail") thumbnail: MultipartFile,
|
|
||||||
@RequestParam(value = "detail", required = false) detail: MultipartFile? = null,
|
|
||||||
@RequestParam(value = "popup", required = false) popup: MultipartFile? = null,
|
|
||||||
@RequestParam(value = "link", required = false) link: String? = null,
|
|
||||||
@RequestParam(value = "title", required = false) title: String? = null,
|
|
||||||
@RequestParam(value = "isAdult", required = false) isAdult: Boolean? = null,
|
|
||||||
@RequestParam(value = "isPopup") isPopup: Boolean,
|
|
||||||
@RequestParam(value = "startDate") startDate: String,
|
|
||||||
@RequestParam(value = "endDate") endDate: String
|
|
||||||
) = ApiResponse.ok(
|
|
||||||
service.save(thumbnail, detail, popup, link, title, isAdult, isPopup, startDate, endDate),
|
|
||||||
"등록되었습니다."
|
|
||||||
)
|
|
||||||
|
|
||||||
@PutMapping
|
|
||||||
fun updateEvent(
|
|
||||||
@RequestParam(value = "id") id: Long,
|
|
||||||
@RequestParam(value = "thumbnail", required = false) thumbnail: MultipartFile? = null,
|
|
||||||
@RequestParam(value = "detail", required = false) detail: MultipartFile? = null,
|
|
||||||
@RequestParam(value = "popup", required = false) popup: MultipartFile? = null,
|
|
||||||
@RequestParam(value = "link", required = false) link: String? = null,
|
|
||||||
@RequestParam(value = "title", required = false) title: String? = null,
|
|
||||||
@RequestParam(value = "isAdult", required = false) isAdult: Boolean? = null,
|
|
||||||
@RequestParam(value = "isPopup", required = false) isPopup: Boolean? = null,
|
|
||||||
@RequestParam(value = "startDate", required = false) startDate: String? = null,
|
|
||||||
@RequestParam(value = "endDate", required = false) endDate: String? = null
|
|
||||||
) = ApiResponse.ok(
|
|
||||||
service.update(id, thumbnail, detail, popup, link, title, isAdult, isPopup, startDate, endDate),
|
|
||||||
"수정되었습니다."
|
|
||||||
)
|
|
||||||
|
|
||||||
@DeleteMapping("/{id}")
|
|
||||||
fun deleteEvent(@PathVariable id: Long) = ApiResponse.ok(service.delete(id), "삭제되었습니다.")
|
|
||||||
|
|
||||||
@GetMapping
|
|
||||||
fun getEventList() = ApiResponse.ok(service.getEventList())
|
|
||||||
}
|
|
|
@ -1,61 +0,0 @@
|
||||||
package kr.co.vividnext.sodalive.admin.event.banner
|
|
||||||
|
|
||||||
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 kr.co.vividnext.sodalive.event.Event
|
|
||||||
import kr.co.vividnext.sodalive.event.QEvent.event
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository
|
|
||||||
import java.time.LocalDateTime
|
|
||||||
|
|
||||||
interface AdminEventBannerRepository : JpaRepository<Event, Long>, AdminEventBannerQueryRepository
|
|
||||||
|
|
||||||
interface AdminEventBannerQueryRepository {
|
|
||||||
fun getEventList(): List<GetAdminEventResponse>
|
|
||||||
}
|
|
||||||
|
|
||||||
class AdminEventBannerQueryRepositoryImpl(
|
|
||||||
private val queryFactory: JPAQueryFactory
|
|
||||||
) : AdminEventBannerQueryRepository {
|
|
||||||
override fun getEventList(): List<GetAdminEventResponse> {
|
|
||||||
val now = LocalDateTime.now()
|
|
||||||
val where = event.isActive.isTrue
|
|
||||||
.and(event.startDate.loe(now))
|
|
||||||
.and(event.endDate.goe(now))
|
|
||||||
|
|
||||||
return queryFactory
|
|
||||||
.select(
|
|
||||||
QGetAdminEventResponse(
|
|
||||||
event.id,
|
|
||||||
event.title,
|
|
||||||
event.thumbnailImage,
|
|
||||||
event.detailImage,
|
|
||||||
event.popupImage,
|
|
||||||
getFormattedDate(event.startDate),
|
|
||||||
getFormattedDate(event.endDate),
|
|
||||||
event.link,
|
|
||||||
event.isAdult,
|
|
||||||
event.isPopup
|
|
||||||
)
|
|
||||||
)
|
|
||||||
.from(event)
|
|
||||||
.where(where)
|
|
||||||
.orderBy(event.id.desc())
|
|
||||||
.fetch()
|
|
||||||
}
|
|
||||||
|
|
||||||
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"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,222 +0,0 @@
|
||||||
package kr.co.vividnext.sodalive.admin.event.banner
|
|
||||||
|
|
||||||
import com.amazonaws.services.s3.model.ObjectMetadata
|
|
||||||
import kr.co.vividnext.sodalive.aws.s3.S3Uploader
|
|
||||||
import kr.co.vividnext.sodalive.common.SodaException
|
|
||||||
import kr.co.vividnext.sodalive.event.Event
|
|
||||||
import kr.co.vividnext.sodalive.utils.generateFileName
|
|
||||||
import org.springframework.beans.factory.annotation.Value
|
|
||||||
import org.springframework.data.repository.findByIdOrNull
|
|
||||||
import org.springframework.stereotype.Service
|
|
||||||
import org.springframework.transaction.annotation.Transactional
|
|
||||||
import org.springframework.web.multipart.MultipartFile
|
|
||||||
import java.time.LocalDate
|
|
||||||
import java.time.ZoneId
|
|
||||||
import java.time.format.DateTimeFormatter
|
|
||||||
|
|
||||||
@Service
|
|
||||||
class AdminEventBannerService(
|
|
||||||
private val repository: AdminEventBannerRepository,
|
|
||||||
private val s3Uploader: S3Uploader,
|
|
||||||
|
|
||||||
@Value("\${cloud.aws.s3.bucket}")
|
|
||||||
private val bucket: String,
|
|
||||||
@Value("\${cloud.aws.cloud-front.host}")
|
|
||||||
private val cloudFrontHost: String
|
|
||||||
) {
|
|
||||||
@Transactional
|
|
||||||
fun save(
|
|
||||||
thumbnail: MultipartFile,
|
|
||||||
detail: MultipartFile? = null,
|
|
||||||
popup: MultipartFile? = null,
|
|
||||||
link: String? = null,
|
|
||||||
title: String? = null,
|
|
||||||
isAdult: Boolean? = null,
|
|
||||||
isPopup: Boolean,
|
|
||||||
startDateString: String,
|
|
||||||
endDateString: String
|
|
||||||
): Long {
|
|
||||||
if (detail == null && link.isNullOrBlank()) throw SodaException("상세이미지 혹은 링크를 등록하세요")
|
|
||||||
|
|
||||||
val dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd")
|
|
||||||
val startDate = LocalDate.parse(startDateString, dateTimeFormatter).atTime(0, 0)
|
|
||||||
.atZone(ZoneId.of("Asia/Seoul"))
|
|
||||||
.withZoneSameInstant(ZoneId.of("UTC"))
|
|
||||||
.toLocalDateTime()
|
|
||||||
|
|
||||||
val endDate = LocalDate.parse(endDateString, dateTimeFormatter).atTime(23, 59, 59)
|
|
||||||
.atZone(ZoneId.of("Asia/Seoul"))
|
|
||||||
.withZoneSameInstant(ZoneId.of("UTC"))
|
|
||||||
.toLocalDateTime()
|
|
||||||
|
|
||||||
val event = repository.save(
|
|
||||||
Event(
|
|
||||||
thumbnailImage = "",
|
|
||||||
detailImage = null,
|
|
||||||
popupImage = null,
|
|
||||||
link = link,
|
|
||||||
title = title,
|
|
||||||
isAdult = isAdult,
|
|
||||||
isPopup = isPopup,
|
|
||||||
startDate = startDate,
|
|
||||||
endDate = endDate
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
var metadata = ObjectMetadata()
|
|
||||||
metadata.contentLength = thumbnail.size
|
|
||||||
val thumbnailImagePath = s3Uploader.upload(
|
|
||||||
inputStream = thumbnail.inputStream,
|
|
||||||
bucket = bucket,
|
|
||||||
filePath = "event/${event.id}/${generateFileName()}",
|
|
||||||
metadata = metadata
|
|
||||||
)
|
|
||||||
|
|
||||||
val detailImagePath = if (detail != null) {
|
|
||||||
metadata = ObjectMetadata()
|
|
||||||
metadata.contentLength = detail.size
|
|
||||||
|
|
||||||
s3Uploader.upload(
|
|
||||||
inputStream = detail.inputStream,
|
|
||||||
bucket = bucket,
|
|
||||||
filePath = "event/${event.id}/${generateFileName()}",
|
|
||||||
metadata = metadata
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
null
|
|
||||||
}
|
|
||||||
|
|
||||||
val popupImagePath = if (popup != null) {
|
|
||||||
metadata = ObjectMetadata()
|
|
||||||
metadata.contentLength = popup.size
|
|
||||||
|
|
||||||
s3Uploader.upload(
|
|
||||||
inputStream = popup.inputStream,
|
|
||||||
bucket = bucket,
|
|
||||||
filePath = "event/${event.id}/${generateFileName()}",
|
|
||||||
metadata = metadata
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
null
|
|
||||||
}
|
|
||||||
|
|
||||||
event.thumbnailImage = thumbnailImagePath
|
|
||||||
event.detailImage = detailImagePath
|
|
||||||
event.popupImage = popupImagePath
|
|
||||||
|
|
||||||
return event.id ?: throw SodaException("이벤트 등록을 하지 못했습니다.")
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
|
||||||
fun update(
|
|
||||||
id: Long,
|
|
||||||
thumbnail: MultipartFile? = null,
|
|
||||||
detail: MultipartFile? = null,
|
|
||||||
popup: MultipartFile? = null,
|
|
||||||
link: String? = null,
|
|
||||||
title: String? = null,
|
|
||||||
isAdult: Boolean? = null,
|
|
||||||
isPopup: Boolean? = null,
|
|
||||||
startDateString: String? = null,
|
|
||||||
endDateString: String? = null
|
|
||||||
) {
|
|
||||||
if (id <= 0) throw SodaException("잘못된 요청입니다.")
|
|
||||||
|
|
||||||
val event = repository.findByIdOrNull(id)
|
|
||||||
?: throw SodaException("잘못된 요청입니다.")
|
|
||||||
|
|
||||||
if (thumbnail != null) {
|
|
||||||
val metadata = ObjectMetadata()
|
|
||||||
metadata.contentLength = thumbnail.size
|
|
||||||
|
|
||||||
event.thumbnailImage = s3Uploader.upload(
|
|
||||||
inputStream = thumbnail.inputStream,
|
|
||||||
bucket = bucket,
|
|
||||||
filePath = "event/${event.id}/${generateFileName()}"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (detail != null) {
|
|
||||||
val metadata = ObjectMetadata()
|
|
||||||
metadata.contentLength = detail.size
|
|
||||||
|
|
||||||
event.detailImage = s3Uploader.upload(
|
|
||||||
inputStream = detail.inputStream,
|
|
||||||
bucket = bucket,
|
|
||||||
filePath = "event/${event.id}/${generateFileName()}"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (popup != null) {
|
|
||||||
val metadata = ObjectMetadata()
|
|
||||||
metadata.contentLength = popup.size
|
|
||||||
|
|
||||||
event.popupImage = s3Uploader.upload(
|
|
||||||
inputStream = popup.inputStream,
|
|
||||||
bucket = bucket,
|
|
||||||
filePath = "event/${event.id}/${generateFileName()}"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!link.isNullOrBlank() && event.link != link) {
|
|
||||||
event.link = link
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!title.isNullOrBlank() && event.title != title) {
|
|
||||||
event.title = title
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isPopup != null) {
|
|
||||||
event.isPopup = isPopup
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isAdult != event.isAdult) {
|
|
||||||
event.isAdult = isAdult
|
|
||||||
}
|
|
||||||
|
|
||||||
val dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd")
|
|
||||||
if (startDateString != null) {
|
|
||||||
event.startDate = LocalDate.parse(startDateString, dateTimeFormatter).atTime(0, 0)
|
|
||||||
.atZone(ZoneId.of("Asia/Seoul"))
|
|
||||||
.withZoneSameInstant(ZoneId.of("UTC"))
|
|
||||||
.toLocalDateTime()
|
|
||||||
}
|
|
||||||
|
|
||||||
if (endDateString != null) {
|
|
||||||
event.endDate = LocalDate.parse(endDateString, dateTimeFormatter).atTime(23, 59, 59)
|
|
||||||
.atZone(ZoneId.of("Asia/Seoul"))
|
|
||||||
.withZoneSameInstant(ZoneId.of("UTC"))
|
|
||||||
.toLocalDateTime()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
|
||||||
fun delete(id: Long) {
|
|
||||||
if (id <= 0) throw SodaException("잘못된 요청입니다.")
|
|
||||||
val event = repository.findByIdOrNull(id)
|
|
||||||
?: throw SodaException("잘못된 요청입니다.")
|
|
||||||
|
|
||||||
event.isActive = false
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getEventList(): List<GetAdminEventResponse> {
|
|
||||||
return repository.getEventList()
|
|
||||||
.asSequence()
|
|
||||||
.map {
|
|
||||||
if (!it.thumbnailImageUrl.startsWith("https://")) {
|
|
||||||
it.thumbnailImageUrl = "$cloudFrontHost/${it.thumbnailImageUrl}"
|
|
||||||
}
|
|
||||||
|
|
||||||
if (it.detailImageUrl != null && !it.detailImageUrl!!.startsWith("https://")) {
|
|
||||||
it.detailImageUrl = "$cloudFrontHost/${it.detailImageUrl}"
|
|
||||||
}
|
|
||||||
|
|
||||||
if (it.popupImageUrl != null && !it.popupImageUrl!!.startsWith("https://")) {
|
|
||||||
it.popupImageUrl = "$cloudFrontHost/${it.popupImageUrl}"
|
|
||||||
}
|
|
||||||
|
|
||||||
it
|
|
||||||
}
|
|
||||||
.toList()
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,16 +0,0 @@
|
||||||
package kr.co.vividnext.sodalive.admin.event.banner
|
|
||||||
|
|
||||||
import com.querydsl.core.annotations.QueryProjection
|
|
||||||
|
|
||||||
data class GetAdminEventResponse @QueryProjection constructor(
|
|
||||||
val id: Long,
|
|
||||||
val title: String? = null,
|
|
||||||
var thumbnailImageUrl: String,
|
|
||||||
var detailImageUrl: String? = null,
|
|
||||||
var popupImageUrl: String? = null,
|
|
||||||
var startDate: String,
|
|
||||||
var endDate: String,
|
|
||||||
val link: String? = null,
|
|
||||||
val isAdult: Boolean? = null,
|
|
||||||
val isPopup: Boolean
|
|
||||||
)
|
|
|
@ -1,8 +1,8 @@
|
||||||
package kr.co.vividnext.sodalive.can.charge.event
|
package kr.co.vividnext.sodalive.can.charge.event
|
||||||
|
|
||||||
import com.querydsl.jpa.impl.JPAQueryFactory
|
import com.querydsl.jpa.impl.JPAQueryFactory
|
||||||
import kr.co.vividnext.sodalive.admin.event.charge.ChargeEvent
|
import kr.co.vividnext.sodalive.admin.event.ChargeEvent
|
||||||
import kr.co.vividnext.sodalive.admin.event.charge.QChargeEvent.chargeEvent
|
import kr.co.vividnext.sodalive.admin.event.QChargeEvent.chargeEvent
|
||||||
import kr.co.vividnext.sodalive.can.charge.QCharge.charge
|
import kr.co.vividnext.sodalive.can.charge.QCharge.charge
|
||||||
import kr.co.vividnext.sodalive.can.payment.PaymentStatus
|
import kr.co.vividnext.sodalive.can.payment.PaymentStatus
|
||||||
import kr.co.vividnext.sodalive.can.payment.QPayment.payment
|
import kr.co.vividnext.sodalive.can.payment.QPayment.payment
|
||||||
|
|
|
@ -14,6 +14,8 @@ 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(
|
||||||
|
@ -91,6 +93,7 @@ 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()
|
||||||
|
@ -106,6 +109,17 @@ 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://")) {
|
||||||
|
@ -122,7 +136,11 @@ class AudioContentMainService(
|
||||||
it.event!!.detailImage
|
it.event!!.detailImage
|
||||||
},
|
},
|
||||||
popupImageUrl = null,
|
popupImageUrl = null,
|
||||||
link = it.event!!.link
|
startDate = startDate,
|
||||||
|
endDate = endDate,
|
||||||
|
link = it.event!!.link,
|
||||||
|
title = it.event!!.title,
|
||||||
|
isPopup = false
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
null
|
null
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
package kr.co.vividnext.sodalive.content.main.banner
|
package kr.co.vividnext.sodalive.content.main.banner
|
||||||
|
|
||||||
import kr.co.vividnext.sodalive.common.BaseEntity
|
import kr.co.vividnext.sodalive.common.BaseEntity
|
||||||
import kr.co.vividnext.sodalive.content.main.tab.AudioContentMainTab
|
|
||||||
import kr.co.vividnext.sodalive.creator.admin.content.series.Series
|
|
||||||
import kr.co.vividnext.sodalive.event.Event
|
import kr.co.vividnext.sodalive.event.Event
|
||||||
import kr.co.vividnext.sodalive.member.Member
|
import kr.co.vividnext.sodalive.member.Member
|
||||||
import javax.persistence.Column
|
import javax.persistence.Column
|
||||||
|
@ -36,18 +34,10 @@ data class AudioContentBanner(
|
||||||
@JoinColumn(name = "creator_id", nullable = true)
|
@JoinColumn(name = "creator_id", nullable = true)
|
||||||
var creator: Member? = null
|
var creator: Member? = null
|
||||||
|
|
||||||
@OneToOne(fetch = FetchType.EAGER)
|
|
||||||
@JoinColumn(name = "series_id", nullable = true)
|
|
||||||
var series: Series? = null
|
|
||||||
|
|
||||||
@OneToOne(fetch = FetchType.EAGER)
|
|
||||||
@JoinColumn(name = "tab_id", nullable = true)
|
|
||||||
var tab: AudioContentMainTab? = null
|
|
||||||
|
|
||||||
@Column(nullable = true)
|
@Column(nullable = true)
|
||||||
var link: String? = null
|
var link: String? = null
|
||||||
}
|
}
|
||||||
|
|
||||||
enum class AudioContentBannerType {
|
enum class AudioContentBannerType {
|
||||||
EVENT, CREATOR, LINK, SERIES
|
EVENT, CREATOR, LINK
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +0,0 @@
|
||||||
package kr.co.vividnext.sodalive.content.main.tab
|
|
||||||
|
|
||||||
import kr.co.vividnext.sodalive.common.BaseEntity
|
|
||||||
import javax.persistence.Entity
|
|
||||||
|
|
||||||
@Entity
|
|
||||||
data class AudioContentMainTab(
|
|
||||||
val title: String,
|
|
||||||
val isActive: Boolean
|
|
||||||
) : BaseEntity()
|
|
|
@ -1,5 +1,8 @@
|
||||||
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
|
||||||
|
@ -40,10 +43,15 @@ 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,
|
||||||
event.link
|
getFormattedDate(event.startDate),
|
||||||
|
getFormattedDate(event.endDate),
|
||||||
|
event.link,
|
||||||
|
event.isAdult,
|
||||||
|
event.isPopup
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.from(event)
|
.from(event)
|
||||||
|
@ -76,10 +84,15 @@ 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,
|
||||||
event.link
|
getFormattedDate(event.startDate),
|
||||||
|
getFormattedDate(event.endDate),
|
||||||
|
event.link,
|
||||||
|
event.isAdult,
|
||||||
|
event.isPopup
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.from(event)
|
.from(event)
|
||||||
|
@ -87,4 +100,18 @@ 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,8 +12,13 @@ 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("link") val link: String? = null
|
@JsonProperty("startDate") var startDate: String,
|
||||||
|
@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