...
|
...
|
@@ -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;
|
|
|
}
|
|
|
|
|
|
BlackUserType blackUserAnnotation = ((MethodSignature) joinPoint.getSignature()).getMethod().getAnnotation(BlackUserType.class);
|
|
|
|
|
|
Object[] argsa = joinPoint.getArgs();
|
|
|
blackUserInteceptorMap.get(blackUserAnnotation.blackType().getCode()).before(uid);
|
|
|
|
|
|
Annotation[][] parameterTypes = ((MethodSignature)joinPoint.getSignature()).getMethod().getParameterAnnotations();
|
|
|
}
|
|
|
|
|
|
BlackUserType blackUserAnnotation = ((MethodSignature) joinPoint.getSignature()).getMethod().getAnnotation(BlackUserType.class);
|
|
|
|
|
|
blackUserInteceptorMap.get(blackUserAnnotation.blackType()).before((int)argsa[0]);
|
|
|
public int getParamUidValue(JoinPoint joinPoint){
|
|
|
|
|
|
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;
|
|
|
}
|
|
|
|
|
|
|
...
|
...
|
|