模块调整
This commit is contained in:
parent
b48206dc80
commit
0a432d1b4f
58
pom.xml
58
pom.xml
@ -222,20 +222,6 @@
|
|||||||
<version>${jakarta.version}</version>
|
<version>${jakarta.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 定时任务-->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.ruoyi</groupId>
|
|
||||||
<artifactId>ruoyi-quartz</artifactId>
|
|
||||||
<version>${ruoyi.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- 代码生成-->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.ruoyi</groupId>
|
|
||||||
<artifactId>ruoyi-generator</artifactId>
|
|
||||||
<version>${ruoyi.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- 核心模块-->
|
<!-- 核心模块-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
@ -257,51 +243,38 @@
|
|||||||
<version>${ruoyi.version}</version>
|
<version>${ruoyi.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 集成第三方登录 -->
|
<!-- 集成第三方登录启动器 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-oauth-starter</artifactId>
|
<artifactId>ruoyi-oauth-starter</artifactId>
|
||||||
<version>${ruoyi.version}</version>
|
<version>${ruoyi.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 集成支付 -->
|
<!-- 集成支付启动器 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-pay-starter</artifactId>
|
<artifactId>ruoyi-pay-starter</artifactId>
|
||||||
<version>${ruoyi.version}</version>
|
<version>${ruoyi.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 集成中间件 -->
|
<!-- 插件启动器 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.ruoyi</groupId>
|
||||||
|
<artifactId>ruoyi-plugins-starter</artifactId>
|
||||||
|
<version>${ruoyi.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 中间件启动器 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-middleware-starter</artifactId>
|
<artifactId>ruoyi-middleware-starter</artifactId>
|
||||||
<version>${ruoyi.version}</version>
|
<version>${ruoyi.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 在线接口 -->
|
<!-- 模块启动器 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-online</artifactId>
|
<artifactId>ruoyi-models-starter</artifactId>
|
||||||
<version>${ruoyi.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- mybatis-jpa-->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.ruoyi</groupId>
|
|
||||||
<artifactId>ruoyi-mybatis-jpa</artifactId>
|
|
||||||
<version>${ruoyi.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- mybatis-minio-->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.ruoyi</groupId>
|
|
||||||
<artifactId>ruoyi-minio</artifactId>
|
|
||||||
<version>${ruoyi.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.ruoyi</groupId>
|
|
||||||
<artifactId>ruoyi-websocket</artifactId>
|
|
||||||
<version>${ruoyi.version}</version>
|
<version>${ruoyi.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
@ -311,15 +284,12 @@
|
|||||||
<module>ruoyi-admin</module>
|
<module>ruoyi-admin</module>
|
||||||
<module>ruoyi-framework</module>
|
<module>ruoyi-framework</module>
|
||||||
<module>ruoyi-system</module>
|
<module>ruoyi-system</module>
|
||||||
<module>ruoyi-quartz</module>
|
|
||||||
<module>ruoyi-generator</module>
|
|
||||||
<module>ruoyi-common</module>
|
<module>ruoyi-common</module>
|
||||||
<module>ruoyi-oauth</module>
|
<module>ruoyi-oauth</module>
|
||||||
<module>ruoyi-pay</module>
|
<module>ruoyi-pay</module>
|
||||||
<module>ruoyi-online</module>
|
|
||||||
<module>ruoyi-mybatis-jpa</module>
|
|
||||||
<module>ruoyi-middleware</module>
|
<module>ruoyi-middleware</module>
|
||||||
<module>ruoyi-websocket</module>
|
<module>ruoyi-plugins</module>
|
||||||
|
<module>ruoyi-models</module>
|
||||||
</modules>
|
</modules>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
|
@ -35,18 +35,6 @@
|
|||||||
<artifactId>ruoyi-framework</artifactId>
|
<artifactId>ruoyi-framework</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 定时任务-->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.ruoyi</groupId>
|
|
||||||
<artifactId>ruoyi-quartz</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- 代码生成-->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.ruoyi</groupId>
|
|
||||||
<artifactId>ruoyi-generator</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- 集成第三方登录启动器 -->
|
<!-- 集成第三方登录启动器 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
@ -59,28 +47,22 @@
|
|||||||
<artifactId>ruoyi-pay-starter</artifactId>
|
<artifactId>ruoyi-pay-starter</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 在线接口 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.ruoyi</groupId>
|
|
||||||
<artifactId>ruoyi-online</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- 在线接口 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.ruoyi</groupId>
|
|
||||||
<artifactId>ruoyi-mybatis-jpa</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- 中间件 -->
|
<!-- 中间件 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-middleware-starter</artifactId>
|
<artifactId>ruoyi-middleware-starter</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- websocket -->
|
<!-- plugins-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-websocket</artifactId>
|
<artifactId>ruoyi-plugins-starter</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- models-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.ruoyi</groupId>
|
||||||
|
<artifactId>ruoyi-models-starter</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- knife4j -->
|
<!-- knife4j -->
|
||||||
@ -88,6 +70,7 @@
|
|||||||
<groupId>com.github.xiaoymin</groupId>
|
<groupId>com.github.xiaoymin</groupId>
|
||||||
<artifactId>knife4j-openapi3-jakarta-spring-boot-starter</artifactId>
|
<artifactId>knife4j-openapi3-jakarta-spring-boot-starter</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
@ -49,7 +49,7 @@ user:
|
|||||||
spring:
|
spring:
|
||||||
cache:
|
cache:
|
||||||
# 指定缓存类型 jcache 本地缓存 redis 缓存
|
# 指定缓存类型 jcache 本地缓存 redis 缓存
|
||||||
type: redis
|
type: jcache
|
||||||
redis:
|
redis:
|
||||||
# 指定存活时间(ms)
|
# 指定存活时间(ms)
|
||||||
time-to-live: 86400000
|
time-to-live: 86400000
|
||||||
|
@ -163,12 +163,6 @@
|
|||||||
<artifactId>spring-boot-starter-cache</artifactId>
|
<artifactId>spring-boot-starter-cache</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Ehcache缓存管理器 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.ehcache</groupId>
|
|
||||||
<artifactId>ehcache</artifactId>
|
|
||||||
<version>3.10.8</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.cache</groupId>
|
<groupId>javax.cache</groupId>
|
||||||
<artifactId>cache-api</artifactId>
|
<artifactId>cache-api</artifactId>
|
||||||
|
@ -1,14 +0,0 @@
|
|||||||
package com.ruoyi.common.core.cache;
|
|
||||||
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
import org.springframework.cache.Cache;
|
|
||||||
|
|
||||||
public interface CacheSpecialUtils {
|
|
||||||
public Set<String> getKeys(Cache cache);
|
|
||||||
|
|
||||||
default public <T> void set(String string, T value, long timeout, TimeUnit unit){}
|
|
||||||
|
|
||||||
default public <T> void set(String string, T value){};
|
|
||||||
}
|
|
10
ruoyi-common/src/main/java/com/ruoyi/common/interceptor/cache/CacheKeys.java
vendored
Normal file
10
ruoyi-common/src/main/java/com/ruoyi/common/interceptor/cache/CacheKeys.java
vendored
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
package com.ruoyi.common.interceptor.cache;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.springframework.cache.Cache;
|
||||||
|
|
||||||
|
public interface CacheKeys {
|
||||||
|
|
||||||
|
public Set<String> getCachekeys(final Cache cache);
|
||||||
|
}
|
7
ruoyi-common/src/main/java/com/ruoyi/common/interceptor/cache/CacheNoTimeOut.java
vendored
Normal file
7
ruoyi-common/src/main/java/com/ruoyi/common/interceptor/cache/CacheNoTimeOut.java
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
package com.ruoyi.common.interceptor.cache;
|
||||||
|
|
||||||
|
public interface CacheNoTimeOut {
|
||||||
|
|
||||||
|
public <T> void setCacheObject(final String cacheName,final String key, final T value);
|
||||||
|
|
||||||
|
}
|
10
ruoyi-common/src/main/java/com/ruoyi/common/interceptor/cache/CacheTimeOut.java
vendored
Normal file
10
ruoyi-common/src/main/java/com/ruoyi/common/interceptor/cache/CacheTimeOut.java
vendored
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
package com.ruoyi.common.interceptor.cache;
|
||||||
|
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
public interface CacheTimeOut extends CacheNoTimeOut {
|
||||||
|
|
||||||
|
public <T> void setCacheObject(final String cacheName, final String key, final T value, final long timeout,
|
||||||
|
final TimeUnit timeUnit);
|
||||||
|
|
||||||
|
}
|
@ -10,7 +10,8 @@ import org.springframework.cache.transaction.TransactionAwareCacheDecorator;
|
|||||||
import org.springframework.lang.Nullable;
|
import org.springframework.lang.Nullable;
|
||||||
import org.springframework.util.ObjectUtils;
|
import org.springframework.util.ObjectUtils;
|
||||||
|
|
||||||
import com.ruoyi.common.core.cache.CacheSpecialUtils;
|
import com.ruoyi.common.interceptor.cache.CacheKeys;
|
||||||
|
import com.ruoyi.common.interceptor.cache.CacheTimeOut;
|
||||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||||
|
|
||||||
public class CacheUtils {
|
public class CacheUtils {
|
||||||
@ -43,8 +44,8 @@ public class CacheUtils {
|
|||||||
@SuppressWarnings(value = { "unchecked", "rawtypes" })
|
@SuppressWarnings(value = { "unchecked", "rawtypes" })
|
||||||
public static Set<String> getkeys(String cacheName) {
|
public static Set<String> getkeys(String cacheName) {
|
||||||
Cache cache = getCacheManager().getCache(cacheName);
|
Cache cache = getCacheManager().getCache(cacheName);
|
||||||
CacheSpecialUtils cacheGetKets = SpringUtils.getBean(CacheSpecialUtils.class);
|
CacheKeys cacheGetKets = SpringUtils.getBean(CacheKeys.class);
|
||||||
return cacheGetKets.getKeys(cache);
|
return cacheGetKets.getCachekeys(cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -73,7 +74,7 @@ public class CacheUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean hasKey(String cacheName, String key){
|
public static boolean hasKey(String cacheName, String key) {
|
||||||
return ObjectUtils.isEmpty(get(cacheName, key));
|
return ObjectUtils.isEmpty(get(cacheName, key));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,11 +94,11 @@ public class CacheUtils {
|
|||||||
JCacheCache ehcache = (JCacheCache) cache;
|
JCacheCache ehcache = (JCacheCache) cache;
|
||||||
ehcache.put(key, value);
|
ehcache.put(key, value);
|
||||||
} else if (cache instanceof TransactionAwareCacheDecorator) {
|
} else if (cache instanceof TransactionAwareCacheDecorator) {
|
||||||
CacheSpecialUtils cacheSet = SpringUtils.getBean(CacheSpecialUtils.class);
|
CacheTimeOut cacheTimeOut = SpringUtils.getBean(CacheTimeOut.class);
|
||||||
if (timeout != 0 && unit != null) {
|
if (timeout != 0 && unit != null) {
|
||||||
cacheSet.set(cacheName + ":" + key, value, timeout, unit);
|
cacheTimeOut.setCacheObject(cacheName, key, value, timeout, unit);
|
||||||
} else {
|
} else {
|
||||||
cacheSet.set(cacheName + ":" + key, value);
|
cacheTimeOut.setCacheObject(cacheName, key, value);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cache.put(key, value);
|
cache.put(key, value);
|
||||||
|
@ -17,8 +17,9 @@
|
|||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<description>
|
<description>
|
||||||
支付模块
|
中间件
|
||||||
</description>
|
</description>
|
||||||
|
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<!-- Minio 文件存储 -->
|
<!-- Minio 文件存储 -->
|
||||||
|
@ -1,12 +1,8 @@
|
|||||||
package com.ruoyi.middleware.redis.config;
|
package com.ruoyi.middleware.redis.config;
|
||||||
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
import org.springframework.cache.Cache;
|
|
||||||
import org.springframework.cache.CacheManager;
|
import org.springframework.cache.CacheManager;
|
||||||
import org.springframework.cache.annotation.CachingConfigurer;
|
import org.springframework.cache.annotation.CachingConfigurer;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
@ -20,9 +16,6 @@ import org.springframework.data.redis.core.script.DefaultRedisScript;
|
|||||||
import org.springframework.data.redis.serializer.RedisSerializationContext;
|
import org.springframework.data.redis.serializer.RedisSerializationContext;
|
||||||
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||||
|
|
||||||
import com.ruoyi.common.core.cache.CacheSpecialUtils;
|
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* redis配置
|
* redis配置
|
||||||
*
|
*
|
||||||
@ -44,31 +37,6 @@ public class RedisConfig implements CachingConfigurer {
|
|||||||
return RedisCacheManager.builder(connectionFactory).cacheDefaults(config).transactionAware().build();
|
return RedisCacheManager.builder(connectionFactory).cacheDefaults(config).transactionAware().build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
|
||||||
public CacheSpecialUtils cacheGetKets(RedisTemplate<Object, Object> redisTemplate) {
|
|
||||||
return new CacheSpecialUtils() {
|
|
||||||
@Override
|
|
||||||
public Set<String> getKeys(Cache cache) {
|
|
||||||
Set<String> keyset = new HashSet<>();
|
|
||||||
Set<Object> keysets = redisTemplate.keys(cache.getName() + "*");
|
|
||||||
for (Object s : keysets) {
|
|
||||||
keyset.add(StringUtils.replace(s.toString(), cache.getName() + ":", ""));
|
|
||||||
}
|
|
||||||
return keyset;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public <T> void set(String cacheName, T value, long timeout, TimeUnit unit){
|
|
||||||
redisTemplate.opsForValue().set(cacheName, value, timeout, unit);
|
|
||||||
}
|
|
||||||
|
|
||||||
public <T> void set(String cacheName, T value){
|
|
||||||
redisTemplate.opsForValue().set(cacheName, value);
|
|
||||||
};
|
|
||||||
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings(value = { "unchecked", "rawtypes" })
|
@SuppressWarnings(value = { "unchecked", "rawtypes" })
|
||||||
private RedisCacheConfiguration instanceConfig(Long ttl) {
|
private RedisCacheConfiguration instanceConfig(Long ttl) {
|
||||||
FastJson2JsonRedisSerializer serializer = new FastJson2JsonRedisSerializer(Object.class);
|
FastJson2JsonRedisSerializer serializer = new FastJson2JsonRedisSerializer(Object.class);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.ruoyi.middleware.redis.utils;
|
package com.ruoyi.middleware.redis.utils;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -9,12 +10,17 @@ import java.util.concurrent.TimeUnit;
|
|||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
|
import org.springframework.cache.Cache;
|
||||||
import org.springframework.data.redis.core.BoundSetOperations;
|
import org.springframework.data.redis.core.BoundSetOperations;
|
||||||
import org.springframework.data.redis.core.HashOperations;
|
import org.springframework.data.redis.core.HashOperations;
|
||||||
import org.springframework.data.redis.core.RedisTemplate;
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
import org.springframework.data.redis.core.ValueOperations;
|
import org.springframework.data.redis.core.ValueOperations;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import com.ruoyi.common.interceptor.cache.CacheKeys;
|
||||||
|
import com.ruoyi.common.interceptor.cache.CacheTimeOut;
|
||||||
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* spring redis 工具类
|
* spring redis 工具类
|
||||||
*
|
*
|
||||||
@ -23,8 +29,7 @@ import org.springframework.stereotype.Component;
|
|||||||
@SuppressWarnings(value = { "unchecked", "rawtypes" })
|
@SuppressWarnings(value = { "unchecked", "rawtypes" })
|
||||||
@Component
|
@Component
|
||||||
@ConditionalOnProperty(prefix = "spring.cache", name = { "type" }, havingValue = "redis", matchIfMissing = false)
|
@ConditionalOnProperty(prefix = "spring.cache", name = { "type" }, havingValue = "redis", matchIfMissing = false)
|
||||||
public class RedisCache
|
public class RedisCache implements CacheKeys, CacheTimeOut {
|
||||||
{
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public RedisTemplate redisTemplate;
|
public RedisTemplate redisTemplate;
|
||||||
|
|
||||||
@ -34,8 +39,17 @@ public class RedisCache
|
|||||||
* @param key 缓存的键值
|
* @param key 缓存的键值
|
||||||
* @param value 缓存的值
|
* @param value 缓存的值
|
||||||
*/
|
*/
|
||||||
public <T> void setCacheObject(final String key, final T value)
|
public <T> void setCacheObject(final String cacheName, final String key, final T value) {
|
||||||
{
|
redisTemplate.opsForValue().set(cacheName + ":" + key, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 缓存基本的对象,Integer、String、实体类等
|
||||||
|
*
|
||||||
|
* @param key 缓存的键值
|
||||||
|
* @param value 缓存的值
|
||||||
|
*/
|
||||||
|
public <T> void setCacheObject(final String key, final T value) {
|
||||||
redisTemplate.opsForValue().set(key, value);
|
redisTemplate.opsForValue().set(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,8 +61,20 @@ public class RedisCache
|
|||||||
* @param timeout 时间
|
* @param timeout 时间
|
||||||
* @param timeUnit 时间颗粒度
|
* @param timeUnit 时间颗粒度
|
||||||
*/
|
*/
|
||||||
public <T> void setCacheObject(final String key, final T value, final Integer timeout, final TimeUnit timeUnit)
|
public <T> void setCacheObject(final String cacheName, final String key, final T value, final long timeout,
|
||||||
{
|
final TimeUnit timeUnit) {
|
||||||
|
redisTemplate.opsForValue().set(cacheName + ":" + key, value, timeout, timeUnit);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 缓存基本的对象,Integer、String、实体类等
|
||||||
|
*
|
||||||
|
* @param key 缓存的键值
|
||||||
|
* @param value 缓存的值
|
||||||
|
* @param timeout 时间
|
||||||
|
* @param timeUnit 时间颗粒度
|
||||||
|
*/
|
||||||
|
public <T> void setCacheObject(final String key, final T value, final long timeout, final TimeUnit timeUnit) {
|
||||||
redisTemplate.opsForValue().set(key, value, timeout, timeUnit);
|
redisTemplate.opsForValue().set(key, value, timeout, timeUnit);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,8 +85,7 @@ public class RedisCache
|
|||||||
* @param timeout 超时时间
|
* @param timeout 超时时间
|
||||||
* @return true=设置成功;false=设置失败
|
* @return true=设置成功;false=设置失败
|
||||||
*/
|
*/
|
||||||
public boolean expire(final String key, final long timeout)
|
public boolean expire(final String key, final long timeout) {
|
||||||
{
|
|
||||||
return expire(key, timeout, TimeUnit.SECONDS);
|
return expire(key, timeout, TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,8 +97,7 @@ public class RedisCache
|
|||||||
* @param unit 时间单位
|
* @param unit 时间单位
|
||||||
* @return true=设置成功;false=设置失败
|
* @return true=设置成功;false=设置失败
|
||||||
*/
|
*/
|
||||||
public boolean expire(final String key, final long timeout, final TimeUnit unit)
|
public boolean expire(final String key, final long timeout, final TimeUnit unit) {
|
||||||
{
|
|
||||||
return redisTemplate.expire(key, timeout, unit);
|
return redisTemplate.expire(key, timeout, unit);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,8 +107,7 @@ public class RedisCache
|
|||||||
* @param key Redis键
|
* @param key Redis键
|
||||||
* @return 有效时间
|
* @return 有效时间
|
||||||
*/
|
*/
|
||||||
public long getExpire(final String key)
|
public long getExpire(final String key) {
|
||||||
{
|
|
||||||
return redisTemplate.getExpire(key);
|
return redisTemplate.getExpire(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,8 +117,7 @@ public class RedisCache
|
|||||||
* @param key 键
|
* @param key 键
|
||||||
* @return true 存在 false不存在
|
* @return true 存在 false不存在
|
||||||
*/
|
*/
|
||||||
public Boolean hasKey(String key)
|
public Boolean hasKey(String key) {
|
||||||
{
|
|
||||||
return redisTemplate.hasKey(key);
|
return redisTemplate.hasKey(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,8 +127,7 @@ public class RedisCache
|
|||||||
* @param key 缓存键值
|
* @param key 缓存键值
|
||||||
* @return 缓存键值对应的数据
|
* @return 缓存键值对应的数据
|
||||||
*/
|
*/
|
||||||
public <T> T getCacheObject(final String key)
|
public <T> T getCacheObject(final String key) {
|
||||||
{
|
|
||||||
ValueOperations<String, T> operation = redisTemplate.opsForValue();
|
ValueOperations<String, T> operation = redisTemplate.opsForValue();
|
||||||
return operation.get(key);
|
return operation.get(key);
|
||||||
}
|
}
|
||||||
@ -116,8 +137,7 @@ public class RedisCache
|
|||||||
*
|
*
|
||||||
* @param key
|
* @param key
|
||||||
*/
|
*/
|
||||||
public boolean deleteObject(final String key)
|
public boolean deleteObject(final String key) {
|
||||||
{
|
|
||||||
return redisTemplate.delete(key);
|
return redisTemplate.delete(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,8 +147,7 @@ public class RedisCache
|
|||||||
* @param collection 多个对象
|
* @param collection 多个对象
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean deleteObject(final Collection collection)
|
public boolean deleteObject(final Collection collection) {
|
||||||
{
|
|
||||||
return redisTemplate.delete(collection) > 0;
|
return redisTemplate.delete(collection) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,8 +158,7 @@ public class RedisCache
|
|||||||
* @param dataList 待缓存的List数据
|
* @param dataList 待缓存的List数据
|
||||||
* @return 缓存的对象
|
* @return 缓存的对象
|
||||||
*/
|
*/
|
||||||
public <T> long setCacheList(final String key, final List<T> dataList)
|
public <T> long setCacheList(final String key, final List<T> dataList) {
|
||||||
{
|
|
||||||
Long count = redisTemplate.opsForList().rightPushAll(key, dataList);
|
Long count = redisTemplate.opsForList().rightPushAll(key, dataList);
|
||||||
return count == null ? 0 : count;
|
return count == null ? 0 : count;
|
||||||
}
|
}
|
||||||
@ -151,8 +169,7 @@ public class RedisCache
|
|||||||
* @param key 缓存的键值
|
* @param key 缓存的键值
|
||||||
* @return 缓存键值对应的数据
|
* @return 缓存键值对应的数据
|
||||||
*/
|
*/
|
||||||
public <T> List<T> getCacheList(final String key)
|
public <T> List<T> getCacheList(final String key) {
|
||||||
{
|
|
||||||
return redisTemplate.opsForList().range(key, 0, -1);
|
return redisTemplate.opsForList().range(key, 0, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,12 +180,10 @@ public class RedisCache
|
|||||||
* @param dataSet 缓存的数据
|
* @param dataSet 缓存的数据
|
||||||
* @return 缓存数据的对象
|
* @return 缓存数据的对象
|
||||||
*/
|
*/
|
||||||
public <T> BoundSetOperations<String, T> setCacheSet(final String key, final Set<T> dataSet)
|
public <T> BoundSetOperations<String, T> setCacheSet(final String key, final Set<T> dataSet) {
|
||||||
{
|
|
||||||
BoundSetOperations<String, T> setOperation = redisTemplate.boundSetOps(key);
|
BoundSetOperations<String, T> setOperation = redisTemplate.boundSetOps(key);
|
||||||
Iterator<T> it = dataSet.iterator();
|
Iterator<T> it = dataSet.iterator();
|
||||||
while (it.hasNext())
|
while (it.hasNext()) {
|
||||||
{
|
|
||||||
setOperation.add(it.next());
|
setOperation.add(it.next());
|
||||||
}
|
}
|
||||||
return setOperation;
|
return setOperation;
|
||||||
@ -180,8 +195,7 @@ public class RedisCache
|
|||||||
* @param key
|
* @param key
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public <T> Set<T> getCacheSet(final String key)
|
public <T> Set<T> getCacheSet(final String key) {
|
||||||
{
|
|
||||||
return redisTemplate.opsForSet().members(key);
|
return redisTemplate.opsForSet().members(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,8 +205,7 @@ public class RedisCache
|
|||||||
* @param key
|
* @param key
|
||||||
* @param dataMap
|
* @param dataMap
|
||||||
*/
|
*/
|
||||||
public <T> void setCacheMap(final String key, final Map<String, T> dataMap)
|
public <T> void setCacheMap(final String key, final Map<String, T> dataMap) {
|
||||||
{
|
|
||||||
if (dataMap != null) {
|
if (dataMap != null) {
|
||||||
redisTemplate.opsForHash().putAll(key, dataMap);
|
redisTemplate.opsForHash().putAll(key, dataMap);
|
||||||
}
|
}
|
||||||
@ -204,8 +217,7 @@ public class RedisCache
|
|||||||
* @param key
|
* @param key
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public <T> Map<String, T> getCacheMap(final String key)
|
public <T> Map<String, T> getCacheMap(final String key) {
|
||||||
{
|
|
||||||
return redisTemplate.opsForHash().entries(key);
|
return redisTemplate.opsForHash().entries(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -216,8 +228,7 @@ public class RedisCache
|
|||||||
* @param hKey Hash键
|
* @param hKey Hash键
|
||||||
* @param value 值
|
* @param value 值
|
||||||
*/
|
*/
|
||||||
public <T> void setCacheMapValue(final String key, final String hKey, final T value)
|
public <T> void setCacheMapValue(final String key, final String hKey, final T value) {
|
||||||
{
|
|
||||||
redisTemplate.opsForHash().put(key, hKey, value);
|
redisTemplate.opsForHash().put(key, hKey, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -228,8 +239,7 @@ public class RedisCache
|
|||||||
* @param hKey Hash键
|
* @param hKey Hash键
|
||||||
* @return Hash中的对象
|
* @return Hash中的对象
|
||||||
*/
|
*/
|
||||||
public <T> T getCacheMapValue(final String key, final String hKey)
|
public <T> T getCacheMapValue(final String key, final String hKey) {
|
||||||
{
|
|
||||||
HashOperations<String, String, T> opsForHash = redisTemplate.opsForHash();
|
HashOperations<String, String, T> opsForHash = redisTemplate.opsForHash();
|
||||||
return opsForHash.get(key, hKey);
|
return opsForHash.get(key, hKey);
|
||||||
}
|
}
|
||||||
@ -241,8 +251,7 @@ public class RedisCache
|
|||||||
* @param hKeys Hash键集合
|
* @param hKeys Hash键集合
|
||||||
* @return Hash对象集合
|
* @return Hash对象集合
|
||||||
*/
|
*/
|
||||||
public <T> List<T> getMultiCacheMapValue(final String key, final Collection<Object> hKeys)
|
public <T> List<T> getMultiCacheMapValue(final String key, final Collection<Object> hKeys) {
|
||||||
{
|
|
||||||
return redisTemplate.opsForHash().multiGet(key, hKeys);
|
return redisTemplate.opsForHash().multiGet(key, hKeys);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -253,8 +262,7 @@ public class RedisCache
|
|||||||
* @param hKey Hash键
|
* @param hKey Hash键
|
||||||
* @return 是否成功
|
* @return 是否成功
|
||||||
*/
|
*/
|
||||||
public boolean deleteCacheMapValue(final String key, final String hKey)
|
public boolean deleteCacheMapValue(final String key, final String hKey) {
|
||||||
{
|
|
||||||
return redisTemplate.opsForHash().delete(key, hKey) > 0;
|
return redisTemplate.opsForHash().delete(key, hKey) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -264,8 +272,17 @@ public class RedisCache
|
|||||||
* @param pattern 字符串前缀
|
* @param pattern 字符串前缀
|
||||||
* @return 对象列表
|
* @return 对象列表
|
||||||
*/
|
*/
|
||||||
public Collection<String> keys(final String pattern)
|
public Collection<String> keys(final String pattern) {
|
||||||
{
|
|
||||||
return redisTemplate.keys(pattern);
|
return redisTemplate.keys(pattern);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<String> getCachekeys(Cache cache) {
|
||||||
|
Set<String> keyset = new HashSet<>();
|
||||||
|
Set<Object> keysets = redisTemplate.keys(cache.getName() + "*");
|
||||||
|
for (Object s : keysets) {
|
||||||
|
keyset.add(StringUtils.replace(s.toString(), cache.getName() + ":", ""));
|
||||||
|
}
|
||||||
|
return keyset;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
63
ruoyi-models/pom.xml
Normal file
63
ruoyi-models/pom.xml
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<parent>
|
||||||
|
<artifactId>ruoyi</artifactId>
|
||||||
|
<groupId>com.ruoyi</groupId>
|
||||||
|
<version>3.8.7.3.2</version>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<artifactId>ruoyi-models</artifactId>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<ruoyi.version>3.8.7.3.2</ruoyi.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<description>
|
||||||
|
中间件
|
||||||
|
</description>
|
||||||
|
|
||||||
|
<dependencyManagement>
|
||||||
|
<dependencies>
|
||||||
|
<!-- 定时任务-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.ruoyi</groupId>
|
||||||
|
<artifactId>ruoyi-quartz</artifactId>
|
||||||
|
<version>${ruoyi.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 代码生成-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.ruoyi</groupId>
|
||||||
|
<artifactId>ruoyi-generator</artifactId>
|
||||||
|
<version>${ruoyi.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 代码生成-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.ruoyi</groupId>
|
||||||
|
<artifactId>ruoyi-online</artifactId>
|
||||||
|
<version>${ruoyi.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 代码生成-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.ruoyi</groupId>
|
||||||
|
<artifactId>ruoyi-models-starter</artifactId>
|
||||||
|
<version>${ruoyi.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
</dependencyManagement>
|
||||||
|
|
||||||
|
|
||||||
|
<modules>
|
||||||
|
<module>ruoyi-models-starter</module>
|
||||||
|
<module>ruoyi-generator</module>
|
||||||
|
<module>ruoyi-quartz</module>
|
||||||
|
<module>ruoyi-online</module>
|
||||||
|
</modules>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
</project>
|
@ -3,7 +3,7 @@
|
|||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<parent>
|
<parent>
|
||||||
<artifactId>ruoyi</artifactId>
|
<artifactId>ruoyi-models</artifactId>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<version>3.8.7.3.2</version>
|
<version>3.8.7.3.2</version>
|
||||||
</parent>
|
</parent>
|
45
ruoyi-models/ruoyi-models-starter/pom.xml
Normal file
45
ruoyi-models/ruoyi-models-starter/pom.xml
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<parent>
|
||||||
|
<artifactId>ruoyi-models</artifactId>
|
||||||
|
<groupId>com.ruoyi</groupId>
|
||||||
|
<version>3.8.7.3.2</version>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<artifactId>ruoyi-models-starter</artifactId>
|
||||||
|
|
||||||
|
<description>
|
||||||
|
中间件
|
||||||
|
</description>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
|
||||||
|
<!-- 通用工具-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.ruoyi</groupId>
|
||||||
|
<artifactId>ruoyi-common</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 定时任务-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.ruoyi</groupId>
|
||||||
|
<artifactId>ruoyi-quartz</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 代码生成-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.ruoyi</groupId>
|
||||||
|
<artifactId>ruoyi-generator</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 代码生成-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.ruoyi</groupId>
|
||||||
|
<artifactId>ruoyi-online</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
</project>
|
@ -3,7 +3,7 @@
|
|||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<parent>
|
<parent>
|
||||||
<artifactId>ruoyi</artifactId>
|
<artifactId>ruoyi-models</artifactId>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<version>3.8.7.3.2</version>
|
<version>3.8.7.3.2</version>
|
||||||
</parent>
|
</parent>
|
@ -1,9 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<parent>
|
<parent>
|
||||||
<artifactId>ruoyi</artifactId>
|
<artifactId>ruoyi-models</artifactId>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<version>3.8.7.3.2</version>
|
<version>3.8.7.3.2</version>
|
||||||
</parent>
|
</parent>
|
75
ruoyi-plugins/pom.xml
Normal file
75
ruoyi-plugins/pom.xml
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<parent>
|
||||||
|
<artifactId>ruoyi</artifactId>
|
||||||
|
<groupId>com.ruoyi</groupId>
|
||||||
|
<version>3.8.7.3.2</version>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<artifactId>ruoyi-plugins</artifactId>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<ruoyi.version>3.8.7.3.2</ruoyi.version>
|
||||||
|
<ehcache.version>3.10.8</ehcache.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<description>
|
||||||
|
|
||||||
|
</description>
|
||||||
|
<dependencyManagement>
|
||||||
|
<dependencies>
|
||||||
|
<!-- Ehcache缓存管理器 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.ehcache</groupId>
|
||||||
|
<artifactId>ehcache</artifactId>
|
||||||
|
<version>${ehcache.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- ehcache-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.ruoyi</groupId>
|
||||||
|
<artifactId>ruoyi-ehcache</artifactId>
|
||||||
|
<version>${ruoyi.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- ehcache-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.ruoyi</groupId>
|
||||||
|
<artifactId>ruoyi-ehcache</artifactId>
|
||||||
|
<version>${ruoyi.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- ehcache-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.ruoyi</groupId>
|
||||||
|
<artifactId>ruoyi-mybatis-jpa</artifactId>
|
||||||
|
<version>${ruoyi.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- websocket -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.ruoyi</groupId>
|
||||||
|
<artifactId>ruoyi-websocket</artifactId>
|
||||||
|
<version>${ruoyi.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- plugins-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.ruoyi</groupId>
|
||||||
|
<artifactId>ruoyi-plugins-starter</artifactId>
|
||||||
|
<version>${ruoyi.version}</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</dependencyManagement>
|
||||||
|
|
||||||
|
|
||||||
|
<modules>
|
||||||
|
<module>ruoyi-ehcache</module>
|
||||||
|
<module>ruoyi-mybatis-jpa</module>
|
||||||
|
<module>ruoyi-websocket</module>
|
||||||
|
<module>ruoyi-plugins-starter</module>
|
||||||
|
</modules>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
</project>
|
33
ruoyi-plugins/ruoyi-ehcache/pom.xml
Normal file
33
ruoyi-plugins/ruoyi-ehcache/pom.xml
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<parent>
|
||||||
|
<artifactId>ruoyi-plugins</artifactId>
|
||||||
|
<groupId>com.ruoyi</groupId>
|
||||||
|
<version>3.8.7.3.2</version>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<artifactId>ruoyi-ehcache</artifactId>
|
||||||
|
|
||||||
|
<description>
|
||||||
|
中间件
|
||||||
|
</description>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
|
||||||
|
<!-- 通用工具-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.ruoyi</groupId>
|
||||||
|
<artifactId>ruoyi-common</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Ehcache缓存管理器 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.ehcache</groupId>
|
||||||
|
<artifactId>ehcache</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
</project>
|
@ -0,0 +1,57 @@
|
|||||||
|
package com.ruoyi.ehcache.config;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
import org.ehcache.core.EhcacheBase;
|
||||||
|
import org.ehcache.impl.internal.store.heap.OnHeapStore;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.cache.Cache;
|
||||||
|
import org.springframework.cache.jcache.JCacheCache;
|
||||||
|
import org.springframework.cache.jcache.JCacheCacheManager;
|
||||||
|
|
||||||
|
import com.ruoyi.common.interceptor.cache.CacheKeys;
|
||||||
|
import com.ruoyi.common.interceptor.cache.CacheNoTimeOut;
|
||||||
|
|
||||||
|
public class Ehcache3Cache implements CacheNoTimeOut, CacheKeys {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private JCacheCacheManager jCacheCacheManager;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<String> getCachekeys(Cache cache) {
|
||||||
|
Set<String> keyset = new HashSet<>();
|
||||||
|
try {
|
||||||
|
JCacheCache jehcache = (JCacheCache) cache;
|
||||||
|
// org.ehcache.jsr107.Eh107Cache 不公开
|
||||||
|
Object nativeCache = jehcache.getNativeCache();
|
||||||
|
Class<?> nativeCacheClass = nativeCache.getClass();
|
||||||
|
Field ehCacheField = nativeCacheClass.getDeclaredField("ehCache");
|
||||||
|
ehCacheField.setAccessible(true);
|
||||||
|
EhcacheBase ehcache = (EhcacheBase) ehCacheField.get(nativeCache);
|
||||||
|
Field storeField = EhcacheBase.class.getDeclaredField("store");
|
||||||
|
storeField.setAccessible(true);
|
||||||
|
OnHeapStore store = (OnHeapStore) storeField.get(ehcache);
|
||||||
|
Field mapField = OnHeapStore.class.getDeclaredField("map");
|
||||||
|
mapField.setAccessible(true);
|
||||||
|
// org.ehcache.impl.internal.store.heap.Backend 不公开
|
||||||
|
Object map = mapField.get(store);
|
||||||
|
Class<?> mapClass = map.getClass();
|
||||||
|
Field realMapField = mapClass.getDeclaredField("realMap");
|
||||||
|
realMapField.setAccessible(true);
|
||||||
|
ConcurrentHashMap<String, ?> realMap = (ConcurrentHashMap<String, ?>) realMapField.get(map);
|
||||||
|
keyset = realMap.keySet();
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
return keyset;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T> void setCacheObject(String cacheName, String key, T value) {
|
||||||
|
Cache cache = jCacheCacheManager.getCache(cacheName);
|
||||||
|
cache.put(cacheName, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package com.ruoyi.framework.config;
|
package com.ruoyi.ehcache.config;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@ -23,47 +23,11 @@ import org.springframework.cache.jcache.JCacheCacheManager;
|
|||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
import com.ruoyi.common.core.cache.CacheSpecialUtils;
|
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableCaching
|
@EnableCaching
|
||||||
@ConditionalOnProperty(prefix = "spring.cache", name = { "type" }, havingValue = "jcache", matchIfMissing = false)
|
@ConditionalOnProperty(prefix = "spring.cache", name = { "type" }, havingValue = "jcache", matchIfMissing = false)
|
||||||
public class Ehcache3Config {
|
public class Ehcache3Config {
|
||||||
|
|
||||||
@Bean
|
|
||||||
@SuppressWarnings(value = { "unchecked", "rawtypes" })
|
|
||||||
public CacheSpecialUtils cacheGetKets() {
|
|
||||||
return new CacheSpecialUtils() {
|
|
||||||
@Override
|
|
||||||
public Set<String> getKeys(Cache cache) {
|
|
||||||
Set<String> keyset = new HashSet<>();
|
|
||||||
try {
|
|
||||||
JCacheCache jehcache = (JCacheCache) cache;
|
|
||||||
// org.ehcache.jsr107.Eh107Cache 不公开
|
|
||||||
Object nativeCache = jehcache.getNativeCache();
|
|
||||||
Class<?> nativeCacheClass = nativeCache.getClass();
|
|
||||||
Field ehCacheField = nativeCacheClass.getDeclaredField("ehCache");
|
|
||||||
ehCacheField.setAccessible(true);
|
|
||||||
EhcacheBase ehcache = (EhcacheBase) ehCacheField.get(nativeCache);
|
|
||||||
Field storeField = EhcacheBase.class.getDeclaredField("store");
|
|
||||||
storeField.setAccessible(true);
|
|
||||||
OnHeapStore store = (OnHeapStore) storeField.get(ehcache);
|
|
||||||
Field mapField = OnHeapStore.class.getDeclaredField("map");
|
|
||||||
mapField.setAccessible(true);
|
|
||||||
// org.ehcache.impl.internal.store.heap.Backend 不公开
|
|
||||||
Object map = mapField.get(store);
|
|
||||||
Class<?> mapClass = map.getClass();
|
|
||||||
Field realMapField = mapClass.getDeclaredField("realMap");
|
|
||||||
realMapField.setAccessible(true);
|
|
||||||
ConcurrentHashMap<String, ?> realMap = (ConcurrentHashMap<String, ?>) realMapField.get(map);
|
|
||||||
keyset = realMap.keySet();
|
|
||||||
} catch (Exception e) {
|
|
||||||
}
|
|
||||||
return keyset;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public JCacheCacheManager ehcacheManager() {
|
public JCacheCacheManager ehcacheManager() {
|
||||||
EhcacheCachingProvider cachingProvider = (EhcacheCachingProvider) Caching.getCachingProvider();
|
EhcacheCachingProvider cachingProvider = (EhcacheCachingProvider) Caching.getCachingProvider();
|
44
ruoyi-plugins/ruoyi-plugins-starter/pom.xml
Normal file
44
ruoyi-plugins/ruoyi-plugins-starter/pom.xml
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<parent>
|
||||||
|
<artifactId>ruoyi-plugins</artifactId>
|
||||||
|
<groupId>com.ruoyi</groupId>
|
||||||
|
<version>3.8.7.3.2</version>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<artifactId>ruoyi-plugins-starter</artifactId>
|
||||||
|
|
||||||
|
<description>
|
||||||
|
中间件
|
||||||
|
</description>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
|
||||||
|
<!-- 通用工具-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.ruoyi</groupId>
|
||||||
|
<artifactId>ruoyi-common</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- ehcache-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.ruoyi</groupId>
|
||||||
|
<artifactId>ruoyi-ehcache</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- websocket -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.ruoyi</groupId>
|
||||||
|
<artifactId>ruoyi-websocket</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- mybatis-jpa -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.ruoyi</groupId>
|
||||||
|
<artifactId>ruoyi-mybatis-jpa</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
</project>
|
@ -2,7 +2,7 @@
|
|||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<parent>
|
<parent>
|
||||||
<artifactId>ruoyi</artifactId>
|
<artifactId>ruoyi-plugins</artifactId>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<version>3.8.7.3.2</version>
|
<version>3.8.7.3.2</version>
|
||||||
</parent>
|
</parent>
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user