From 550fd946f46aed69f91d4808c2c24fe4302f784f Mon Sep 17 00:00:00 2001 From: TommyLemon Date: Sun, 10 Sep 2023 03:13:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BB=E9=94=AE=E7=B1=BB=E5=9E=8B=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E4=BB=A3=E7=A0=81=E5=85=A8=E9=9D=A2=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E6=B3=9B=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../framework/APIJSONFunctionParser.java | 29 +++++-------------- .../framework/APIJSONObjectParser.java | 15 ++++------ .../java/apijson/framework/APIJSONParser.java | 4 +-- .../apijson/framework/APIJSONSQLConfig.java | 10 +++---- .../apijson/framework/APIJSONSQLExecutor.java | 6 ++-- 5 files changed, 23 insertions(+), 41 deletions(-) diff --git a/src/main/java/apijson/framework/APIJSONFunctionParser.java b/src/main/java/apijson/framework/APIJSONFunctionParser.java index 332c80f..061a74b 100755 --- a/src/main/java/apijson/framework/APIJSONFunctionParser.java +++ b/src/main/java/apijson/framework/APIJSONFunctionParser.java @@ -53,7 +53,7 @@ /**可远程调用的函数类 * @author Lemon */ -public class APIJSONFunctionParser extends AbstractFunctionParser { +public class APIJSONFunctionParser extends AbstractFunctionParser { public static final String TAG = "APIJSONFunctionParser"; @NotNull @@ -79,23 +79,23 @@ public APIJSONFunctionParser(RequestMethod method, String tag, int version, JSON public HttpSession getSession() { return session; } - public APIJSONFunctionParser setSession(HttpSession session) { + public APIJSONFunctionParser setSession(HttpSession session) { this.session = session; return this; } @Override - public APIJSONFunctionParser setMethod(RequestMethod method) { + public APIJSONFunctionParser setMethod(RequestMethod method) { super.setMethod(method); return this; } @Override - public APIJSONFunctionParser setTag(String tag) { + public APIJSONFunctionParser setTag(String tag) { super.setTag(tag); return this; } @Override - public APIJSONFunctionParser setVersion(int version) { + public APIJSONFunctionParser setVersion(int version) { super.setVersion(version); return this; } @@ -283,7 +283,7 @@ public static JSONObject init(boolean shutdownWhenServerError if (item.get("language") != null) { String language = item.getString("language"); if (SCRIPT_EXECUTOR_MAP.get(language) == null) { - onServerError("找不到脚本语言 " + language + " 对应的执行引擎!请先依赖相关库并在后端 APIJSONFunctionParser 中注册!", shutdownWhenServerError); + onServerError("找不到脚本语言 " + language + " 对应的执行引擎!请先依赖相关库并在后端 APIJSONFunctionParser 中注册!", shutdownWhenServerError); } ScriptExecutor scriptExecutor = SCRIPT_EXECUTOR_MAP.get(language); scriptExecutor.load(name, scriptMap.get(name).getString("script")); @@ -337,7 +337,7 @@ protected static void onServerError(String msg, boolean shutdown) throws ServerE public static void test() throws Exception { test(null); } - public static void test(APIJSONFunctionParser function) throws Exception { + public static void test(APIJSONFunctionParser function) throws Exception { int i0 = 1, i1 = -2; JSONObject request = new JSONObject(); request.put("id", 10); @@ -710,14 +710,6 @@ public String getMethodArguments(@NotNull JSONObject curObj, String methodArgsKe } - /**改用 getMethodDefinition - */ - @Deprecated - public String getMethodDefination(@NotNull JSONObject curObj) throws IllegalArgumentException { - // curObj.put("arguments", removeComment(curObj.getString("methodArgs"))); - return getMethodDefination(curObj, "method", "arguments", "genericType", "genericExceptions", "Java"); - } - /**获取方法的定义 * @param curObj * @return @@ -729,13 +721,6 @@ public String getMethodDefinition(@NotNull JSONObject curObj) throws IllegalArgu // curObj.put("arguments", removeComment(curObj.getString("methodArgs"))); return getMethodDefinition(curObj, "method", "arguments", "genericType", "genericExceptions", "Java"); } - /**改用 getMethodDefinition - */ - @Deprecated - public String getMethodDefination(@NotNull JSONObject curObj, String method, String arguments - , String type, String exceptions, String language) throws IllegalArgumentException { - return getMethodDefinition(curObj, method, arguments, type, exceptions, language); - } /**获取方法的定义 * @param curObj * @param method diff --git a/src/main/java/apijson/framework/APIJSONObjectParser.java b/src/main/java/apijson/framework/APIJSONObjectParser.java index da2b588..26c898e 100755 --- a/src/main/java/apijson/framework/APIJSONObjectParser.java +++ b/src/main/java/apijson/framework/APIJSONObjectParser.java @@ -18,20 +18,17 @@ import javax.servlet.http.HttpSession; +import apijson.orm.*; import com.alibaba.fastjson.JSONObject; import apijson.NotNull; import apijson.RequestMethod; -import apijson.orm.AbstractObjectParser; -import apijson.orm.AbstractParser; -import apijson.orm.Join; -import apijson.orm.SQLConfig; /**简化Parser,getObject和getArray(getArrayConfig)都能用 * @author Lemon */ -public class APIJSONObjectParser extends AbstractObjectParser { +public class APIJSONObjectParser extends AbstractObjectParser { public static final String TAG = "APIJSONObjectParser"; /**for single object @@ -44,26 +41,26 @@ public class APIJSONObjectParser extends AbstractObjectParser { * @param isArrayMainTable * @throws Exception */ - public APIJSONObjectParser(HttpSession session, @NotNull JSONObject request, String parentPath, SQLConfig arrayConfig + public APIJSONObjectParser(HttpSession session, @NotNull JSONObject request, String parentPath, SQLConfig arrayConfig , boolean isSubquery, boolean isTable, boolean isArrayMainTable) throws Exception { super(request, parentPath, arrayConfig, isSubquery, isTable, isArrayMainTable); } @Override - public APIJSONObjectParser setMethod(RequestMethod method) { + public APIJSONObjectParser setMethod(RequestMethod method) { super.setMethod(method); return this; } @Override - public APIJSONObjectParser setParser(AbstractParser parser) { + public APIJSONObjectParser setParser(Parser parser) { super.setParser(parser); return this; } @Override - public SQLConfig newSQLConfig(RequestMethod method, String table, String alias, JSONObject request, List joinList, boolean isProcedure) throws Exception { + public SQLConfig newSQLConfig(RequestMethod method, String table, String alias, JSONObject request, List joinList, boolean isProcedure) throws Exception { return APIJSONSQLConfig.newSQLConfig(method, table, alias, request, joinList, isProcedure); } diff --git a/src/main/java/apijson/framework/APIJSONParser.java b/src/main/java/apijson/framework/APIJSONParser.java index 62d30b2..ebb1e1f 100755 --- a/src/main/java/apijson/framework/APIJSONParser.java +++ b/src/main/java/apijson/framework/APIJSONParser.java @@ -145,10 +145,10 @@ public Object onFunctionParse(String key, String function, String parentPath, St @Override - public APIJSONObjectParser createObjectParser(JSONObject request, String parentPath, SQLConfig arrayConfig + public APIJSONObjectParser createObjectParser(JSONObject request, String parentPath, SQLConfig arrayConfig , boolean isSubquery, boolean isTable, boolean isArrayMainTable) throws Exception { - return new APIJSONObjectParser(getSession(), request, parentPath, arrayConfig, isSubquery, isTable, isArrayMainTable) { + return new APIJSONObjectParser(getSession(), request, parentPath, arrayConfig, isSubquery, isTable, isArrayMainTable) { // @Override // protected APIJSONSQLConfig newQueryConfig() { diff --git a/src/main/java/apijson/framework/APIJSONSQLConfig.java b/src/main/java/apijson/framework/APIJSONSQLConfig.java index e6cf6b0..af4eb91 100755 --- a/src/main/java/apijson/framework/APIJSONSQLConfig.java +++ b/src/main/java/apijson/framework/APIJSONSQLConfig.java @@ -59,8 +59,8 @@ public class APIJSONSQLConfig extends AbstractSQLConfig { SIMPLE_CALLBACK = new SimpleCallback() { @Override - public SQLConfig getSQLConfig(RequestMethod method, String database, String schema,String datasource, String table) { - SQLConfig config = APIJSON_CREATOR.createSQLConfig(); + public SQLConfig getSQLConfig(RequestMethod method, String database, String schema,String datasource, String table) { + SQLConfig config = APIJSON_CREATOR.createSQLConfig(); config.setMethod(method); config.setDatabase(database); config.setDatasource(datasource); @@ -228,14 +228,14 @@ public APIJSONSQLConfig(RequestMethod method, int count, int page) { * @return * @throws Exception */ - public static SQLConfig newSQLConfig(RequestMethod method, String table, String alias, JSONObject request, List joinList, boolean isProcedure) throws Exception { - return newSQLConfig(method, table, alias, request, joinList, isProcedure, SIMPLE_CALLBACK); + public static SQLConfig newSQLConfig(RequestMethod method, String table, String alias, JSONObject request, List joinList, boolean isProcedure) throws Exception { + return (SQLConfig) newSQLConfig(method, table, alias, request, joinList, isProcedure, SIMPLE_CALLBACK); } // 支持 !key 反选字段 和 字段名映射,依赖插件 https://github.com/APIJSON/apijson-column @Override - public AbstractSQLConfig setColumn(List column) { + public AbstractSQLConfig setColumn(List column) { if (ENABLE_COLUMN_CONFIG) { column = ColumnUtil.compatInputColumn(column, getTable(), getMethod(), getVersion(), ! isConfigTable()); } diff --git a/src/main/java/apijson/framework/APIJSONSQLExecutor.java b/src/main/java/apijson/framework/APIJSONSQLExecutor.java index 23b390a..c18b12e 100755 --- a/src/main/java/apijson/framework/APIJSONSQLExecutor.java +++ b/src/main/java/apijson/framework/APIJSONSQLExecutor.java @@ -73,7 +73,7 @@ public class APIJSONSQLExecutor extends AbstractSQLExecutor @Override - public PreparedStatement setArgument(@NotNull SQLConfig config, @NotNull PreparedStatement statement, int index, Object value) throws SQLException { + public PreparedStatement setArgument(@NotNull SQLConfig config, @NotNull PreparedStatement statement, int index, Object value) throws SQLException { if (config.isPostgreSQL() && JSON.isBooleanOrNumberOrString(value) == false) { PGobject o = new PGobject(); o.setType("jsonb"); @@ -87,7 +87,7 @@ public PreparedStatement setArgument(@NotNull SQLConfig config, @NotNull Prepare @Override - protected Object getValue(SQLConfig config, ResultSet rs, ResultSetMetaData rsmd, int tablePosition, + protected Object getValue(SQLConfig config, ResultSet rs, ResultSetMetaData rsmd, int tablePosition, JSONObject table, int columnIndex, String lable, Map childMap) throws Exception { Object value = super.getValue(config, rs, rsmd, tablePosition, table, columnIndex, lable, childMap); @@ -97,7 +97,7 @@ protected Object getValue(SQLConfig config, ResultSet rs, ResultSetMetaData rsmd // 支持 !key 反选字段 和 字段名映射,依赖插件 https://github.com/APIJSON/apijson-column @Override - protected String getKey(SQLConfig config, ResultSet rs, ResultSetMetaData rsmd, int tablePosition, JSONObject table, + protected String getKey(SQLConfig config, ResultSet rs, ResultSetMetaData rsmd, int tablePosition, JSONObject table, int columnIndex, Map childMap) throws Exception { String key = super.getKey(config, rs, rsmd, tablePosition, table, columnIndex, childMap);