Browse Source

数据集接口

refactor
richie 5 years ago
parent
commit
1af53ffcff
  1. 7
      src/main/java/com/fr/plugin/db/redis/bean/ParameterBean.java
  2. 11
      src/main/java/com/fr/plugin/db/redis/util/RedisUtils.java

7
src/main/java/com/fr/plugin/db/redis/bean/ParameterBean.java

@ -1,7 +1,6 @@
package com.fr.plugin.db.redis.bean;
import com.fanruan.api.util.StringKit;
import com.fr.base.ParameterTypeHandler;
import com.fr.stable.ParameterProvider;
import java.util.ArrayList;
@ -12,12 +11,12 @@ import java.util.List;
* @version 10.0.4
* Created by Elijah on 2019/10/30
*/
public class ParameterBean{
public class ParameterBean {
public static final String TYPE = "type";
public static final String NAME = "name";
public static final String VALUE = "value";
private String type = ParameterTypeHandler.String.name();
private String type = "String";
private String name;
private String value;
@ -69,7 +68,7 @@ public class ParameterBean{
public static List<ParameterBean> createParameterBeans(ParameterProvider[] parameterProviders) {
List<ParameterBean> parameterBeans = new ArrayList<ParameterBean>();
for (ParameterProvider parameterProvider: parameterProviders) {
for (ParameterProvider parameterProvider : parameterProviders) {
parameterBeans.add(ParameterBean.createBean(parameterProvider));
}
return parameterBeans;

11
src/main/java/com/fr/plugin/db/redis/util/RedisUtils.java

@ -6,7 +6,6 @@ import com.fanruan.api.util.ArrayKit;
import com.fanruan.api.util.GeneralKit;
import com.fanruan.api.util.RenderKit;
import com.fanruan.api.util.StringKit;
import com.fr.base.Parameter;
import com.fr.json.JSONArray;
import com.fr.plugin.db.redis.core.order.OrderValue;
import com.fr.plugin.db.redis.help.ScriptBridge;
@ -74,18 +73,18 @@ public class RedisUtils {
}
}
public static ParameterProvider[] analyzeParameter(JSONArray existParameters, OrderValue orderValue, String ...parameterTexts) {
Parameter[] oldParameters = new Parameter[existParameters.size()];
public static ParameterProvider[] analyzeParameter(JSONArray existParameters, OrderValue orderValue, String... parameterTexts) {
ParameterProvider[] oldParameters = new ParameterProvider[existParameters.size()];
for (int i = 0; i < existParameters.size(); i++) {
oldParameters[i] = Parameter.getParameterFromJson(existParameters.getJSONObject(i));
oldParameters[i] = ParameterKit.json2Parameter(existParameters.getJSONObject(i));
}
ParameterProvider[] newParameters = ParameterKit.analyzeAndUnionSameParameters(parameterTexts, oldParameters);
ParameterProvider[] newOrderParameters = orderValue.analyze4Parameters();
Map<String, ParameterProvider> parameterProviderMap = new HashMap<String, ParameterProvider>();
for (ParameterProvider parameterProvider: oldParameters) {
for (ParameterProvider parameterProvider : oldParameters) {
parameterProviderMap.put(parameterProvider.getName(), parameterProvider);
}
for (ParameterProvider parameterProvider: newOrderParameters) {
for (ParameterProvider parameterProvider : newOrderParameters) {
if (parameterProviderMap.containsKey(parameterProvider.getName())) {
parameterProvider.setValue(parameterProviderMap.get(parameterProvider.getName()).getValue());
}

Loading…
Cancel
Save