Commit d26c78a0df09d1cb7f0d5a539d0934097c230486

Authored by YunaiV
2 parents d3c37c41 1be09d09

Merge branch 'master' of https://gitee.com/zhijiantianya/ruoyi-vue-pro into feature/1.8.0-uniapp

yudao-dependencies/pom.xml
@@ -58,6 +58,7 @@ @@ -58,6 +58,7 @@
58 <jsch.version>0.1.55</jsch.version> 58 <jsch.version>0.1.55</jsch.version>
59 <tika-core.version>2.4.1</tika-core.version> 59 <tika-core.version>2.4.1</tika-core.version>
60 <aj-captcha.version>1.3.0</aj-captcha.version> 60 <aj-captcha.version>1.3.0</aj-captcha.version>
  61 + <netty-all.version>4.1.82.Final</netty-all.version>
61 <!-- 三方云服务相关 --> 62 <!-- 三方云服务相关 -->
62 <minio.version>8.2.2</minio.version> 63 <minio.version>8.2.2</minio.version>
63 <aliyun-java-sdk-core.version>4.6.0</aliyun-java-sdk-core.version> 64 <aliyun-java-sdk-core.version>4.6.0</aliyun-java-sdk-core.version>
@@ -521,6 +522,12 @@ @@ -521,6 +522,12 @@
521 <version>${jsch.version}</version> 522 <version>${jsch.version}</version>
522 </dependency> 523 </dependency>
523 524
  525 + <dependency>
  526 + <groupId>io.netty</groupId>
  527 + <artifactId>netty-all</artifactId>
  528 + <version>${netty-all.version}</version>
  529 + </dependency>
  530 +
524 <!-- 三方云服务相关 --> 531 <!-- 三方云服务相关 -->
525 <dependency> 532 <dependency>
526 <groupId>cn.iocoder.boot</groupId> 533 <groupId>cn.iocoder.boot</groupId>
yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/config/YudaoTenantAutoConfiguration.java
@@ -9,6 +9,7 @@ import cn.iocoder.yudao.framework.tenant.core.db.TenantDatabaseInterceptor; @@ -9,6 +9,7 @@ import cn.iocoder.yudao.framework.tenant.core.db.TenantDatabaseInterceptor;
9 import cn.iocoder.yudao.framework.tenant.core.job.TenantJob; 9 import cn.iocoder.yudao.framework.tenant.core.job.TenantJob;
10 import cn.iocoder.yudao.framework.tenant.core.job.TenantJobHandlerDecorator; 10 import cn.iocoder.yudao.framework.tenant.core.job.TenantJobHandlerDecorator;
11 import cn.iocoder.yudao.framework.tenant.core.mq.TenantRedisMessageInterceptor; 11 import cn.iocoder.yudao.framework.tenant.core.mq.TenantRedisMessageInterceptor;
  12 +import cn.iocoder.yudao.framework.tenant.core.redis.TenantRedisCacheManager;
12 import cn.iocoder.yudao.framework.tenant.core.security.TenantSecurityWebFilter; 13 import cn.iocoder.yudao.framework.tenant.core.security.TenantSecurityWebFilter;
13 import cn.iocoder.yudao.framework.tenant.core.service.TenantFrameworkService; 14 import cn.iocoder.yudao.framework.tenant.core.service.TenantFrameworkService;
14 import cn.iocoder.yudao.framework.tenant.core.service.TenantFrameworkServiceImpl; 15 import cn.iocoder.yudao.framework.tenant.core.service.TenantFrameworkServiceImpl;
@@ -25,6 +26,14 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties @@ -25,6 +26,14 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties
25 import org.springframework.boot.web.servlet.FilterRegistrationBean; 26 import org.springframework.boot.web.servlet.FilterRegistrationBean;
26 import org.springframework.context.annotation.Bean; 27 import org.springframework.context.annotation.Bean;
27 import org.springframework.context.annotation.Configuration; 28 import org.springframework.context.annotation.Configuration;
  29 +import org.springframework.context.annotation.Primary;
  30 +import org.springframework.data.redis.cache.RedisCacheConfiguration;
  31 +import org.springframework.data.redis.cache.RedisCacheManager;
  32 +import org.springframework.data.redis.cache.RedisCacheWriter;
  33 +import org.springframework.data.redis.connection.RedisConnectionFactory;
  34 +import org.springframework.data.redis.core.RedisTemplate;
  35 +
  36 +import java.util.Objects;
28 37
29 @Configuration 38 @Configuration
30 @ConditionalOnProperty(prefix = "yudao.tenant", value = "enable", matchIfMissing = true) // 允许使用 yudao.tenant.enable=false 禁用多租户 39 @ConditionalOnProperty(prefix = "yudao.tenant", value = "enable", matchIfMissing = true) // 允许使用 yudao.tenant.enable=false 禁用多租户
@@ -110,4 +119,15 @@ public class YudaoTenantAutoConfiguration { @@ -110,4 +119,15 @@ public class YudaoTenantAutoConfiguration {
110 }; 119 };
111 } 120 }
112 121
  122 + @Bean
  123 + @Primary // 引入租户时,tenantRedisCacheManager 为主 Bean
  124 + public RedisCacheManager tenantRedisCacheManager(RedisTemplate<String, Object> redisTemplate,
  125 + RedisCacheConfiguration redisCacheConfiguration) {
  126 + // 创建 RedisCacheWriter 对象
  127 + RedisConnectionFactory connectionFactory = Objects.requireNonNull(redisTemplate.getConnectionFactory());
  128 + RedisCacheWriter cacheWriter = RedisCacheWriter.nonLockingRedisCacheWriter(connectionFactory);
  129 + // 创建 TenantRedisCacheManager 对象
  130 + return new TenantRedisCacheManager(cacheWriter, redisCacheConfiguration);
  131 + }
  132 +
113 } 133 }
yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/core/redis/TenantRedisCacheManager.java 0 → 100644
  1 +package cn.iocoder.yudao.framework.tenant.core.redis;
  2 +
  3 +import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
  4 +import lombok.extern.slf4j.Slf4j;
  5 +import org.jetbrains.annotations.NotNull;
  6 +import org.springframework.cache.Cache;
  7 +import org.springframework.data.redis.cache.RedisCacheConfiguration;
  8 +import org.springframework.data.redis.cache.RedisCacheManager;
  9 +import org.springframework.data.redis.cache.RedisCacheWriter;
  10 +
  11 +/**
  12 + * 多租户的 {@link RedisCacheManager} 实现类
  13 + *
  14 + * 操作指定 name 的 {@link Cache} 时,自动拼接租户后缀,格式为 name + ":" + tenantId
  15 + *
  16 + * @author airhead
  17 + */
  18 +@Slf4j
  19 +public class TenantRedisCacheManager extends RedisCacheManager {
  20 +
  21 + public TenantRedisCacheManager(RedisCacheWriter cacheWriter,
  22 + RedisCacheConfiguration defaultCacheConfiguration) {
  23 + super(cacheWriter, defaultCacheConfiguration);
  24 + }
  25 +
  26 + @Override
  27 + public Cache getCache(@NotNull String name) {
  28 + // 如果开启多租户,则 name 拼接租户后缀
  29 + if (!TenantContextHolder.isIgnore()
  30 + && TenantContextHolder.getTenantId() != null) {
  31 + name = name + ":" + TenantContextHolder.getTenantId();
  32 + }
  33 +
  34 + // 继续基于父方法
  35 + return super.getCache(name);
  36 + }
  37 +
  38 +}
yudao-framework/yudao-spring-boot-starter-redis/pom.xml
@@ -32,6 +32,11 @@ @@ -32,6 +32,11 @@
32 <artifactId>spring-boot-starter-cache</artifactId> <!-- 实现对 Caches 的自动化配置 --> 32 <artifactId>spring-boot-starter-cache</artifactId> <!-- 实现对 Caches 的自动化配置 -->
33 </dependency> 33 </dependency>
34 34
  35 + <dependency>
  36 + <groupId>io.netty</groupId>
  37 + <artifactId>netty-all</artifactId>
  38 + </dependency>
  39 +
35 </dependencies> 40 </dependencies>
36 41
37 </project> 42 </project>
yudao-framework/yudao-spring-boot-starter-redis/src/main/java/cn/iocoder/yudao/framework/redis/config/YudaoCacheAutoConfiguration.java
1 package cn.iocoder.yudao.framework.redis.config; 1 package cn.iocoder.yudao.framework.redis.config;
2 2
3 import org.springframework.boot.autoconfigure.cache.CacheProperties; 3 import org.springframework.boot.autoconfigure.cache.CacheProperties;
  4 +import org.springframework.boot.context.properties.EnableConfigurationProperties;
4 import org.springframework.cache.annotation.EnableCaching; 5 import org.springframework.cache.annotation.EnableCaching;
5 import org.springframework.context.annotation.Bean; 6 import org.springframework.context.annotation.Bean;
6 import org.springframework.context.annotation.Configuration; 7 import org.springframework.context.annotation.Configuration;
@@ -13,6 +14,7 @@ import org.springframework.data.redis.serializer.RedisSerializer; @@ -13,6 +14,7 @@ import org.springframework.data.redis.serializer.RedisSerializer;
13 * Cache 配置类,基于 Redis 实现 14 * Cache 配置类,基于 Redis 实现
14 */ 15 */
15 @Configuration 16 @Configuration
  17 +@EnableConfigurationProperties({CacheProperties.class})
16 @EnableCaching 18 @EnableCaching
17 public class YudaoCacheAutoConfiguration { 19 public class YudaoCacheAutoConfiguration {
18 20
yudao-server/src/main/resources/application-local.yaml
@@ -51,7 +51,7 @@ spring: @@ -51,7 +51,7 @@ spring:
51 # url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例 51 # url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例
52 # url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=${spring.datasource.dynamic.datasource.master.name} # SQLServer 连接的示例 52 # url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=${spring.datasource.dynamic.datasource.master.name} # SQLServer 连接的示例
53 username: root 53 username: root
54 - password: 123456 54 + password: ${RUOYI_VUE_PRO}
55 # username: sa 55 # username: sa
56 # password: JSm:g(*%lU4ZAkz06cd52KqT3)i1?H7W 56 # password: JSm:g(*%lU4ZAkz06cd52KqT3)i1?H7W
57 slave: # 模拟从库,可根据自己需要修改 57 slave: # 模拟从库,可根据自己需要修改
@@ -62,7 +62,7 @@ spring: @@ -62,7 +62,7 @@ spring:
62 # url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例 62 # url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例
63 # url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=${spring.datasource.dynamic.datasource.slave.name} # SQLServer 连接的示例 63 # url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=${spring.datasource.dynamic.datasource.slave.name} # SQLServer 连接的示例
64 username: root 64 username: root
65 - password: 123456 65 + password: ${RUOYI_VUE_PRO}
66 # username: sa 66 # username: sa
67 # password: JSm:g(*%lU4ZAkz06cd52KqT3)i1?H7W 67 # password: JSm:g(*%lU4ZAkz06cd52KqT3)i1?H7W
68 68
yudao-ui-admin/src/views/infra/job/log.vue
@@ -77,7 +77,7 @@ @@ -77,7 +77,7 @@
77 <el-form-item label="处理器的参数:">{{ form.handlerParam }}</el-form-item> 77 <el-form-item label="处理器的参数:">{{ form.handlerParam }}</el-form-item>
78 <el-form-item label="第几次执行:">{{ form.executeIndex }}</el-form-item> 78 <el-form-item label="第几次执行:">{{ form.executeIndex }}</el-form-item>
79 <el-form-item label="执行时间:">{{ parseTime(form.beginTime) + ' ~ ' + parseTime(form.endTime) }}</el-form-item> 79 <el-form-item label="执行时间:">{{ parseTime(form.beginTime) + ' ~ ' + parseTime(form.endTime) }}</el-form-item>
80 - <el-form-item label="执行时长:">{{ parseTime(form.duration) + ' 毫秒' }}</el-form-item> 80 + <el-form-item label="执行时长:">{{ form.duration + ' 毫秒' }}</el-form-item>
81 <el-form-item label="任务状态:"> 81 <el-form-item label="任务状态:">
82 <dict-tag :type="DICT_TYPE.INFRA_JOB_LOG_STATUS" :value="form.status" /> 82 <dict-tag :type="DICT_TYPE.INFRA_JOB_LOG_STATUS" :value="form.status" />
83 </el-form-item> 83 </el-form-item>