Merge pull request '콘텐츠 정산 - group by 날짜 수정' (#76) from test into main

Reviewed-on: #76
This commit is contained in:
klaus 2023-11-10 12:46:07 +00:00
commit c5164c76fc
3 changed files with 17 additions and 2 deletions

View File

@ -71,8 +71,8 @@ class AdminCalculateQueryRepository(private val queryFactory: JPAQueryFactory) {
.and(order.createdAt.goe(startDate)) .and(order.createdAt.goe(startDate))
.and(order.createdAt.loe(endDate)) .and(order.createdAt.loe(endDate))
) )
.groupBy(audioContent.id, order.type, order.createdAt, order.can) .groupBy(audioContent.id, order.type, orderFormattedDate, order.can)
.orderBy(member.id.desc(), orderFormattedDate.desc()) .orderBy(member.id.desc(), orderFormattedDate.desc(), audioContent.id.asc())
.fetch() .fetch()
} }

View File

@ -2,7 +2,9 @@ package kr.co.vividnext.sodalive.admin.calculate
import kr.co.vividnext.sodalive.can.use.CanUsage import kr.co.vividnext.sodalive.can.use.CanUsage
import kr.co.vividnext.sodalive.content.order.OrderType import kr.co.vividnext.sodalive.content.order.OrderType
import org.springframework.cache.annotation.Cacheable
import org.springframework.stereotype.Service import org.springframework.stereotype.Service
import org.springframework.transaction.annotation.Transactional
import java.time.LocalDate import java.time.LocalDate
import java.time.ZoneId import java.time.ZoneId
import java.time.format.DateTimeFormatter import java.time.format.DateTimeFormatter
@ -72,6 +74,11 @@ class AdminCalculateService(private val repository: AdminCalculateQueryRepositor
.toList() .toList()
} }
@Transactional(readOnly = true)
@Cacheable(
cacheNames = ["cache_ttl_3_hours"],
key = "'calculateContent:' + " + "#startDateStr + ':' + #endDateStr"
)
fun getCalculateContentList(startDateStr: String, endDateStr: String): List<GetCalculateContentResponse> { fun getCalculateContentList(startDateStr: String, endDateStr: String): List<GetCalculateContentResponse> {
val dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd") val dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd")
val startDate = LocalDate.parse(startDateStr, dateTimeFormatter).atTime(0, 0, 0) val startDate = LocalDate.parse(startDateStr, dateTimeFormatter).atTime(0, 0, 0)

View File

@ -64,6 +64,14 @@ class RedisConfig(
GenericJackson2JsonRedisSerializer() GenericJackson2JsonRedisSerializer()
) )
) )
cacheConfigMap["cache_ttl_3_hours"] = RedisCacheConfiguration.defaultCacheConfig()
.entryTtl(Duration.ofHours(3))
.serializeKeysWith(RedisSerializationContext.SerializationPair.fromSerializer(StringRedisSerializer()))
.serializeValuesWith(
RedisSerializationContext.SerializationPair.fromSerializer(
GenericJackson2JsonRedisSerializer()
)
)
return RedisCacheManager.builder(redisConnectionFactory) return RedisCacheManager.builder(redisConnectionFactory)
.cacheDefaults(defaultCacheConfig) .cacheDefaults(defaultCacheConfig)