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; package com.chinaunicom.mall.ebtp.common.util;
import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.RandomUtil;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
/** /**
@ -30,15 +31,17 @@ public class PropertyUtils {
* @return * @return
*/ */
public static String getSnowflakeId() { public static String getSnowflakeId() {
long l = IdUtil.getSnowflake(WORKER_ID, DATACENTER_ID).nextId(); return String.valueOf(getSnowflakeLongId());
return String.valueOf(l);
} }
/** /**
* 生成雪花id * 生成雪花id
* *
* @return * @return
*/ */
public static long getSnowflakeLongId() { 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();
} }
} }