|
@@ -39,38 +39,36 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
public class RestUtil {
|
|
|
public static String query(String param) {
|
|
|
Repository Repository = RepositoryBase.instance;
|
|
|
+ JSONObject result = new JSONObject();
|
|
|
+ Object Content;
|
|
|
try {
|
|
|
JSONObject sql_json = JSON.parseObject(param);
|
|
|
+ Integer read_level = (Integer) sql_json.get("read_level");
|
|
|
+ read_level = read_level == null ? 4 : read_level;
|
|
|
Object queryResult = QueryUtil.query(Repository, null, sql_json, new QueryAssist());
|
|
|
- if (queryResult instanceof List) {
|
|
|
+ if (queryResult instanceof SceneDataSet) {
|
|
|
SceneDataSet sdvList = (SceneDataSet) queryResult;
|
|
|
- JSONArray arrayResult = new JSONArray();
|
|
|
SceneDataValue sdv = new SceneDataValue(null, null, null, null);
|
|
|
- sdv.value_array = new SceneDataSet(false);
|
|
|
- sdv.value_array.set = new ArrayList<SceneDataObject>();
|
|
|
- for (SceneDataObject sdvInner : sdvList.set) {
|
|
|
- if (sdvInner != null) {
|
|
|
- sdv.value_array.set.add(sdvInner);
|
|
|
- }
|
|
|
- }
|
|
|
- if (arrayResult.size() > 0) {
|
|
|
- return arrayResult.toString();
|
|
|
- } else {
|
|
|
- Integer read_level = (Integer) sql_json.get("read_level");
|
|
|
- read_level = read_level == null ? 4 : read_level;
|
|
|
- return sdv.toJSON(true, read_level == 0 ? -1 : read_level).toString();
|
|
|
- }
|
|
|
+ sdv.value_array = sdvList;
|
|
|
+ Content = sdv.toJSON(true, read_level == 0 ? -1 : read_level);
|
|
|
} else if (queryResult instanceof SceneDataValue) {
|
|
|
SceneDataValue sdv = (SceneDataValue) queryResult;
|
|
|
- int read_level = 0;
|
|
|
- return sdv.toJSON(true, read_level == 0 ? -1 : read_level).toString();
|
|
|
+ Content = sdv.toJSON(true, read_level == 0 ? -1 : read_level);
|
|
|
} else {
|
|
|
- return queryResult.toString();
|
|
|
+ Content = queryResult;
|
|
|
+ }
|
|
|
+ result.put("Result", "success");
|
|
|
+ result.put("Content", Content);
|
|
|
+ if (Content instanceof JSONArray) {
|
|
|
+ JSONArray array = (JSONArray) Content;
|
|
|
+ result.put("Count", array.size());
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
+ result.put("Result", "failure");
|
|
|
+ result.put("Reason", LogUtil.GetExceptionStackTrace(e));
|
|
|
}
|
|
|
- return null;
|
|
|
+ return FastJsonUtil.toFormatString(result);
|
|
|
}
|
|
|
|
|
|
public static String showTree() {
|
|
@@ -318,41 +316,6 @@ public class RestUtil {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
public static String post_filter_and_page(String param) {
|
|
|
JSONObject result = new JSONObject();
|
|
|
try {
|
|
@@ -388,44 +351,6 @@ public class RestUtil {
|
|
|
return result.toJSONString();
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
private static List<SceneDataObject> filter_and_page(JSONObject paramObject) throws Exception {
|
|
|
Repository Repository = RepositoryBase.instance;
|
|
|
JSONArray path = (JSONArray) paramObject.get("path");
|
|
@@ -613,38 +538,6 @@ public class RestUtil {
|
|
|
return result.toJSONString();
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
public static String get_control_value(String param) {
|
|
|
JSONObject result = new JSONObject();
|
|
|
try {
|