Skip to content

Commit e0d9a7c

Browse files
committed
SQLConfig 和 SQLExecutor 也指定主键泛型
1 parent 7a24178 commit e0d9a7c

File tree

7 files changed

+39
-10
lines changed

7 files changed

+39
-10
lines changed

APIJSONORM/src/main/java/apijson/orm/AbstractFunctionParser.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,17 @@ public AbstractFunctionParser(RequestMethod method, String tag, int version, @No
6262
setRequest(request);
6363
}
6464

65+
private Parser<?> parser;
66+
@Override
67+
public Parser<?> getParser() {
68+
return parser;
69+
}
70+
@Override
71+
public AbstractFunctionParser setParser(Parser<?> parser) {
72+
this.parser = parser;
73+
return this;
74+
}
75+
6576
@Override
6677
public RequestMethod getMethod() {
6778
return method;

APIJSONORM/src/main/java/apijson/orm/AbstractParser.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,7 @@ public AbstractParser<T> setNeedVerifyContent(boolean needVerifyContent) {
344344
public SQLExecutor getSQLExecutor() {
345345
if (sqlExecutor == null) {
346346
sqlExecutor = createSQLExecutor();
347+
sqlExecutor.setParser(this);
347348
}
348349
return sqlExecutor;
349350
}

APIJSONORM/src/main/java/apijson/orm/AbstractSQLConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
/**config sql for JSON Request
8080
* @author Lemon
8181
*/
82-
public abstract class AbstractSQLConfig implements SQLConfig {
82+
public abstract class AbstractSQLConfig<T extends Object> implements SQLConfig<T> {
8383
private static final String TAG = "AbstractSQLConfig";
8484

8585
/**

APIJSONORM/src/main/java/apijson/orm/AbstractSQLExecutor.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,22 @@
4646
/**executor for query(read) or update(write) MySQL database
4747
* @author Lemon
4848
*/
49-
public abstract class AbstractSQLExecutor implements SQLExecutor {
49+
public abstract class AbstractSQLExecutor<T extends Object> implements SQLExecutor<T> {
5050
private static final String TAG = "AbstractSQLExecutor";
5151

5252
public static String KEY_RAW_LIST = "@RAW@LIST"; // 避免和字段命名冲突,不用 $RAW@LIST$ 是因为 $ 会在 fastjson 内部转义,浪费性能
5353

54+
private Parser<T> parser;
55+
@Override
56+
public Parser<T> getParser() {
57+
return parser;
58+
}
59+
@Override
60+
public AbstractSQLExecutor setParser(Parser<T> parser) {
61+
this.parser = parser;
62+
return this;
63+
}
64+
5465
private int generatedSQLCount = 0;
5566
private int cachedSQLCount = 0;
5667
private int executedSQLCount = 0;
@@ -1195,7 +1206,7 @@ public void setTransactionIsolation(int transactionIsolation) {
11951206
@Override
11961207
public void begin(int transactionIsolation) throws SQLException {
11971208
Log.d("\n\n" + TAG, "<<<<<<<<<<<<<< TRANSACTION begin transactionIsolation = " + transactionIsolation + " >>>>>>>>>>>>>>>>>>>>>>> \n\n");
1198-
//不做判断,如果掩盖了问题,调用层都不知道为啥事务没有提交成功
1209+
// 不做判断,如果掩盖了问题,调用层都不知道为啥事务没有提交成功
11991210
// if (connection == null || connection.isClosed()) {
12001211
// return;
12011212
// }

APIJSONORM/src/main/java/apijson/orm/FunctionParser.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ public interface FunctionParser {
1919
Object invoke(@NotNull String function, @NotNull JSONObject currentObject) throws Exception;
2020
Object invoke(@NotNull String function, @NotNull JSONObject currentObject, boolean containRaw) throws Exception;
2121

22+
Parser<?> getParser();
23+
24+
AbstractFunctionParser setParser(Parser<?> parser);
25+
2226
RequestMethod getMethod();
2327
FunctionParser setMethod(RequestMethod method);
2428

APIJSONORM/src/main/java/apijson/orm/SQLConfig.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
/**SQL配置
1616
* @author Lemon
1717
*/
18-
public interface SQLConfig {
18+
public interface SQLConfig<T extends Object> {
1919

2020
String DATABASE_MYSQL = "MYSQL"; // https://www.mysql.com
2121
String DATABASE_POSTGRESQL = "POSTGRESQL"; // https://www.postgresql.org
@@ -48,9 +48,9 @@ public interface SQLConfig {
4848
int TYPE_ITEM = 1;
4949
int TYPE_ITEM_CHILD_0 = 2;
5050

51-
Parser<?> getParser();
51+
Parser<T> getParser();
5252

53-
AbstractSQLConfig setParser(Parser<?> parser);
53+
AbstractSQLConfig setParser(Parser<T> parser);
5454

5555
ObjectParser getObjectParser();
5656

@@ -345,9 +345,9 @@ default int[] getDBVersionNums() {
345345

346346

347347
List<Object> getWithAsExprPreparedValueList();
348-
void setWithAsExprPreparedValueList(List<Object> withAsExprePreparedValueList);
348+
SQLConfig setWithAsExprPreparedValueList(List<Object> withAsExprePreparedValueList);
349349

350350
boolean isFakeDelete();
351-
352-
void onFakeDelete(Map<String, Object> map);
351+
352+
Map<String, Object> onFakeDelete(Map<String, Object> map);
353353
}

APIJSONORM/src/main/java/apijson/orm/SQLExecutor.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
/**executor for query(read) or update(write) MySQL database
2121
* @author Lemon
2222
*/
23-
public interface SQLExecutor {
23+
public interface SQLExecutor<T extends Object> {
24+
Parser<T> getParser();
25+
SQLExecutor setParser(Parser<T> parser);
2426

2527
/**保存缓存
2628
* @param sql

0 commit comments

Comments
 (0)