generated from pricelees/issue-pr-template
[#48] Tosspay mocking 서버 구현을 위한 멀티모듈 전환 #49
@ -0,0 +1,36 @@
|
|||||||
|
package com.sangdol.common.persistence
|
||||||
|
|
||||||
|
import com.github.f4b6a3.tsid.TsidFactory
|
||||||
|
import com.sangdol.common.utils.MdcPrincipalIdUtil
|
||||||
|
import org.springframework.beans.factory.annotation.Value
|
||||||
|
import org.springframework.context.annotation.Bean
|
||||||
|
import org.springframework.context.annotation.Configuration
|
||||||
|
import org.springframework.context.annotation.Primary
|
||||||
|
import org.springframework.data.domain.AuditorAware
|
||||||
|
import org.springframework.data.jpa.repository.config.EnableJpaAuditing
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@EnableJpaAuditing
|
||||||
|
class PersistenceConfig {
|
||||||
|
|
||||||
|
@Value("\${POD_NAME:app-0}")
|
||||||
|
private lateinit var podName: String
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
fun auditorAware(): AuditorAware<Long> = MdcAuditorAware()
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@Primary
|
||||||
|
fun idGenerator(): IDGenerator {
|
||||||
|
val node = podName.substringAfterLast("-").toInt()
|
||||||
|
|
||||||
|
val tsidFactory = TsidFactory.builder().withNode(node).build()
|
||||||
|
|
||||||
|
return TsidIDGenerator(tsidFactory)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class MdcAuditorAware : AuditorAware<Long> {
|
||||||
|
override fun getCurrentAuditor(): Optional<Long> = MdcPrincipalIdUtil.extractAsOptionalLongOrEmpty()
|
||||||
|
}
|
||||||
@ -1,20 +0,0 @@
|
|||||||
package com.sangdol.roomescape.common.config
|
|
||||||
|
|
||||||
import org.springframework.context.annotation.Bean
|
|
||||||
import org.springframework.context.annotation.Configuration
|
|
||||||
import org.springframework.data.domain.AuditorAware
|
|
||||||
import org.springframework.data.jpa.repository.config.EnableJpaAuditing
|
|
||||||
import com.sangdol.roomescape.common.util.MdcPrincipalId
|
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
@Configuration
|
|
||||||
@EnableJpaAuditing
|
|
||||||
class JpaConfig {
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
fun auditorAware(): AuditorAware<Long> = MdcAuditorAware()
|
|
||||||
}
|
|
||||||
|
|
||||||
class MdcAuditorAware : AuditorAware<Long> {
|
|
||||||
override fun getCurrentAuditor(): Optional<Long> = MdcPrincipalId.extractAsOptionalLongOrEmpty()
|
|
||||||
}
|
|
||||||
Loading…
x
Reference in New Issue
Block a user