key.setMethodName(method.getName()); key.setParameTypes(method.getParameterTypes()); SqlMethod sqlMethod = neo4jDaoInfo.getSqlMethods().get(key); if(sqlMethod.getSqlClipMethod() == null) return next.compute(method , neo4jDaoInfo , values);
@Override public Optional<Sql> compute(Method method , Neo4jDaoInfo neo4jDaoInfo , Object... values) { final MethodKey key = new MethodKey(); key.setMethodName(method.getName()); key.setParameTypes(method.getParameterTypes()); SqlMethod sqlMethod = neo4jDaoInfo.getSqlMethods().get(key); String sql = sqlMethod.getSql(); if(StringOperation.isTrimEmptyOrNull(sql)) return next.compute(method , neo4jDaoInfo , values); SqlMethodParam[] sqlMethodParams = sqlMethod.getSqlMethodParams(); Map<String , Object> params = new HashMap<>(); Pageable<?> pageable = null; for(int i=0; i<sqlMethodParams.length; i++) { String paramKey; Param param = sqlMethodParams[i].getParam(); if(param != null) paramKey = param.value(); else paramKey = sqlMethodParams[i].getNativeName(); Object value = values[i]; params.put(paramKey , value); if(value instanceof Pageable) pageable = (Pageable<?>) value; } if(SqlComputes.isPageReturn(sqlMethod) && pageable != null) sql = sql + SqlComputes.pageable(pageable); return sqlFormatter.format(sql , params); }
@SuppressWarnings("unchecked") public <T> T process(DaoProcessorParam param, Neo4jDaoInfo neo4jDaoInfo) { MethodKey methodKey = new MethodKey(); methodKey.setMethodName(param.getMethodName()); methodKey.setParameTypes(param.getArgTypes()); SqlMethod sqlMethod = neo4jDaoInfo.getSqlMethods().get(methodKey); Optional<Sql> query = sqlCompute.compute(sqlMethod.getDefinition() , neo4jDaoInfo , param.getArgs()); if(!query.isPresent()) throw new Neo4jException("No Query find out"); Sql sql = query.get(); Transaction tx = null; for(Object arg : param.getArgs()) { if(arg instanceof Transaction) tx = (Transaction) arg; } Object obj = tx.runAsync(sql.getSql(), Values.value(sql.getParameters())) .thenComposeAsync(src -> deSerializer.deSerialize(src , sqlMethod)); return (T) obj; } }
methodKey.setMethodName(param.getMethodName()); methodKey.setParameTypes(param.getArgTypes()); SqlMethod sqlMethod = neo4jDaoInfo.getSqlMethods().get(methodKey); Optional<Sql> query = sqlCompute.compute(sqlMethod.getDefinition() , neo4jDaoInfo , param.getArgs()); if(!query.isPresent()) throw new Neo4jException("No Query find out");