|
|
@@ -0,0 +1,16 @@
|
|
|
+package com.izouma.nineth.config;
|
|
|
+
|
|
|
+import com.izouma.nineth.utils.SnowflakeIdWorker;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.context.annotation.Bean;
|
|
|
+import org.springframework.context.annotation.Configuration;
|
|
|
+
|
|
|
+@Configuration
|
|
|
+@Slf4j
|
|
|
+public class SnowflakeIdWorkerConfig {
|
|
|
+ @Bean
|
|
|
+ public SnowflakeIdWorker snowflakeIdWorker(GeneralProperties generalProperties) {
|
|
|
+ log.info("init snowflakeIdWorker worker={} dataCenter={}", generalProperties.getWorkerId(), generalProperties.getDataCenterId());
|
|
|
+ return new SnowflakeIdWorker(generalProperties.getWorkerId(), generalProperties.getDataCenterId());
|
|
|
+ }
|
|
|
+}
|