...
|
...
|
@@ -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;
|
|
|
}
|
|
|
|
|
|
|
...
|
...
|
|