fix(uboot-core): 修改分表aop线程参数类型
This commit is contained in:
@ -1,23 +0,0 @@
|
|||||||
package com.chinaunicom.mall.ebtp.common.sharding.algorithm.handler;
|
|
||||||
|
|
||||||
import com.chinaunicom.mall.ebtp.common.sharding.annotation.RequestShardValue;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* redis键值存储类
|
|
||||||
*
|
|
||||||
* @author dino
|
|
||||||
* @date 2021/09/06 10:48
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor(staticName = "of")
|
|
||||||
public class ShardValue {
|
|
||||||
|
|
||||||
private String redisKey;
|
|
||||||
|
|
||||||
private RequestShardValue requestShardValue;
|
|
||||||
|
|
||||||
}
|
|
@ -26,7 +26,7 @@ public class YearHintShardingHandler {
|
|||||||
/*表名*/
|
/*表名*/
|
||||||
private static final String BIZ_RSMS_BID_EVAL_DETAIL = "biz_rsms_bid_eval_detail";
|
private static final String BIZ_RSMS_BID_EVAL_DETAIL = "biz_rsms_bid_eval_detail";
|
||||||
/**分片值*/
|
/**分片值*/
|
||||||
public static final FastThreadLocal<ShardValue> REQUEST_SHARD_VALUE = new FastThreadLocal<>();
|
public static final FastThreadLocal<String> REQUEST_SHARD_VALUE = new FastThreadLocal<>();
|
||||||
/**分片缓存前缀*/
|
/**分片缓存前缀*/
|
||||||
public static final String REQUEST_SHARD_KEY = "request_shard_key:";
|
public static final String REQUEST_SHARD_KEY = "request_shard_key:";
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ public @interface RequestShardValue {
|
|||||||
* 提示信息,可自定义
|
* 提示信息,可自定义
|
||||||
* @return String
|
* @return String
|
||||||
*/
|
*/
|
||||||
String info() default "无法获取分片规则,请稍后重试";
|
String info() default "无法获取分片规则,请联系管理员";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否在业务完成后删除key true:删除 false:不删除
|
* 是否在业务完成后删除key true:删除 false:不删除
|
||||||
|
@ -4,7 +4,6 @@ import cn.hutool.json.JSONUtil;
|
|||||||
import com.chinaunicom.mall.ebtp.common.base.entity.BaseResponse;
|
import com.chinaunicom.mall.ebtp.common.base.entity.BaseResponse;
|
||||||
import com.chinaunicom.mall.ebtp.common.exception.common.CommonExceptionEnum;
|
import com.chinaunicom.mall.ebtp.common.exception.common.CommonExceptionEnum;
|
||||||
import com.chinaunicom.mall.ebtp.common.exception.entity.BusinessException;
|
import com.chinaunicom.mall.ebtp.common.exception.entity.BusinessException;
|
||||||
import com.chinaunicom.mall.ebtp.common.sharding.algorithm.handler.ShardValue;
|
|
||||||
import com.chinaunicom.mall.ebtp.common.sharding.algorithm.handler.YearHintShardingHandler;
|
import com.chinaunicom.mall.ebtp.common.sharding.algorithm.handler.YearHintShardingHandler;
|
||||||
import com.chinaunicom.mall.ebtp.common.sharding.annotation.RequestShardValue;
|
import com.chinaunicom.mall.ebtp.common.sharding.annotation.RequestShardValue;
|
||||||
import com.chinaunicom.mall.ebtp.common.sharding.expression.KeyResolver;
|
import com.chinaunicom.mall.ebtp.common.sharding.expression.KeyResolver;
|
||||||
@ -71,7 +70,7 @@ public class RequestShardValueAspect {
|
|||||||
/*新增rsms分表*/
|
/*新增rsms分表*/
|
||||||
YearHintShardingHandler.addRsmsTableShardingValue(year);
|
YearHintShardingHandler.addRsmsTableShardingValue(year);
|
||||||
/*新增线程*/
|
/*新增线程*/
|
||||||
REQUEST_SHARD_VALUE.set(ShardValue.of(redisKey, requestShardValue));
|
REQUEST_SHARD_VALUE.set(redisKey);
|
||||||
synchronized(this) {
|
synchronized(this) {
|
||||||
this.redisTemplate.opsForValue().setIfAbsent(redisKey, projectVO, requestShardValue.expireTime(), requestShardValue.timeUnit());
|
this.redisTemplate.opsForValue().setIfAbsent(redisKey, projectVO, requestShardValue.expireTime(), requestShardValue.timeUnit());
|
||||||
}
|
}
|
||||||
@ -84,9 +83,8 @@ public class RequestShardValueAspect {
|
|||||||
if (!method.isAnnotationPresent(RequestShardValue.class)) {
|
if (!method.isAnnotationPresent(RequestShardValue.class)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ShardValue shardValue = REQUEST_SHARD_VALUE.get();
|
RequestShardValue requestShardValue = method.getAnnotation(RequestShardValue.class);
|
||||||
RequestShardValue requestShardValue = shardValue.getRequestShardValue();
|
String key = REQUEST_SHARD_VALUE.get();
|
||||||
String key = shardValue.getRedisKey();
|
|
||||||
Optional<Object> o = Optional.ofNullable(this.redisTemplate.opsForValue().get(key));
|
Optional<Object> o = Optional.ofNullable(this.redisTemplate.opsForValue().get(key));
|
||||||
if (o.isPresent() && requestShardValue.delKey()) {
|
if (o.isPresent() && requestShardValue.delKey()) {
|
||||||
this.redisTemplate.delete(key);
|
this.redisTemplate.delete(key);
|
||||||
|
Reference in New Issue
Block a user