/**
 * Copyright 2008-2009. Chongqing Communications Industry Services Co.,Ltd Information Technology Branch. All rights reserved. <a>http://www.crunii.com</a>
 */
package com.crunii.micro.ds.config;

import com.crunii.micro.ds.uid.worker.UidGenerator;
import com.crunii.micro.ds.uid.worker.impl.CachedUidGenerator;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;

/**
 * @author 田平 create 2019年7月1日下午5:20:25
 */
@Configuration
@ConditionalOnProperty(value = "uid.enabled", havingValue = "true")
public class UidConfiguration {

	@Bean
	@DependsOn("mainNPJT")
	public UidGenerator registerUidGenerator() {
		CachedUidGenerator cachedUidGenerator = new CachedUidGenerator();
		cachedUidGenerator.setTimeBits(30);
		cachedUidGenerator.setWorkerBits(20);
		cachedUidGenerator.setSeqBits(13);
		cachedUidGenerator.setEpochStr("2023-03-20");
		return cachedUidGenerator;
	}

}
