Compare commits
No commits in common. "e5fdced681369634db82ed69d3bad967940fdccb" and "afb99fef64a3d4f2570ae13bbe04899b30187651" have entirely different histories.
e5fdced681
...
afb99fef64
|
@ -10,6 +10,9 @@ import org.springframework.data.redis.connection.RedisConnectionFactory
|
||||||
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory
|
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory
|
||||||
import org.springframework.data.redis.core.RedisTemplate
|
import org.springframework.data.redis.core.RedisTemplate
|
||||||
import org.springframework.data.redis.repository.configuration.EnableRedisRepositories
|
import org.springframework.data.redis.repository.configuration.EnableRedisRepositories
|
||||||
|
import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer
|
||||||
|
import org.springframework.data.redis.serializer.RedisSerializationContext
|
||||||
|
import org.springframework.data.redis.serializer.StringRedisSerializer
|
||||||
import java.time.Duration
|
import java.time.Duration
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
|
@ -34,19 +37,29 @@ class RedisConfig(
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
fun cacheManager(redisConnectionFactory: RedisConnectionFactory): RedisCacheManager {
|
fun cacheManager(connectionFactory: RedisConnectionFactory): RedisCacheManager {
|
||||||
val defaultCacheConfig = RedisCacheConfiguration.defaultCacheConfig()
|
val defaultConfig = RedisCacheConfiguration.defaultCacheConfig()
|
||||||
.entryTtl(Duration.ofMinutes(30))
|
.entryTtl(Duration.ofHours(1)) // Default TTL
|
||||||
|
.serializeKeysWith(RedisSerializationContext.SerializationPair.fromSerializer(StringRedisSerializer()))
|
||||||
|
.serializeValuesWith(
|
||||||
|
RedisSerializationContext.SerializationPair.fromSerializer(
|
||||||
|
GenericJackson2JsonRedisSerializer()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
val cacheConfigMap = mutableMapOf<String, RedisCacheConfiguration>()
|
val weekLivedCacheConfig = RedisCacheConfiguration.defaultCacheConfig()
|
||||||
cacheConfigMap["default"] = RedisCacheConfiguration.defaultCacheConfig()
|
|
||||||
.entryTtl(Duration.ofMinutes(30))
|
|
||||||
cacheConfigMap["cache_ttl_3_days"] = RedisCacheConfiguration.defaultCacheConfig()
|
|
||||||
.entryTtl(Duration.ofDays(3))
|
.entryTtl(Duration.ofDays(3))
|
||||||
|
.serializeKeysWith(RedisSerializationContext.SerializationPair.fromSerializer(StringRedisSerializer()))
|
||||||
|
.serializeValuesWith(
|
||||||
|
RedisSerializationContext.SerializationPair.fromSerializer(
|
||||||
|
GenericJackson2JsonRedisSerializer()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
return RedisCacheManager.builder(redisConnectionFactory)
|
return RedisCacheManager.RedisCacheManagerBuilder
|
||||||
.cacheDefaults(defaultCacheConfig)
|
.fromConnectionFactory(connectionFactory)
|
||||||
.withInitialCacheConfigurations(cacheConfigMap)
|
.cacheDefaults(defaultConfig)
|
||||||
|
.withCacheConfiguration("weekLivedCache", weekLivedCacheConfig)
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ import kr.co.vividnext.sodalive.content.order.QOrder.order
|
||||||
import kr.co.vividnext.sodalive.content.theme.QAudioContentTheme.audioContentTheme
|
import kr.co.vividnext.sodalive.content.theme.QAudioContentTheme.audioContentTheme
|
||||||
import kr.co.vividnext.sodalive.event.QEvent.event
|
import kr.co.vividnext.sodalive.event.QEvent.event
|
||||||
import kr.co.vividnext.sodalive.member.QMember.member
|
import kr.co.vividnext.sodalive.member.QMember.member
|
||||||
|
import org.springframework.cache.annotation.Cacheable
|
||||||
import org.springframework.data.jpa.repository.JpaRepository
|
import org.springframework.data.jpa.repository.JpaRepository
|
||||||
import org.springframework.stereotype.Repository
|
import org.springframework.stereotype.Repository
|
||||||
import java.time.LocalDateTime
|
import java.time.LocalDateTime
|
||||||
|
@ -76,6 +77,9 @@ interface AudioContentQueryRepository {
|
||||||
|
|
||||||
fun getAudioContentMainBannerList(isAdult: Boolean): List<AudioContentBanner>
|
fun getAudioContentMainBannerList(isAdult: Boolean): List<AudioContentBanner>
|
||||||
fun getAudioContentCurations(isAdult: Boolean): List<AudioContentCuration>
|
fun getAudioContentCurations(isAdult: Boolean): List<AudioContentCuration>
|
||||||
|
|
||||||
|
fun getAudioContentCurationList(isAdult: Boolean, offset: Long = 0, limit: Long = 10): List<AudioContentCuration>
|
||||||
|
|
||||||
fun findAudioContentByCurationId(
|
fun findAudioContentByCurationId(
|
||||||
curationId: Long,
|
curationId: Long,
|
||||||
cloudfrontHost: String,
|
cloudfrontHost: String,
|
||||||
|
@ -386,6 +390,10 @@ class AudioContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory)
|
||||||
.fetch()
|
.fetch()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Cacheable(
|
||||||
|
value = ["getAudioContentCurations"],
|
||||||
|
cacheManager = "cacheManager"
|
||||||
|
)
|
||||||
override fun getAudioContentCurations(isAdult: Boolean): List<AudioContentCuration> {
|
override fun getAudioContentCurations(isAdult: Boolean): List<AudioContentCuration> {
|
||||||
var where = audioContentCuration.isActive.isTrue
|
var where = audioContentCuration.isActive.isTrue
|
||||||
|
|
||||||
|
@ -400,6 +408,26 @@ class AudioContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory)
|
||||||
.fetch()
|
.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)
|
||||||
|
.orderBy(audioContentCuration.orders.asc())
|
||||||
|
.offset(offset)
|
||||||
|
.limit(limit)
|
||||||
|
.fetch()
|
||||||
|
}
|
||||||
|
|
||||||
override fun findAudioContentByCurationId(
|
override fun findAudioContentByCurationId(
|
||||||
curationId: Long,
|
curationId: Long,
|
||||||
cloudfrontHost: String,
|
cloudfrontHost: String,
|
||||||
|
@ -437,6 +465,10 @@ class AudioContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory)
|
||||||
.fetch()
|
.fetch()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Cacheable(
|
||||||
|
value = ["weekLivedCache"],
|
||||||
|
cacheManager = "cacheManager"
|
||||||
|
)
|
||||||
override fun getAudioContentRanking(
|
override fun getAudioContentRanking(
|
||||||
cloudfrontHost: String,
|
cloudfrontHost: String,
|
||||||
isAdult: Boolean,
|
isAdult: Boolean,
|
||||||
|
|
|
@ -23,6 +23,33 @@ class AudioContentMainController(private val service: AudioContentMainService) {
|
||||||
ApiResponse.ok(service.getMain(member = member))
|
ApiResponse.ok(service.getMain(member = member))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/new-content-upload-creator")
|
||||||
|
fun getNewContentUploadCreatorList(
|
||||||
|
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||||
|
) = run {
|
||||||
|
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||||
|
|
||||||
|
ApiResponse.ok(service.getNewContentUploadCreatorList(member = member))
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/banner-list")
|
||||||
|
fun getAudioContentMainBannerList(
|
||||||
|
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||||
|
) = run {
|
||||||
|
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||||
|
|
||||||
|
ApiResponse.ok(service.getAudioContentMainBannerList(member = member))
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/order-list")
|
||||||
|
fun getAudioContentMainOrderList(
|
||||||
|
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||||
|
) = run {
|
||||||
|
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||||
|
|
||||||
|
ApiResponse.ok(service.getAudioContentMainOrderList(member = member))
|
||||||
|
}
|
||||||
|
|
||||||
@GetMapping("/new")
|
@GetMapping("/new")
|
||||||
fun getNewContentByTheme(
|
fun getNewContentByTheme(
|
||||||
@RequestParam("theme") theme: String,
|
@RequestParam("theme") theme: String,
|
||||||
|
@ -53,4 +80,29 @@ class AudioContentMainController(private val service: AudioContentMainService) {
|
||||||
|
|
||||||
ApiResponse.ok(service.getNewContentFor2WeeksByTheme(theme, member, pageable))
|
ApiResponse.ok(service.getNewContentFor2WeeksByTheme(theme, member, pageable))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/curation-list")
|
||||||
|
fun getAudioContentMainCurationList(
|
||||||
|
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?,
|
||||||
|
pageable: Pageable
|
||||||
|
) = run {
|
||||||
|
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||||
|
|
||||||
|
ApiResponse.ok(
|
||||||
|
service.getAudioContentMainCurationList(
|
||||||
|
member,
|
||||||
|
offset = pageable.offset,
|
||||||
|
limit = pageable.pageSize.toLong()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/content-ranking")
|
||||||
|
fun getAudioContentMainContentRanking(
|
||||||
|
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||||
|
) = run {
|
||||||
|
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||||
|
|
||||||
|
ApiResponse.ok(service.getAudioContentMainContentRanking(member))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,103 +30,21 @@ class AudioContentMainService(
|
||||||
) {
|
) {
|
||||||
fun getMain(member: Member): GetAudioContentMainResponse {
|
fun getMain(member: Member): GetAudioContentMainResponse {
|
||||||
val isAdult = member.auth != null
|
val isAdult = member.auth != null
|
||||||
val memberId = member.id!!
|
|
||||||
|
|
||||||
// 2주일 이내에 콘텐츠를 올린 크리에이터 20명 조회
|
// 2주일 이내에 콘텐츠를 올린 크리에이터 20명 조회
|
||||||
val newContentUploadCreatorList = getNewContentUploadCreatorList(memberId = memberId, isAdult = isAdult)
|
val newContentUploadCreatorList = repository.getNewContentUploadCreatorList(
|
||||||
|
|
||||||
val bannerList = getAudioContentMainBannerList(memberId = memberId, isAdult = isAdult)
|
|
||||||
|
|
||||||
// 구매목록 20개
|
|
||||||
val orderList = orderService.getAudioContentMainOrderList(
|
|
||||||
member = member,
|
|
||||||
limit = 20
|
|
||||||
)
|
|
||||||
|
|
||||||
// 콘텐츠 테마
|
|
||||||
val themeList = audioContentThemeRepository.getActiveThemeOfContent(isAdult = isAdult)
|
|
||||||
|
|
||||||
// 새 콘텐츠 20개 - 시간 내림차순 정렬
|
|
||||||
val newContentList = repository.findByTheme(
|
|
||||||
cloudfrontHost = imageHost,
|
cloudfrontHost = imageHost,
|
||||||
isAdult = isAdult
|
isAdult = isAdult
|
||||||
)
|
|
||||||
.asSequence()
|
|
||||||
.filter { !blockMemberRepository.isBlocked(blockedMemberId = memberId, memberId = it.creatorId) }
|
|
||||||
.toList()
|
|
||||||
|
|
||||||
val curationList = getAudioContentCurationList(memberId = memberId, isAdult = isAdult)
|
|
||||||
|
|
||||||
val currentDateTime = LocalDateTime.now()
|
|
||||||
val startDate = currentDateTime
|
|
||||||
.minusWeeks(1)
|
|
||||||
.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY))
|
|
||||||
.withHour(15)
|
|
||||||
.withMinute(0)
|
|
||||||
.withSecond(0)
|
|
||||||
val endDate = startDate.plusDays(7)
|
|
||||||
|
|
||||||
val contentRanking = getContentRanking(isAdult = isAdult, startDate = startDate, endDate = endDate)
|
|
||||||
|
|
||||||
return GetAudioContentMainResponse(
|
|
||||||
newContentUploadCreatorList = newContentUploadCreatorList,
|
|
||||||
bannerList = bannerList,
|
|
||||||
orderList = orderList,
|
|
||||||
themeList = themeList,
|
|
||||||
newContentList = newContentList,
|
|
||||||
curationList = curationList,
|
|
||||||
contentRanking = contentRanking
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getThemeList(member: Member): List<String> {
|
|
||||||
return audioContentThemeRepository.getActiveThemeOfContent(isAdult = member.auth != null)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getNewContentByTheme(theme: String, member: Member, pageable: Pageable): List<GetAudioContentMainItem> {
|
|
||||||
return repository.findByTheme(
|
|
||||||
cloudfrontHost = imageHost,
|
|
||||||
theme = theme,
|
|
||||||
isAdult = member.auth != null,
|
|
||||||
offset = pageable.offset,
|
|
||||||
limit = pageable.pageSize.toLong()
|
|
||||||
)
|
)
|
||||||
.asSequence()
|
.asSequence()
|
||||||
.filter { !blockMemberRepository.isBlocked(blockedMemberId = member.id!!, memberId = it.creatorId) }
|
.filter { !blockMemberRepository.isBlocked(blockedMemberId = member.id!!, memberId = it.creatorId) }
|
||||||
.toList()
|
.toList()
|
||||||
}
|
|
||||||
|
|
||||||
fun getNewContentFor2WeeksByTheme(theme: String, member: Member, pageable: Pageable): GetNewContentAllResponse {
|
val bannerList = repository.getAudioContentMainBannerList(isAdult = isAdult)
|
||||||
val totalCount = repository.totalCountNewContentFor2Weeks(theme, isAdult = member.auth != null)
|
|
||||||
val items = repository.findByThemeFor2Weeks(
|
|
||||||
cloudfrontHost = imageHost,
|
|
||||||
theme = theme,
|
|
||||||
isAdult = member.auth != null,
|
|
||||||
offset = pageable.offset,
|
|
||||||
limit = pageable.pageSize.toLong()
|
|
||||||
)
|
|
||||||
|
|
||||||
return GetNewContentAllResponse(totalCount, items)
|
|
||||||
}
|
|
||||||
|
|
||||||
@Cacheable(cacheNames = ["default"], key = "'getNewContentUploadCreatorList:' + #memberId + ':' + #isAdult")
|
|
||||||
fun getNewContentUploadCreatorList(memberId: Long, isAdult: Boolean): List<GetNewContentUploadCreator> {
|
|
||||||
return repository.getNewContentUploadCreatorList(
|
|
||||||
cloudfrontHost = imageHost,
|
|
||||||
isAdult = isAdult
|
|
||||||
)
|
|
||||||
.asSequence()
|
|
||||||
.filter { !blockMemberRepository.isBlocked(blockedMemberId = memberId, memberId = it.creatorId) }
|
|
||||||
.toList()
|
|
||||||
}
|
|
||||||
|
|
||||||
@Cacheable(cacheNames = ["default"], key = "'getAudioContentMainBannerList:' + #memberId + ':' + #isAdult")
|
|
||||||
fun getAudioContentMainBannerList(memberId: Long, isAdult: Boolean) =
|
|
||||||
repository.getAudioContentMainBannerList(isAdult = isAdult)
|
|
||||||
.asSequence()
|
.asSequence()
|
||||||
.filter {
|
.filter {
|
||||||
if (it.type == AudioContentBannerType.CREATOR && it.creator != null) {
|
if (it.type == AudioContentBannerType.CREATOR && it.creator != null) {
|
||||||
!blockMemberRepository.isBlocked(blockedMemberId = memberId, memberId = it.creator!!.id!!)
|
!blockMemberRepository.isBlocked(blockedMemberId = member.id!!, memberId = it.creator!!.id!!)
|
||||||
} else {
|
} else {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
@ -169,9 +87,26 @@ class AudioContentMainService(
|
||||||
}
|
}
|
||||||
.toList()
|
.toList()
|
||||||
|
|
||||||
@Cacheable(cacheNames = ["default"], key = "'getAudioContentCurationList:' + #memberId + ':' + #isAdult")
|
// 구매목록 20개
|
||||||
fun getAudioContentCurationList(memberId: Long, isAdult: Boolean) =
|
val orderList = orderService.getAudioContentMainOrderList(
|
||||||
repository.getAudioContentCurations(isAdult = isAdult)
|
member = member,
|
||||||
|
limit = 20
|
||||||
|
)
|
||||||
|
|
||||||
|
// 콘텐츠 테마
|
||||||
|
val themeList = audioContentThemeRepository.getActiveThemeOfContent(isAdult = isAdult)
|
||||||
|
|
||||||
|
// 새 콘텐츠 20개 - 시간 내림차순 정렬
|
||||||
|
val newContentList = repository.findByTheme(
|
||||||
|
cloudfrontHost = imageHost,
|
||||||
|
isAdult = isAdult
|
||||||
|
)
|
||||||
|
.asSequence()
|
||||||
|
.filter { !blockMemberRepository.isBlocked(blockedMemberId = member.id!!, memberId = it.creatorId) }
|
||||||
|
.toList()
|
||||||
|
|
||||||
|
val curationList = repository
|
||||||
|
.getAudioContentCurations(isAdult = isAdult)
|
||||||
.asSequence()
|
.asSequence()
|
||||||
.map {
|
.map {
|
||||||
GetAudioContentCurationResponse(
|
GetAudioContentCurationResponse(
|
||||||
|
@ -185,7 +120,10 @@ class AudioContentMainService(
|
||||||
)
|
)
|
||||||
.asSequence()
|
.asSequence()
|
||||||
.filter { content ->
|
.filter { content ->
|
||||||
!blockMemberRepository.isBlocked(blockedMemberId = memberId, memberId = content.creatorId)
|
!blockMemberRepository.isBlocked(
|
||||||
|
blockedMemberId = member.id!!,
|
||||||
|
memberId = content.creatorId
|
||||||
|
)
|
||||||
}
|
}
|
||||||
.toList()
|
.toList()
|
||||||
)
|
)
|
||||||
|
@ -193,11 +131,210 @@ class AudioContentMainService(
|
||||||
.filter { it.contents.isNotEmpty() }
|
.filter { it.contents.isNotEmpty() }
|
||||||
.toList()
|
.toList()
|
||||||
|
|
||||||
@Cacheable(
|
val currentDateTime = LocalDateTime.now()
|
||||||
cacheNames = ["cache_ttl_3_days"],
|
val startDate = currentDateTime
|
||||||
key = "'getAudioContentCurationList:' + ':' + #isAdult + ':' + #startDate + ':' + #endDate"
|
.minusWeeks(1)
|
||||||
|
.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY))
|
||||||
|
.withHour(15)
|
||||||
|
.withMinute(0)
|
||||||
|
.withSecond(0)
|
||||||
|
val endDate = startDate
|
||||||
|
.plusDays(7)
|
||||||
|
|
||||||
|
val startDateFormatter = DateTimeFormatter.ofPattern("yyyy년 MM월 dd일")
|
||||||
|
val endDateFormatter = DateTimeFormatter.ofPattern("MM월 dd일")
|
||||||
|
|
||||||
|
val contentRankingItemList = repository
|
||||||
|
.getAudioContentRanking(
|
||||||
|
cloudfrontHost = imageHost,
|
||||||
|
startDate = startDate.minusDays(1),
|
||||||
|
endDate = endDate.minusDays(1),
|
||||||
|
isAdult = isAdult
|
||||||
)
|
)
|
||||||
fun getContentRanking(isAdult: Boolean, startDate: LocalDateTime, endDate: LocalDateTime): GetAudioContentRanking {
|
|
||||||
|
val contentRanking = GetAudioContentRanking(
|
||||||
|
startDate = startDate.format(startDateFormatter),
|
||||||
|
endDate = endDate.minusDays(1).format(endDateFormatter),
|
||||||
|
contentRankingItemList
|
||||||
|
)
|
||||||
|
|
||||||
|
return GetAudioContentMainResponse(
|
||||||
|
newContentUploadCreatorList = newContentUploadCreatorList,
|
||||||
|
bannerList = bannerList,
|
||||||
|
orderList = orderList,
|
||||||
|
themeList = themeList,
|
||||||
|
newContentList = newContentList,
|
||||||
|
curationList = curationList,
|
||||||
|
contentRanking = contentRanking
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Cacheable(
|
||||||
|
value = ["getNewContentUploadCreatorList"],
|
||||||
|
cacheManager = "cacheManager"
|
||||||
|
)
|
||||||
|
fun getNewContentUploadCreatorList(member: Member): List<GetNewContentUploadCreator> {
|
||||||
|
val isAdult = member.auth != null
|
||||||
|
|
||||||
|
// 2주일 이내에 콘텐츠를 올린 크리에이터 20명 조회
|
||||||
|
return repository.getNewContentUploadCreatorList(
|
||||||
|
cloudfrontHost = imageHost,
|
||||||
|
isAdult = isAdult
|
||||||
|
)
|
||||||
|
.asSequence()
|
||||||
|
.filter { !blockMemberRepository.isBlocked(blockedMemberId = member.id!!, memberId = it.creatorId) }
|
||||||
|
.toList()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Cacheable(
|
||||||
|
value = ["getAudioContentMainBannerList"],
|
||||||
|
cacheManager = "cacheManager"
|
||||||
|
)
|
||||||
|
fun getAudioContentMainBannerList(member: Member): List<GetAudioContentBannerResponse> {
|
||||||
|
val isAdult = member.auth != null
|
||||||
|
|
||||||
|
return repository
|
||||||
|
.getAudioContentMainBannerList(isAdult = isAdult)
|
||||||
|
.asSequence()
|
||||||
|
.filter {
|
||||||
|
if (it.type == AudioContentBannerType.CREATOR && it.creator != null) {
|
||||||
|
!blockMemberRepository.isBlocked(blockedMemberId = member.id!!, memberId = it.creator!!.id!!)
|
||||||
|
} else {
|
||||||
|
true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.map {
|
||||||
|
GetAudioContentBannerResponse(
|
||||||
|
type = it.type,
|
||||||
|
thumbnailImageUrl = "$imageHost/${it.thumbnailImage}",
|
||||||
|
eventItem = if (it.type == AudioContentBannerType.EVENT && it.event != null) {
|
||||||
|
EventItem(
|
||||||
|
id = it.event!!.id!!,
|
||||||
|
thumbnailImageUrl = if (!it.event!!.thumbnailImage.startsWith("https://")) {
|
||||||
|
"$imageHost/${it.event!!.thumbnailImage}"
|
||||||
|
} else {
|
||||||
|
it.event!!.thumbnailImage
|
||||||
|
},
|
||||||
|
detailImageUrl = if (
|
||||||
|
it.event!!.detailImage != null &&
|
||||||
|
!it.event!!.detailImage!!.startsWith("https://")
|
||||||
|
) {
|
||||||
|
"$imageHost/${it.event!!.detailImage}"
|
||||||
|
} else {
|
||||||
|
it.event!!.detailImage
|
||||||
|
},
|
||||||
|
popupImageUrl = null,
|
||||||
|
link = it.event!!.link,
|
||||||
|
title = it.event!!.title,
|
||||||
|
isPopup = false
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
null
|
||||||
|
},
|
||||||
|
creatorId = if (it.type == AudioContentBannerType.CREATOR && it.creator != null) {
|
||||||
|
it.creator!!.id
|
||||||
|
} else {
|
||||||
|
null
|
||||||
|
},
|
||||||
|
link = it.link
|
||||||
|
)
|
||||||
|
}
|
||||||
|
.toList()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getAudioContentMainOrderList(member: Member): List<GetAudioContentMainItem> {
|
||||||
|
return orderService
|
||||||
|
.getAudioContentMainOrderList(
|
||||||
|
member = member,
|
||||||
|
limit = 20
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getThemeList(member: Member): List<String> {
|
||||||
|
return audioContentThemeRepository.getActiveThemeOfContent(isAdult = member.auth != null)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getNewContentByTheme(theme: String, member: Member, pageable: Pageable): List<GetAudioContentMainItem> {
|
||||||
|
return repository.findByTheme(
|
||||||
|
cloudfrontHost = imageHost,
|
||||||
|
theme = theme,
|
||||||
|
isAdult = member.auth != null,
|
||||||
|
offset = pageable.offset,
|
||||||
|
limit = pageable.pageSize.toLong()
|
||||||
|
)
|
||||||
|
.asSequence()
|
||||||
|
.filter { !blockMemberRepository.isBlocked(blockedMemberId = member.id!!, memberId = it.creatorId) }
|
||||||
|
.toList()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getNewContentFor2WeeksByTheme(theme: String, member: Member, pageable: Pageable): GetNewContentAllResponse {
|
||||||
|
val totalCount = repository.totalCountNewContentFor2Weeks(theme, isAdult = member.auth != null)
|
||||||
|
val items = repository.findByThemeFor2Weeks(
|
||||||
|
cloudfrontHost = imageHost,
|
||||||
|
theme = theme,
|
||||||
|
isAdult = member.auth != null,
|
||||||
|
offset = pageable.offset,
|
||||||
|
limit = pageable.pageSize.toLong()
|
||||||
|
)
|
||||||
|
|
||||||
|
return GetNewContentAllResponse(totalCount, items)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Cacheable(
|
||||||
|
value = ["getAudioContentMainCurationList"],
|
||||||
|
cacheManager = "cacheManager"
|
||||||
|
)
|
||||||
|
fun getAudioContentMainCurationList(
|
||||||
|
member: Member,
|
||||||
|
offset: Long,
|
||||||
|
limit: Long
|
||||||
|
): List<GetAudioContentCurationResponse> {
|
||||||
|
val isAdult = member.auth != null
|
||||||
|
|
||||||
|
return 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 = member.id!!,
|
||||||
|
memberId = content.creatorId
|
||||||
|
)
|
||||||
|
}
|
||||||
|
.toList()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
.filter { it.contents.isNotEmpty() }
|
||||||
|
.toList()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getAudioContentMainContentRanking(member: Member): GetAudioContentRanking {
|
||||||
|
val isAdult = member.auth != null
|
||||||
|
|
||||||
|
val currentDateTime = LocalDateTime.now()
|
||||||
|
val startDate = currentDateTime
|
||||||
|
.minusWeeks(1)
|
||||||
|
.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY))
|
||||||
|
.withHour(15)
|
||||||
|
.withMinute(0)
|
||||||
|
.withSecond(0)
|
||||||
|
val endDate = startDate
|
||||||
|
.plusDays(7)
|
||||||
|
|
||||||
val startDateFormatter = DateTimeFormatter.ofPattern("yyyy년 MM월 dd일")
|
val startDateFormatter = DateTimeFormatter.ofPattern("yyyy년 MM월 dd일")
|
||||||
val endDateFormatter = DateTimeFormatter.ofPattern("MM월 dd일")
|
val endDateFormatter = DateTimeFormatter.ofPattern("MM월 dd일")
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@ import com.querydsl.jpa.impl.JPAQueryFactory
|
||||||
import kr.co.vividnext.sodalive.content.QAudioContent.audioContent
|
import kr.co.vividnext.sodalive.content.QAudioContent.audioContent
|
||||||
import kr.co.vividnext.sodalive.content.theme.QAudioContentTheme.audioContentTheme
|
import kr.co.vividnext.sodalive.content.theme.QAudioContentTheme.audioContentTheme
|
||||||
import org.springframework.beans.factory.annotation.Value
|
import org.springframework.beans.factory.annotation.Value
|
||||||
import org.springframework.cache.annotation.Cacheable
|
|
||||||
import org.springframework.stereotype.Repository
|
import org.springframework.stereotype.Repository
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
|
@ -28,7 +27,6 @@ class AudioContentThemeQueryRepository(
|
||||||
.fetch()
|
.fetch()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Cacheable(cacheNames = ["default"], key = "'getActiveThemeOfContent:' + ':' + #isAdult")
|
|
||||||
fun getActiveThemeOfContent(isAdult: Boolean = false): List<String> {
|
fun getActiveThemeOfContent(isAdult: Boolean = false): List<String> {
|
||||||
var where = audioContent.isActive.isTrue
|
var where = audioContent.isActive.isTrue
|
||||||
.and(audioContentTheme.isActive.isTrue)
|
.and(audioContentTheme.isActive.isTrue)
|
||||||
|
|
|
@ -5,6 +5,7 @@ import kr.co.vividnext.sodalive.aws.s3.S3Uploader
|
||||||
import kr.co.vividnext.sodalive.common.SodaException
|
import kr.co.vividnext.sodalive.common.SodaException
|
||||||
import kr.co.vividnext.sodalive.utils.generateFileName
|
import kr.co.vividnext.sodalive.utils.generateFileName
|
||||||
import org.springframework.beans.factory.annotation.Value
|
import org.springframework.beans.factory.annotation.Value
|
||||||
|
import org.springframework.cache.annotation.Cacheable
|
||||||
import org.springframework.data.repository.findByIdOrNull
|
import org.springframework.data.repository.findByIdOrNull
|
||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
import org.springframework.transaction.annotation.Transactional
|
import org.springframework.transaction.annotation.Transactional
|
||||||
|
@ -20,6 +21,10 @@ class EventService(
|
||||||
@Value("\${cloud.aws.cloud-front.host}")
|
@Value("\${cloud.aws.cloud-front.host}")
|
||||||
private val cloudFrontHost: String
|
private val cloudFrontHost: String
|
||||||
) {
|
) {
|
||||||
|
@Cacheable(
|
||||||
|
value = ["getEventList"],
|
||||||
|
cacheManager = "cacheManager"
|
||||||
|
)
|
||||||
fun getEventList(): GetEventResponse {
|
fun getEventList(): GetEventResponse {
|
||||||
val eventList = repository.getEventList()
|
val eventList = repository.getEventList()
|
||||||
.asSequence()
|
.asSequence()
|
||||||
|
|
|
@ -9,6 +9,7 @@ import kr.co.vividnext.sodalive.member.MemberRole
|
||||||
import kr.co.vividnext.sodalive.member.QMember.member
|
import kr.co.vividnext.sodalive.member.QMember.member
|
||||||
import kr.co.vividnext.sodalive.member.following.QCreatorFollowing.creatorFollowing
|
import kr.co.vividnext.sodalive.member.following.QCreatorFollowing.creatorFollowing
|
||||||
import org.springframework.beans.factory.annotation.Value
|
import org.springframework.beans.factory.annotation.Value
|
||||||
|
import org.springframework.cache.annotation.Cacheable
|
||||||
import org.springframework.stereotype.Repository
|
import org.springframework.stereotype.Repository
|
||||||
import java.time.LocalDateTime
|
import java.time.LocalDateTime
|
||||||
|
|
||||||
|
@ -19,6 +20,10 @@ class LiveRecommendRepository(
|
||||||
@Value("\${cloud.aws.cloud-front.host}")
|
@Value("\${cloud.aws.cloud-front.host}")
|
||||||
private val cloudFrontHost: String
|
private val cloudFrontHost: String
|
||||||
) {
|
) {
|
||||||
|
@Cacheable(
|
||||||
|
value = ["getRecommendLive"],
|
||||||
|
cacheManager = "cacheManager"
|
||||||
|
)
|
||||||
fun getRecommendLive(
|
fun getRecommendLive(
|
||||||
memberId: Long,
|
memberId: Long,
|
||||||
isBlocked: (Long) -> Boolean,
|
isBlocked: (Long) -> Boolean,
|
||||||
|
|
Loading…
Reference in New Issue