use of com.github.lybgeek.elasticsearch.enu.OperateType in project springboot-learning by lyb-geek.
the class ElasticsearchAspect method around.
@Around(value = "@annotation(operate)")
public Object around(ProceedingJoinPoint pjp, EsOperate operate) {
OperateType type = operate.type();
Object[] args = pjp.getArgs();
Object result = null;
String methodName = pjp.getSignature().getName();
if (ArrayUtils.isNotEmpty(args) && args.length == 1) {
Object param = args[0];
switch(type) {
case QUERY:
if (param instanceof PageQuery) {
PageQuery pageQuery = (PageQuery) param;
result = this.pageQuery(pageQuery, operate.indexName());
} else {
result = this.query(param, operate.indexName());
}
break;
}
}
if (ObjectUtils.isEmpty(result)) {
try {
log.info("{} load data from db", methodName);
return pjp.proceed();
} catch (Throwable throwable) {
log.error(throwable.getMessage(), throwable);
}
}
if (OperateType.QUERY == type) {
log.info("{} load data from es", methodName);
}
return result;
}
Aggregations