Merge pull request '크리에이터 관리자 - 정산 API 캐시 추가' (#82) from test into main
Reviewed-on: #82
This commit is contained in:
		| @@ -7,7 +7,9 @@ import kr.co.vividnext.sodalive.admin.calculate.GetCumulativeSalesByContentRespo | |||||||
| 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 kr.co.vividnext.sodalive.member.Member | import kr.co.vividnext.sodalive.member.Member | ||||||
|  | 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 | ||||||
| @@ -15,6 +17,11 @@ import kotlin.math.roundToInt | |||||||
|  |  | ||||||
| @Service | @Service | ||||||
| class CreatorAdminCalculateService(private val repository: CreatorAdminCalculateQueryRepository) { | class CreatorAdminCalculateService(private val repository: CreatorAdminCalculateQueryRepository) { | ||||||
|  |     @Transactional(readOnly = true) | ||||||
|  |     @Cacheable( | ||||||
|  |         cacheNames = ["default"], | ||||||
|  |         key = "'creatorCalculateLive:' + " + "#member + ':' + #startDateStr + ':' + #endDateStr" | ||||||
|  |     ) | ||||||
|     fun getCalculateLive(startDateStr: String, endDateStr: String, member: Member): List<GetCalculateLiveResponse> { |     fun getCalculateLive(startDateStr: String, endDateStr: String, member: Member): List<GetCalculateLiveResponse> { | ||||||
|         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) | ||||||
| @@ -77,6 +84,11 @@ class CreatorAdminCalculateService(private val repository: CreatorAdminCalculate | |||||||
|             .toList() |             .toList() | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Transactional(readOnly = true) | ||||||
|  |     @Cacheable( | ||||||
|  |         cacheNames = ["cache_ttl_3_hours"], | ||||||
|  |         key = "'creatorCalculateContentList:' + " + "#memberId + ':' + #startDateStr + ':' + #endDateStr" | ||||||
|  |     ) | ||||||
|     fun getCalculateContentList( |     fun getCalculateContentList( | ||||||
|         startDateStr: String, |         startDateStr: String, | ||||||
|         endDateStr: String, |         endDateStr: String, | ||||||
| @@ -141,6 +153,11 @@ class CreatorAdminCalculateService(private val repository: CreatorAdminCalculate | |||||||
|         return GetCalculateContentListResponse(totalCount, items) |         return GetCalculateContentListResponse(totalCount, items) | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Transactional(readOnly = true) | ||||||
|  |     @Cacheable( | ||||||
|  |         cacheNames = ["cache_ttl_3_hours"], | ||||||
|  |         key = "'creatorCumulativeSalesByContent:' + " + "#memberId + ':' + #offset + ':' + #limit" | ||||||
|  |     ) | ||||||
|     fun getCumulativeSalesByContent(memberId: Long, offset: Long, limit: Long): GetCumulativeSalesByContentResponse { |     fun getCumulativeSalesByContent(memberId: Long, offset: Long, limit: Long): GetCumulativeSalesByContentResponse { | ||||||
|         val totalCount = repository.getCumulativeSalesByContentTotalCount(memberId) |         val totalCount = repository.getCumulativeSalesByContentTotalCount(memberId) | ||||||
|         val items = repository |         val items = repository | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user