提交 4b7bb57a 编写于 作者: zhouweidong's avatar zhouweidong

优化处理逻辑

上级 5970506a
......@@ -90,7 +90,7 @@ public class DELogicAspect {
String action = point.getSignature().getName();
EntityBase entity = null;
if ("remove".equalsIgnoreCase(action) || "get".equalsIgnoreCase(action)) {
entity = getEntity(service);
entity = getEntity(service.getClass());
String id = DEFieldCacheMap.getDEKeyField(entity.getClass());
if(StringUtils.isEmpty(id)) {
log.debug("无法获取实体主键属性[{}]",entity.getClass().getSimpleName());
......@@ -319,10 +319,9 @@ public class DELogicAspect {
*
* @param service
* @return
* @throws Exception
*/
private EntityBase getEntity(Object service) throws Exception {
Method[] methods = service.getClass().getDeclaredMethods();
private EntityBase getEntity(Class service) {
Method[] methods = service.getDeclaredMethods();
for (Method method : methods) {
for (Class cls : method.getParameterTypes()) {
try {
......@@ -330,10 +329,13 @@ public class DELogicAspect {
if (arg instanceof EntityBase) {
return (EntityBase) arg;
}
} catch (InstantiationException e) {
} catch (Exception e) {
}
}
}
if(!ObjectUtils.isEmpty(service.getSuperclass()) && !service.getSuperclass().getName().equals(Object.class.getName())) {
return getEntity(service.getSuperclass());
}
throw new BadRequestAlertException("获取实体信息失败", "DELogicAspect", "getEntity");
}
......@@ -585,7 +587,7 @@ public class DELogicAspect {
String action = point.getSignature().getName();
EntityBase entity = null;
if ("remove".equalsIgnoreCase(action) || "get".equalsIgnoreCase(action)) {
entity = getEntity(service);
entity = getEntity(service.getClass());
String id = DEFieldCacheMap.getDEKeyField(entity.getClass());
if(StringUtils.isEmpty(id)) {
log.debug("无法获取实体主键属性[{}]",entity.getClass().getSimpleName());
......@@ -839,10 +841,9 @@ public class DELogicAspect {
*
* @param service
* @return
* @throws Exception
*/
private EntityBase getEntity(Object service) throws Exception {
Method[] methods = service.getClass().getDeclaredMethods();
private EntityBase getEntity(Class service) {
Method[] methods = service.getDeclaredMethods();
for (Method method : methods) {
for (Class cls : method.getParameterTypes()) {
try {
......@@ -850,10 +851,13 @@ public class DELogicAspect {
if (arg instanceof EntityBase) {
return (EntityBase) arg;
}
} catch (InstantiationException e) {
} catch (Exception e) {
}
}
}
if(!ObjectUtils.isEmpty(service.getSuperclass()) && !service.getSuperclass().getName().equals(Object.class.getName())) {
return getEntity(service.getSuperclass());
}
throw new BadRequestAlertException("获取实体信息失败", "DELogicAspect", "getEntity");
}
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册