fix(agent-assignment): 소속 시각 UTC 변환을 적용한다
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package kr.co.vividnext.sodalive.admin.partner.agent.assignment
|
||||
|
||||
import kr.co.vividnext.sodalive.common.SodaException
|
||||
import kr.co.vividnext.sodalive.extensions.convertToUtc
|
||||
import kr.co.vividnext.sodalive.member.MemberRepository
|
||||
import kr.co.vividnext.sodalive.member.MemberRole
|
||||
import kr.co.vividnext.sodalive.partner.agent.assignment.AgentCreatorRelation
|
||||
@@ -37,14 +38,15 @@ class AdminAgentCreatorService(
|
||||
}
|
||||
|
||||
val existingRelations = relationRepository.findAllByCreatorIdOrderByAssignedAtAsc(request.creatorId)
|
||||
if (hasAssignmentOverlap(existingRelations, request.assignedAt)) {
|
||||
val assignedAt = request.assignedAt.convertToUtc()
|
||||
if (hasAssignmentOverlap(existingRelations, assignedAt)) {
|
||||
throw SodaException(messageKey = "partner.agent.assignment.assignment_overlap")
|
||||
}
|
||||
|
||||
val relation = AgentCreatorRelation()
|
||||
relation.agent = agent
|
||||
relation.creator = creator
|
||||
relation.assignedAt = request.assignedAt
|
||||
relation.assignedAt = assignedAt
|
||||
try {
|
||||
relationRepository.saveAndFlush(relation)
|
||||
} catch (e: DataIntegrityViolationException) {
|
||||
@@ -67,11 +69,12 @@ class AdminAgentCreatorService(
|
||||
|
||||
val assignedAt = relation.assignedAt
|
||||
?: throw SodaException(messageKey = "partner.agent.assignment.not_found")
|
||||
if (!request.unassignedAt.isAfter(assignedAt)) {
|
||||
val unassignedAt = request.unassignedAt.convertToUtc()
|
||||
if (!unassignedAt.isAfter(assignedAt)) {
|
||||
throw SodaException(messageKey = "partner.agent.assignment.invalid_unassigned_at")
|
||||
}
|
||||
|
||||
relation.unassignedAt = request.unassignedAt
|
||||
relation.unassignedAt = unassignedAt
|
||||
relationRepository.save(relation)
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,10 @@ package kr.co.vividnext.sodalive.extensions
|
||||
|
||||
import java.time.Duration
|
||||
import java.time.LocalDateTime
|
||||
import java.time.ZoneId
|
||||
|
||||
private val DEFAULT_KST_ZONE_ID: ZoneId = ZoneId.of("Asia/Seoul")
|
||||
private val UTC_ZONE_ID: ZoneId = ZoneId.of("UTC")
|
||||
|
||||
fun LocalDateTime.getTimeAgoString(): String {
|
||||
val now = LocalDateTime.now()
|
||||
@@ -16,3 +20,9 @@ fun LocalDateTime.getTimeAgoString(): String {
|
||||
else -> "${duration.toDays() / 365}년전"
|
||||
}
|
||||
}
|
||||
|
||||
fun LocalDateTime.convertToUtc(timeZone: ZoneId = DEFAULT_KST_ZONE_ID): LocalDateTime {
|
||||
return atZone(timeZone)
|
||||
.withZoneSameInstant(UTC_ZONE_ID)
|
||||
.toLocalDateTime()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user