Compare commits
No commits in common. "cb1dde17bb50c159ede400c653d508fc10fa7ab1" and "c29988acf491635eaf7b0a15d650f59d4732de50" have entirely different histories.
cb1dde17bb
...
c29988acf4
|
@ -10,9 +10,6 @@ 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
|
||||||
|
@ -40,30 +37,12 @@ class RedisConfig(
|
||||||
fun cacheManager(redisConnectionFactory: RedisConnectionFactory): RedisCacheManager {
|
fun cacheManager(redisConnectionFactory: RedisConnectionFactory): RedisCacheManager {
|
||||||
val defaultCacheConfig = RedisCacheConfiguration.defaultCacheConfig()
|
val defaultCacheConfig = RedisCacheConfiguration.defaultCacheConfig()
|
||||||
.entryTtl(Duration.ofMinutes(30))
|
.entryTtl(Duration.ofMinutes(30))
|
||||||
.serializeKeysWith(RedisSerializationContext.SerializationPair.fromSerializer(StringRedisSerializer()))
|
|
||||||
.serializeValuesWith(
|
|
||||||
RedisSerializationContext.SerializationPair.fromSerializer(
|
|
||||||
GenericJackson2JsonRedisSerializer()
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
val cacheConfigMap = mutableMapOf<String, RedisCacheConfiguration>()
|
val cacheConfigMap = mutableMapOf<String, RedisCacheConfiguration>()
|
||||||
cacheConfigMap["default"] = RedisCacheConfiguration.defaultCacheConfig()
|
cacheConfigMap["default"] = RedisCacheConfiguration.defaultCacheConfig()
|
||||||
.entryTtl(Duration.ofMinutes(30))
|
.entryTtl(Duration.ofMinutes(30))
|
||||||
.serializeKeysWith(RedisSerializationContext.SerializationPair.fromSerializer(StringRedisSerializer()))
|
|
||||||
.serializeValuesWith(
|
|
||||||
RedisSerializationContext.SerializationPair.fromSerializer(
|
|
||||||
GenericJackson2JsonRedisSerializer()
|
|
||||||
)
|
|
||||||
)
|
|
||||||
cacheConfigMap["cache_ttl_3_days"] = RedisCacheConfiguration.defaultCacheConfig()
|
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.builder(redisConnectionFactory)
|
||||||
.cacheDefaults(defaultCacheConfig)
|
.cacheDefaults(defaultCacheConfig)
|
||||||
|
|
|
@ -19,9 +19,6 @@ import org.springframework.web.bind.annotation.RequestParam
|
||||||
import org.springframework.web.bind.annotation.RequestPart
|
import org.springframework.web.bind.annotation.RequestPart
|
||||||
import org.springframework.web.bind.annotation.RestController
|
import org.springframework.web.bind.annotation.RestController
|
||||||
import org.springframework.web.multipart.MultipartFile
|
import org.springframework.web.multipart.MultipartFile
|
||||||
import java.time.DayOfWeek
|
|
||||||
import java.time.LocalDateTime
|
|
||||||
import java.time.temporal.TemporalAdjusters
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/audio-content")
|
@RequestMapping("/audio-content")
|
||||||
|
@ -152,41 +149,18 @@ class AudioContentController(private val service: AudioContentService) {
|
||||||
ApiResponse.ok(service.audioContentLike(request, member))
|
ApiResponse.ok(service.audioContentLike(request, member))
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/ranking-sort-type")
|
|
||||||
fun getAudioContentRankingSort(
|
|
||||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
|
||||||
) = run {
|
|
||||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
|
||||||
|
|
||||||
ApiResponse.ok(service.getContentRankingSortTypeList())
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/ranking")
|
@GetMapping("/ranking")
|
||||||
fun getAudioContentRanking(
|
fun getAudioContentRanking(
|
||||||
@RequestParam("sort-type", required = false) sortType: String? = "매출",
|
|
||||||
@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("로그인 정보를 확인해주세요.")
|
||||||
|
|
||||||
val currentDateTime = LocalDateTime.now()
|
|
||||||
val startDate = currentDateTime
|
|
||||||
.withHour(15)
|
|
||||||
.withMinute(0)
|
|
||||||
.withSecond(0)
|
|
||||||
.minusWeeks(1)
|
|
||||||
.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY))
|
|
||||||
val endDate = startDate
|
|
||||||
.plusDays(7)
|
|
||||||
|
|
||||||
ApiResponse.ok(
|
ApiResponse.ok(
|
||||||
service.getAudioContentRanking(
|
service.getAudioContentRanking(
|
||||||
isAdult = member.auth != null,
|
member = member,
|
||||||
startDate = startDate,
|
|
||||||
endDate = endDate,
|
|
||||||
offset = pageable.offset,
|
offset = pageable.offset,
|
||||||
limit = pageable.pageSize.toLong(),
|
limit = pageable.pageSize.toLong()
|
||||||
sortType = sortType ?: "매출"
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,11 +2,8 @@ package kr.co.vividnext.sodalive.content
|
||||||
|
|
||||||
import com.querydsl.core.types.dsl.Expressions
|
import com.querydsl.core.types.dsl.Expressions
|
||||||
import com.querydsl.jpa.impl.JPAQueryFactory
|
import com.querydsl.jpa.impl.JPAQueryFactory
|
||||||
import kr.co.vividnext.sodalive.can.use.QUseCan.useCan
|
|
||||||
import kr.co.vividnext.sodalive.content.QAudioContent.audioContent
|
import kr.co.vividnext.sodalive.content.QAudioContent.audioContent
|
||||||
import kr.co.vividnext.sodalive.content.QBundleAudioContent.bundleAudioContent
|
import kr.co.vividnext.sodalive.content.QBundleAudioContent.bundleAudioContent
|
||||||
import kr.co.vividnext.sodalive.content.comment.QAudioContentComment.audioContentComment
|
|
||||||
import kr.co.vividnext.sodalive.content.like.QAudioContentLike.audioContentLike
|
|
||||||
import kr.co.vividnext.sodalive.content.main.GetAudioContentMainItem
|
import kr.co.vividnext.sodalive.content.main.GetAudioContentMainItem
|
||||||
import kr.co.vividnext.sodalive.content.main.GetAudioContentRankingItem
|
import kr.co.vividnext.sodalive.content.main.GetAudioContentRankingItem
|
||||||
import kr.co.vividnext.sodalive.content.main.GetNewContentUploadCreator
|
import kr.co.vividnext.sodalive.content.main.GetNewContentUploadCreator
|
||||||
|
@ -91,8 +88,7 @@ interface AudioContentQueryRepository {
|
||||||
startDate: LocalDateTime,
|
startDate: LocalDateTime,
|
||||||
endDate: LocalDateTime,
|
endDate: LocalDateTime,
|
||||||
offset: Long = 0,
|
offset: Long = 0,
|
||||||
limit: Long = 12,
|
limit: Long = 12
|
||||||
sortType: String = "매출"
|
|
||||||
): List<GetAudioContentRankingItem>
|
): List<GetAudioContentRankingItem>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -447,11 +443,11 @@ class AudioContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory)
|
||||||
startDate: LocalDateTime,
|
startDate: LocalDateTime,
|
||||||
endDate: LocalDateTime,
|
endDate: LocalDateTime,
|
||||||
offset: Long,
|
offset: Long,
|
||||||
limit: Long,
|
limit: Long
|
||||||
sortType: String
|
|
||||||
): List<GetAudioContentRankingItem> {
|
): List<GetAudioContentRankingItem> {
|
||||||
var where = audioContent.isActive.isTrue
|
var where = order.createdAt.goe(startDate)
|
||||||
.and(audioContent.member.id.ne(648))
|
.and(order.createdAt.lt(endDate))
|
||||||
|
.and(audioContent.isActive.isTrue)
|
||||||
.and(audioContent.member.isNotNull)
|
.and(audioContent.member.isNotNull)
|
||||||
.and(audioContent.duration.isNotNull)
|
.and(audioContent.duration.isNotNull)
|
||||||
.and(audioContent.member.isActive.isTrue)
|
.and(audioContent.member.isActive.isTrue)
|
||||||
|
@ -461,7 +457,7 @@ class AudioContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory)
|
||||||
where = where.and(audioContent.isAdult.isFalse)
|
where = where.and(audioContent.isAdult.isFalse)
|
||||||
}
|
}
|
||||||
|
|
||||||
var select = queryFactory
|
return queryFactory
|
||||||
.select(
|
.select(
|
||||||
QGetAudioContentRankingItem(
|
QGetAudioContentRankingItem(
|
||||||
audioContent.id,
|
audioContent.id,
|
||||||
|
@ -474,70 +470,13 @@ class AudioContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory)
|
||||||
member.nickname
|
member.nickname
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
select = when (sortType) {
|
|
||||||
"후원" -> {
|
|
||||||
select
|
|
||||||
.from(useCan)
|
|
||||||
.innerJoin(useCan.audioContent, audioContent)
|
|
||||||
.innerJoin(audioContent.member, member)
|
|
||||||
.innerJoin(audioContent.theme, audioContentTheme)
|
|
||||||
.where(
|
|
||||||
where
|
|
||||||
.and(useCan.createdAt.goe(startDate))
|
|
||||||
.and(useCan.createdAt.lt(endDate))
|
|
||||||
)
|
|
||||||
.groupBy(audioContent.id)
|
|
||||||
.orderBy(useCan.can.add(useCan.rewardCan).sum().desc(), audioContent.createdAt.asc())
|
|
||||||
}
|
|
||||||
|
|
||||||
"댓글" -> {
|
|
||||||
select
|
|
||||||
.from(audioContentComment)
|
|
||||||
.innerJoin(audioContentComment.audioContent, audioContent)
|
|
||||||
.innerJoin(audioContentComment.audioContent.member, member)
|
|
||||||
.innerJoin(audioContentComment.audioContent.theme, audioContentTheme)
|
|
||||||
.where(
|
|
||||||
where
|
|
||||||
.and(audioContentComment.createdAt.goe(startDate))
|
|
||||||
.and(audioContentComment.createdAt.lt(endDate))
|
|
||||||
)
|
|
||||||
.groupBy(audioContentComment.audioContent.id)
|
|
||||||
.orderBy(audioContentComment.id.count().desc(), audioContent.createdAt.asc())
|
|
||||||
}
|
|
||||||
|
|
||||||
"좋아요" -> {
|
|
||||||
select
|
|
||||||
.from(audioContentLike)
|
|
||||||
.innerJoin(audioContentLike.audioContent, audioContent)
|
|
||||||
.innerJoin(audioContentLike.audioContent.member, member)
|
|
||||||
.innerJoin(audioContentLike.audioContent.theme, audioContentTheme)
|
|
||||||
.where(
|
|
||||||
where
|
|
||||||
.and(audioContentLike.createdAt.goe(startDate))
|
|
||||||
.and(audioContentLike.createdAt.lt(endDate))
|
|
||||||
)
|
|
||||||
.groupBy(audioContentLike.audioContent.id)
|
|
||||||
.orderBy(audioContentLike.id.count().desc(), audioContent.createdAt.asc())
|
|
||||||
}
|
|
||||||
|
|
||||||
else -> {
|
|
||||||
select
|
|
||||||
.from(order)
|
.from(order)
|
||||||
.innerJoin(order.audioContent, audioContent)
|
.innerJoin(order.audioContent, audioContent)
|
||||||
.innerJoin(audioContent.member, member)
|
.innerJoin(audioContent.member, member)
|
||||||
.innerJoin(audioContent.theme, audioContentTheme)
|
.innerJoin(audioContent.theme, audioContentTheme)
|
||||||
.where(
|
.where(where)
|
||||||
where
|
|
||||||
.and(order.createdAt.goe(startDate))
|
|
||||||
.and(order.createdAt.lt(endDate))
|
|
||||||
)
|
|
||||||
.groupBy(audioContent.id)
|
.groupBy(audioContent.id)
|
||||||
.orderBy(order.can.sum().desc(), audioContent.createdAt.asc())
|
.orderBy(order.can.sum().desc(), audioContent.createdAt.asc())
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return select
|
|
||||||
.offset(offset)
|
.offset(offset)
|
||||||
.limit(limit)
|
.limit(limit)
|
||||||
.fetch()
|
.fetch()
|
||||||
|
|
|
@ -24,16 +24,17 @@ import kr.co.vividnext.sodalive.member.Member
|
||||||
import kr.co.vividnext.sodalive.member.block.BlockMemberRepository
|
import kr.co.vividnext.sodalive.member.block.BlockMemberRepository
|
||||||
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.context.ApplicationEventPublisher
|
import org.springframework.context.ApplicationEventPublisher
|
||||||
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
|
||||||
import org.springframework.web.multipart.MultipartFile
|
import org.springframework.web.multipart.MultipartFile
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
|
import java.time.DayOfWeek
|
||||||
import java.time.LocalDateTime
|
import java.time.LocalDateTime
|
||||||
import java.time.ZoneId
|
import java.time.ZoneId
|
||||||
import java.time.format.DateTimeFormatter
|
import java.time.format.DateTimeFormatter
|
||||||
|
import java.time.temporal.TemporalAdjusters
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
|
@ -71,10 +72,11 @@ class AudioContentService(
|
||||||
)
|
)
|
||||||
|
|
||||||
if (audioContentLike == null) {
|
if (audioContentLike == null) {
|
||||||
audioContentLike = AudioContentLike(memberId = member.id!!)
|
audioContentLike = AudioContentLike(
|
||||||
|
memberId = member.id!!,
|
||||||
|
contentId = request.contentId
|
||||||
|
)
|
||||||
|
|
||||||
val audioContent = repository.findByIdAndActive(request.contentId)
|
|
||||||
audioContentLike.audioContent = audioContent
|
|
||||||
audioContentLikeRepository.save(audioContentLike)
|
audioContentLikeRepository.save(audioContentLike)
|
||||||
} else {
|
} else {
|
||||||
audioContentLike.isActive = !audioContentLike.isActive
|
audioContentLike.isActive = !audioContentLike.isActive
|
||||||
|
@ -577,19 +579,21 @@ class AudioContentService(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Cacheable(
|
|
||||||
cacheNames = ["cache_ttl_3_days"],
|
|
||||||
key = "'contentRanking:' + ':' +" +
|
|
||||||
"#isAdult + ':' + #startDate + ':' + #endDate + ':' + #sortType + ':' + #offset + ':' + #limit"
|
|
||||||
)
|
|
||||||
fun getAudioContentRanking(
|
fun getAudioContentRanking(
|
||||||
isAdult: Boolean,
|
member: Member,
|
||||||
startDate: LocalDateTime,
|
|
||||||
endDate: LocalDateTime,
|
|
||||||
offset: Long,
|
offset: Long,
|
||||||
limit: Long,
|
limit: Long
|
||||||
sortType: String = "매출"
|
|
||||||
): GetAudioContentRanking {
|
): GetAudioContentRanking {
|
||||||
|
val currentDateTime = LocalDateTime.now()
|
||||||
|
val startDate = currentDateTime
|
||||||
|
.withHour(15)
|
||||||
|
.withMinute(0)
|
||||||
|
.withSecond(0)
|
||||||
|
.minusWeeks(1)
|
||||||
|
.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY))
|
||||||
|
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일")
|
||||||
|
|
||||||
|
@ -598,10 +602,9 @@ class AudioContentService(
|
||||||
cloudfrontHost = coverImageHost,
|
cloudfrontHost = coverImageHost,
|
||||||
startDate = startDate.minusDays(1),
|
startDate = startDate.minusDays(1),
|
||||||
endDate = endDate.minusDays(1),
|
endDate = endDate.minusDays(1),
|
||||||
isAdult = isAdult,
|
isAdult = member.auth != null,
|
||||||
offset = offset,
|
offset = offset,
|
||||||
limit = limit,
|
limit = limit
|
||||||
sortType = sortType
|
|
||||||
)
|
)
|
||||||
|
|
||||||
return GetAudioContentRanking(
|
return GetAudioContentRanking(
|
||||||
|
@ -610,8 +613,4 @@ class AudioContentService(
|
||||||
items = contentRankingItemList
|
items = contentRankingItemList
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getContentRankingSortTypeList(): List<String> {
|
|
||||||
return listOf("매출", "후원", "댓글", "좋아요")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,21 +1,20 @@
|
||||||
package kr.co.vividnext.sodalive.content.like
|
package kr.co.vividnext.sodalive.content.like
|
||||||
|
|
||||||
import kr.co.vividnext.sodalive.content.AudioContent
|
|
||||||
import java.time.LocalDateTime
|
import java.time.LocalDateTime
|
||||||
import javax.persistence.Entity
|
import javax.persistence.Entity
|
||||||
import javax.persistence.FetchType
|
|
||||||
import javax.persistence.GeneratedValue
|
import javax.persistence.GeneratedValue
|
||||||
import javax.persistence.GenerationType
|
import javax.persistence.GenerationType
|
||||||
import javax.persistence.Id
|
import javax.persistence.Id
|
||||||
import javax.persistence.JoinColumn
|
|
||||||
import javax.persistence.ManyToOne
|
|
||||||
import javax.persistence.PrePersist
|
import javax.persistence.PrePersist
|
||||||
import javax.persistence.PreUpdate
|
import javax.persistence.PreUpdate
|
||||||
import javax.persistence.Table
|
import javax.persistence.Table
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "content_like")
|
@Table(name = "content_like")
|
||||||
data class AudioContentLike(val memberId: Long) {
|
data class AudioContentLike(
|
||||||
|
val memberId: Long,
|
||||||
|
val contentId: Long
|
||||||
|
) {
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
var id: Long? = null
|
var id: Long? = null
|
||||||
|
@ -35,8 +34,4 @@ data class AudioContentLike(val memberId: Long) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var isActive = true
|
var isActive = true
|
||||||
|
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
|
||||||
@JoinColumn(name = "content_id", nullable = false)
|
|
||||||
var audioContent: AudioContent? = null
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ class AudioContentLikeQueryRepositoryImpl(private val queryFactory: JPAQueryFact
|
||||||
.selectFrom(audioContentLike)
|
.selectFrom(audioContentLike)
|
||||||
.where(
|
.where(
|
||||||
audioContentLike.memberId.eq(memberId)
|
audioContentLike.memberId.eq(memberId)
|
||||||
.and(audioContentLike.audioContent.id.eq(contentId))
|
.and(audioContentLike.contentId.eq(contentId))
|
||||||
)
|
)
|
||||||
.fetchFirst()
|
.fetchFirst()
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ class AudioContentLikeQueryRepositoryImpl(private val queryFactory: JPAQueryFact
|
||||||
.select(audioContentLike.id)
|
.select(audioContentLike.id)
|
||||||
.from(audioContentLike)
|
.from(audioContentLike)
|
||||||
.where(
|
.where(
|
||||||
audioContentLike.audioContent.id.eq(contentId)
|
audioContentLike.contentId.eq(contentId)
|
||||||
.and(audioContentLike.isActive.isTrue)
|
.and(audioContentLike.isActive.isTrue)
|
||||||
)
|
)
|
||||||
.fetch()
|
.fetch()
|
||||||
|
|
|
@ -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.AudioContentService
|
|
||||||
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
|
||||||
|
@ -16,12 +15,12 @@ import org.springframework.data.domain.Pageable
|
||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
import java.time.DayOfWeek
|
import java.time.DayOfWeek
|
||||||
import java.time.LocalDateTime
|
import java.time.LocalDateTime
|
||||||
|
import java.time.format.DateTimeFormatter
|
||||||
import java.time.temporal.TemporalAdjusters
|
import java.time.temporal.TemporalAdjusters
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
class AudioContentMainService(
|
class AudioContentMainService(
|
||||||
private val repository: AudioContentRepository,
|
private val repository: AudioContentRepository,
|
||||||
private val audioContentService: AudioContentService,
|
|
||||||
private val blockMemberRepository: BlockMemberRepository,
|
private val blockMemberRepository: BlockMemberRepository,
|
||||||
private val orderService: OrderService,
|
private val orderService: OrderService,
|
||||||
private val audioContentThemeRepository: AudioContentThemeQueryRepository,
|
private val audioContentThemeRepository: AudioContentThemeQueryRepository,
|
||||||
|
@ -67,14 +66,7 @@ class AudioContentMainService(
|
||||||
.withSecond(0)
|
.withSecond(0)
|
||||||
val endDate = startDate.plusDays(7)
|
val endDate = startDate.plusDays(7)
|
||||||
|
|
||||||
val contentRankingSortTypeList = audioContentService.getContentRankingSortTypeList()
|
val contentRanking = getContentRanking(isAdult = isAdult, startDate = startDate, endDate = endDate)
|
||||||
val contentRanking = audioContentService.getAudioContentRanking(
|
|
||||||
isAdult = isAdult,
|
|
||||||
startDate = startDate,
|
|
||||||
endDate = endDate,
|
|
||||||
offset = 0,
|
|
||||||
limit = 12
|
|
||||||
)
|
|
||||||
|
|
||||||
return GetAudioContentMainResponse(
|
return GetAudioContentMainResponse(
|
||||||
newContentUploadCreatorList = newContentUploadCreatorList,
|
newContentUploadCreatorList = newContentUploadCreatorList,
|
||||||
|
@ -83,7 +75,6 @@ class AudioContentMainService(
|
||||||
themeList = themeList,
|
themeList = themeList,
|
||||||
newContentList = newContentList,
|
newContentList = newContentList,
|
||||||
curationList = curationList,
|
curationList = curationList,
|
||||||
contentRankingSortTypeList = contentRankingSortTypeList,
|
|
||||||
contentRanking = contentRanking
|
contentRanking = contentRanking
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -118,7 +109,7 @@ class AudioContentMainService(
|
||||||
return GetNewContentAllResponse(totalCount, items)
|
return GetNewContentAllResponse(totalCount, items)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Cacheable(cacheNames = ["default"], key = "'newContentUploadCreatorList:' + #memberId + ':' + #isAdult")
|
@Cacheable(cacheNames = ["default"], key = "'getNewContentUploadCreatorList:' + #memberId + ':' + #isAdult")
|
||||||
fun getNewContentUploadCreatorList(memberId: Long, isAdult: Boolean): List<GetNewContentUploadCreator> {
|
fun getNewContentUploadCreatorList(memberId: Long, isAdult: Boolean): List<GetNewContentUploadCreator> {
|
||||||
return repository.getNewContentUploadCreatorList(
|
return repository.getNewContentUploadCreatorList(
|
||||||
cloudfrontHost = imageHost,
|
cloudfrontHost = imageHost,
|
||||||
|
@ -129,7 +120,7 @@ class AudioContentMainService(
|
||||||
.toList()
|
.toList()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Cacheable(cacheNames = ["default"], key = "'contentMainBannerList:' + #memberId + ':' + #isAdult")
|
@Cacheable(cacheNames = ["default"], key = "'getAudioContentMainBannerList:' + #memberId + ':' + #isAdult")
|
||||||
fun getAudioContentMainBannerList(memberId: Long, isAdult: Boolean) =
|
fun getAudioContentMainBannerList(memberId: Long, isAdult: Boolean) =
|
||||||
repository.getAudioContentMainBannerList(isAdult = isAdult)
|
repository.getAudioContentMainBannerList(isAdult = isAdult)
|
||||||
.asSequence()
|
.asSequence()
|
||||||
|
@ -178,7 +169,7 @@ class AudioContentMainService(
|
||||||
}
|
}
|
||||||
.toList()
|
.toList()
|
||||||
|
|
||||||
@Cacheable(cacheNames = ["default"], key = "'contentCurationList:' + #memberId + ':' + #isAdult")
|
@Cacheable(cacheNames = ["default"], key = "'getAudioContentCurationList:' + #memberId + ':' + #isAdult")
|
||||||
fun getAudioContentCurationList(memberId: Long, isAdult: Boolean) =
|
fun getAudioContentCurationList(memberId: Long, isAdult: Boolean) =
|
||||||
repository.getAudioContentCurations(isAdult = isAdult)
|
repository.getAudioContentCurations(isAdult = isAdult)
|
||||||
.asSequence()
|
.asSequence()
|
||||||
|
@ -201,4 +192,27 @@ class AudioContentMainService(
|
||||||
}
|
}
|
||||||
.filter { it.contents.isNotEmpty() }
|
.filter { it.contents.isNotEmpty() }
|
||||||
.toList()
|
.toList()
|
||||||
|
|
||||||
|
@Cacheable(
|
||||||
|
cacheNames = ["cache_ttl_3_days"],
|
||||||
|
key = "'getAudioContentCurationList:' + ':' + #isAdult + ':' + #startDate + ':' + #endDate"
|
||||||
|
)
|
||||||
|
fun getContentRanking(isAdult: Boolean, startDate: LocalDateTime, endDate: LocalDateTime): GetAudioContentRanking {
|
||||||
|
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
|
||||||
|
)
|
||||||
|
|
||||||
|
return GetAudioContentRanking(
|
||||||
|
startDate = startDate.format(startDateFormatter),
|
||||||
|
endDate = endDate.minusDays(1).format(endDateFormatter),
|
||||||
|
contentRankingItemList
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,5 @@ data class GetAudioContentMainResponse(
|
||||||
val themeList: List<String>,
|
val themeList: List<String>,
|
||||||
val newContentList: List<GetAudioContentMainItem>,
|
val newContentList: List<GetAudioContentMainItem>,
|
||||||
val curationList: List<GetAudioContentCurationResponse>,
|
val curationList: List<GetAudioContentCurationResponse>,
|
||||||
val contentRankingSortTypeList: List<String>,
|
|
||||||
val contentRanking: GetAudioContentRanking
|
val contentRanking: GetAudioContentRanking
|
||||||
)
|
)
|
||||||
|
|
|
@ -4,9 +4,9 @@ import com.fasterxml.jackson.annotation.JsonProperty
|
||||||
import com.querydsl.core.annotations.QueryProjection
|
import com.querydsl.core.annotations.QueryProjection
|
||||||
|
|
||||||
data class GetAudioContentRanking(
|
data class GetAudioContentRanking(
|
||||||
@JsonProperty("startDate") val startDate: String,
|
val startDate: String,
|
||||||
@JsonProperty("endDate") val endDate: String,
|
val endDate: String,
|
||||||
@JsonProperty("items") val items: List<GetAudioContentRankingItem>
|
val items: List<GetAudioContentRankingItem>
|
||||||
)
|
)
|
||||||
|
|
||||||
data class GetAudioContentRankingItem @QueryProjection constructor(
|
data class GetAudioContentRankingItem @QueryProjection constructor(
|
||||||
|
|
|
@ -28,7 +28,7 @@ class AudioContentThemeQueryRepository(
|
||||||
.fetch()
|
.fetch()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Cacheable(cacheNames = ["default"], key = "'activeThemeOfContent:' + ':' + #isAdult")
|
@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)
|
||||||
|
|
Loading…
Reference in New Issue