Skip to content

Commit 56131b5

Browse files
committed
Java:APIJSONBoot 升级 APIJSON 及 apijson-framework 6.3.0, apijson-column 及 apijson-router 1.8.0,unitauto-java 及 unitauto-jar 3.0.5
1 parent 36de714 commit 56131b5

File tree

4 files changed

+37
-36
lines changed

4 files changed

+37
-36
lines changed

APIJSON-Java-Server/APIJSONBoot/pom.xml

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

66
<groupId>apijson.boot</groupId>
77
<artifactId>apijson-boot</artifactId>
8-
<version>6.0.0</version>
8+
<version>6.3.0</version>
99
<packaging>jar</packaging>
1010

1111
<name>APIJSONBoot</name>
@@ -36,12 +36,12 @@
3636
<dependency>
3737
<groupId>com.github.TommyLemon</groupId>
3838
<artifactId>unitauto-java</artifactId>
39-
<version>2.7.2</version>
39+
<version>3.0.5</version>
4040
</dependency>
4141
<dependency>
4242
<groupId>com.github.TommyLemon</groupId>
4343
<artifactId>unitauto-jar</artifactId>
44-
<version>2.7.2</version>
44+
<version>3.0.5</version>
4545
</dependency>
4646
<dependency>
4747
<groupId>io.github.classgraph</groupId>
@@ -55,17 +55,17 @@
5555
<dependency>
5656
<groupId>com.github.Tencent</groupId>
5757
<artifactId>APIJSON</artifactId>
58-
<version>6.0.0</version>
58+
<version>6.3.0</version>
5959
</dependency>
6060
<dependency>
6161
<groupId>com.github.APIJSON</groupId>
6262
<artifactId>apijson-framework</artifactId>
63-
<version>6.0.0</version>
63+
<version>6.3.0</version>
6464
</dependency>
6565
<dependency>
6666
<groupId>com.github.APIJSON</groupId>
6767
<artifactId>apijson-column</artifactId>
68-
<version>1.5.0</version>
68+
<version>1.8.0</version>
6969
</dependency>
7070
<!-- 可使用 libs 目录的 apijson-orm.jar, apijson-framework.jar, apijson-column.jar 来替代,两种方式二选一 >>>>>>>>>> -->
7171

APIJSON-Java-Server/APIJSONBoot/src/main/java/apijson/demo/DemoObjectParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
/**对象解析器,用来简化 Parser
3131
* @author Lemon
3232
*/
33-
public class DemoObjectParser extends APIJSONObjectParser {
33+
public class DemoObjectParser extends APIJSONObjectParser<Long> {
3434

3535
public DemoObjectParser(HttpSession session, @NotNull JSONObject request, String parentPath, SQLConfig arrayConfig
3636
, boolean isSubquery, boolean isTable, boolean isArrayMainTable) throws Exception {

APIJSON-Java-Server/APIJSONBoot/src/main/java/apijson/demo/DemoSQLConfig.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
* https://github.com/Tencent/APIJSON/blob/master/%E8%AF%A6%E7%BB%86%E7%9A%84%E8%AF%B4%E6%98%8E%E6%96%87%E6%A1%A3.md#c-1-1%E4%BF%AE%E6%94%B9%E6%95%B0%E6%8D%AE%E5%BA%93%E9%93%BE%E6%8E%A5
4444
* @author Lemon
4545
*/
46-
public class DemoSQLConfig extends APIJSONSQLConfig {
46+
public class DemoSQLConfig extends APIJSONSQLConfig<Long> {
4747

4848
public DemoSQLConfig() {
4949
super();
@@ -119,7 +119,7 @@ public String getUserIdKey(String database, String schema, String datasource, St
119119
tableColumnMap.put("User", Arrays.asList(StringUtil.split("id,sex,name,tag,head,contactIdList,pictureList,date")));
120120
// 需要对应方法传参也是这样拼接才行,例如 ColumnUtil.compatInputColumn(column, getSQLDatabase() + "-" + getSQLSchema() + "-" + getTable(), getMethod());
121121
tableColumnMap.put("MYSQL-sys-Privacy", Arrays.asList(StringUtil.split("id,certified,phone,balance,_password,_payPassword")));
122-
ColumnUtil.VERSIONED_TABLE_COLUMN_MAP.put(null, tableColumnMap);
122+
ColumnUtil.VERSIONED_TABLE_COLUMN_MAP.put(0, tableColumnMap);
123123

124124
// 字段名映射配置 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
125125
Map<String, Map<String, String>> tableKeyColumnMap = new HashMap<>();
@@ -134,7 +134,7 @@ public String getUserIdKey(String database, String schema, String datasource, St
134134
// 需要对应方法传参也是这样拼接才行,例如 ColumnUtil.compatInputKey(super.getKey(key), getSQLDatabase() + "-" + getSQLSchema() + "-" + getTable(), getMethod());
135135
tableKeyColumnMap.put("MYSQL-sys-Privacy", privacyKeyColumnMap);
136136

137-
ColumnUtil.VERSIONED_KEY_COLUMN_MAP.put(null, tableKeyColumnMap);
137+
ColumnUtil.VERSIONED_KEY_COLUMN_MAP.put(0, tableKeyColumnMap);
138138
// 字段名映射配置 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
139139

140140
ColumnUtil.init();
@@ -146,7 +146,8 @@ public String getUserIdKey(String database, String schema, String datasource, St
146146
@Override
147147
public String getDBVersion() {
148148
if (isMySQL()) {
149-
return "5.7.22"; //"8.0.11"; //TODO 改成你自己的 MySQL 或 PostgreSQL 数据库版本号 //MYSQL 8 和 7 使用的 JDBC 配置不一样
149+
// return "5.7.22";
150+
return "8.0.11"; //TODO 改成你自己的 MySQL 或 PostgreSQL 数据库版本号 //MYSQL 8 和 7 使用的 JDBC 配置、正则条件 等不一样
150151
}
151152
if (isPostgreSQL()) {
152153
return "9.6.15"; //TODO 改成你自己的
@@ -318,11 +319,11 @@ protected void onGetCrossJoinString(Join j) throws UnsupportedOperationException
318319
// 开启 CROSS JOIN 笛卡尔积联表 super.onGetCrossJoinString(j);
319320
}
320321
@Override
321-
protected void onJoinNotRelation(String sql, String quote, Join j, String jt, List<On> onList, On on) {
322+
protected void onJoinNotRelation(String sql, String quote, Join join, String table, List<Join.On> onList, Join.On on) {
322323
// 开启 JOIN ON t1.c1 != t2.c2 等不等式关联 super.onJoinNotRelation(sql, quote, j, jt, onList, on);
323324
}
324325
@Override
325-
protected void onJoinComplextRelation(String sql, String quote, Join j, String jt, List<On> onList, On on) {
326+
protected void onJoinComplexRelation(String sql, String quote, Join join, String table, List<Join.On> onList, Join.On on) {
326327
// 开启 JOIN ON t1.c1 LIKE concat('%', t2.c2, '%') 等复杂关联 super.onJoinComplextRelation(sql, quote, j, jt, onList, on);
327328
}
328329

APIJSON-Java-Server/APIJSONBoot/src/main/java/apijson/demo/DemoSQLExecutor.java

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@
2121
import apijson.Log;
2222
import apijson.boot.DemoApplication;
2323
import apijson.framework.APIJSONSQLExecutor;
24-
import apijson.orm.SQLConfig;
24+
import apijson.orm.SQLConfig;
2525

2626

2727
/**SQL 执行器,支持连接池及多数据源
2828
* 具体见 https://github.com/Tencent/APIJSON/issues/151
2929
* @author Lemon
3030
*/
31-
public class DemoSQLExecutor extends APIJSONSQLExecutor {
31+
public class DemoSQLExecutor extends APIJSONSQLExecutor<Long> {
3232
public static final String TAG = "DemoSQLExecutor";
3333

3434
// 可重写以下方法,支持 Redis 等单机全局缓存或分布式缓存
@@ -45,27 +45,27 @@ public class DemoSQLExecutor extends APIJSONSQLExecutor {
4545
// super.removeCache(sql, type);
4646
// }
4747

48-
// 适配连接池,如果这里能拿到连接池的有效 Connection,则 SQLConfig 不需要配置 dbVersion, dbUri, dbAccount, dbPassword
49-
@Override
48+
// 适配连接池,如果这里能拿到连接池的有效 Connection,则 SQLConfig 不需要配置 dbVersion, dbUri, dbAccount, dbPassword
49+
@Override
5050
public Connection getConnection(SQLConfig config) throws Exception {
5151
Log.d(TAG, "getConnection config.getDatasource() = " + config.getDatasource());
52-
53-
Connection c = connectionMap.get(config.getDatabase());
54-
if (c == null || c.isClosed()) {
55-
try {
56-
DataSource ds = DemoApplication.getApplicationContext().getBean(DataSource.class);
57-
// 另一种方式是 DruidConfig 初始化获取到 Datasource 后给静态变量 DATA_SOURCE 赋值: ds = DruidConfig.DATA_SOURCE.getConnection();
58-
connectionMap.put(config.getDatabase(), ds == null ? null : ds.getConnection());
59-
} catch (Exception e) {
60-
Log.e(TAG, "getConnection try { "
61-
+ "DataSource ds = DemoApplication.getApplicationContext().getBean(DataSource.class); .."
62-
+ "} catch (Exception e) = " + e.getMessage());
63-
}
64-
}
65-
66-
// 必须最后执行 super 方法,因为里面还有事务相关处理。
67-
// 如果这里是 return c,则会导致 增删改 多个对象时只有第一个会 commit,即只有第一个对象成功插入数据库表
68-
return super.getConnection(config);
52+
53+
Connection c = connectionMap.get(config.getDatabase());
54+
if (c == null || c.isClosed()) {
55+
try {
56+
DataSource ds = DemoApplication.getApplicationContext().getBean(DataSource.class);
57+
// 另一种方式是 DruidConfig 初始化获取到 Datasource 后给静态变量 DATA_SOURCE 赋值: ds = DruidConfig.DATA_SOURCE.getConnection();
58+
connectionMap.put(config.getDatabase(), ds == null ? null : ds.getConnection());
59+
} catch (Exception e) {
60+
Log.e(TAG, "getConnection try { "
61+
+ "DataSource ds = DemoApplication.getApplicationContext().getBean(DataSource.class); .."
62+
+ "} catch (Exception e) = " + e.getMessage());
63+
}
64+
}
65+
66+
// 必须最后执行 super 方法,因为里面还有事务相关处理。
67+
// 如果这里是 return c,则会导致 增删改 多个对象时只有第一个会 commit,即只有第一个对象成功插入数据库表
68+
return super.getConnection(config);
6969
}
7070

7171

@@ -81,6 +81,6 @@ public Connection getConnection(SQLConfig config) throws Exception {
8181
// protected boolean isHideColumn(SQLConfig config, ResultSet rs, ResultSetMetaData rsmd, int tablePosition,
8282
// JSONObject table, int columnIndex, Map<String, JSONObject> childMap) throws SQLException {
8383
// return false;
84-
// }
85-
84+
// }
85+
8686
}

0 commit comments

Comments
 (0)