Parser 移除没必要的方法 parseCorrectResponse

This commit is contained in:
TommyLemon 2021-09-26 23:57:11 +08:00
parent 5c682cbf34
commit 47961e3ee4
3 changed files with 15 additions and 33 deletions

View File

@ -852,14 +852,17 @@ public abstract class AbstractObjectParser implements ObjectParser {
if (list != null) {
String arrayPath = parentPath.substring(0, parentPath.lastIndexOf("[]") + 2);
long startTime = System.currentTimeMillis();
for (int i = 1; i < list.size(); i++) { // 1 开始0 已经处理过
JSONObject obj = parser.parseCorrectResponse(table, list.get(i));
list.set(i, obj);
JSONObject obj = list.get(i);
if (obj != null) {
parser.putQueryResult(arrayPath + "/" + i + "/" + name, obj); //解决获取关联数据时requestObject里不存在需要的关联数据
}
}
long endTime = System.currentTimeMillis();
Log.e(TAG, "onSQLExecute for (int i = 1; i < list.size(); i++) startTime = " + startTime + "; endTime = " + endTime + "; duration = " + (endTime - startTime));
parser.putArrayMainCache(arrayPath, list);
}

View File

@ -719,33 +719,6 @@ public abstract class AbstractParser<T> implements Parser<T>, ParserCreator<T>,
}
//TODO 优化性能
/**获取正确的返回结果
* @param method
* @param response
* @return
* @throws Exception
*/
@Override
public JSONObject parseCorrectResponse(String table, JSONObject response) throws Exception {
// Log.d(TAG, "getCorrectResponse method = " + method + "; table = " + table);
// if (response == null || response.isEmpty()) {//避免无效空result:{}添加内容后变有效
// Log.e(TAG, "getCorrectResponse response == null || response.isEmpty() >> return response;");
return response;
// }
//
// JSONObject target = apijson.JSONObject.isTableKey(table) == false
// ? new JSONObject() : getStructure(method, "Response", "model", table);
//
// return MethodStructure.parseResponse(method, table, target, response, new OnParseCallback() {
//
// @Override
// protected JSONObject onParseJSONObject(String key, JSONObject tobj, JSONObject robj) throws Exception {
// return getCorrectResponse(method, key, robj);
// }
// });
}
/**获取Request或Response内指定JSON结构
* @param table
* @param method
@ -1075,15 +1048,22 @@ public abstract class AbstractParser<T> implements Parser<T>, ParserCreator<T>,
.setJoinList(onJoinParse(join, request));
JSONObject parent;
long startTime = System.currentTimeMillis();
//生成size个
for (int i = 0; i < (isSubquery ? 1 : size); i++) {
parent = onObjectParse(request, isSubquery ? parentPath : path, isSubquery ? name : "" + i, config.setType(SQLConfig.TYPE_ITEM).setPosition(i), isSubquery);
if (parent == null || parent.isEmpty()) {
break;
}
//key[]:{Table:{}}中key equals Table时 提取Table
response.add(getValue(parent, childKeys)); //null有意义
}
long endTime = System.currentTimeMillis();
Log.e(TAG, "onArrayParse for for (int i = 0; i < (isSubquery ? 1 : size); i++) startTime = " + startTime + "; endTime = " + endTime + "; duration = " + (endTime - startTime));
//Table>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
@ -1665,7 +1645,7 @@ public abstract class AbstractParser<T> implements Parser<T>, ParserCreator<T>,
result = getSQLExecutor().execute(config, false);
}
return parseCorrectResponse(config.getTable(), result);
return result;
}
catch (Exception e) {
if (Log.DEBUG == false && e instanceof SQLException) {

View File

@ -64,6 +64,7 @@ public interface Parser<T> {
JSONObject parseResponse(String request);
JSONObject parseResponse(JSONObject request);
// 没必要性能还差 JSONObject parseCorrectResponse(String table, JSONObject response) throws Exception;
JSONObject parseCorrectRequest() throws Exception;
@ -71,12 +72,10 @@ public interface Parser<T> {
JSONObject parseCorrectRequest(RequestMethod method, String tag, int version, String name, JSONObject request,
int maxUpdateCount, SQLCreator creator) throws Exception;
JSONObject parseCorrectResponse(String table, JSONObject response) throws Exception;
JSONObject getStructure(String table, String method, String tag, int version) throws Exception;
JSONObject onObjectParse(JSONObject request, String parentPath, String name, SQLConfig arrayConfig, boolean isSubquery) throws Exception;
JSONArray onArrayParse(JSONObject request, String parentPath, String name, boolean isSubquery) throws Exception;