Merge remote-tracking branch 'origin/tiangong' into tiangong

This commit is contained in:
zhangqinbin
2021-09-02 18:32:51 +08:00

View File

@ -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();
}
}