From 5adbae3213398776f9f9ab9702a7886ae4d68683 Mon Sep 17 00:00:00 2001 From: Klaus Date: Wed, 1 Jul 2026 14:00:09 +0900 Subject: [PATCH] =?UTF-8?q?fix(channel-donation):=20=ED=9B=84=EC=9B=90=20?= =?UTF-8?q?=EB=A9=94=EC=8B=9C=EC=A7=80=20=ED=9A=8C=EC=9B=90=20=EB=A1=9C?= =?UTF-8?q?=EB=94=A9=EC=9D=84=20=EB=B3=B4=EC=9E=A5=ED=95=9C=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ChannelDonationMessageRepository.kt | 1 + .../channelDonation/ChannelDonationService.kt | 1 + .../ChannelDonationMessageRepositoryTest.kt | 31 +++++++++++++++++++ 3 files changed, 33 insertions(+) diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/explorer/profile/channelDonation/ChannelDonationMessageRepository.kt b/src/main/kotlin/kr/co/vividnext/sodalive/explorer/profile/channelDonation/ChannelDonationMessageRepository.kt index 6938c582..b5f18b33 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/explorer/profile/channelDonation/ChannelDonationMessageRepository.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/explorer/profile/channelDonation/ChannelDonationMessageRepository.kt @@ -52,6 +52,7 @@ class ChannelDonationMessageQueryRepositoryImpl( return queryFactory .selectFrom(channelDonationMessage) + .leftJoin(channelDonationMessage.member).fetchJoin() .where(where) .offset(offset) .limit(limit) 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 b0ccc1f6..9cb46f3a 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 @@ -18,6 +18,7 @@ import java.time.format.DateTimeFormatter import java.time.temporal.TemporalAdjusters @Service +@Transactional(readOnly = true) class ChannelDonationService( private val canPaymentService: CanPaymentService, private val memberRepository: MemberRepository, diff --git a/src/test/kotlin/kr/co/vividnext/sodalive/explorer/profile/channelDonation/ChannelDonationMessageRepositoryTest.kt b/src/test/kotlin/kr/co/vividnext/sodalive/explorer/profile/channelDonation/ChannelDonationMessageRepositoryTest.kt index 42502116..3b8f9148 100644 --- a/src/test/kotlin/kr/co/vividnext/sodalive/explorer/profile/channelDonation/ChannelDonationMessageRepositoryTest.kt +++ b/src/test/kotlin/kr/co/vividnext/sodalive/explorer/profile/channelDonation/ChannelDonationMessageRepositoryTest.kt @@ -133,6 +133,37 @@ class ChannelDonationMessageRepositoryTest @Autowired constructor( assertEquals(3, totalCount) } + @Test + @DisplayName("목록 조회 시 후원자 회원 정보를 함께 로딩한다") + fun shouldFetchMemberWithDonationMessages() { + // given: 크리에이터/후원자와 조회 대상 메시지를 준비한다. + val creator = saveMember(nickname = "creator3", role = MemberRole.CREATOR) + val viewer = saveMember(nickname = "viewer3", role = MemberRole.USER) + val message = saveMessage(member = viewer, creator = creator, can = 1, isSecret = false) + val monthStart = LocalDateTime.now().withDayOfMonth(1).toLocalDate().atStartOfDay() + val nextMonthStart = monthStart.plusMonths(1) + updateCreatedAt(message.id!!, monthStart.plusDays(1)) + entityManager.flush() + entityManager.clear() + + // when: 목록을 조회한 뒤 영속성 컨텍스트를 비운다. + val list = channelDonationMessageRepository.getChannelDonationMessageList( + creatorId = creator.id!!, + memberId = viewer.id!!, + isCreator = false, + offset = 0, + limit = 10, + startDateTime = monthStart, + endDateTime = nextMonthStart + ) + entityManager.clear() + + // then: 조회 결과의 후원자 정보는 세션 없이도 접근 가능해야 한다. + assertEquals(1, list.size) + assertEquals(viewer.id, list[0].member!!.id) + assertEquals("viewer3", list[0].member!!.nickname) + } + private fun saveMember(nickname: String, role: MemberRole): Member { return memberRepository.saveAndFlush( Member(