test #99

Merged
klaus merged 2 commits from test into main 2023-12-10 12:34:52 +00:00
5 changed files with 114 additions and 4 deletions

View File

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

View File

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

View File

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

View File

@ -41,7 +41,7 @@ interface LiveRoomQueryRepository {
fun getRecentRoomInfo(memberId: Long, cloudFrontHost: String): GetRecentRoomInfoResponse?
fun getDonationTotal(roomId: Long): Int?
fun getDonationList(roomId: Long, cloudFrontHost: String): List<GetLiveRoomDonationItem>
fun getRoomActiveAndChannelNameIsNotNull(): List<LiveRoom>
fun getRoomActiveAndChannelNameIsNotNull(memberId: Long): List<LiveRoom>
}
class LiveRoomQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) : LiveRoomQueryRepository {
@ -191,12 +191,13 @@ class LiveRoomQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) : L
.fetch()
}
override fun getRoomActiveAndChannelNameIsNotNull(): List<LiveRoom> {
override fun getRoomActiveAndChannelNameIsNotNull(memberId: Long): List<LiveRoom> {
return queryFactory
.selectFrom(liveRoom)
.where(
liveRoom.isActive.isTrue
.and(liveRoom.channelName.isNotNull)
.and(liveRoom.member.id.eq(memberId))
)
.fetch()
}

View File

@ -183,7 +183,7 @@ class LiveRoomService(
}
if (now == beginDateTime) {
val activeRooms = repository.getRoomActiveAndChannelNameIsNotNull()
val activeRooms = repository.getRoomActiveAndChannelNameIsNotNull(memberId = member.id!!)
for (activeRoom in activeRooms) {
activeRoom.isActive = false
}
@ -410,7 +410,7 @@ class LiveRoomService(
throw SodaException("$startAvailableDateTimeString 이후에 시작할 수 있습니다.")
}
val activeRooms = repository.getRoomActiveAndChannelNameIsNotNull()
val activeRooms = repository.getRoomActiveAndChannelNameIsNotNull(memberId = member.id!!)
for (activeRoom in activeRooms) {
activeRoom.isActive = false
}