Compare commits

..

No commits in common. "ceef9ca9798d154e7b7369e996589edbdec4af6f" and "efe8f4f939b0510234e7f25db61cd8721d8cbb0a" have entirely different histories.

7 changed files with 44 additions and 171 deletions

View File

@ -64,7 +64,6 @@ interface AudioContentQueryRepository {
theme: String = "", theme: String = "",
sortType: SortType = SortType.NEWEST, sortType: SortType = SortType.NEWEST,
isAdult: Boolean = false, isAdult: Boolean = false,
contentType: ContentType = ContentType.ALL,
offset: Long = 0, offset: Long = 0,
limit: Long = 20 limit: Long = 20
): List<GetAudioContentMainItem> ): List<GetAudioContentMainItem>
@ -80,17 +79,11 @@ interface AudioContentQueryRepository {
memberId: Long, memberId: Long,
theme: String = "", theme: String = "",
isAdult: Boolean = false, isAdult: Boolean = false,
contentType: ContentType = ContentType.ALL,
offset: Long = 0, offset: Long = 0,
limit: Long = 20 limit: Long = 20
): List<GetAudioContentMainItem> ): List<GetAudioContentMainItem>
fun totalCountNewContentFor2Weeks( fun totalCountNewContentFor2Weeks(theme: String, memberId: Long, isAdult: Boolean): Int
theme: String,
memberId: Long,
isAdult: Boolean,
contentType: ContentType = ContentType.ALL
): Int
fun getNewContentUploadCreatorList( fun getNewContentUploadCreatorList(
cloudfrontHost: String, cloudfrontHost: String,
@ -102,8 +95,7 @@ interface AudioContentQueryRepository {
fun findAudioContentByCurationId( fun findAudioContentByCurationId(
curationId: Long, curationId: Long,
cloudfrontHost: String, cloudfrontHost: String,
isAdult: Boolean, isAdult: Boolean
contentType: ContentType = ContentType.ALL
): List<GetAudioContentMainItem> ): List<GetAudioContentMainItem>
fun getAudioContentRanking( fun getAudioContentRanking(
@ -341,7 +333,6 @@ class AudioContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory)
theme: String, theme: String,
sortType: SortType, sortType: SortType,
isAdult: Boolean, isAdult: Boolean,
contentType: ContentType,
offset: Long, offset: Long,
limit: Long limit: Long
): List<GetAudioContentMainItem> { ): List<GetAudioContentMainItem> {
@ -370,13 +361,6 @@ class AudioContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory)
if (!isAdult) { if (!isAdult) {
where = where.and(audioContent.isAdult.isFalse) where = where.and(audioContent.isAdult.isFalse)
} else {
if (contentType != ContentType.ALL) {
where = where.and(
audioContent.member.auth.gender.eq(if (contentType == ContentType.MALE) 0 else 1)
.or(audioContent.isAdult.isFalse)
)
}
} }
if (theme.isNotBlank()) { if (theme.isNotBlank()) {
@ -433,12 +417,7 @@ class AudioContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory)
.size .size
} }
override fun totalCountNewContentFor2Weeks( override fun totalCountNewContentFor2Weeks(theme: String, memberId: Long, isAdult: Boolean): Int {
theme: String,
memberId: Long,
isAdult: Boolean,
contentType: ContentType
): Int {
var where = audioContent.isActive.isTrue var where = audioContent.isActive.isTrue
.and(audioContent.duration.isNotNull) .and(audioContent.duration.isNotNull)
.and(audioContent.releaseDate.goe(LocalDateTime.now().minusWeeks(2))) .and(audioContent.releaseDate.goe(LocalDateTime.now().minusWeeks(2)))
@ -450,13 +429,6 @@ class AudioContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory)
if (!isAdult) { if (!isAdult) {
where = where.and(audioContent.isAdult.isFalse) where = where.and(audioContent.isAdult.isFalse)
} else {
if (contentType != ContentType.ALL) {
where = where.and(
audioContent.member.auth.gender.eq(if (contentType == ContentType.MALE) 0 else 1)
.or(audioContent.isAdult.isFalse)
)
}
} }
if (theme.isNotBlank()) { if (theme.isNotBlank()) {
@ -478,7 +450,6 @@ class AudioContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory)
memberId: Long, memberId: Long,
theme: String, theme: String,
isAdult: Boolean, isAdult: Boolean,
contentType: ContentType,
offset: Long, offset: Long,
limit: Long limit: Long
): List<GetAudioContentMainItem> { ): List<GetAudioContentMainItem> {
@ -493,13 +464,6 @@ class AudioContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory)
if (!isAdult) { if (!isAdult) {
where = where.and(audioContent.isAdult.isFalse) where = where.and(audioContent.isAdult.isFalse)
} else {
if (contentType != ContentType.ALL) {
where = where.and(
audioContent.member.auth.gender.eq(if (contentType == ContentType.MALE) 0 else 1)
.or(audioContent.isAdult.isFalse)
)
}
} }
if (theme.isNotBlank()) { if (theme.isNotBlank()) {
@ -550,6 +514,7 @@ class AudioContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory)
.orderBy(Expressions.numberTemplate(Double::class.java, "function('rand')").asc()) .orderBy(Expressions.numberTemplate(Double::class.java, "function('rand')").asc())
.limit(20) .limit(20)
.fetch() .fetch()
.asSequence()
.map { .map {
GetNewContentUploadCreator( GetNewContentUploadCreator(
it.id!!, it.id!!,
@ -561,6 +526,7 @@ class AudioContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory)
} }
) )
} }
.toList()
} }
override fun getAudioContentMainBannerList(isAdult: Boolean): List<AudioContentBanner> { override fun getAudioContentMainBannerList(isAdult: Boolean): List<AudioContentBanner> {
@ -596,8 +562,7 @@ class AudioContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory)
override fun findAudioContentByCurationId( override fun findAudioContentByCurationId(
curationId: Long, curationId: Long,
cloudfrontHost: String, cloudfrontHost: String,
isAdult: Boolean, isAdult: Boolean
contentType: ContentType
): List<GetAudioContentMainItem> { ): List<GetAudioContentMainItem> {
var where = audioContent.isActive.isTrue var where = audioContent.isActive.isTrue
.and(audioContent.member.isNotNull) .and(audioContent.member.isNotNull)
@ -607,13 +572,6 @@ class AudioContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory)
if (!isAdult) { if (!isAdult) {
where = where.and(audioContent.isAdult.isFalse) where = where.and(audioContent.isAdult.isFalse)
} else {
if (contentType != ContentType.ALL) {
where = where.and(
audioContent.member.auth.gender.eq(if (contentType == ContentType.MALE) 0 else 1)
.or(audioContent.isAdult.isFalse)
)
}
} }
return queryFactory 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.ApiResponse
import kr.co.vividnext.sodalive.common.SodaException 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.content.order.OrderService
import kr.co.vividnext.sodalive.member.Member import kr.co.vividnext.sodalive.member.Member
import org.springframework.data.domain.Pageable import org.springframework.data.domain.Pageable
@ -63,22 +62,12 @@ class AudioContentMainController(
@GetMapping("/new") @GetMapping("/new")
fun getNewContentByTheme( fun getNewContentByTheme(
@RequestParam("theme") theme: String, @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?, @AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?,
pageable: Pageable pageable: Pageable
) = run { ) = run {
if (member == null) throw SodaException("로그인 정보를 확인해주세요.") if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
ApiResponse.ok( ApiResponse.ok(service.getNewContentByTheme(theme, member, pageable))
service.getNewContentByTheme(
theme,
isAdultContentVisible = isAdultContentVisible ?: true,
contentType = contentType ?: ContentType.ALL,
member,
pageable
)
)
} }
@GetMapping("/theme") @GetMapping("/theme")
@ -93,28 +82,16 @@ class AudioContentMainController(
@GetMapping("/new/all") @GetMapping("/new/all")
fun getNewContentAllByTheme( fun getNewContentAllByTheme(
@RequestParam("theme") theme: String, @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?, @AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?,
pageable: Pageable pageable: Pageable
) = run { ) = run {
if (member == null) throw SodaException("로그인 정보를 확인해주세요.") if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
ApiResponse.ok( ApiResponse.ok(service.getNewContentFor2WeeksByTheme(theme, member, pageable))
service.getNewContentFor2WeeksByTheme(
theme = theme,
isAdultContentVisible = isAdultContentVisible ?: true,
contentType = contentType ?: ContentType.ALL,
member = member,
pageable = pageable
)
)
} }
@GetMapping("/curation-list") @GetMapping("/curation-list")
fun getCurationList( fun getCurationList(
@RequestParam("isAdultContentVisible", required = false) isAdultContentVisible: Boolean? = null,
@RequestParam("contentType", required = false) contentType: ContentType? = null,
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?, @AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?,
pageable: Pageable pageable: Pageable
) = run { ) = run {
@ -123,8 +100,7 @@ class AudioContentMainController(
ApiResponse.ok( ApiResponse.ok(
service.getAudioContentCurationListWithPaging( service.getAudioContentCurationListWithPaging(
memberId = member.id!!, memberId = member.id!!,
isAdult = member.auth != null && (isAdultContentVisible ?: true), isAdult = member.auth != null,
contentType = contentType ?: ContentType.ALL,
offset = pageable.offset, offset = pageable.offset,
limit = pageable.pageSize.toLong() limit = pageable.pageSize.toLong()
) )

View File

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

View File

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

View File

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

View File

@ -6,17 +6,15 @@ import kr.co.vividnext.sodalive.member.Member
import org.springframework.security.access.prepost.PreAuthorize import org.springframework.security.access.prepost.PreAuthorize
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.PostMapping
import org.springframework.web.bind.annotation.RequestBody
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.RequestParam
import org.springframework.web.bind.annotation.RestController import org.springframework.web.bind.annotation.RestController
@RestController @RestController
@PreAuthorize("hasRole('CREATOR')")
@RequestMapping("/live/room/menu") @RequestMapping("/live/room/menu")
class LiveRoomMenuController(private val service: LiveRoomMenuService) { class LiveRoomMenuController(private val service: LiveRoomMenuService) {
@GetMapping("/all") @GetMapping("/all")
@PreAuthorize("hasRole('CREATOR')")
fun getAllLiveMenu( fun getAllLiveMenu(
@RequestParam creatorId: Long, @RequestParam creatorId: Long,
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member? @AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
@ -25,23 +23,4 @@ class LiveRoomMenuController(private val service: LiveRoomMenuService) {
ApiResponse.ok(service.getAllLiveMenu(creatorId = creatorId, memberId = member.id!!)) ApiResponse.ok(service.getAllLiveMenu(creatorId = creatorId, memberId = member.id!!))
} }
@PostMapping
fun createOrUpdateLiveMenu(
@RequestBody request: UpdateLiveMenuRequest,
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
) = run {
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
ApiResponse.ok(
if (request.id > 0) {
service.updateLiveMenu(memberId = member.id!!, request = request)
} else {
service.createLiveMenu(
memberId = member.id!!,
request = CreateLiveMenuRequest(menu = request.menu, isActive = false)
)
}
)
}
} }