update m2pool 新增注销账号功能
This commit is contained in:
@@ -15,6 +15,7 @@ public class RedisTransKey {
|
||||
public static final String RedisAddCreditEmailCodeName="addCreditEmailCode";
|
||||
public static final String RedisResetPwdCodeName="restPwdCode";
|
||||
public static final String RedisUpdatePwdCodeName="updatePwdCode";
|
||||
public static final String RedisCloseAccountName="closeAccount";
|
||||
|
||||
public static String setEmailKey(String key){
|
||||
return RedisNameSpace+":"+RedisEmailCodeName+":"+key;
|
||||
@@ -39,6 +40,10 @@ public class RedisTransKey {
|
||||
return RedisNameSpace+":"+RedisAddCreditEmailCodeName+":"+key;
|
||||
}
|
||||
|
||||
public static String setCloseAccountKey(String key){
|
||||
return RedisNameSpace+":"+RedisCloseAccountName+":"+key;
|
||||
}
|
||||
|
||||
public static String getEmailKey(String key){return setEmailKey(key);}
|
||||
public static String getRootKey(String key){return setRootKey(key);}
|
||||
public static String getTokenKey(String key){return setTokenKey(key);}
|
||||
@@ -47,4 +52,8 @@ public class RedisTransKey {
|
||||
public static String getUpdatePwdKey(String key){return setUpdatePwdKey(key);}
|
||||
public static String getAddCreditEmailKey(String key){return setAddCreditEmailKey(key);}
|
||||
|
||||
public static String getCloseAccountKey(String key){return setCloseAccountKey(key);}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除集合对象
|
||||
*
|
||||
|
||||
@@ -179,5 +179,5 @@ public class GlobalExceptionHandler {
|
||||
log.error("请求地址'{}',发生SQL异常.", requestURI, e);
|
||||
return AjaxResult.error(HttpStatus.ERROR, "数据库异常!");
|
||||
}
|
||||
//todo 根据业务需求增加异常
|
||||
//todo 根据业务需求增加异常
|
||||
}
|
||||
|
||||
@@ -39,9 +39,9 @@ public class HeaderInterceptor implements AsyncHandlerInterceptor {
|
||||
SecurityContextHolder.setUserKey(ServletUtils.getHeader(request,SecurityConstants.USER_KEY));
|
||||
|
||||
//开发环境
|
||||
String authorization = request.getHeader("Authorization");
|
||||
String userName = JwtUtils.getUserName(authorization);
|
||||
SecurityContextHolder.setUserName(userName);
|
||||
//String authorization = request.getHeader("Authorization");
|
||||
//String userName = JwtUtils.getUserName(authorization);
|
||||
//SecurityContextHolder.setUserName(userName);
|
||||
|
||||
String token = SecurityUtils.getToken();
|
||||
if(StringUtils.isNotEmpty(token)){
|
||||
|
||||
Reference in New Issue
Block a user