From cf2bf9af277c5c51308685811c54b24a82921389 Mon Sep 17 00:00:00 2001 From: TommyLemon <1184482681@qq.com> Date: Sun, 22 Nov 2020 02:37:27 +0800 Subject: [PATCH] =?UTF-8?q?AbstractSQLConfig=20=E6=96=B0=E5=A2=9E=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E6=8A=8A=20APIJSON=20=E9=85=8D=E7=BD=AE=E8=A1=A8?= =?UTF-8?q?=E4=BB=8E=E4=B8=9A=E5=8A=A1=E8=A1=A8=E6=89=80=E5=9C=A8=20schema?= =?UTF-8?q?=20=E9=9A=94=E7=A6=BB=E5=87=BA=E6=9D=A5=E5=88=B0=E5=8D=95?= =?UTF-8?q?=E7=8B=AC=E7=9A=84=20schema=EF=BC=9B=E8=A7=A3=E5=86=B3=20SQLCon?= =?UTF-8?q?fig=20=E8=87=AA=E5=AE=9A=E4=B9=89=E7=9A=84=20idKey=20=E5=92=8C?= =?UTF-8?q?=20userIdKey=20=E5=9C=A8=20Structure=20=E4=B8=AD=E6=9C=AA?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E5=AF=BC=E8=87=B4=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E5=80=BC=E6=A0=A1=E9=AA=8C=E4=B8=8D=E9=80=9A=E8=BF=87=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 8 ++++--- .../apijson/framework/APIJSONApplication.java | 21 ++++++++++-------- .../apijson/framework/APIJSONConstant.java | 18 +++++++++++++++ .../apijson/framework/APIJSONCreator.java | 15 +++++++++++++ .../java/apijson/framework/APIJSONParser.java | 13 +++++++++++ .../apijson/framework/APIJSONSQLConfig.java | 22 +++++++++++++++++-- 6 files changed, 83 insertions(+), 14 deletions(-) diff --git a/pom.xml b/pom.xml index 5fe30c7..f0a4c3d 100755 --- a/pom.xml +++ b/pom.xml @@ -22,7 +22,7 @@ com.github.Tencent APIJSON - 4.2.4 + 4.2.5 @@ -53,7 +53,8 @@ - + com.github.TommyLemon unitauto-java @@ -64,7 +65,8 @@ unitauto-jar 2.5.3 - + diff --git a/src/main/java/apijson/framework/APIJSONApplication.java b/src/main/java/apijson/framework/APIJSONApplication.java index 87526a3..350fbef 100755 --- a/src/main/java/apijson/framework/APIJSONApplication.java +++ b/src/main/java/apijson/framework/APIJSONApplication.java @@ -70,6 +70,18 @@ public static void init(boolean shutdownWhenServerError, @NotNull APIJSONCreator APIJSONParser.APIJSON_CREATOR = creator; APIJSONController.APIJSON_CREATOR = creator; + + System.out.println("\n\n\n开始初始化:权限校验配置 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n"); + try { + APIJSONVerifier.init(shutdownWhenServerError, creator); + } + catch (Exception e) { + e.printStackTrace(); + } + System.out.println("\n完成初始化:权限校验配置 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); + + + System.out.println("\n\n\n开始初始化:远程函数配置 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n"); try { APIJSONFunctionParser.init(shutdownWhenServerError, creator); @@ -110,15 +122,6 @@ public static void init(boolean shutdownWhenServerError, @NotNull APIJSONCreator - System.out.println("\n\n\n开始初始化:权限校验配置 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n"); - try { - APIJSONVerifier.init(shutdownWhenServerError, creator); - } - catch (Exception e) { - e.printStackTrace(); - } - System.out.println("\n完成初始化:权限校验配置 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); - System.out.println("\n\n<<<<<<<<<<<<<<<<<<<<<<<<< APIJSON 启动完成,试试调用自动化 API 吧 ^_^ >>>>>>>>>>>>>>>>>>>>>>>>\n"); } diff --git a/src/main/java/apijson/framework/APIJSONConstant.java b/src/main/java/apijson/framework/APIJSONConstant.java index 6a840b3..deb30c4 100644 --- a/src/main/java/apijson/framework/APIJSONConstant.java +++ b/src/main/java/apijson/framework/APIJSONConstant.java @@ -1,5 +1,23 @@ +/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License.*/ + package apijson.framework; + +/**APIJSON 常量类 + * @author Lemon + */ import apijson.JSONResponse; import apijson.orm.JSONRequest; import apijson.orm.Visitor; diff --git a/src/main/java/apijson/framework/APIJSONCreator.java b/src/main/java/apijson/framework/APIJSONCreator.java index 8fb14ea..5b29e56 100644 --- a/src/main/java/apijson/framework/APIJSONCreator.java +++ b/src/main/java/apijson/framework/APIJSONCreator.java @@ -1,3 +1,17 @@ +/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License.*/ + package apijson.framework; import apijson.orm.FunctionParser; @@ -9,6 +23,7 @@ import apijson.orm.Verifier; import apijson.orm.VerifierCreator; + /**APIJSON相关创建器 * @author Lemon */ diff --git a/src/main/java/apijson/framework/APIJSONParser.java b/src/main/java/apijson/framework/APIJSONParser.java index 7b8f3de..6bd6ef6 100755 --- a/src/main/java/apijson/framework/APIJSONParser.java +++ b/src/main/java/apijson/framework/APIJSONParser.java @@ -183,5 +183,18 @@ public void onVerifyContent() throws Exception { // public int getMaxQueryCount() { // return 50; // } + + @Override + public String getIdKey(String database, String schema, String table) { + return APIJSONSQLConfig.SIMPLE_CALLBACK.getIdKey(database, schema, table); + } + @Override + public String getUserIdKey(String database, String schema, String table) { + return APIJSONSQLConfig.SIMPLE_CALLBACK.getUserIdKey(database, schema, table); + } + @Override + public Object newId(RequestMethod method, String database, String schema, String table) { + return APIJSONSQLConfig.SIMPLE_CALLBACK.newId(method, database, schema, table); + } } diff --git a/src/main/java/apijson/framework/APIJSONSQLConfig.java b/src/main/java/apijson/framework/APIJSONSQLConfig.java index b2c5e6f..d929b08 100755 --- a/src/main/java/apijson/framework/APIJSONSQLConfig.java +++ b/src/main/java/apijson/framework/APIJSONSQLConfig.java @@ -42,6 +42,7 @@ public class APIJSONSQLConfig extends AbstractSQLConfig { static { DEFAULT_DATABASE = DATABASE_MYSQL; //TODO 默认数据库类型,改成你自己的 DEFAULT_SCHEMA = "sys"; //TODO 默认模式名,改成你自己的,默认情况是 MySQL: sys, PostgreSQL: public, SQL Server: dbo, Oracle: + // TABLE_KEY_MAP.put(Access.class.getSimpleName(), "apijson_access"); // 由 APIJSONVerifier.init 方法读取数据库 Access 表来替代手动输入配置 // //表名映射,隐藏真实表名,对安全要求很高的表可以这么做 @@ -79,11 +80,11 @@ public String getUserIdKey(String database, String schema, String table) { // return null; // return null 则不生成 id,一般用于数据库自增 id // } }; - + } - + @Override public String getDBVersion() { if (isMySQL()) { @@ -179,6 +180,23 @@ public String getDBPassword() { // return false; // } + /**获取 APIJSON 配置表所在数据库模式 schema,默认与业务表一块 + * @return + */ + public String getConfigSchema() { + return getSchema(); + } + /**是否为 APIJSON 配置表 + * @return + */ + public boolean isConfigTable() { + return CONFIG_TABLE_LIST.contains(getTable()); + } + @Override + public String getSQLSchema() { + String sch = isConfigTable() ? getConfigSchema() : super.getSQLSchema(); + return sch == null ? DEFAULT_SCHEMA : sch; + } @Override