parent
c5539bc7e3
commit
d1579126f3
|
@ -104,7 +104,6 @@ interface AudioContentQueryRepository {
|
|||
fun getAudioContentCurations(isAdult: Boolean): List<AudioContentCuration>
|
||||
fun findAudioContentByCurationId(
|
||||
curationId: Long,
|
||||
cloudfrontHost: String,
|
||||
isAdult: Boolean,
|
||||
contentType: ContentType
|
||||
): List<GetAudioContentMainItem>
|
||||
|
@ -601,7 +600,6 @@ class AudioContentQueryRepositoryImpl(
|
|||
|
||||
override fun findAudioContentByCurationId(
|
||||
curationId: Long,
|
||||
cloudfrontHost: String,
|
||||
isAdult: Boolean,
|
||||
contentType: ContentType
|
||||
): List<GetAudioContentMainItem> {
|
||||
|
@ -625,12 +623,12 @@ class AudioContentQueryRepositoryImpl(
|
|||
.select(
|
||||
QGetAudioContentMainItem(
|
||||
audioContent.id,
|
||||
audioContent.coverImage.prepend("/").prepend(cloudfrontHost),
|
||||
audioContent.coverImage.prepend("/").prepend(imageHost),
|
||||
audioContent.title,
|
||||
member.id,
|
||||
member.profileImage
|
||||
.prepend("/")
|
||||
.prepend(cloudfrontHost),
|
||||
.prepend(imageHost),
|
||||
member.nickname,
|
||||
audioContent.price,
|
||||
audioContent.duration
|
||||
|
|
|
@ -162,7 +162,6 @@ class AudioContentMainService(
|
|||
description = it.description,
|
||||
contents = repository.findAudioContentByCurationId(
|
||||
curationId = it.id!!,
|
||||
cloudfrontHost = imageHost,
|
||||
isAdult = isAdult,
|
||||
contentType = contentType
|
||||
)
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
package kr.co.vividnext.sodalive.content.main.tab
|
||||
|
||||
import kr.co.vividnext.sodalive.content.main.GetAudioContentMainItem
|
||||
|
||||
data class GetContentCurationResponse(
|
||||
val title: String,
|
||||
val items: List<GetAudioContentMainItem>
|
||||
)
|
|
@ -0,0 +1,22 @@
|
|||
package kr.co.vividnext.sodalive.content.main.tab.alarm
|
||||
|
||||
import kr.co.vividnext.sodalive.common.ApiResponse
|
||||
import kr.co.vividnext.sodalive.common.SodaException
|
||||
import kr.co.vividnext.sodalive.member.Member
|
||||
import org.springframework.security.core.annotation.AuthenticationPrincipal
|
||||
import org.springframework.web.bind.annotation.GetMapping
|
||||
import org.springframework.web.bind.annotation.RequestMapping
|
||||
import org.springframework.web.bind.annotation.RestController
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/v2/audio-content/main/alarm")
|
||||
class AudioContentMainTabAlarmController(private val service: AudioContentMainTabAlarmService) {
|
||||
@GetMapping
|
||||
fun fetchContentMainTabAlarm(
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
|
||||
ApiResponse.ok(service.fetchData(member))
|
||||
}
|
||||
}
|
|
@ -0,0 +1,85 @@
|
|||
package kr.co.vividnext.sodalive.content.main.tab.alarm
|
||||
|
||||
import kr.co.vividnext.sodalive.content.AudioContentRepository
|
||||
import kr.co.vividnext.sodalive.content.ContentType
|
||||
import kr.co.vividnext.sodalive.content.main.banner.AudioContentBannerService
|
||||
import kr.co.vividnext.sodalive.content.main.curation.AudioContentCurationQueryRepository
|
||||
import kr.co.vividnext.sodalive.content.main.tab.GetContentCurationResponse
|
||||
import kr.co.vividnext.sodalive.event.EventService
|
||||
import kr.co.vividnext.sodalive.member.Member
|
||||
import kr.co.vividnext.sodalive.rank.RankingService
|
||||
import org.springframework.stereotype.Service
|
||||
import java.time.DayOfWeek
|
||||
import java.time.LocalDateTime
|
||||
import java.time.temporal.TemporalAdjusters
|
||||
|
||||
@Service
|
||||
class AudioContentMainTabAlarmService(
|
||||
private val bannerService: AudioContentBannerService,
|
||||
private val contentRepository: AudioContentRepository,
|
||||
private val rankingService: RankingService,
|
||||
private val eventService: EventService,
|
||||
private val curationRepository: AudioContentCurationQueryRepository
|
||||
) {
|
||||
fun fetchData(member: Member): GetContentMainTabAlarmResponse {
|
||||
val isAdult = member.auth != null
|
||||
val memberId = member.id!!
|
||||
|
||||
// 메인 배너 (시리즈)
|
||||
val contentBannerList = bannerService.getBannerList(
|
||||
tabId = 4,
|
||||
memberId = memberId,
|
||||
isAdult = isAdult
|
||||
)
|
||||
|
||||
val alarmThemeList = listOf("모닝콜", "슬립콜", "알람")
|
||||
val newAlarmContentList = contentRepository.findByTheme(
|
||||
memberId = memberId,
|
||||
theme = alarmThemeList[0],
|
||||
isAdult = isAdult,
|
||||
contentType = ContentType.ALL,
|
||||
limit = 10
|
||||
)
|
||||
|
||||
// 주간 랭킹 기간
|
||||
val currentDateTime = LocalDateTime.now()
|
||||
val startDate = currentDateTime
|
||||
.withHour(15)
|
||||
.withMinute(0)
|
||||
.withSecond(0)
|
||||
.minusWeeks(1)
|
||||
.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY))
|
||||
val endDate = startDate
|
||||
.plusDays(6)
|
||||
|
||||
val rankAlarmContentList = rankingService.getContentRanking(
|
||||
memberId = memberId,
|
||||
isAdult = isAdult,
|
||||
startDate = startDate,
|
||||
endDate = endDate,
|
||||
theme = alarmThemeList[0]
|
||||
)
|
||||
|
||||
val eventBannerList = eventService.getEventList(isAdult = isAdult)
|
||||
val curationList = curationRepository.findByContentMainTabId(tabId = 4, isAdult = isAdult)
|
||||
.map {
|
||||
GetContentCurationResponse(
|
||||
title = it.title,
|
||||
items = contentRepository.findAudioContentByCurationId(
|
||||
curationId = it.id!!,
|
||||
isAdult = isAdult,
|
||||
contentType = ContentType.ALL
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
return GetContentMainTabAlarmResponse(
|
||||
contentBannerList = contentBannerList,
|
||||
alarmThemeList = alarmThemeList,
|
||||
newAlarmContentList = newAlarmContentList,
|
||||
rankAlarmContentList = rankAlarmContentList,
|
||||
eventBannerList = eventBannerList,
|
||||
curationList = curationList
|
||||
)
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package kr.co.vividnext.sodalive.content.main.tab.alarm
|
||||
|
||||
import kr.co.vividnext.sodalive.content.main.GetAudioContentMainItem
|
||||
import kr.co.vividnext.sodalive.content.main.GetAudioContentRankingItem
|
||||
import kr.co.vividnext.sodalive.content.main.banner.GetAudioContentBannerResponse
|
||||
import kr.co.vividnext.sodalive.content.main.tab.GetContentCurationResponse
|
||||
import kr.co.vividnext.sodalive.event.GetEventResponse
|
||||
|
||||
data class GetContentMainTabAlarmResponse(
|
||||
val tab: Long = 4,
|
||||
val contentBannerList: List<GetAudioContentBannerResponse>,
|
||||
val alarmThemeList: List<String>,
|
||||
val newAlarmContentList: List<GetAudioContentMainItem>,
|
||||
val rankAlarmContentList: List<GetAudioContentRankingItem>,
|
||||
val eventBannerList: GetEventResponse,
|
||||
val curationList: List<GetContentCurationResponse>
|
||||
)
|
|
@ -19,11 +19,6 @@ class AudioContentMainTabContentService(
|
|||
private val eventService: EventService
|
||||
) {
|
||||
fun fetchData(member: Member): GetContentMainTabContentResponse {
|
||||
/**
|
||||
* 새로운 단편
|
||||
* 일간 랭킹
|
||||
* 채널별 추천 단편
|
||||
*/
|
||||
val memberId = member.id!!
|
||||
val isAdult = member.auth != null
|
||||
|
||||
|
|
|
@ -48,7 +48,8 @@ class RankingRepository(
|
|||
endDate: LocalDateTime,
|
||||
offset: Long,
|
||||
limit: Long,
|
||||
sortType: String
|
||||
sortType: String,
|
||||
theme: String = ""
|
||||
): List<GetAudioContentRankingItem> {
|
||||
val blockMemberCondition = blockMember.member.id.eq(member.id)
|
||||
.and(blockMember.isActive.isTrue)
|
||||
|
@ -67,6 +68,10 @@ class RankingRepository(
|
|||
where = where.and(audioContent.isAdult.isFalse)
|
||||
}
|
||||
|
||||
if (theme.isNotBlank()) {
|
||||
where = where.and(audioContentTheme.theme.eq(theme))
|
||||
}
|
||||
|
||||
var select = queryFactory
|
||||
.select(
|
||||
QGetAudioContentRankingItem(
|
||||
|
|
|
@ -44,7 +44,8 @@ class RankingService(
|
|||
endDate: LocalDateTime,
|
||||
offset: Long = 0,
|
||||
limit: Long = 12,
|
||||
sortType: String = "매출"
|
||||
sortType: String = "매출",
|
||||
theme: String = ""
|
||||
): List<GetAudioContentRankingItem> {
|
||||
return repository.getAudioContentRanking(
|
||||
memberId = memberId,
|
||||
|
@ -53,7 +54,8 @@ class RankingService(
|
|||
endDate = endDate,
|
||||
offset = offset,
|
||||
limit = limit,
|
||||
sortType = sortType
|
||||
sortType = sortType,
|
||||
theme = theme
|
||||
)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue