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) } }