Browse Source

fix

pull/15/head
Elijah 5 years ago
parent
commit
4d53bd19a4
  1. BIN
      lib/finekit-10.0.jar
  2. 7
      src/main/java/com/fr/plugin/db/redis/RedisScriptUniversalTableDataImpl.java
  3. 7
      src/main/java/com/fr/plugin/db/redis/RedisUniversalTableDataImpl.java
  4. 11
      src/main/java/com/fr/plugin/db/redis/action/SearchKeysAction.java

BIN
lib/finekit-10.0.jar

Binary file not shown.

7
src/main/java/com/fr/plugin/db/redis/RedisScriptUniversalTableDataImpl.java

@ -1,10 +1,10 @@
package com.fr.plugin.db.redis; package com.fr.plugin.db.redis;
import com.fanruan.api.cal.FormulaKit; import com.fanruan.api.cal.FormulaKit;
import com.fanruan.api.data.ConnectionKit;
import com.fanruan.api.data.TableDataKit; import com.fanruan.api.data.TableDataKit;
import com.fanruan.api.util.StringKit; import com.fanruan.api.util.StringKit;
import com.fr.data.impl.Connection; import com.fr.data.impl.Connection;
import com.fr.data.impl.NameDatabaseConnection;
import com.fr.decision.fun.impl.AbstractUniversalServerTableDataProvider; import com.fr.decision.fun.impl.AbstractUniversalServerTableDataProvider;
import com.fr.json.JSONObject; import com.fr.json.JSONObject;
import com.fr.plugin.db.redis.bean.ParameterBean; import com.fr.plugin.db.redis.bean.ParameterBean;
@ -15,6 +15,7 @@ import com.fr.plugin.db.redis.core.order.impl.NumberOrderValue;
import com.fr.plugin.db.redis.core.script.EngineType; import com.fr.plugin.db.redis.core.script.EngineType;
import com.fr.plugin.db.redis.util.RedisUtils; import com.fr.plugin.db.redis.util.RedisUtils;
import com.fr.script.Calculator; import com.fr.script.Calculator;
import com.fr.stable.NameReference;
import com.fr.web.struct.Atom; import com.fr.web.struct.Atom;
/** /**
@ -38,7 +39,7 @@ public class RedisScriptUniversalTableDataImpl extends AbstractUniversalServerTa
public JSONObject serialize(RedisScriptTableData redisScriptTableData) { public JSONObject serialize(RedisScriptTableData redisScriptTableData) {
JSONObject data = new JSONObject(); JSONObject data = new JSONObject();
Connection database = redisScriptTableData.getDatabase(); Connection database = redisScriptTableData.getDatabase();
data.put(RedisConstants.DATABASE, database instanceof NameDatabaseConnection ? ((NameDatabaseConnection) database).getName() : StringKit.EMPTY); data.put(RedisConstants.DATABASE, database instanceof NameReference ? ((NameReference) database).getName() : StringKit.EMPTY);
data.put(RedisConstants.ORDER, redisScriptTableData.getOrderValue().toString()); data.put(RedisConstants.ORDER, redisScriptTableData.getOrderValue().toString());
data.put(RedisConstants.SCRIPT, redisScriptTableData.getScript()); data.put(RedisConstants.SCRIPT, redisScriptTableData.getScript());
data.put(RedisConstants.ENGINE, redisScriptTableData.getEngineType().getType()); data.put(RedisConstants.ENGINE, redisScriptTableData.getEngineType().getType());
@ -52,7 +53,7 @@ public class RedisScriptUniversalTableDataImpl extends AbstractUniversalServerTa
String databaseName = data.getString(RedisConstants.DATABASE); String databaseName = data.getString(RedisConstants.DATABASE);
String script = data.getString(RedisConstants.SCRIPT); String script = data.getString(RedisConstants.SCRIPT);
if (!StringKit.isEmpty(databaseName) && TableDataKit.findTableData(databaseName) != null) { if (!StringKit.isEmpty(databaseName) && TableDataKit.findTableData(databaseName) != null) {
newTableData.setDatabase(new NameDatabaseConnection(databaseName)); newTableData.setDatabase(ConnectionKit.createNameConnection(databaseName));
} }
newTableData.setEngineType(EngineType.parse(data.getInt(RedisConstants.ENGINE))); newTableData.setEngineType(EngineType.parse(data.getInt(RedisConstants.ENGINE)));
newTableData.setScript(script); newTableData.setScript(script);

7
src/main/java/com/fr/plugin/db/redis/RedisUniversalTableDataImpl.java

@ -1,10 +1,10 @@
package com.fr.plugin.db.redis; package com.fr.plugin.db.redis;
import com.fanruan.api.cal.FormulaKit; import com.fanruan.api.cal.FormulaKit;
import com.fanruan.api.data.ConnectionKit;
import com.fanruan.api.data.TableDataKit; import com.fanruan.api.data.TableDataKit;
import com.fanruan.api.util.StringKit; import com.fanruan.api.util.StringKit;
import com.fr.data.impl.Connection; import com.fr.data.impl.Connection;
import com.fr.data.impl.NameDatabaseConnection;
import com.fr.decision.fun.impl.AbstractUniversalServerTableDataProvider; import com.fr.decision.fun.impl.AbstractUniversalServerTableDataProvider;
import com.fr.json.JSONObject; import com.fr.json.JSONObject;
import com.fr.plugin.db.redis.bean.ParameterBean; import com.fr.plugin.db.redis.bean.ParameterBean;
@ -14,6 +14,7 @@ import com.fr.plugin.db.redis.core.order.impl.FormulaOrderValue;
import com.fr.plugin.db.redis.core.order.impl.NumberOrderValue; import com.fr.plugin.db.redis.core.order.impl.NumberOrderValue;
import com.fr.plugin.db.redis.util.RedisUtils; import com.fr.plugin.db.redis.util.RedisUtils;
import com.fr.script.Calculator; import com.fr.script.Calculator;
import com.fr.stable.NameReference;
import com.fr.web.struct.Atom; import com.fr.web.struct.Atom;
/** /**
@ -37,7 +38,7 @@ public class RedisUniversalTableDataImpl extends AbstractUniversalServerTableDat
public JSONObject serialize(RedisTableData redisTableData) { public JSONObject serialize(RedisTableData redisTableData) {
JSONObject data = new JSONObject(); JSONObject data = new JSONObject();
Connection database = redisTableData.getDatabase(); Connection database = redisTableData.getDatabase();
data.put(RedisConstants.DATABASE, database instanceof NameDatabaseConnection ? ((NameDatabaseConnection) database).getName() : StringKit.EMPTY); data.put(RedisConstants.DATABASE, database instanceof NameReference ? ((NameReference) database).getName() : StringKit.EMPTY);
data.put(RedisConstants.ORDER, redisTableData.getOrderValue().toString()); data.put(RedisConstants.ORDER, redisTableData.getOrderValue().toString());
data.put(RedisConstants.SCRIPT, redisTableData.getScript()); data.put(RedisConstants.SCRIPT, redisTableData.getScript());
data.put(RedisConstants.QUERY, redisTableData.getQuery()); data.put(RedisConstants.QUERY, redisTableData.getQuery());
@ -52,7 +53,7 @@ public class RedisUniversalTableDataImpl extends AbstractUniversalServerTableDat
String script = data.getString(RedisConstants.SCRIPT); String script = data.getString(RedisConstants.SCRIPT);
String query = data.getString(RedisConstants.QUERY); String query = data.getString(RedisConstants.QUERY);
if (!StringKit.isEmpty(databaseName) && TableDataKit.findTableData(databaseName) != null) { if (!StringKit.isEmpty(databaseName) && TableDataKit.findTableData(databaseName) != null) {
newTableData.setDatabase(new NameDatabaseConnection(databaseName)); newTableData.setDatabase(ConnectionKit.createNameConnection(databaseName));
} }
newTableData.setScript(script); newTableData.setScript(script);
newTableData.setQuery(query); newTableData.setQuery(query);

11
src/main/java/com/fr/plugin/db/redis/action/SearchKeysAction.java

@ -1,17 +1,18 @@
package com.fr.plugin.db.redis.action; package com.fr.plugin.db.redis.action;
import com.fanruan.api.data.ConnectionKit; import com.fanruan.api.data.ConnectionKit;
import com.fanruan.api.util.StringKit;
import com.fanruan.api.web.FlushKit;
import com.fr.base.ServerConfig; import com.fr.base.ServerConfig;
import com.fr.data.impl.Connection; import com.fr.data.impl.Connection;
import com.fr.decision.fun.impl.BaseHttpHandler; import com.fr.decision.fun.impl.BaseHttpHandler;
import com.fr.json.JSONArray; import com.fr.json.JSONFactory;
import com.fr.plugin.db.redis.core.RedisDatabaseConnection; import com.fr.plugin.db.redis.core.RedisDatabaseConnection;
import com.fr.stable.StringUtils;
import com.fr.third.springframework.web.bind.annotation.RequestMethod; import com.fr.third.springframework.web.bind.annotation.RequestMethod;
import com.fr.web.utils.WebUtils;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.Arrays;
/** /**
* @author Elijah * @author Elijah
@ -39,13 +40,13 @@ public class SearchKeysAction extends BaseHttpHandler {
String[] keys = new String[0]; String[] keys = new String[0];
String pattern = request.getParameter("pattern"); String pattern = request.getParameter("pattern");
String connectionName = request.getParameter("database"); String connectionName = request.getParameter("database");
if (StringUtils.isNotEmpty(pattern) && StringUtils.isNotEmpty(connectionName)) { if (StringKit.isNotEmpty(pattern) && StringKit.isNotEmpty(connectionName)) {
Connection connection = ConnectionKit.getConnection(connectionName); Connection connection = ConnectionKit.getConnection(connectionName);
if (connection instanceof RedisDatabaseConnection) { if (connection instanceof RedisDatabaseConnection) {
keys = connection.summary(pattern); keys = connection.summary(pattern);
} }
} }
WebUtils.printAsJSON(response, new JSONArray(keys)); FlushKit.printAsJSON(response, JSONFactory.createJSON(Arrays.asList(keys)));
response.setContentType("application/json;charset=" + ServerConfig.getInstance().getServerCharset()); response.setContentType("application/json;charset=" + ServerConfig.getInstance().getServerCharset());
} }
} }
Loading…
Cancel
Save