Authored by tanling

优化黑名单

... ... @@ -33,23 +33,60 @@ public class BlackUserAspect {
private static Map<Integer, AbstractBlackUserInterceptor> blackUserInteceptorMap = Maps.newHashMap();
Logger logger = LoggerFactory.getLogger(AbstractBlackUserInterceptor.class);
@Pointcut("@annotation(com.yohoufo.order.annotation.BlackUserType)")
private void pointId(){
}
public static final String UID= "uid";
@Before("pointId()")
private void before(JoinPoint joinPoint) throws Throwable{
int uid = getParamUidValue(joinPoint);
if (uid == -1){
return;
}
Object[] argsa = joinPoint.getArgs();
BlackUserType blackUserAnnotation = ((MethodSignature) joinPoint.getSignature()).getMethod().getAnnotation(BlackUserType.class);
Annotation[][] parameterTypes = ((MethodSignature)joinPoint.getSignature()).getMethod().getParameterAnnotations();
blackUserInteceptorMap.get(blackUserAnnotation.blackType().getCode()).before(uid);
BlackUserType blackUserAnnotation = ((MethodSignature) joinPoint.getSignature()).getMethod().getAnnotation(BlackUserType.class);
}
public int getParamUidValue(JoinPoint joinPoint){
blackUserInteceptorMap.get(blackUserAnnotation.blackType()).before((int)argsa[0]);
try{
int paramUidIndex = -1;
String[] paramNames = ((MethodSignature)joinPoint.getSignature()).getParameterNames();
for (int i = 0; i< paramNames.length; i++){
if (UID.equals(paramNames[i])){
paramUidIndex = i;
break;
}
}
if (paramUidIndex == -1){
return -1;
}
Object[] argValues = joinPoint.getArgs();
for (int i = 0; i < argValues.length; i++){
if (i == paramUidIndex){
return (int)argValues[i];
}
}
}catch (Exception e){
logger.warn("black user aspect param uis. e {}",e);
return -1;
}
return -1;
}
... ...
... ... @@ -119,7 +119,7 @@ yoho.message.controller.url=http://message-controller.yohoops.org/yoho-message-c
yoho.reviewed.controller.url=http://172.16.6.54:8063/reviewed
#rabbit address for transaction compensate
rabbit_host=192.168.104.199:30005
rabbit_host=192.168.102.45:5672
rabbit_user=yoho
rabbit_password=yoho
... ...
redis:
gwNoSyncRedis :
servers:
- 192.168.102.45:6379
auth: redis9646
- 192.168.104.246:6379
... ...