Skip to content

Commit ddd40c2

Browse files
authored
Merge pull request #22 from csx-bill/master
6.2.0 版本  javax.servlet-api 升级 jakarta.servlet-api  jdk 升级为 17
2 parents 1439e29 + f4b05aa commit ddd40c2

File tree

9 files changed

+237
-175
lines changed

9 files changed

+237
-175
lines changed

pom.xml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>apijson.framework</groupId>
77
<artifactId>apijson-framework-spring-boot3</artifactId>
8-
<version>6.1.0</version>
8+
<version>6.2.0</version>
99
<packaging>jar</packaging>
1010

1111
<name>APIJSONFramework</name>
@@ -15,6 +15,9 @@
1515
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1616
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
1717
<java.version>17</java.version>
18+
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
19+
<maven.compiler.source>17</maven.compiler.source>
20+
<maven.compiler.target>17</maven.compiler.target>
1821
</properties>
1922

2023
<dependencies>
@@ -35,7 +38,12 @@
3538
<dependency>
3639
<groupId>com.github.Tencent</groupId>
3740
<artifactId>APIJSON</artifactId>
38-
<version>6.1.0</version>
41+
<version>6.2.0</version>
42+
</dependency>
43+
<dependency>
44+
<groupId>com.github.APIJSON</groupId>
45+
<artifactId>apijson-column</artifactId>
46+
<version>1.7.0</version>
3947
</dependency>
4048

4149
<!-- 数据库 JDBC 驱动 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< -->

src/main/java/apijson/framework/APIJSONApplication.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public static <T extends Object> void init(boolean shutdownWhenServerError, @Not
8282
} catch (Throwable e) {
8383
e.printStackTrace();
8484
if (shutdownWhenServerError) {
85-
onServerError("权Access 限校验配置 初始化失败!", shutdownWhenServerError);
85+
onServerError("Access 权限校验配置 初始化失败!", shutdownWhenServerError);
8686
}
8787
}
8888
System.out.println("\n完成初始化: Access 权限校验配置 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");

src/main/java/apijson/framework/APIJSONController.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@
3636
import java.rmi.ServerException;
3737
import java.util.Map;
3838

39-
39+
import jakarta.servlet.AsyncContext;
40+
import jakarta.servlet.ServletResponse;
41+
import jakarta.servlet.http.HttpServletRequest;
42+
import jakarta.servlet.http.HttpSession;
4043

4144
import com.alibaba.fastjson.JSONObject;
4245

@@ -48,10 +51,6 @@
4851
import apijson.orm.AbstractParser;
4952
import apijson.orm.Parser;
5053
import apijson.orm.Visitor;
51-
import jakarta.servlet.AsyncContext;
52-
import jakarta.servlet.ServletResponse;
53-
import jakarta.servlet.http.HttpServletRequest;
54-
import jakarta.servlet.http.HttpSession;
5554
import unitauto.MethodUtil;
5655
import unitauto.MethodUtil.InterfaceProxy;
5756

@@ -109,7 +108,7 @@ public String parseByTag(RequestMethod method, String tag, Map<String, String> p
109108

110109
//通用接口,非事务型操作 和 简单事务型操作 都可通过这些接口自动化实现<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
111110

112-
/**增删改查统一入口,这个一个方法可替代以下 7 个方法,牺牲一些路由解析性能来提升一点开发效率
111+
/**增删改查统一入口,这个一个方法可替代以下 7 个方法,牺牲一点路由解析性能来提升一些开发效率
113112
* @param method
114113
* @param tag
115114
* @param params

src/main/java/apijson/framework/APIJSONFunctionParser.java

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
import java.util.List;
3232
import java.util.Map;
3333

34-
34+
import jakarta.servlet.http.HttpSession;
3535

3636
import com.alibaba.fastjson.JSONArray;
3737
import com.alibaba.fastjson.JSONObject;
@@ -46,15 +46,14 @@
4646
import apijson.orm.JSONRequest;
4747
import apijson.orm.script.JavaScriptExecutor;
4848
import apijson.orm.script.ScriptExecutor;
49-
import jakarta.servlet.http.HttpSession;
5049
import unitauto.MethodUtil;
5150
import unitauto.MethodUtil.Argument;
5251

5352

5453
/**可远程调用的函数类
5554
* @author Lemon
5655
*/
57-
public class APIJSONFunctionParser extends AbstractFunctionParser {
56+
public class APIJSONFunctionParser<T extends Object> extends AbstractFunctionParser<T> {
5857
public static final String TAG = "APIJSONFunctionParser";
5958

6059
@NotNull
@@ -80,23 +79,23 @@ public APIJSONFunctionParser(RequestMethod method, String tag, int version, JSON
8079
public HttpSession getSession() {
8180
return session;
8281
}
83-
public APIJSONFunctionParser setSession(HttpSession session) {
82+
public APIJSONFunctionParser<T> setSession(HttpSession session) {
8483
this.session = session;
8584
return this;
8685
}
8786

8887
@Override
89-
public APIJSONFunctionParser setMethod(RequestMethod method) {
88+
public APIJSONFunctionParser<T> setMethod(RequestMethod method) {
9089
super.setMethod(method);
9190
return this;
9291
}
9392
@Override
94-
public APIJSONFunctionParser setTag(String tag) {
93+
public APIJSONFunctionParser<T> setTag(String tag) {
9594
super.setTag(tag);
9695
return this;
9796
}
9897
@Override
99-
public APIJSONFunctionParser setVersion(int version) {
98+
public APIJSONFunctionParser<T> setVersion(int version) {
10099
super.setVersion(version);
101100
return this;
102101
}
@@ -284,7 +283,7 @@ public static <T extends Object> JSONObject init(boolean shutdownWhenServerError
284283
if (item.get("language") != null) {
285284
String language = item.getString("language");
286285
if (SCRIPT_EXECUTOR_MAP.get(language) == null) {
287-
onServerError("找不到脚本语言 " + language + " 对应的执行引擎!请先依赖相关库并在后端 APIJSONFunctionParser 中注册!", shutdownWhenServerError);
286+
onServerError("找不到脚本语言 " + language + " 对应的执行引擎!请先依赖相关库并在后端 APIJSONFunctionParser<T> 中注册!", shutdownWhenServerError);
288287
}
289288
ScriptExecutor scriptExecutor = SCRIPT_EXECUTOR_MAP.get(language);
290289
scriptExecutor.load(name, scriptMap.get(name).getString("script"));
@@ -297,12 +296,13 @@ public static <T extends Object> JSONObject init(boolean shutdownWhenServerError
297296
methods = ALL_METHODS;
298297
}
299298

299+
demo.put(JSONRequest.KEY_TAG, item.get(JSONRequest.KEY_TAG));
300+
demo.put(JSONRequest.KEY_VERSION, item.get(JSONRequest.KEY_VERSION));
301+
300302
for (String method : methods) {
301303
JSONObject r = APIJSON_CREATOR.createParser()
302304
.setMethod(RequestMethod.valueOf(method))
303305
.setNeedVerify(false)
304-
.setTag(item.getString(JSONRequest.KEY_TAG))
305-
.setVersion(item.getIntValue(JSONRequest.KEY_VERSION))
306306
.parseResponse(demo);
307307

308308
if (JSONResponse.isSuccess(r) == false) {
@@ -337,7 +337,7 @@ protected static void onServerError(String msg, boolean shutdown) throws ServerE
337337
public static void test() throws Exception {
338338
test(null);
339339
}
340-
public static void test(APIJSONFunctionParser function) throws Exception {
340+
public static <T extends Object> void test(APIJSONFunctionParser<T> function) throws Exception {
341341
int i0 = 1, i1 = -2;
342342
JSONObject request = new JSONObject();
343343
request.put("id", 10);
@@ -710,14 +710,6 @@ public String getMethodArguments(@NotNull JSONObject curObj, String methodArgsKe
710710
}
711711

712712

713-
/**改用 getMethodDefinition
714-
*/
715-
@Deprecated
716-
public String getMethodDefination(@NotNull JSONObject curObj) throws IllegalArgumentException {
717-
// curObj.put("arguments", removeComment(curObj.getString("methodArgs")));
718-
return getMethodDefination(curObj, "method", "arguments", "genericType", "genericExceptions", "Java");
719-
}
720-
721713
/**获取方法的定义
722714
* @param curObj
723715
* @return
@@ -729,13 +721,6 @@ public String getMethodDefinition(@NotNull JSONObject curObj) throws IllegalArgu
729721
// curObj.put("arguments", removeComment(curObj.getString("methodArgs")));
730722
return getMethodDefinition(curObj, "method", "arguments", "genericType", "genericExceptions", "Java");
731723
}
732-
/**改用 getMethodDefinition
733-
*/
734-
@Deprecated
735-
public String getMethodDefination(@NotNull JSONObject curObj, String method, String arguments
736-
, String type, String exceptions, String language) throws IllegalArgumentException {
737-
return getMethodDefinition(curObj, method, arguments, type, exceptions, language);
738-
}
739724
/**获取方法的定义
740725
* @param curObj
741726
* @param method

src/main/java/apijson/framework/APIJSONObjectParser.java

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,19 @@
1616

1717
import java.util.List;
1818

19+
import jakarta.servlet.http.HttpSession;
1920

21+
import apijson.orm.*;
2022
import com.alibaba.fastjson.JSONObject;
2123

2224
import apijson.NotNull;
2325
import apijson.RequestMethod;
24-
import apijson.orm.AbstractObjectParser;
25-
import apijson.orm.AbstractParser;
26-
import apijson.orm.Join;
27-
import apijson.orm.SQLConfig;
28-
import jakarta.servlet.http.HttpSession;
2926

3027

3128
/**简化Parser,getObject和getArray(getArrayConfig)都能用
3229
* @author Lemon
3330
*/
34-
public class APIJSONObjectParser extends AbstractObjectParser {
31+
public class APIJSONObjectParser<T extends Object> extends AbstractObjectParser<T> {
3532
public static final String TAG = "APIJSONObjectParser";
3633

3734
/**for single object
@@ -44,26 +41,26 @@ public class APIJSONObjectParser extends AbstractObjectParser {
4441
* @param isArrayMainTable
4542
* @throws Exception
4643
*/
47-
public APIJSONObjectParser(HttpSession session, @NotNull JSONObject request, String parentPath, SQLConfig arrayConfig
44+
public APIJSONObjectParser(HttpSession session, @NotNull JSONObject request, String parentPath, SQLConfig<T> arrayConfig
4845
, boolean isSubquery, boolean isTable, boolean isArrayMainTable) throws Exception {
4946
super(request, parentPath, arrayConfig, isSubquery, isTable, isArrayMainTable);
5047
}
5148

5249
@Override
53-
public APIJSONObjectParser setMethod(RequestMethod method) {
50+
public APIJSONObjectParser<T> setMethod(RequestMethod method) {
5451
super.setMethod(method);
5552
return this;
5653
}
5754

5855
@Override
59-
public APIJSONObjectParser setParser(AbstractParser<?> parser) {
56+
public APIJSONObjectParser<T> setParser(Parser<T> parser) {
6057
super.setParser(parser);
6158
return this;
6259
}
6360

6461

6562
@Override
66-
public SQLConfig newSQLConfig(RequestMethod method, String table, String alias, JSONObject request, List<Join> joinList, boolean isProcedure) throws Exception {
63+
public SQLConfig<T> newSQLConfig(RequestMethod method, String table, String alias, JSONObject request, List<Join> joinList, boolean isProcedure) throws Exception {
6764
return APIJSONSQLConfig.newSQLConfig(method, table, alias, request, joinList, isProcedure);
6865
}
6966

src/main/java/apijson/framework/APIJSONParser.java

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.util.Map;
2222
import java.util.Set;
2323

24+
import jakarta.servlet.http.HttpSession;
2425

2526
import com.alibaba.fastjson.JSONObject;
2627

@@ -32,7 +33,6 @@
3233
import apijson.orm.SQLConfig;
3334
import apijson.orm.SQLExecutor;
3435
import apijson.orm.Verifier;
35-
import jakarta.servlet.http.HttpSession;
3636

3737

3838
/**请求解析器
@@ -125,6 +125,7 @@ public FunctionParser getFunctionParser() {
125125
public Object onFunctionParse(String key, String function, String parentPath, String currentName, JSONObject currentObject, boolean containRaw) throws Exception {
126126
if (functionParser == null) {
127127
functionParser = createFunctionParser();
128+
functionParser.setParser(this);
128129
functionParser.setMethod(getMethod());
129130
functionParser.setTag(getTag());
130131
functionParser.setVersion(getVersion());
@@ -144,10 +145,10 @@ public Object onFunctionParse(String key, String function, String parentPath, St
144145

145146

146147
@Override
147-
public APIJSONObjectParser createObjectParser(JSONObject request, String parentPath, SQLConfig arrayConfig
148+
public APIJSONObjectParser<T> createObjectParser(JSONObject request, String parentPath, SQLConfig<T> arrayConfig
148149
, boolean isSubquery, boolean isTable, boolean isArrayMainTable) throws Exception {
149150

150-
return new APIJSONObjectParser(getSession(), request, parentPath, arrayConfig, isSubquery, isTable, isArrayMainTable) {
151+
return new APIJSONObjectParser<T>(getSession(), request, parentPath, arrayConfig, isSubquery, isTable, isArrayMainTable) {
151152

152153
// @Override
153154
// protected APIJSONSQLConfig newQueryConfig() {
@@ -157,11 +158,11 @@ public APIJSONObjectParser createObjectParser(JSONObject request, String parentP
157158
// return super.newQueryConfig();
158159
// }
159160

160-
//导致最多评论的(Strong 30个)的那个动态详情界面Android(82001)无姓名和头像,即User=null
161+
// 导致最多评论的(Strong 30个)的那个动态详情界面Android(82001)无姓名和头像,即User=null
161162
// @Override
162163
// protected void onComplete() {
163164
// if (response != null) {
164-
// putQueryResult(path, response);//解决获取关联数据时requestObject里不存在需要的关联数据
165+
// putQueryResult(path, response); // 解决获取关联数据时requestObject里不存在需要的关联数据
165166
// }
166167
// }
167168

@@ -179,13 +180,6 @@ public void onVerifyContent() throws Exception {
179180
}
180181
super.onVerifyContent();
181182
}
182-
183-
184-
// //可重写来设置最大查询数量
185-
// @Override
186-
// public int getMaxQueryCount() {
187-
// return 50;
188-
// }
189183

190184

191185
}

0 commit comments

Comments
 (0)