xuekang
2024-05-11 bac0878349a1db23e7b420ea164e22fb9db73a99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package com.nuvole.util;
 
import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.RandomUtil;
 
/**
 * @author ChenLong
 * @version 1.0
 * @ClassName IdGenerator
 * @Description id生成器
 * @date 2019/4/18 11:33
 */
public class IdGenerator {
 
    private static Snowflake snowflake;
 
    public static Long getId() {
        return snowflake.nextId();
    }
 
    static {
        snowflake = IdUtil.createSnowflake(RandomUtil.randomInt(0, 31), RandomUtil.randomInt(0, 31));
    }
 
    public static String getUUID() {
 
        return IdUtil.simpleUUID();
    }
}