diff --git a/buildSrc/src/main/kotlin/Version.kt b/buildSrc/src/main/kotlin/Version.kt index c3320483..4b3e275b 100644 --- a/buildSrc/src/main/kotlin/Version.kt +++ b/buildSrc/src/main/kotlin/Version.kt @@ -9,6 +9,7 @@ object Version { const val SONAR_CLOUD = "4.4.1.3373" // dependencies + const val UUID_CREATOR = "5.3.3" const val MOCKK = "1.13.7" const val SPRING_MOCKK = "4.0.2" const val KOTEST = "5.6.0" diff --git a/support/common/build.gradle.kts b/support/common/build.gradle.kts index 16270d9b..7b46614d 100644 --- a/support/common/build.gradle.kts +++ b/support/common/build.gradle.kts @@ -5,3 +5,7 @@ val bootJar: BootJar by tasks bootJar.enabled = false jar.enabled = true + +dependencies { + implementation("com.github.f4b6a3:uuid-creator:${Version.UUID_CREATOR}") +} diff --git a/support/common/src/main/kotlin/com/studentcenter/weave/support/common/uuid/UuidCreator.kt b/support/common/src/main/kotlin/com/studentcenter/weave/support/common/uuid/UuidCreator.kt new file mode 100644 index 00000000..5524ee50 --- /dev/null +++ b/support/common/src/main/kotlin/com/studentcenter/weave/support/common/uuid/UuidCreator.kt @@ -0,0 +1,22 @@ +package com.studentcenter.weave.support.common.uuid + +import java.util.* +import com.github.f4b6a3.uuid.UuidCreator + +object UuidCreator { + + /** + * uuid version 7 기반으로 uuid 를 생성합니다. + * millisecond 단위로 정렬된 uuid 를 생성하며, + * 동일한 시간에 생성될 경우 단조 증가 counter를 활용해, unique 하게 생성됩니다. + * + * @return uuid version 7 type 2 + * @see Universally Unique IDentifiers (UUID) + * @see UuidCreator.getTimeOrdered() + * @author San Kim + */ + fun create(): UUID { + return UuidCreator.getTimeOrderedEpochPlus1() + } + +}