parent
713d42a674
commit
34452525d4
|
@ -73,6 +73,14 @@ interface AudioContentQueryRepository {
|
||||||
isFree: Boolean = false
|
isFree: Boolean = false
|
||||||
): List<GetAudioContentMainItem>
|
): List<GetAudioContentMainItem>
|
||||||
|
|
||||||
|
fun findAlarmContentByTheme(
|
||||||
|
memberId: Long,
|
||||||
|
theme: List<String>,
|
||||||
|
isAdult: Boolean = false,
|
||||||
|
offset: Long = 0,
|
||||||
|
limit: Long = 20
|
||||||
|
): List<GetAudioContentMainItem>
|
||||||
|
|
||||||
fun totalCountByTheme(
|
fun totalCountByTheme(
|
||||||
memberId: Long,
|
memberId: Long,
|
||||||
theme: String = "",
|
theme: String = "",
|
||||||
|
@ -424,6 +432,60 @@ class AudioContentQueryRepositoryImpl(
|
||||||
.fetch()
|
.fetch()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun findAlarmContentByTheme(
|
||||||
|
memberId: Long,
|
||||||
|
theme: List<String>,
|
||||||
|
isAdult: Boolean,
|
||||||
|
offset: Long,
|
||||||
|
limit: Long
|
||||||
|
): List<GetAudioContentMainItem> {
|
||||||
|
val blockMemberCondition = blockMember.member.id.eq(member.id)
|
||||||
|
.and(blockMember.isActive.isTrue)
|
||||||
|
.and(blockMember.blockedMember.id.eq(memberId))
|
||||||
|
|
||||||
|
val orderBy = listOf(audioContent.releaseDate.desc(), audioContent.id.desc())
|
||||||
|
|
||||||
|
var where = audioContent.isActive.isTrue
|
||||||
|
.and(audioContent.duration.isNotNull)
|
||||||
|
.and(
|
||||||
|
audioContent.releaseDate.isNull
|
||||||
|
.or(audioContent.releaseDate.loe(LocalDateTime.now()))
|
||||||
|
.or(audioContent.member.id.eq(memberId))
|
||||||
|
)
|
||||||
|
.and(blockMember.id.isNull)
|
||||||
|
|
||||||
|
if (!isAdult) {
|
||||||
|
where = where.and(audioContent.isAdult.isFalse)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (theme.isNotEmpty()) {
|
||||||
|
where = where.and(audioContentTheme.theme.`in`(theme))
|
||||||
|
}
|
||||||
|
|
||||||
|
return queryFactory
|
||||||
|
.select(
|
||||||
|
QGetAudioContentMainItem(
|
||||||
|
audioContent.id,
|
||||||
|
audioContent.coverImage.prepend("/").prepend(imageHost),
|
||||||
|
audioContent.title,
|
||||||
|
member.id,
|
||||||
|
member.profileImage.prepend("/").prepend(imageHost),
|
||||||
|
member.nickname,
|
||||||
|
audioContent.price,
|
||||||
|
audioContent.duration
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.from(audioContent)
|
||||||
|
.innerJoin(audioContent.member, member)
|
||||||
|
.innerJoin(audioContent.theme, audioContentTheme)
|
||||||
|
.leftJoin(blockMember).on(blockMemberCondition)
|
||||||
|
.where(where)
|
||||||
|
.offset(offset)
|
||||||
|
.limit(limit)
|
||||||
|
.orderBy(*orderBy.toTypedArray())
|
||||||
|
.fetch()
|
||||||
|
}
|
||||||
|
|
||||||
override fun totalCountByTheme(memberId: Long, theme: String, isAdult: Boolean, contentType: ContentType): Int {
|
override fun totalCountByTheme(memberId: Long, theme: String, isAdult: Boolean, contentType: ContentType): Int {
|
||||||
var where = audioContent.isActive.isTrue
|
var where = audioContent.isActive.isTrue
|
||||||
.and(audioContent.duration.isNotNull)
|
.and(audioContent.duration.isNotNull)
|
||||||
|
|
|
@ -3,9 +3,11 @@ package kr.co.vividnext.sodalive.content.main.tab.alarm
|
||||||
import kr.co.vividnext.sodalive.common.ApiResponse
|
import kr.co.vividnext.sodalive.common.ApiResponse
|
||||||
import kr.co.vividnext.sodalive.common.SodaException
|
import kr.co.vividnext.sodalive.common.SodaException
|
||||||
import kr.co.vividnext.sodalive.member.Member
|
import kr.co.vividnext.sodalive.member.Member
|
||||||
|
import org.springframework.data.domain.Pageable
|
||||||
import org.springframework.security.core.annotation.AuthenticationPrincipal
|
import org.springframework.security.core.annotation.AuthenticationPrincipal
|
||||||
import org.springframework.web.bind.annotation.GetMapping
|
import org.springframework.web.bind.annotation.GetMapping
|
||||||
import org.springframework.web.bind.annotation.RequestMapping
|
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.bind.annotation.RestController
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
|
@ -19,4 +21,22 @@ class AudioContentMainTabAlarmController(private val service: AudioContentMainTa
|
||||||
|
|
||||||
ApiResponse.ok(service.fetchData(member))
|
ApiResponse.ok(service.fetchData(member))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/all")
|
||||||
|
fun fetchAlarmContentByTheme(
|
||||||
|
@RequestParam("theme") theme: String,
|
||||||
|
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?,
|
||||||
|
pageable: Pageable
|
||||||
|
) = run {
|
||||||
|
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||||
|
|
||||||
|
ApiResponse.ok(
|
||||||
|
service.fetchAlarmContentByTheme(
|
||||||
|
theme,
|
||||||
|
member,
|
||||||
|
offset = pageable.offset,
|
||||||
|
limit = pageable.pageSize.toLong()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package kr.co.vividnext.sodalive.content.main.tab.alarm
|
package kr.co.vividnext.sodalive.content.main.tab.alarm
|
||||||
|
|
||||||
import kr.co.vividnext.sodalive.content.AudioContentRepository
|
import kr.co.vividnext.sodalive.content.AudioContentRepository
|
||||||
import kr.co.vividnext.sodalive.content.ContentType
|
import kr.co.vividnext.sodalive.content.main.GetAudioContentMainItem
|
||||||
import kr.co.vividnext.sodalive.content.main.banner.AudioContentBannerService
|
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.curation.AudioContentCurationQueryRepository
|
||||||
import kr.co.vividnext.sodalive.content.main.tab.GetContentCurationResponse
|
import kr.co.vividnext.sodalive.content.main.tab.GetContentCurationResponse
|
||||||
|
@ -32,11 +32,10 @@ class AudioContentMainTabAlarmService(
|
||||||
)
|
)
|
||||||
|
|
||||||
val alarmThemeList = listOf("모닝콜", "슬립콜", "알람")
|
val alarmThemeList = listOf("모닝콜", "슬립콜", "알람")
|
||||||
val newAlarmContentList = contentRepository.findByTheme(
|
val newAlarmContentList = contentRepository.findAlarmContentByTheme(
|
||||||
memberId = memberId,
|
memberId = memberId,
|
||||||
theme = alarmThemeList[0],
|
theme = alarmThemeList,
|
||||||
isAdult = isAdult,
|
isAdult = isAdult,
|
||||||
contentType = ContentType.ALL,
|
|
||||||
limit = 10
|
limit = 10
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -81,4 +80,28 @@ class AudioContentMainTabAlarmService(
|
||||||
curationList = curationList
|
curationList = curationList
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun fetchAlarmContentByTheme(
|
||||||
|
theme: String,
|
||||||
|
member: Member,
|
||||||
|
offset: Long,
|
||||||
|
limit: Long
|
||||||
|
): List<GetAudioContentMainItem> {
|
||||||
|
val alarmThemeList = if (theme.isNotBlank()) {
|
||||||
|
listOf(theme)
|
||||||
|
} else {
|
||||||
|
listOf("모닝콜", "슬립콜", "알람")
|
||||||
|
}
|
||||||
|
|
||||||
|
val memberId = member.id!!
|
||||||
|
val isAdult = member.auth != null
|
||||||
|
|
||||||
|
return contentRepository.findAlarmContentByTheme(
|
||||||
|
memberId = memberId,
|
||||||
|
theme = alarmThemeList,
|
||||||
|
isAdult = isAdult,
|
||||||
|
offset = offset,
|
||||||
|
limit = limit
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue