콘텐츠 메인 - 순위 정렬(매출, 후원, 댓글, 좋아요) 추가
This commit is contained in:
@@ -24,17 +24,16 @@ import kr.co.vividnext.sodalive.member.Member
|
||||
import kr.co.vividnext.sodalive.member.block.BlockMemberRepository
|
||||
import kr.co.vividnext.sodalive.utils.generateFileName
|
||||
import org.springframework.beans.factory.annotation.Value
|
||||
import org.springframework.cache.annotation.Cacheable
|
||||
import org.springframework.context.ApplicationEventPublisher
|
||||
import org.springframework.data.repository.findByIdOrNull
|
||||
import org.springframework.stereotype.Service
|
||||
import org.springframework.transaction.annotation.Transactional
|
||||
import org.springframework.web.multipart.MultipartFile
|
||||
import java.text.SimpleDateFormat
|
||||
import java.time.DayOfWeek
|
||||
import java.time.LocalDateTime
|
||||
import java.time.ZoneId
|
||||
import java.time.format.DateTimeFormatter
|
||||
import java.time.temporal.TemporalAdjusters
|
||||
import java.util.Locale
|
||||
|
||||
@Service
|
||||
@@ -72,11 +71,10 @@ class AudioContentService(
|
||||
)
|
||||
|
||||
if (audioContentLike == null) {
|
||||
audioContentLike = AudioContentLike(
|
||||
memberId = member.id!!,
|
||||
contentId = request.contentId
|
||||
)
|
||||
audioContentLike = AudioContentLike(memberId = member.id!!)
|
||||
|
||||
val audioContent = repository.findByIdAndActive(request.contentId)
|
||||
audioContentLike.audioContent = audioContent
|
||||
audioContentLikeRepository.save(audioContentLike)
|
||||
} else {
|
||||
audioContentLike.isActive = !audioContentLike.isActive
|
||||
@@ -579,21 +577,19 @@ class AudioContentService(
|
||||
}
|
||||
}
|
||||
|
||||
@Cacheable(
|
||||
cacheNames = ["cache_ttl_3_days"],
|
||||
key = "'contentRanking:' + ':' +" +
|
||||
"#isAdult + ':' + #startDate + ':' + #endDate + ':' + #sortType + ':' + #offset + ':' + #limit"
|
||||
)
|
||||
fun getAudioContentRanking(
|
||||
member: Member,
|
||||
isAdult: Boolean,
|
||||
startDate: LocalDateTime,
|
||||
endDate: LocalDateTime,
|
||||
offset: Long,
|
||||
limit: Long
|
||||
limit: Long,
|
||||
sortType: String = "매출"
|
||||
): 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 endDateFormatter = DateTimeFormatter.ofPattern("MM월 dd일")
|
||||
|
||||
@@ -602,9 +598,10 @@ class AudioContentService(
|
||||
cloudfrontHost = coverImageHost,
|
||||
startDate = startDate.minusDays(1),
|
||||
endDate = endDate.minusDays(1),
|
||||
isAdult = member.auth != null,
|
||||
isAdult = isAdult,
|
||||
offset = offset,
|
||||
limit = limit
|
||||
limit = limit,
|
||||
sortType = sortType
|
||||
)
|
||||
|
||||
return GetAudioContentRanking(
|
||||
@@ -613,4 +610,8 @@ class AudioContentService(
|
||||
items = contentRankingItemList
|
||||
)
|
||||
}
|
||||
|
||||
fun getContentRankingSortTypeList(): List<String> {
|
||||
return listOf("매출", "후원", "댓글", "좋아요")
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user