Merge pull request 'fix(channel-donation): 기부 목록 조회 월 범위를 한국 시간 기준으로 계산한다' (#394) from test into main

Reviewed-on: #394
This commit is contained in:
2026-03-03 02:23:01 +00:00
2 changed files with 29 additions and 2 deletions

View File

@@ -0,0 +1,23 @@
# 20260303_기부목록조회월범위한국시간수정
## 구현 항목
- [x] `ChannelDonationService.kt``getChannelDonationList` 내 조회 범위 수정
- 현재 UTC 기준을 한국 시간(KST) 기준으로 변경
- 해당월 1일 00:00:00(KST) ~ 다음달 1일 00:00:00(KST)
## 검증 결과
### 1차 구현
- 무엇을: 기부 목록 조회 시 사용되는 시간 범위를 한국 시간 기준으로 변경
- 왜: 현재 UTC 기준으로 1일~말일이 설정되어 있어 한국 사용자의 기대와 다름
- 어떻게: `ZoneId.of("Asia/Seoul")`을 사용하여 현재 한국 시간을 구하고, 해당 월의 시작일 자정을 계산하도록 수정함.
```kotlin
val kstZoneId = ZoneId.of("Asia/Seoul")
val nowKst = ZonedDateTime.now(kstZoneId)
val startDateTime = nowKst
.with(TemporalAdjusters.firstDayOfMonth())
.toLocalDate()
.atStartOfDay()
val endDateTime = startDateTime.plusMonths(1)
```
- 결과: 기존 단위 테스트(`ChannelDonationServiceTest`) 4건 모두 통과 확인.
- `./gradlew test --tests kr.co.vividnext.sodalive.explorer.profile.channelDonation.ChannelDonationServiceTest` 실행 결과 성공.

View File

@@ -11,7 +11,8 @@ import kr.co.vividnext.sodalive.member.MemberRole
import org.springframework.beans.factory.annotation.Value import org.springframework.beans.factory.annotation.Value
import org.springframework.stereotype.Service import org.springframework.stereotype.Service
import org.springframework.transaction.annotation.Transactional import org.springframework.transaction.annotation.Transactional
import java.time.LocalDate import java.time.ZoneId
import java.time.ZonedDateTime
import java.time.format.DateTimeFormatter import java.time.format.DateTimeFormatter
import java.time.temporal.TemporalAdjusters import java.time.temporal.TemporalAdjusters
@@ -62,8 +63,11 @@ class ChannelDonationService(
memberRepository.findCreatorByIdOrNull(creatorId) memberRepository.findCreatorByIdOrNull(creatorId)
?: throw SodaException(messageKey = "member.validation.creator_not_found") ?: throw SodaException(messageKey = "member.validation.creator_not_found")
val startDateTime = LocalDate.now() val kstZoneId = ZoneId.of("Asia/Seoul")
val nowKst = ZonedDateTime.now(kstZoneId)
val startDateTime = nowKst
.with(TemporalAdjusters.firstDayOfMonth()) .with(TemporalAdjusters.firstDayOfMonth())
.toLocalDate()
.atStartOfDay() .atStartOfDay()
val endDateTime = startDateTime.plusMonths(1) val endDateTime = startDateTime.plusMonths(1)
val isCreator = member.role == MemberRole.CREATOR && creatorId == member.id val isCreator = member.role == MemberRole.CREATOR && creatorId == member.id