修改雪花id生成方式
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
package com.chinaunicom.mall.ebtp.common.util;
|
||||
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
|
||||
/**
|
||||
@ -30,15 +31,17 @@ public class PropertyUtils {
|
||||
* @return
|
||||
*/
|
||||
public static String getSnowflakeId() {
|
||||
long l = IdUtil.getSnowflake(WORKER_ID, DATACENTER_ID).nextId();
|
||||
return String.valueOf(l);
|
||||
return String.valueOf(getSnowflakeLongId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成雪花id
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static long getSnowflakeLongId() {
|
||||
return IdUtil.getSnowflake(WORKER_ID, DATACENTER_ID).nextId();
|
||||
long workerId = RandomUtil.getRandom().nextLong(31);
|
||||
long datacenterId = RandomUtil.getRandom().nextLong(31);
|
||||
return IdUtil.getSnowflake(workerId, datacenterId).nextId();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user