Commit d26c78a0df09d1cb7f0d5a539d0934097c230486
Merge branch 'master' of https://gitee.com/zhijiantianya/ruoyi-vue-pro into feature/1.8.0-uniapp
Showing
7 changed files
with
75 additions
and
3 deletions
yudao-dependencies/pom.xml
| ... | ... | @@ -58,6 +58,7 @@ |
| 58 | 58 | <jsch.version>0.1.55</jsch.version> |
| 59 | 59 | <tika-core.version>2.4.1</tika-core.version> |
| 60 | 60 | <aj-captcha.version>1.3.0</aj-captcha.version> |
| 61 | + <netty-all.version>4.1.82.Final</netty-all.version> | |
| 61 | 62 | <!-- 三方云服务相关 --> |
| 62 | 63 | <minio.version>8.2.2</minio.version> |
| 63 | 64 | <aliyun-java-sdk-core.version>4.6.0</aliyun-java-sdk-core.version> |
| ... | ... | @@ -521,6 +522,12 @@ |
| 521 | 522 | <version>${jsch.version}</version> |
| 522 | 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 | 532 | <dependency> |
| 526 | 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 | 9 | import cn.iocoder.yudao.framework.tenant.core.job.TenantJob; |
| 10 | 10 | import cn.iocoder.yudao.framework.tenant.core.job.TenantJobHandlerDecorator; |
| 11 | 11 | import cn.iocoder.yudao.framework.tenant.core.mq.TenantRedisMessageInterceptor; |
| 12 | +import cn.iocoder.yudao.framework.tenant.core.redis.TenantRedisCacheManager; | |
| 12 | 13 | import cn.iocoder.yudao.framework.tenant.core.security.TenantSecurityWebFilter; |
| 13 | 14 | import cn.iocoder.yudao.framework.tenant.core.service.TenantFrameworkService; |
| 14 | 15 | import cn.iocoder.yudao.framework.tenant.core.service.TenantFrameworkServiceImpl; |
| ... | ... | @@ -25,6 +26,14 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties |
| 25 | 26 | import org.springframework.boot.web.servlet.FilterRegistrationBean; |
| 26 | 27 | import org.springframework.context.annotation.Bean; |
| 27 | 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 | 38 | @Configuration |
| 30 | 39 | @ConditionalOnProperty(prefix = "yudao.tenant", value = "enable", matchIfMissing = true) // 允许使用 yudao.tenant.enable=false 禁用多租户 |
| ... | ... | @@ -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 | 32 | <artifactId>spring-boot-starter-cache</artifactId> <!-- 实现对 Caches 的自动化配置 --> |
| 33 | 33 | </dependency> |
| 34 | 34 | |
| 35 | + <dependency> | |
| 36 | + <groupId>io.netty</groupId> | |
| 37 | + <artifactId>netty-all</artifactId> | |
| 38 | + </dependency> | |
| 39 | + | |
| 35 | 40 | </dependencies> |
| 36 | 41 | |
| 37 | 42 | </project> | ... | ... |
yudao-framework/yudao-spring-boot-starter-redis/src/main/java/cn/iocoder/yudao/framework/redis/config/YudaoCacheAutoConfiguration.java
| 1 | 1 | package cn.iocoder.yudao.framework.redis.config; |
| 2 | 2 | |
| 3 | 3 | import org.springframework.boot.autoconfigure.cache.CacheProperties; |
| 4 | +import org.springframework.boot.context.properties.EnableConfigurationProperties; | |
| 4 | 5 | import org.springframework.cache.annotation.EnableCaching; |
| 5 | 6 | import org.springframework.context.annotation.Bean; |
| 6 | 7 | import org.springframework.context.annotation.Configuration; |
| ... | ... | @@ -13,6 +14,7 @@ import org.springframework.data.redis.serializer.RedisSerializer; |
| 13 | 14 | * Cache 配置类,基于 Redis 实现 |
| 14 | 15 | */ |
| 15 | 16 | @Configuration |
| 17 | +@EnableConfigurationProperties({CacheProperties.class}) | |
| 16 | 18 | @EnableCaching |
| 17 | 19 | public class YudaoCacheAutoConfiguration { |
| 18 | 20 | ... | ... |
yudao-server/src/main/resources/application-local.yaml
| ... | ... | @@ -51,7 +51,7 @@ spring: |
| 51 | 51 | # url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例 |
| 52 | 52 | # url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=${spring.datasource.dynamic.datasource.master.name} # SQLServer 连接的示例 |
| 53 | 53 | username: root |
| 54 | - password: 123456 | |
| 54 | + password: ${RUOYI_VUE_PRO} | |
| 55 | 55 | # username: sa |
| 56 | 56 | # password: JSm:g(*%lU4ZAkz06cd52KqT3)i1?H7W |
| 57 | 57 | slave: # 模拟从库,可根据自己需要修改 |
| ... | ... | @@ -62,7 +62,7 @@ spring: |
| 62 | 62 | # url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例 |
| 63 | 63 | # url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=${spring.datasource.dynamic.datasource.slave.name} # SQLServer 连接的示例 |
| 64 | 64 | username: root |
| 65 | - password: 123456 | |
| 65 | + password: ${RUOYI_VUE_PRO} | |
| 66 | 66 | # username: sa |
| 67 | 67 | # password: JSm:g(*%lU4ZAkz06cd52KqT3)i1?H7W |
| 68 | 68 | ... | ... |
yudao-ui-admin/src/views/infra/job/log.vue
| ... | ... | @@ -77,7 +77,7 @@ |
| 77 | 77 | <el-form-item label="处理器的参数:">{{ form.handlerParam }}</el-form-item> |
| 78 | 78 | <el-form-item label="第几次执行:">{{ form.executeIndex }}</el-form-item> |
| 79 | 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 | 81 | <el-form-item label="任务状态:"> |
| 82 | 82 | <dict-tag :type="DICT_TYPE.INFRA_JOB_LOG_STATUS" :value="form.status" /> |
| 83 | 83 | </el-form-item> | ... | ... |