refactor(admin-charge): 충전 상세 응답 QueryProjection 조회로 구조를 단순화한다
This commit is contained in:
13
docs/20260305_관리자충전상세쿼리프로젝션리팩토링.md
Normal file
13
docs/20260305_관리자충전상세쿼리프로젝션리팩토링.md
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
# 관리자 충전 상세 QueryProjection 리팩토링
|
||||||
|
|
||||||
|
- [x] `AdminChargeStatusService.getChargeStatusDetail` 후처리 매핑 제거
|
||||||
|
- [x] `AdminChargeStatusQueryRepository.getChargeStatusDetail` 반환 타입을 응답 DTO QueryProjection으로 변경
|
||||||
|
- [x] 관련 DTO/QueryDSL 생성 타입 정합성 확인
|
||||||
|
- [x] 검증 수행 (`lsp_diagnostics`, `./gradlew test`, `./gradlew build`)
|
||||||
|
|
||||||
|
## 검증 기록
|
||||||
|
|
||||||
|
### 1차 구현
|
||||||
|
- 무엇을: `GetChargeStatusDetailResponse`에 `@QueryProjection`을 적용하고, `AdminChargeStatusQueryRepository`가 해당 DTO를 직접 select 하도록 변경했으며, 서비스의 후처리 `map`을 제거했다. 또한 불필요해진 `GetChargeStatusDetailQueryDto.kt` 파일을 삭제했다.
|
||||||
|
- 왜: 상세 응답 가공을 서비스에서 한 번 더 수행하지 않고 DB 조회 시점(QueryProjection)에서 완성된 응답 형태를 가져오도록 구조를 단순화하기 위해서다.
|
||||||
|
- 어떻게: `lsp_diagnostics`로 수정 파일 진단을 시도했으나 `.kt` LSP 미설정으로 도구 검증이 불가함을 확인했고, 대신 `./gradlew test`와 `./gradlew build -x test`를 실행해 테스트/빌드 성공(`BUILD SUCCESSFUL`)을 확인했다.
|
||||||
@@ -88,7 +88,7 @@ class AdminChargeStatusQueryRepository(private val queryFactory: JPAQueryFactory
|
|||||||
endDate: LocalDateTime,
|
endDate: LocalDateTime,
|
||||||
paymentGateway: PaymentGateway,
|
paymentGateway: PaymentGateway,
|
||||||
currency: String? = null
|
currency: String? = null
|
||||||
): List<GetChargeStatusDetailQueryDto> {
|
): List<GetChargeStatusDetailResponse> {
|
||||||
val formattedDate = Expressions.stringTemplate(
|
val formattedDate = Expressions.stringTemplate(
|
||||||
"DATE_FORMAT({0}, {1})",
|
"DATE_FORMAT({0}, {1})",
|
||||||
Expressions.dateTimeTemplate(
|
Expressions.dateTimeTemplate(
|
||||||
@@ -117,7 +117,7 @@ class AdminChargeStatusQueryRepository(private val queryFactory: JPAQueryFactory
|
|||||||
|
|
||||||
return queryFactory
|
return queryFactory
|
||||||
.select(
|
.select(
|
||||||
QGetChargeStatusDetailQueryDto(
|
QGetChargeStatusDetailResponse(
|
||||||
charge.id,
|
charge.id,
|
||||||
member.nickname,
|
member.nickname,
|
||||||
payment.method.coalesce(""),
|
payment.method.coalesce(""),
|
||||||
|
|||||||
@@ -44,15 +44,5 @@ class AdminChargeStatusService(val repository: AdminChargeStatusQueryRepository)
|
|||||||
.toLocalDateTime()
|
.toLocalDateTime()
|
||||||
|
|
||||||
return repository.getChargeStatusDetail(startDate, endDate, paymentGateway, currency)
|
return repository.getChargeStatusDetail(startDate, endDate, paymentGateway, currency)
|
||||||
.map {
|
|
||||||
GetChargeStatusDetailResponse(
|
|
||||||
chargeId = it.chargeId,
|
|
||||||
nickname = it.nickname,
|
|
||||||
method = it.method,
|
|
||||||
amount = it.amount,
|
|
||||||
locale = it.locale,
|
|
||||||
datetime = it.datetime
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
package kr.co.vividnext.sodalive.admin.charge
|
|
||||||
|
|
||||||
import com.querydsl.core.annotations.QueryProjection
|
|
||||||
import java.math.BigDecimal
|
|
||||||
|
|
||||||
data class GetChargeStatusDetailQueryDto @QueryProjection constructor(
|
|
||||||
val chargeId: Long,
|
|
||||||
val nickname: String,
|
|
||||||
val method: String,
|
|
||||||
val amount: BigDecimal,
|
|
||||||
val locale: String,
|
|
||||||
val datetime: String
|
|
||||||
)
|
|
||||||
@@ -1,8 +1,9 @@
|
|||||||
package kr.co.vividnext.sodalive.admin.charge
|
package kr.co.vividnext.sodalive.admin.charge
|
||||||
|
|
||||||
|
import com.querydsl.core.annotations.QueryProjection
|
||||||
import java.math.BigDecimal
|
import java.math.BigDecimal
|
||||||
|
|
||||||
data class GetChargeStatusDetailResponse(
|
data class GetChargeStatusDetailResponse @QueryProjection constructor(
|
||||||
val chargeId: Long,
|
val chargeId: Long,
|
||||||
val nickname: String,
|
val nickname: String,
|
||||||
val method: String,
|
val method: String,
|
||||||
|
|||||||
Reference in New Issue
Block a user