라이브 메인 - 추천라이브, 추천채널, 예약중인 라이브, 진행중인 라이브, 이벤트 배너 API 추가

This commit is contained in:
2023-07-27 06:24:23 +09:00
parent ee124e258e
commit ee99dd3147
20 changed files with 757 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
package kr.co.vividnext.sodalive.event
import kr.co.vividnext.sodalive.common.BaseEntity
import javax.persistence.Column
import javax.persistence.Entity
@Entity
data class Event(
@Column(nullable = false)
var thumbnailImage: String,
@Column(nullable = true)
var detailImage: String?,
@Column(nullable = true)
var popupImage: String?,
@Column(nullable = true)
var link: String?,
@Column(nullable = true)
var title: String?,
@Column(nullable = false)
var isPopup: Boolean = false,
@Column(nullable = false)
var isActive: Boolean = true
) : BaseEntity()

View File

@@ -0,0 +1,13 @@
package kr.co.vividnext.sodalive.event
import kr.co.vividnext.sodalive.common.ApiResponse
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController
@RestController
@RequestMapping("/event")
class EventController(private val service: EventService) {
@GetMapping
fun getEventList() = ApiResponse.ok(service.getEventList())
}

View File

@@ -0,0 +1,35 @@
package kr.co.vividnext.sodalive.event
import com.querydsl.jpa.impl.JPAQueryFactory
import kr.co.vividnext.sodalive.event.QEvent.event
import org.springframework.data.jpa.repository.JpaRepository
import org.springframework.stereotype.Repository
@Repository
interface EventRepository : JpaRepository<Event, Long>, EventQueryRepository
interface EventQueryRepository {
fun getEventList(): List<EventItem>
}
@Repository
class EventQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) : EventQueryRepository {
override fun getEventList(): List<EventItem> {
return queryFactory
.select(
QEventItem(
event.id,
event.title,
event.thumbnailImage,
event.detailImage,
event.popupImage,
event.link,
event.isPopup
)
)
.from(event)
.where(event.isActive.isTrue)
.orderBy(event.id.desc())
.fetch()
}
}

View File

@@ -0,0 +1,35 @@
package kr.co.vividnext.sodalive.event
import org.springframework.beans.factory.annotation.Value
import org.springframework.stereotype.Service
@Service
class EventService(
private val repository: EventRepository,
@Value("\${cloud.aws.cloud-front.host}")
private val cloudFrontHost: String
) {
fun getEventList(): GetEventResponse {
val eventList = 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()
return GetEventResponse(0, eventList)
}
}

View File

@@ -0,0 +1,18 @@
package kr.co.vividnext.sodalive.event
import com.querydsl.core.annotations.QueryProjection
data class GetEventResponse(
val totalCount: Int,
val eventList: List<EventItem>
)
data class EventItem @QueryProjection constructor(
val id: Long,
val title: String? = null,
var thumbnailImageUrl: String,
var detailImageUrl: String? = null,
var popupImageUrl: String? = null,
val link: String? = null,
val isPopup: Boolean
)