Compare commits
2 Commits
5970a9a5b6
...
151cc10caf
Author | SHA1 | Date |
---|---|---|
|
151cc10caf | |
|
22a79c0be4 |
|
@ -52,6 +52,7 @@ interface AudioContentQueryRepository {
|
|||
cloudfrontHost: String,
|
||||
theme: String = "",
|
||||
isAdult: Boolean = false,
|
||||
offset: Long = 0,
|
||||
limit: Long = 20
|
||||
): List<GetAudioContentMainItem>
|
||||
|
||||
|
@ -215,6 +216,7 @@ class AudioContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory)
|
|||
cloudfrontHost: String,
|
||||
theme: String,
|
||||
isAdult: Boolean,
|
||||
offset: Long,
|
||||
limit: Long
|
||||
): List<GetAudioContentMainItem> {
|
||||
var where = audioContent.isActive.isTrue
|
||||
|
@ -243,6 +245,7 @@ class AudioContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory)
|
|||
.innerJoin(audioContent.member, member)
|
||||
.innerJoin(audioContent.theme, audioContentTheme)
|
||||
.where(where)
|
||||
.offset(offset)
|
||||
.limit(limit)
|
||||
.orderBy(audioContent.createdAt.desc())
|
||||
.fetch()
|
||||
|
|
|
@ -3,6 +3,7 @@ package kr.co.vividnext.sodalive.content.main
|
|||
import kr.co.vividnext.sodalive.common.ApiResponse
|
||||
import kr.co.vividnext.sodalive.common.SodaException
|
||||
import kr.co.vividnext.sodalive.member.Member
|
||||
import org.springframework.data.domain.Pageable
|
||||
import org.springframework.security.core.annotation.AuthenticationPrincipal
|
||||
import org.springframework.web.bind.annotation.GetMapping
|
||||
import org.springframework.web.bind.annotation.RequestMapping
|
||||
|
@ -25,10 +26,11 @@ class AudioContentMainController(private val service: AudioContentMainService) {
|
|||
@GetMapping("/new")
|
||||
fun getNewContentByTheme(
|
||||
@RequestParam("theme") theme: String,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?,
|
||||
pageable: Pageable
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
|
||||
ApiResponse.ok(service.getNewContentByTheme(theme, member))
|
||||
ApiResponse.ok(service.getNewContentByTheme(theme, member, pageable))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import kr.co.vividnext.sodalive.event.EventItem
|
|||
import kr.co.vividnext.sodalive.member.Member
|
||||
import kr.co.vividnext.sodalive.member.block.BlockMemberRepository
|
||||
import org.springframework.beans.factory.annotation.Value
|
||||
import org.springframework.data.domain.Pageable
|
||||
import org.springframework.stereotype.Service
|
||||
|
||||
@Service
|
||||
|
@ -104,6 +105,7 @@ class AudioContentMainService(
|
|||
.asSequence()
|
||||
.map {
|
||||
GetAudioContentCurationResponse(
|
||||
curationId = it.id!!,
|
||||
title = it.title,
|
||||
description = it.description,
|
||||
contents = repository.findAudioContentByCurationId(
|
||||
|
@ -134,11 +136,13 @@ class AudioContentMainService(
|
|||
)
|
||||
}
|
||||
|
||||
fun getNewContentByTheme(theme: String, member: Member): List<GetAudioContentMainItem> {
|
||||
fun getNewContentByTheme(theme: String, member: Member, pageable: Pageable): List<GetAudioContentMainItem> {
|
||||
return repository.findByTheme(
|
||||
cloudfrontHost = imageHost,
|
||||
theme = theme,
|
||||
isAdult = member.auth != null
|
||||
isAdult = member.auth != null,
|
||||
offset = pageable.offset,
|
||||
limit = pageable.pageSize.toLong()
|
||||
)
|
||||
.asSequence()
|
||||
.filter { !blockMemberRepository.isBlocked(blockedMemberId = member.id!!, memberId = it.creatorId) }
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
package kr.co.vividnext.sodalive.content.main.curation
|
||||
|
||||
import kr.co.vividnext.sodalive.common.ApiResponse
|
||||
import kr.co.vividnext.sodalive.common.SodaException
|
||||
import kr.co.vividnext.sodalive.member.Member
|
||||
import org.springframework.data.domain.Pageable
|
||||
import org.springframework.security.core.annotation.AuthenticationPrincipal
|
||||
import org.springframework.web.bind.annotation.GetMapping
|
||||
import org.springframework.web.bind.annotation.PathVariable
|
||||
import org.springframework.web.bind.annotation.RequestMapping
|
||||
import org.springframework.web.bind.annotation.RestController
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/audio-content/curation")
|
||||
class AudioContentCurationController(private val service: AudioContentCurationService) {
|
||||
@GetMapping("/{id}")
|
||||
fun getCurationContent(
|
||||
@PathVariable id: Long,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?,
|
||||
pageable: Pageable
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
|
||||
ApiResponse.ok(service.getCurationContent(id, member, pageable))
|
||||
}
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
package kr.co.vividnext.sodalive.content.main.curation
|
||||
|
||||
import com.querydsl.jpa.impl.JPAQueryFactory
|
||||
import kr.co.vividnext.sodalive.content.QAudioContent.audioContent
|
||||
import kr.co.vividnext.sodalive.content.main.GetAudioContentMainItem
|
||||
import kr.co.vividnext.sodalive.content.main.QGetAudioContentMainItem
|
||||
import kr.co.vividnext.sodalive.member.QMember.member
|
||||
import org.springframework.beans.factory.annotation.Value
|
||||
import org.springframework.stereotype.Repository
|
||||
|
||||
@Repository
|
||||
class AudioContentCurationQueryRepository(
|
||||
private val queryFactory: JPAQueryFactory,
|
||||
|
||||
@Value("\${cloud.aws.cloud-front.host}")
|
||||
private val cloudFrontHost: String
|
||||
) {
|
||||
fun findByCurationId(curationId: Long, offset: Long, limit: Long, isAdult: Boolean): List<GetAudioContentMainItem> {
|
||||
var where = audioContent.isActive.isTrue
|
||||
.and(audioContent.member.isNotNull)
|
||||
.and(audioContent.duration.isNotNull)
|
||||
.and(audioContent.member.isActive.isTrue)
|
||||
.and(audioContent.curation.id.eq(curationId))
|
||||
|
||||
if (!isAdult) {
|
||||
where = where.and(audioContent.isAdult.isFalse)
|
||||
}
|
||||
|
||||
return queryFactory
|
||||
.select(
|
||||
QGetAudioContentMainItem(
|
||||
audioContent.id,
|
||||
audioContent.coverImage.prepend("/").prepend(cloudFrontHost),
|
||||
audioContent.title,
|
||||
audioContent.isAdult,
|
||||
member.id,
|
||||
member.profileImage
|
||||
.prepend("/")
|
||||
.prepend(cloudFrontHost),
|
||||
member.nickname
|
||||
)
|
||||
)
|
||||
.from(audioContent)
|
||||
.innerJoin(audioContent.member, member)
|
||||
.leftJoin(audioContent.curation, QAudioContentCuration.audioContentCuration)
|
||||
.where(where)
|
||||
.offset(offset)
|
||||
.limit(limit)
|
||||
.orderBy(audioContent.id.desc())
|
||||
.fetch()
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package kr.co.vividnext.sodalive.content.main.curation
|
||||
|
||||
import kr.co.vividnext.sodalive.content.main.GetAudioContentMainItem
|
||||
import kr.co.vividnext.sodalive.member.Member
|
||||
import kr.co.vividnext.sodalive.member.block.BlockMemberRepository
|
||||
import org.springframework.data.domain.Pageable
|
||||
import org.springframework.stereotype.Service
|
||||
|
||||
@Service
|
||||
class AudioContentCurationService(
|
||||
private val repository: AudioContentCurationQueryRepository,
|
||||
private val blockMemberRepository: BlockMemberRepository
|
||||
) {
|
||||
fun getCurationContent(curationId: Long, member: Member, pageable: Pageable): List<GetAudioContentMainItem> {
|
||||
return repository.findByCurationId(
|
||||
curationId = curationId,
|
||||
offset = pageable.offset,
|
||||
limit = pageable.pageSize.toLong(),
|
||||
isAdult = member.auth != null
|
||||
)
|
||||
.asSequence()
|
||||
.filter { content ->
|
||||
!blockMemberRepository.isBlocked(
|
||||
blockedMemberId = member.id!!,
|
||||
memberId = content.creatorId
|
||||
)
|
||||
}
|
||||
.toList()
|
||||
}
|
||||
}
|
|
@ -3,6 +3,7 @@ package kr.co.vividnext.sodalive.content.main.curation
|
|||
import kr.co.vividnext.sodalive.content.main.GetAudioContentMainItem
|
||||
|
||||
data class GetAudioContentCurationResponse(
|
||||
val curationId: Long,
|
||||
val title: String,
|
||||
val description: String,
|
||||
val contents: List<GetAudioContentMainItem>
|
||||
|
|
Loading…
Reference in New Issue