From de8917b312538ad00edc82873be2d10ad80722c3 Mon Sep 17 00:00:00 2001 From: Klaus Date: Tue, 3 Mar 2026 11:11:30 +0900 Subject: [PATCH] =?UTF-8?q?fix(channel-donation):=20=EA=B8=B0=EB=B6=80=20?= =?UTF-8?q?=EB=AA=A9=EB=A1=9D=20=EC=A1=B0=ED=9A=8C=20=EC=9B=94=20=EB=B2=94?= =?UTF-8?q?=EC=9C=84=EB=A5=BC=20=ED=95=9C=EA=B5=AD=20=EC=8B=9C=EA=B0=84=20?= =?UTF-8?q?=EA=B8=B0=EC=A4=80=EC=9C=BC=EB=A1=9C=20=EA=B3=84=EC=82=B0?= =?UTF-8?q?=ED=95=9C=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...20260303_기부목록조회월범위한국시간수정.md | 23 +++++++++++++++++++ .../channelDonation/ChannelDonationService.kt | 8 +++++-- 2 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 docs/20260303_기부목록조회월범위한국시간수정.md 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