务工者-用户1.0

This commit is contained in:
2025-02-17 09:17:05 +08:00
parent d27512baa4
commit 08e242ce85
16 changed files with 1318 additions and 2 deletions

View File

@ -0,0 +1,27 @@
package com.ruoyi.wgz.common;
import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.IdUtil;
/**
* 雪花 ID 生成工具类
*/
public class SnowflakeIdUtil {
// 定义静态的 Snowflake 实例
private static final Snowflake snowflake;
// 静态代码块,在类加载时初始化 Snowflake 实例
static {
// 这里的数据中心 ID 和机器 ID 可以根据实际情况进行配置
// 此处假设数据中心 ID 为 1机器 ID 为 1
snowflake = IdUtil.createSnowflake(1, 1);
}
/**
* 生成雪花 ID 的静态方法
* @return 生成的雪花 ID
*/
public static long generateId() {
return snowflake.nextId();
}
}