update m2pool 新增注销账号功能
This commit is contained in:
@@ -5,11 +5,19 @@ import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
||||
import com.fasterxml.jackson.annotation.PropertyAccessor;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.jsontype.impl.LaissezFaireSubTypeValidator;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.cache.annotation.CachingConfigurerSupport;
|
||||
import org.springframework.cache.annotation.EnableCaching;
|
||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.data.redis.connection.RedisStandaloneConfiguration;
|
||||
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
|
||||
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.core.script.DefaultRedisScript;
|
||||
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||
@@ -19,13 +27,21 @@ import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||
* @Date 2024/6/13 09:58
|
||||
* @Author dy
|
||||
*/
|
||||
@RefreshScope
|
||||
@Configuration
|
||||
@EnableCaching
|
||||
public class RedisConfig extends CachingConfigurerSupport {
|
||||
|
||||
@Value("${spring.redis.host}")
|
||||
private String host;
|
||||
@Value("${spring.redis.port}")
|
||||
private int port;
|
||||
@Value("${spring.redis.database:0}")
|
||||
private int database = 0;
|
||||
|
||||
@Bean
|
||||
@SuppressWarnings(value = { "unchecked", "rawtypes" })
|
||||
public RedisTemplate<Object, Object> redisTemplate(RedisConnectionFactory connectionFactory)
|
||||
public RedisTemplate<Object, Object> redisTemplate(@Qualifier("redisConnectionFactory0") RedisConnectionFactory connectionFactory)
|
||||
{
|
||||
RedisTemplate<Object, Object> template = new RedisTemplate<>();
|
||||
template.setConnectionFactory(connectionFactory);
|
||||
@@ -50,6 +66,45 @@ public class RedisConfig extends CachingConfigurerSupport {
|
||||
return template;
|
||||
}
|
||||
|
||||
@Bean(name = "redisTemplate7")
|
||||
public RedisTemplate<Object, Object> redisTemplate7(@Qualifier("redisConnectionFactory7") RedisConnectionFactory redisConnectionFactory0) {
|
||||
RedisTemplate<Object, Object> template = new RedisTemplate<>();
|
||||
template.setConnectionFactory(redisConnectionFactory0);
|
||||
template.setKeySerializer(new StringRedisSerializer());
|
||||
template.setValueSerializer(new StringRedisSerializer());
|
||||
return template;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 7号 数据库 - >
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public RedisConnectionFactory redisConnectionFactory7() {
|
||||
LettuceConnectionFactory factory = new LettuceConnectionFactory();
|
||||
factory.setHostName(host);
|
||||
factory.setPort(port);
|
||||
factory.setDatabase(7);
|
||||
return factory;
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认 数据库
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
@Primary //添加@Primary默认使用的库
|
||||
public RedisConnectionFactory redisConnectionFactory0() {
|
||||
LettuceConnectionFactory factory = new LettuceConnectionFactory();
|
||||
factory.setHostName(host);
|
||||
factory.setPort(port);
|
||||
factory.setDatabase(database);
|
||||
return factory;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Bean
|
||||
public DefaultRedisScript<Long> limitScript()
|
||||
{
|
||||
@@ -62,6 +117,8 @@ public class RedisConfig extends CachingConfigurerSupport {
|
||||
return redisScript;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 限流脚本
|
||||
*/
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.m2pool.common.redis.service;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.data.redis.core.BoundSetOperations;
|
||||
import org.springframework.data.redis.core.HashOperations;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
@@ -21,8 +22,14 @@ import java.util.concurrent.TimeUnit;
|
||||
public class RedisService {
|
||||
|
||||
@Autowired
|
||||
@Qualifier("redisTemplate")
|
||||
private RedisTemplate redisTemplate;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("redisTemplate7")
|
||||
private RedisTemplate redisTemplate7;
|
||||
|
||||
|
||||
/**
|
||||
* 缓存基本的对象,Integer、String、实体类等
|
||||
*
|
||||
@@ -34,6 +41,7 @@ public class RedisService {
|
||||
redisTemplate.opsForValue().set(key, value);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 缓存基本的对象,Integer、String、实体类等
|
||||
*
|
||||
@@ -47,6 +55,12 @@ public class RedisService {
|
||||
redisTemplate.opsForValue().set(key, value, timeout, timeUnit);
|
||||
}
|
||||
|
||||
|
||||
public <T> void setCacheObject7(final String key, final T value, final Long timeout, final TimeUnit timeUnit)
|
||||
{
|
||||
redisTemplate7.opsForValue().set(key, value, timeout, timeUnit);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置有效时间
|
||||
*
|
||||
@@ -118,6 +132,12 @@ public class RedisService {
|
||||
return operation.get(key);
|
||||
}
|
||||
|
||||
public <T> T getCacheObject7(final String key)
|
||||
{
|
||||
ValueOperations<String, T> operation = redisTemplate7.opsForValue();
|
||||
return operation.get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 所有数字类型转换为BigDecimal
|
||||
* @param key 缓存键值
|
||||
@@ -153,6 +173,7 @@ public class RedisService {
|
||||
return redisTemplate.delete(key);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除集合对象
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user