diff --git a/docs/20260303_기부목록조회월범위한국시간수정.md b/docs/20260303_기부목록조회월범위한국시간수정.md new file mode 100644 index 00000000..cb926b1d --- /dev/null +++ b/docs/20260303_기부목록조회월범위한국시간수정.md @@ -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` 실행 결과 성공. diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/explorer/profile/channelDonation/ChannelDonationService.kt b/src/main/kotlin/kr/co/vividnext/sodalive/explorer/profile/channelDonation/ChannelDonationService.kt index 041ed9b2..d6a48a16 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/explorer/profile/channelDonation/ChannelDonationService.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/explorer/profile/channelDonation/ChannelDonationService.kt @@ -11,7 +11,8 @@ import kr.co.vividnext.sodalive.member.MemberRole import org.springframework.beans.factory.annotation.Value import org.springframework.stereotype.Service 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.temporal.TemporalAdjusters @@ -62,8 +63,11 @@ class ChannelDonationService( memberRepository.findCreatorByIdOrNull(creatorId) ?: 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()) + .toLocalDate() .atStartOfDay() val endDateTime = startDateTime.plusMonths(1) val isCreator = member.role == MemberRole.CREATOR && creatorId == member.id