fix(can): 캔 사용 내역 조회 DISTINCT 오류를 수정한다

This commit is contained in:
2026-03-16 15:46:37 +09:00
parent 8cf1ef5c69
commit 9007bd6593
4 changed files with 21 additions and 1 deletions

View File

@@ -0,0 +1,16 @@
# 20260316_캔사용내역조회DISTINCT오류수정.md
## 구현 목표
- `CanRepository.getCanUseStatus` 호출 시 발생하는 `java.sql.SQLException` (DISTINCT와 ORDER BY 충돌)을 해결한다.
## 작업 내용
- [x] `UseCanQueryDto.kt``id: Long` 필드 추가
- [x] `CanRepository.kt``getCanUseStatus` 쿼리 `select` 절에 `useCan.id` 추가
- [x] `CanServiceTest.kt``UseCanQueryDto` 생성자 호출 로직에 `id` 추가
- [x] `./gradlew ktlintFormat` 실행 및 스타일 확인
- [x] `./gradlew test` 실행하여 검증
## 검증 결과
- 무엇을: 캔 사용 내역 조회 API
- 왜: `DISTINCT` 사용 시 `ORDER BY` 컬럼(`id`)이 `SELECT` 목록에 없어 발생하는 런타임 오류 해결
- 어떻게: `id`를 DTO에 포함시켜 `SELECT` 목록에 노출되도록 수정

View File

@@ -91,6 +91,7 @@ class CanQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) : CanQue
return queryFactory
.select(
QUseCanQueryDto(
useCan.id,
useCan.canUsage,
useCan.can,
useCan.rewardCan,

View File

@@ -5,6 +5,7 @@ import kr.co.vividnext.sodalive.can.use.CanUsage
import java.time.LocalDateTime
data class UseCanQueryDto @QueryProjection constructor(
val id: Long,
val canUsage: CanUsage,
val can: Int,
val rewardCan: Int,

View File

@@ -145,9 +145,11 @@ class CanServiceTest {
audioContentTitle: String? = null,
communityPostMemberNickname: String? = null,
auditionTitle: String? = null,
characterName: String? = null
characterName: String? = null,
id: Long = 1L
): UseCanQueryDto {
return UseCanQueryDto(
id = id,
canUsage = usage,
can = can,
rewardCan = rewardCan,