콘텐츠 메인 - 메인 페이지 섹션별 API 추가
This commit is contained in:
parent
0c3f190044
commit
13088f53a6
|
@ -94,6 +94,8 @@ interface AudioContentQueryRepository {
|
|||
limit: Long = 12,
|
||||
sortType: String = "매출"
|
||||
): List<GetAudioContentRankingItem>
|
||||
|
||||
fun getAudioContentCurationList(isAdult: Boolean, offset: Long, limit: Long): List<AudioContentCuration>
|
||||
}
|
||||
|
||||
@Repository
|
||||
|
@ -544,4 +546,20 @@ class AudioContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory)
|
|||
.limit(limit)
|
||||
.fetch()
|
||||
}
|
||||
|
||||
override fun getAudioContentCurationList(isAdult: Boolean, offset: Long, limit: Long): List<AudioContentCuration> {
|
||||
var where = audioContentCuration.isActive.isTrue
|
||||
|
||||
if (!isAdult) {
|
||||
where = where.and(audioContentCuration.isAdult.isFalse)
|
||||
}
|
||||
|
||||
return queryFactory
|
||||
.selectFrom(audioContentCuration)
|
||||
.where(where)
|
||||
.offset(offset)
|
||||
.limit(limit)
|
||||
.orderBy(audioContentCuration.orders.asc())
|
||||
.fetch()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,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.content.order.OrderService
|
||||
import kr.co.vividnext.sodalive.member.Member
|
||||
import org.springframework.data.domain.Pageable
|
||||
import org.springframework.security.core.annotation.AuthenticationPrincipal
|
||||
|
@ -14,6 +15,7 @@ import org.springframework.web.bind.annotation.RestController
|
|||
@RequestMapping("/audio-content/main")
|
||||
class AudioContentMainController(
|
||||
private val service: AudioContentMainService,
|
||||
private val orderService: OrderService,
|
||||
private val manageService: AudioContentMainManageService
|
||||
) {
|
||||
|
||||
|
@ -26,6 +28,48 @@ class AudioContentMainController(
|
|||
ApiResponse.ok(manageService.getMain(member))
|
||||
}
|
||||
|
||||
@GetMapping("/new-content-upload-creator")
|
||||
fun newContentUploadCreatorList(
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
|
||||
ApiResponse.ok(
|
||||
service.getNewContentUploadCreatorList(
|
||||
memberId = member.id!!,
|
||||
isAdult = member.auth != null
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@GetMapping("/banner-list")
|
||||
fun getMainBannerList(
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
|
||||
ApiResponse.ok(
|
||||
service.getAudioContentMainBannerList(
|
||||
memberId = member.id!!,
|
||||
isAdult = member.auth != null
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@GetMapping("/order-list")
|
||||
fun getMainOrderList(
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
|
||||
ApiResponse.ok(
|
||||
orderService.getAudioContentMainOrderList(
|
||||
memberId = member.id!!,
|
||||
limit = 20
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@GetMapping("/new")
|
||||
fun getNewContentByTheme(
|
||||
@RequestParam("theme") theme: String,
|
||||
|
@ -56,4 +100,21 @@ class AudioContentMainController(
|
|||
|
||||
ApiResponse.ok(service.getNewContentFor2WeeksByTheme(theme, member, pageable))
|
||||
}
|
||||
|
||||
@GetMapping("/curation-list")
|
||||
fun getCurationList(
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?,
|
||||
pageable: Pageable
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
|
||||
ApiResponse.ok(
|
||||
service.getAudioContentCurationListWithPaging(
|
||||
memberId = member.id!!,
|
||||
isAdult = member.auth != null,
|
||||
offset = pageable.offset,
|
||||
limit = pageable.pageSize.toLong()
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ class AudioContentMainService(
|
|||
return audioContentThemeRepository.getActiveThemeOfContent(isAdult = isAdult)
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
fun getNewContentByTheme(theme: String, member: Member, pageable: Pageable): List<GetAudioContentMainItem> {
|
||||
return repository.findByTheme(
|
||||
cloudfrontHost = imageHost,
|
||||
|
@ -42,6 +43,7 @@ class AudioContentMainService(
|
|||
.toList()
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
fun getNewContentFor2WeeksByTheme(theme: String, member: Member, pageable: Pageable): GetNewContentAllResponse {
|
||||
val totalCount = repository.totalCountNewContentFor2Weeks(theme, isAdult = member.auth != null)
|
||||
val items = repository.findByThemeFor2Weeks(
|
||||
|
@ -141,4 +143,32 @@ class AudioContentMainService(
|
|||
}
|
||||
.filter { it.contents.isNotEmpty() }
|
||||
.toList()
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
@Cacheable(
|
||||
cacheNames = ["default"],
|
||||
key = "'getAudioContentCurationListWithPaging:' + #memberId + ':' + #isAdult + ':' + #offset + ':' + #limit"
|
||||
)
|
||||
fun getAudioContentCurationListWithPaging(memberId: Long, isAdult: Boolean, offset: Long, limit: Long) =
|
||||
repository.getAudioContentCurationList(isAdult = isAdult, offset = offset, limit = limit)
|
||||
.asSequence()
|
||||
.map {
|
||||
GetAudioContentCurationResponse(
|
||||
curationId = it.id!!,
|
||||
title = it.title,
|
||||
description = it.description,
|
||||
contents = repository.findAudioContentByCurationId(
|
||||
curationId = it.id!!,
|
||||
cloudfrontHost = imageHost,
|
||||
isAdult = isAdult
|
||||
)
|
||||
.asSequence()
|
||||
.filter { content ->
|
||||
!blockMemberRepository.isBlocked(blockedMemberId = memberId, memberId = content.creatorId)
|
||||
}
|
||||
.toList()
|
||||
)
|
||||
}
|
||||
.filter { it.contents.isNotEmpty() }
|
||||
.toList()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue