test #340
| @@ -68,4 +68,24 @@ class AdminChatCalculateQueryRepository( | |||||||
|             .limit(limit) |             .limit(limit) | ||||||
|             .fetch() |             .fetch() | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     fun getCharacterCalculateTotalCount( | ||||||
|  |         startUtc: LocalDateTime, | ||||||
|  |         endInclusiveUtc: LocalDateTime | ||||||
|  |     ): Int { | ||||||
|  |         return queryFactory | ||||||
|  |             .select(chatCharacter.id) | ||||||
|  |             .from(useCan) | ||||||
|  |             .innerJoin(useCan.characterImage, characterImage) | ||||||
|  |             .innerJoin(characterImage.chatCharacter, chatCharacter) | ||||||
|  |             .where( | ||||||
|  |                 useCan.isRefund.isFalse | ||||||
|  |                     .and(useCan.canUsage.`in`(CanUsage.CHARACTER_IMAGE_PURCHASE, CanUsage.CHAT_MESSAGE_PURCHASE)) | ||||||
|  |                     .and(useCan.createdAt.goe(startUtc)) | ||||||
|  |                     .and(useCan.createdAt.loe(endInclusiveUtc)) | ||||||
|  |             ) | ||||||
|  |             .groupBy(chatCharacter.id) | ||||||
|  |             .fetch() | ||||||
|  |             .size | ||||||
|  |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -21,7 +21,7 @@ class AdminChatCalculateService( | |||||||
|         sort: ChatCharacterCalculateSort, |         sort: ChatCharacterCalculateSort, | ||||||
|         offset: Long, |         offset: Long, | ||||||
|         pageSize: Int |         pageSize: Int | ||||||
|     ): List<ChatCharacterCalculateItem> { |     ): ChatCharacterCalculateResponse { | ||||||
|         // 날짜 유효성 검증 (KST 기준) |         // 날짜 유효성 검증 (KST 기준) | ||||||
|         val startDate = LocalDate.parse(startDateStr, dateFormatter) |         val startDate = LocalDate.parse(startDateStr, dateFormatter) | ||||||
|         val endDate = LocalDate.parse(endDateStr, dateFormatter) |         val endDate = LocalDate.parse(endDateStr, dateFormatter) | ||||||
| @@ -35,7 +35,9 @@ class AdminChatCalculateService( | |||||||
|         val startUtc = startDateStr.convertLocalDateTime() |         val startUtc = startDateStr.convertLocalDateTime() | ||||||
|         val endInclusiveUtc = endDateStr.convertLocalDateTime(hour = 23, minute = 59, second = 59) |         val endInclusiveUtc = endDateStr.convertLocalDateTime(hour = 23, minute = 59, second = 59) | ||||||
|  |  | ||||||
|  |         val totalCount = repository.getCharacterCalculateTotalCount(startUtc, endInclusiveUtc) | ||||||
|         val rows = repository.getCharacterCalculate(startUtc, endInclusiveUtc, sort, offset, pageSize.toLong()) |         val rows = repository.getCharacterCalculate(startUtc, endInclusiveUtc, sort, offset, pageSize.toLong()) | ||||||
|         return rows.map { it.toItem() } |         val items = rows.map { it.toItem() } | ||||||
|  |         return ChatCharacterCalculateResponse(totalCount, items) | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -20,7 +20,7 @@ data class ChatCharacterCalculateQueryData @QueryProjection constructor( | |||||||
|     val messagePurchaseCan: Int? |     val messagePurchaseCan: Int? | ||||||
| ) | ) | ||||||
|  |  | ||||||
| // 응답 DTO | // 응답 DTO (아이템) | ||||||
| data class ChatCharacterCalculateItem( | data class ChatCharacterCalculateItem( | ||||||
|     @JsonProperty("characterId") val characterId: Long, |     @JsonProperty("characterId") val characterId: Long, | ||||||
|     @JsonProperty("characterImage") val characterImage: String?, |     @JsonProperty("characterImage") val characterImage: String?, | ||||||
| @@ -32,6 +32,12 @@ data class ChatCharacterCalculateItem( | |||||||
|     @JsonProperty("settlementKrw") val settlementKrw: Int |     @JsonProperty("settlementKrw") val settlementKrw: Int | ||||||
| ) | ) | ||||||
|  |  | ||||||
|  | // 응답 DTO (전체) | ||||||
|  | data class ChatCharacterCalculateResponse( | ||||||
|  |     @JsonProperty("totalCount") val totalCount: Int, | ||||||
|  |     @JsonProperty("items") val items: List<ChatCharacterCalculateItem> | ||||||
|  | ) | ||||||
|  |  | ||||||
| fun ChatCharacterCalculateQueryData.toItem(): ChatCharacterCalculateItem { | fun ChatCharacterCalculateQueryData.toItem(): ChatCharacterCalculateItem { | ||||||
|     val image = imagePurchaseCan ?: 0 |     val image = imagePurchaseCan ?: 0 | ||||||
|     val message = messagePurchaseCan ?: 0 |     val message = messagePurchaseCan ?: 0 | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user