123
This commit is contained in:
26
ruoyi-cai/src/main/java/com/ruoyi/cai/manager/IdManager.java
Normal file
26
ruoyi-cai/src/main/java/com/ruoyi/cai/manager/IdManager.java
Normal file
@@ -0,0 +1,26 @@
|
||||
package com.ruoyi.cai.manager;
|
||||
|
||||
import cn.hutool.core.lang.Snowflake;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
|
||||
public class IdManager {
|
||||
|
||||
private static final Snowflake SNOWFLAKE;
|
||||
|
||||
static {
|
||||
int dataId = 1;
|
||||
String id = System.getProperty("DATA_ID");
|
||||
if(id != null){
|
||||
dataId = Integer.parseInt(id);
|
||||
}
|
||||
SNOWFLAKE = IdUtil.getSnowflake(1, dataId);
|
||||
}
|
||||
|
||||
public static Long nextId(){
|
||||
return SNOWFLAKE.nextId();
|
||||
}
|
||||
|
||||
public static String nextIdStr(){
|
||||
return SNOWFLAKE.nextIdStr();
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,8 @@ public class LockManager {
|
||||
public static final String LOCK_DEAL_INVITE_REDIS = RedisConstant.REDIS_P + "lock:dealInvite:%s";
|
||||
public static final String LOCK_ADD_USER_GREET_REDIS = RedisConstant.REDIS_P + "lock:addUserGreet:%s";
|
||||
public static final String LOCK_SEND_GREET_REDIS = RedisConstant.REDIS_P + "lock:sendGreet:%s";
|
||||
public static final String LOCK_SEND_GUARD_REDIS = RedisConstant.REDIS_P + "lock:sendGuard:%s";
|
||||
public static final String LOCK_SEND_GIFT_REDIS = RedisConstant.REDIS_P + "lock:sendGift:%s";
|
||||
|
||||
public static String getRegisterLockKey(String mobile){
|
||||
return String.format(LOCK_REGISTER_REDIS,mobile);
|
||||
@@ -24,4 +26,12 @@ public class LockManager {
|
||||
public static String getSendGreetLock(Long userId){
|
||||
return String.format(LOCK_SEND_GREET_REDIS,userId);
|
||||
}
|
||||
|
||||
public static String getSendGuardLock(Long userId){
|
||||
return String.format(LOCK_SEND_GUARD_REDIS,userId);
|
||||
}
|
||||
|
||||
public static String getSendGiftLock(Long userId){
|
||||
return String.format(LOCK_SEND_GIFT_REDIS,userId);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user