fix(agent-assignment): 소속 크리에이터 조회 시각을 KST로 변환한다
This commit is contained in:
@@ -56,9 +56,19 @@ class AdminAgentReadService(
|
||||
fun getAssignedCreators(agentId: Long, offset: Long, limit: Long): GetAdminAgentAssignedCreatorResponse {
|
||||
validateAgent(agentId)
|
||||
val now = LocalDateTime.now()
|
||||
val items = queryRepository.getAssignedCreators(agentId = agentId, offset = offset, limit = limit, currentTime = now)
|
||||
.map {
|
||||
it.copy(
|
||||
assignedAt = it.assignedAt
|
||||
.atZone(ZoneId.of("UTC"))
|
||||
.withZoneSameInstant(kstZoneId)
|
||||
.toLocalDateTime()
|
||||
)
|
||||
}
|
||||
|
||||
return GetAdminAgentAssignedCreatorResponse(
|
||||
totalCount = queryRepository.getAssignedCreatorTotalCount(agentId = agentId, currentTime = now),
|
||||
items = queryRepository.getAssignedCreators(agentId = agentId, offset = offset, limit = limit, currentTime = now)
|
||||
items = items
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ import org.junit.jupiter.api.BeforeEach
|
||||
import org.junit.jupiter.api.DisplayName
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.mockito.Mockito
|
||||
import java.time.LocalDateTime
|
||||
import java.time.ZonedDateTime
|
||||
import java.util.Optional
|
||||
|
||||
@@ -117,6 +118,45 @@ class AdminAgentReadServiceTest {
|
||||
assertEquals("partner.agent.ratio.invalid_agent", exception.messageKey)
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("소속 크리에이터 목록 조회는 assignedAt을 UTC에서 KST로 변환해 반환한다")
|
||||
fun shouldConvertAssignedAtToKstWhenGettingAssignedCreators() {
|
||||
val agent = Member(
|
||||
email = "agent@test.com",
|
||||
password = "password",
|
||||
nickname = "agent",
|
||||
role = MemberRole.AGENT
|
||||
)
|
||||
agent.id = 11L
|
||||
|
||||
Mockito.`when`(memberRepository.findById(11L)).thenReturn(Optional.of(agent))
|
||||
Mockito.`when`(
|
||||
queryRepository.getAssignedCreatorTotalCount(
|
||||
Mockito.eq(11L),
|
||||
Mockito.any(LocalDateTime::class.java) ?: LocalDateTime.now()
|
||||
)
|
||||
).thenReturn(1)
|
||||
Mockito.doReturn(
|
||||
listOf(
|
||||
GetAdminAgentAssignedCreatorItem(
|
||||
creatorId = 21L,
|
||||
creatorNickname = "creator-a",
|
||||
assignedAt = LocalDateTime.of(2026, 4, 10, 3, 0)
|
||||
)
|
||||
)
|
||||
).`when`(queryRepository).getAssignedCreators(
|
||||
Mockito.eq(11L),
|
||||
Mockito.eq(0L),
|
||||
Mockito.eq(20L),
|
||||
Mockito.any(LocalDateTime::class.java) ?: LocalDateTime.now()
|
||||
)
|
||||
|
||||
val actual = service.getAssignedCreators(agentId = 11L, offset = 0L, limit = 20L)
|
||||
|
||||
assertEquals(1, actual.totalCount)
|
||||
assertEquals(LocalDateTime.of(2026, 4, 10, 12, 0), actual.items.first().assignedAt)
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("라이브 정산 상세 조회는 기존 AgentCalculateService로 위임한다")
|
||||
fun shouldDelegateLiveSettlementToAgentCalculateService() {
|
||||
|
||||
Reference in New Issue
Block a user