This commit is contained in:
77
2024-05-18 01:02:13 +08:00
parent 874b33557d
commit 32933c2840
47 changed files with 416 additions and 282 deletions

View File

@@ -80,5 +80,9 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>transmittable-thread-local</artifactId>
</dependency>
</dependencies>
</project>

View File

@@ -25,10 +25,9 @@ import java.util.concurrent.ThreadPoolExecutor;
public class ThreadPoolConfig {
/**
* 核心线程数 = cpu 核心数 + 1
* 核心线程数 = cpu 核心数 + 1 TODO 线程池
*/
// private final int core = Runtime.getRuntime().availableProcessors() + 1;
private final int core = 6 + 1;
private final int core = Runtime.getRuntime().availableProcessors() + 1;
@Bean(name = "threadPoolTaskExecutor")

View File

@@ -12,38 +12,4 @@ public interface CacheConstants {
*/
String ONLINE_TOKEN_KEY = "online_tokens:";
/**
* 单天在线APP用户
*/
String ONLINE_TODAY_TOKEN_KEY = "online_tokens_today:%s";
/**
* 验证码 redis key
*/
String CAPTCHA_CODE_KEY = "captcha_codes:";
/**
* 参数管理 cache key
*/
String SYS_CONFIG_KEY = "sys_config:";
/**
* 字典管理 cache key
*/
String SYS_DICT_KEY = "sys_dict:";
/**
* 防重提交 redis key
*/
String REPEAT_SUBMIT_KEY = "repeat_submit:";
/**
* 限流 redis key
*/
String RATE_LIMIT_KEY = "rate_limit:";
/**
* 登录账户密码错误次数 redis key
*/
String PWD_ERR_CNT_KEY = "pwd_err_cnt:";
}

View File

@@ -15,20 +15,15 @@ package com.ruoyi.component.core.constant;
*/
public interface CacheNames {
/**
* 演示案例
*/
String DEMO_CACHE = "demo:cache#60s#10m#20";
/**
* 系统配置
*/
String SYS_CONFIG = "sys_config";
String SYS_CONFIG = GlobalConstants.GLOBAL_REDIS_KEY + "sys_config";
/**
* 数据字典
*/
String SYS_DICT = "sys_dict";
String SYS_DICT = GlobalConstants.GLOBAL_REDIS_KEY + "sys_dict";
/**
* 用户账户
@@ -52,9 +47,4 @@ public interface CacheNames {
*/
String SYS_OSS_CONFIG = GlobalConstants.GLOBAL_REDIS_KEY + "sys_oss_config";
/**
* 在线用户
*/
String ONLINE_TOKEN = "online_tokens";
}

View File

@@ -36,4 +36,14 @@ public interface GlobalConstants {
* 三方认证 redis key
*/
String SOCIAL_AUTH_CODE_KEY = GLOBAL_REDIS_KEY + "social_auth_codes:";
/**
* 字典管理 cache key
*/
String SYS_DICT_KEY = GLOBAL_REDIS_KEY + "sys_dict:";
/**
* 参数管理 cache key
*/
String SYS_CONFIG_KEY = GLOBAL_REDIS_KEY + "sys_config:";
}

View File

@@ -139,9 +139,4 @@ public interface UserConstants {
*/
Long ADMIN_ID = 1L;
/**
* 管理员角色key
*/
String ADMIN_ROLE_KEY = "admin";
}

View File

@@ -100,6 +100,8 @@ public class LoginUser implements Serializable {
*/
private Long roleId;
private String tenantId;
/**
* 获取登录id
*/

View File

@@ -0,0 +1,34 @@
package com.ruoyi.component.core.executor;
import com.alibaba.ttl.threadpool.TtlExecutors;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import java.util.concurrent.*;
public class ExecutorConstant {
private final static int CPU_NUM = Runtime.getRuntime().availableProcessors();
public static Executor COMMON_EXECUTOR;
static {
ThreadPoolExecutor commonExecutor = new ThreadPoolExecutor(CPU_NUM,
CPU_NUM << 2,
5,
TimeUnit.SECONDS,
new ArrayBlockingQueue<>(50),
init("commonThreadPool-%d"),
new ThreadPoolExecutor.CallerRunsPolicy());
COMMON_EXECUTOR = TtlExecutors.getTtlExecutor(commonExecutor);
}
private static ThreadFactory init(String nameFormat){
return new ThreadFactoryBuilder().setNameFormat(nameFormat).build();
}
private static ThreadPoolExecutor initExecutor(int corePoolSize, int maxPoolSize, int keepAliveTime, TimeUnit timeUnit,
BlockingQueue<Runnable> workQueue, String nameFormat){
return new ThreadPoolExecutor(corePoolSize, maxPoolSize, keepAliveTime, timeUnit, workQueue,
init(nameFormat));
}
}