Compare commits

..

No commits in common. "5bfcbe912624988859b407edb5fff84192bb78a6" and "d024e0fa230f02cf0d222da6b168f2664769cc71" have entirely different histories.

6 changed files with 38 additions and 119 deletions

View File

@ -79,17 +79,11 @@ interface AudioContentQueryRepository {
memberId: Long,
theme: String = "",
isAdult: Boolean = false,
contentType: ContentType = ContentType.ALL,
offset: Long = 0,
limit: Long = 20
): List<GetAudioContentMainItem>
fun totalCountNewContentFor2Weeks(
theme: String,
memberId: Long,
isAdult: Boolean,
contentType: ContentType = ContentType.ALL
): Int
fun totalCountNewContentFor2Weeks(theme: String, memberId: Long, isAdult: Boolean): Int
fun getNewContentUploadCreatorList(
cloudfrontHost: String,
@ -101,8 +95,7 @@ interface AudioContentQueryRepository {
fun findAudioContentByCurationId(
curationId: Long,
cloudfrontHost: String,
isAdult: Boolean,
contentType: ContentType = ContentType.ALL
isAdult: Boolean
): List<GetAudioContentMainItem>
fun getAudioContentRanking(
@ -424,12 +417,7 @@ class AudioContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory)
.size
}
override fun totalCountNewContentFor2Weeks(
theme: String,
memberId: Long,
isAdult: Boolean,
contentType: ContentType
): Int {
override fun totalCountNewContentFor2Weeks(theme: String, memberId: Long, isAdult: Boolean): Int {
var where = audioContent.isActive.isTrue
.and(audioContent.duration.isNotNull)
.and(audioContent.releaseDate.goe(LocalDateTime.now().minusWeeks(2)))
@ -441,12 +429,6 @@ class AudioContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory)
if (!isAdult) {
where = where.and(audioContent.isAdult.isFalse)
} else {
if (contentType != ContentType.ALL) {
where = where.and(
audioContent.member.auth.gender.eq(if (contentType == ContentType.MALE) 1 else 0)
)
}
}
if (theme.isNotBlank()) {
@ -468,7 +450,6 @@ class AudioContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory)
memberId: Long,
theme: String,
isAdult: Boolean,
contentType: ContentType,
offset: Long,
limit: Long
): List<GetAudioContentMainItem> {
@ -483,12 +464,6 @@ class AudioContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory)
if (!isAdult) {
where = where.and(audioContent.isAdult.isFalse)
} else {
if (contentType != ContentType.ALL) {
where = where.and(
audioContent.member.auth.gender.eq(if (contentType == ContentType.MALE) 1 else 0)
)
}
}
if (theme.isNotBlank()) {
@ -539,6 +514,7 @@ class AudioContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory)
.orderBy(Expressions.numberTemplate(Double::class.java, "function('rand')").asc())
.limit(20)
.fetch()
.asSequence()
.map {
GetNewContentUploadCreator(
it.id!!,
@ -550,6 +526,7 @@ class AudioContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory)
}
)
}
.toList()
}
override fun getAudioContentMainBannerList(isAdult: Boolean): List<AudioContentBanner> {
@ -585,8 +562,7 @@ class AudioContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory)
override fun findAudioContentByCurationId(
curationId: Long,
cloudfrontHost: String,
isAdult: Boolean,
contentType: ContentType
isAdult: Boolean
): List<GetAudioContentMainItem> {
var where = audioContent.isActive.isTrue
.and(audioContent.member.isNotNull)
@ -596,14 +572,6 @@ class AudioContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory)
if (!isAdult) {
where = where.and(audioContent.isAdult.isFalse)
} else {
if (contentType != ContentType.ALL) {
where = where.and(
audioContent.member.auth.gender.eq(
if (contentType == ContentType.MALE) 1 else 0
)
)
}
}
return queryFactory

View File

@ -1,12 +0,0 @@
package kr.co.vividnext.sodalive.content
enum class ContentType {
// 전체
ALL,
// 남성향
MALE,
// 여성향
FEMALE
}

View File

@ -2,7 +2,6 @@ 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.ContentType
import kr.co.vividnext.sodalive.content.order.OrderService
import kr.co.vividnext.sodalive.member.Member
import org.springframework.data.domain.Pageable
@ -83,28 +82,16 @@ class AudioContentMainController(
@GetMapping("/new/all")
fun getNewContentAllByTheme(
@RequestParam("theme") theme: String,
@RequestParam("isAdultContentVisible", required = false) isAdultContentVisible: Boolean? = null,
@RequestParam("contentType", required = false) contentType: ContentType? = null,
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?,
pageable: Pageable
) = run {
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
ApiResponse.ok(
service.getNewContentFor2WeeksByTheme(
theme = theme,
isAdultContentVisible = isAdultContentVisible ?: true,
contentType = contentType ?: ContentType.ALL,
member = member,
pageable = pageable
)
)
ApiResponse.ok(service.getNewContentFor2WeeksByTheme(theme, member, pageable))
}
@GetMapping("/curation-list")
fun getCurationList(
@RequestParam("isAdultContentVisible", required = false) isAdultContentVisible: Boolean? = null,
@RequestParam("contentType", required = false) contentType: ContentType? = null,
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?,
pageable: Pageable
) = run {
@ -113,8 +100,7 @@ class AudioContentMainController(
ApiResponse.ok(
service.getAudioContentCurationListWithPaging(
memberId = member.id!!,
isAdult = member.auth != null && (isAdultContentVisible ?: true),
contentType = contentType ?: ContentType.ALL,
isAdult = member.auth != null,
offset = pageable.offset,
limit = pageable.pageSize.toLong()
)

View File

@ -1,7 +1,6 @@
package kr.co.vividnext.sodalive.content.main
import kr.co.vividnext.sodalive.content.AudioContentRepository
import kr.co.vividnext.sodalive.content.ContentType
import kr.co.vividnext.sodalive.content.main.banner.AudioContentBannerType
import kr.co.vividnext.sodalive.content.main.banner.GetAudioContentBannerResponse
import kr.co.vividnext.sodalive.content.main.curation.GetAudioContentCurationResponse
@ -46,29 +45,20 @@ class AudioContentMainService(
}
@Transactional(readOnly = true)
fun getNewContentFor2WeeksByTheme(
theme: String,
isAdultContentVisible: Boolean,
contentType: ContentType,
member: Member,
pageable: Pageable
): GetNewContentAllResponse {
val totalCount = repository.totalCountNewContentFor2Weeks(
theme,
memberId = member.id!!,
isAdult = member.auth != null && isAdultContentVisible,
contentType = contentType
)
fun getNewContentFor2WeeksByTheme(theme: String, member: Member, pageable: Pageable): GetNewContentAllResponse {
val totalCount =
repository.totalCountNewContentFor2Weeks(theme, memberId = member.id!!, isAdult = member.auth != null)
val items = repository.findByThemeFor2Weeks(
cloudfrontHost = imageHost,
memberId = member.id!!,
theme = theme,
isAdult = member.auth != null && isAdultContentVisible,
contentType = contentType,
isAdult = member.auth != null,
offset = pageable.offset,
limit = pageable.pageSize.toLong()
)
.asSequence()
.filter { !blockMemberRepository.isBlocked(blockedMemberId = member.id!!, memberId = it.creatorId) }
.toList()
return GetNewContentAllResponse(totalCount, items)
}
@ -140,28 +130,26 @@ class AudioContentMainService(
cacheNames = ["default"],
key = "'getAudioContentCurationListWithPaging:' + #memberId + ':' + #isAdult + ':' + #offset + ':' + #limit"
)
fun getAudioContentCurationListWithPaging(
memberId: Long,
isAdult: Boolean,
contentType: ContentType,
offset: Long,
limit: Long
) = repository.getAudioContentCurationList(isAdult = isAdult, offset = offset, limit = limit)
.map {
GetAudioContentCurationResponse(
curationId = it.id!!,
title = it.title,
description = it.description,
contents = repository.findAudioContentByCurationId(
fun getAudioContentCurationListWithPaging(memberId: Long, isAdult: Boolean, offset: Long, limit: Long) =
repository.getAudioContentCurationList(isAdult = isAdult, offset = offset, limit = limit)
.asSequence()
.map {
GetAudioContentCurationResponse(
curationId = it.id!!,
cloudfrontHost = imageHost,
isAdult = isAdult,
contentType = contentType
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 { content ->
!blockMemberRepository.isBlocked(blockedMemberId = memberId, memberId = content.creatorId)
}
)
}
.filter { it.contents.isNotEmpty() }
}
.filter { it.contents.isNotEmpty() }
.toList()
}

View File

@ -33,22 +33,12 @@ class LiveRoomController(
@RequestParam timezone: String,
@RequestParam dateString: String? = null,
@RequestParam status: LiveRoomStatus,
@RequestParam("isAdultContentVisible", required = false) isAdultContentVisible: Boolean? = null,
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?,
pageable: Pageable
) = run {
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
ApiResponse.ok(
service.getRoomList(
dateString,
status,
isAdultContentVisible ?: true,
pageable,
member,
timezone
)
)
ApiResponse.ok(service.getRoomList(dateString, status, pageable, member, timezone))
}
@PostMapping

View File

@ -113,7 +113,6 @@ class LiveRoomService(
fun getRoomList(
dateString: String?,
status: LiveRoomStatus,
isAdultContentVisible: Boolean,
pageable: Pageable,
member: Member,
timezone: String
@ -124,7 +123,7 @@ class LiveRoomService(
timezone,
memberId = member.id!!,
isCreator = member.role == MemberRole.CREATOR,
isAdult = member.auth != null && isAdultContentVisible
isAdult = member.auth != null
)
} else if (dateString != null) {
getLiveRoomListReservationWithDate(
@ -133,14 +132,14 @@ class LiveRoomService(
timezone,
memberId = member.id!!,
isCreator = member.role == MemberRole.CREATOR,
isAdult = member.auth != null && isAdultContentVisible
isAdult = member.auth != null
)
} else {
getLiveRoomListReservationWithoutDate(
timezone,
isCreator = member.role == MemberRole.CREATOR,
memberId = member.id!!,
isAdult = member.auth != null && isAdultContentVisible
isAdult = member.auth != null
)
}