dbproxy modified

This commit is contained in:
insanity 2017-06-23 17:31:12 +09:00
parent 3936d7d11b
commit 98f13e9c1e

View File

@ -3,11 +3,9 @@ package com.loafle.overflow.proxy.db;
import com.loafle.overflow.db.api.DBGrpc;
import com.loafle.overflow.db.api.DBInput;
import com.loafle.overflow.db.api.DBOutput;
import com.loafle.overflow.module.domain.dao.DomainDAO;
import com.loafle.overflow.module.email.dao.EmailAuthDAO;
import com.loafle.overflow.module.member.dao.MemberDAO;
import com.loafle.overflow.module.noauthprobe.dao.NoAuthProbeDAO;
import com.loafle.overflow.module.probe.dao.ProbeDAO;
import com.loafle.overflow.module.sensor.dao.SensorDao;
@ -19,7 +17,6 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext
import org.springframework.data.jpa.repository.JpaRepository;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
@ -137,23 +134,32 @@ public class DBProxy {
paramTypes.add(cls);
}
try {
//Check if it belongs to the JPABaseDAO.
method = dao.getClass().getSuperclass().getMethod(methodName, Object.class);
retObj = method.invoke(dao, valueList.toArray(new Object[valueList.size()]));
}catch(NoSuchMethodException e) {
if(params.size() > 0) {
method = dao.getClass().getMethod(methodName, paramTypes.toArray(new Class[paramTypes.size()]));
retObj = method.invoke(dao, valueList.toArray(new Object[valueList.size()]));
}else {
method = dao.getClass().getMethod(methodName);
retObj = method.invoke(dao);
}
}catch(InvocationTargetException e) {
e.printStackTrace();
if(params.size() > 0) {
method = dao.getClass().getMethod(methodName, Object.class);
//method = dao.getClass().getMethod(methodName, paramTypes.toArray(new Class[paramTypes.size()]));
retObj = method.invoke(dao, valueList.toArray(new Object[valueList.size()]));
}else {
method = dao.getClass().getMethod(methodName);
retObj = method.invoke(dao);
}
// try {
// method = dao.getClass().getSuperclass().getMethod(methodName, Object.class);
// retObj = method.invoke(dao, valueList.toArray(new Object[valueList.size()]));
//
// }catch(NoSuchMethodException e) {
// if(params.size() > 0) {
// method = dao.getClass().getMethod(methodName, paramTypes.toArray(new Class[paramTypes.size()]));
// retObj = method.invoke(dao, valueList.toArray(new Object[valueList.size()]));
// }else {
// method = dao.getClass().getMethod(methodName);
// retObj = method.invoke(dao);
// }
// }catch(InvocationTargetException e) {
// e.printStackTrace();
// }
return mapper.writeValueAsString(retObj);
}
}