generated from pricelees/issue-pr-template
refactor: 새로 분리된 persistence 모듈에 기존 TsidFactory 추상화 및 재정의
This commit is contained in:
parent
430630a02b
commit
c524cc6fdf
@ -0,0 +1,13 @@
|
||||
package com.sangdol.common.persistence
|
||||
|
||||
import com.github.f4b6a3.tsid.TsidFactory
|
||||
|
||||
interface IDGenerator {
|
||||
fun create(): Long
|
||||
}
|
||||
|
||||
class TsidIDGenerator(
|
||||
private val tsidFactory: TsidFactory
|
||||
) : IDGenerator {
|
||||
override fun create(): Long = tsidFactory.create().toLong()
|
||||
}
|
||||
@ -1,17 +0,0 @@
|
||||
package com.sangdol.roomescape.common.config
|
||||
|
||||
import com.github.f4b6a3.tsid.TsidFactory
|
||||
import org.springframework.beans.factory.annotation.Value
|
||||
import org.springframework.context.annotation.Bean
|
||||
import org.springframework.context.annotation.Configuration
|
||||
|
||||
@Configuration
|
||||
class TsidConfig {
|
||||
@Value("\${POD_NAME:app-0}")
|
||||
private lateinit var podName: String
|
||||
|
||||
@Bean
|
||||
fun tsidFactory(): TsidFactory = TsidFactory(podName.substringAfterLast("-").toInt())
|
||||
}
|
||||
|
||||
fun TsidFactory.next(): Long = this.create().toLong()
|
||||
Loading…
x
Reference in New Issue
Block a user