You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.1 KiB
41 lines
1.1 KiB
6 years ago
|
package com.fr.plugin.db.redis.util;
|
||
|
|
||
|
import com.eclipsesource.v8.V8Object;
|
||
|
import com.fr.base.Parameter;
|
||
|
import com.fr.base.TemplateUtils;
|
||
|
import com.fr.stable.ArrayUtils;
|
||
|
|
||
|
import java.lang.reflect.Method;
|
||
|
import java.util.HashMap;
|
||
|
import java.util.Map;
|
||
|
|
||
|
/**
|
||
|
* @author richie
|
||
|
* @version 10.0
|
||
|
* Created by richie on 2019-03-18
|
||
|
*/
|
||
|
public class RedisUtils {
|
||
|
|
||
|
public static String calculateQuery(String query, Parameter[] ps) {
|
||
|
if (ArrayUtils.isEmpty(ps)) {
|
||
|
return query;
|
||
|
}
|
||
|
Map<String, Object> map = new HashMap<String, Object>();
|
||
|
for (Parameter p : ps) {
|
||
|
map.put(p.getName(), p.getValue());
|
||
|
}
|
||
|
try {
|
||
|
return TemplateUtils.renderParameter4Tpl(query, map);
|
||
|
} catch (Exception e) {
|
||
|
return query;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static void registerJavaMethods(V8Object v8Object, Object target) {
|
||
|
Method[] methods = target.getClass().getDeclaredMethods();
|
||
|
for (Method m : methods) {
|
||
|
v8Object.registerJavaMethod(target, m.getName(), m.getName(), m.getParameterTypes());
|
||
|
}
|
||
|
}
|
||
|
}
|