Skip to content

Commit 23b5c20

Browse files
committed
Java: 所有 Demo 升级 APIJSON 6.2, apijson-framework 6.2, apijson-column 1.7;解决 泛型 及 配置问题
1 parent c503a2c commit 23b5c20

File tree

58 files changed

+220
-219
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+220
-219
lines changed

APIJSON-Java-Server/APIJSONBoot-BigData/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.2.0</version>
99
<packaging>jar</packaging>
1010

1111
<name>APIJSONBoot-BigData</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>2.9.0</version>
4040
</dependency>
4141
<dependency>
4242
<groupId>com.github.TommyLemon</groupId>
4343
<artifactId>unitauto-jar</artifactId>
44-
<version>2.7.2</version>
44+
<version>2.9.0</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.2.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.2.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.7.0</version>
6969
</dependency>
7070
<!-- 可使用 libs 目录的 apijson-orm.jar, apijson-framework.jar, apijson-column.jar 来替代,两种方式二选一 >>>>>>>>>> -->
7171

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

Lines changed: 7 additions & 5 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); // SortedMap 不允许 key = null
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); // SortedMap 不允许 key = null
138138
// 字段名映射配置 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
139139

140140
ColumnUtil.init();
@@ -302,10 +302,12 @@ public String getDBPassword() {
302302
protected void onGetCrossJoinString(Join j) throws UnsupportedOperationException {
303303
// 开启 CROSS JOIN 笛卡尔积联表 super.onGetCrossJoinString(j);
304304
}
305+
305306
@Override
306-
protected void onJoinNotRelation(String sql, String quote, Join j, String jt, List<On> onList, On on) {
307-
// 开启 JOIN ON t1.c1 != t2.c2 等不等式关联 super.onJoinNotRelation(sql, quote, j, jt, onList, on);
307+
protected void onJoinNotRelation(String sql, String quote, Join join, String table, List<On> onList, On on) {
308+
// 开启 JOIN ON t1.c1 != t2.c2 等不等式关联 super.onJoinNotRelation(sql, quote, join, table, onList, on);
308309
}
310+
309311
@Override
310312
protected void onJoinComplextRelation(String sql, String quote, Join j, String jt, List<On> onList, On on) {
311313
// 开启 JOIN ON t1.c1 LIKE concat('%', t2.c2, '%') 等复杂关联 super.onJoinComplextRelation(sql, quote, j, jt, onList, on);

APIJSON-Java-Server/APIJSONBoot-BigData/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
}

APIJSON-Java-Server/APIJSONDemo-ClickHouse/pom.xml

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

66
<groupId>apijson.demo</groupId>
77
<artifactId>apijson-demo</artifactId>
8-
<version>6.1.0</version>
8+
<version>6.2.0</version>
99

1010
<name>APIJSONDemo-ClickHouse</name>
1111
<description>Demo project for testing APIJSON server based on SpringBoot</description>
@@ -45,12 +45,12 @@
4545
<dependency>
4646
<groupId>com.github.Tencent</groupId>
4747
<artifactId>APIJSON</artifactId>
48-
<version>6.1.0</version>
48+
<version>6.2.0</version>
4949
</dependency>
5050
<dependency>
5151
<groupId>com.github.APIJSON</groupId>
5252
<artifactId>apijson-framework</artifactId>
53-
<version>6.1.0</version>
53+
<version>6.2.0</version>
5454
</dependency>
5555

5656
<!-- Oracle, SQLServer 等其它数据库的 JDBC 驱动,可以在这里加上 Maven 依赖或 libs 目录放 Jar 包并依赖 -->
@@ -69,10 +69,6 @@
6969
<plugin>
7070
<groupId>org.springframework.boot</groupId>
7171
<artifactId>spring-boot-maven-plugin</artifactId>
72-
<configuration>
73-
<fork>true</fork>
74-
<mainClass>apijson.demo.DemoApplication</mainClass>
75-
</configuration>
7672
<executions>
7773
<execution>
7874
<goals>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
* 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
2626
* @author Lemon
2727
*/
28-
public class DemoSQLConfig extends APIJSONSQLConfig {
28+
public class DemoSQLConfig extends APIJSONSQLConfig<Long> {
2929

3030
static {
3131
DEFAULT_DATABASE = DATABASE_CLICKHOUSE; // TODO 默认数据库类型,改成你自己的

APIJSON-Java-Server/APIJSONDemo-Druid/pom.xml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<groupId>apijson.demo</groupId>
77
<artifactId>apijson-demo-druid</artifactId>
88
<packaging>jar</packaging>
9-
<version>6.1.0</version>
9+
<version>6.2.0</version>
1010

1111
<name>APIJSONDemo-Druid</name>
1212
<description>Demo project for Testing APIJSON Server based on SpringBoot</description>
@@ -22,12 +22,12 @@
2222
<dependency>
2323
<groupId>com.github.Tencent</groupId>
2424
<artifactId>APIJSON</artifactId>
25-
<version>6.1.0</version>
25+
<version>6.2.0</version>
2626
</dependency>
2727
<dependency>
2828
<groupId>com.github.APIJSON</groupId>
2929
<artifactId>apijson-framework</artifactId>
30-
<version>6.1.0</version>
30+
<version>6.2.0</version>
3131
</dependency>
3232

3333
<!-- 需要用的数据库 JDBC 驱动 -->
@@ -64,10 +64,6 @@
6464
<plugin>
6565
<groupId>org.springframework.boot</groupId>
6666
<artifactId>spring-boot-maven-plugin</artifactId>
67-
<configuration>
68-
<fork>true</fork>
69-
<mainClass>apijson.demo.DemoApplication</mainClass>
70-
</configuration>
7167
<executions>
7268
<execution>
7369
<goals>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
* 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
2424
* @author Lemon
2525
*/
26-
public class DemoSQLConfig extends APIJSONSQLConfig {
26+
public class DemoSQLConfig extends APIJSONSQLConfig<Long> {
2727

2828
static {
2929
DEFAULT_DATABASE = DATABASE_MYSQL; // TODO 默认数据库类型,改成你自己的

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
* 具体见 https://github.com/Tencent/APIJSON/issues/151
2727
* @author Lemon
2828
*/
29-
public class DemoSQLExecutor extends APIJSONSQLExecutor {
29+
public class DemoSQLExecutor extends APIJSONSQLExecutor<Long> {
3030
public static final String TAG = "DemoSQLExecutor";
3131

3232
// 适配连接池,如果这里能拿到连接池的有效 Connection,则 SQLConfig 不需要配置 dbVersion, dbUri, dbAccount, dbPassword

APIJSON-Java-Server/APIJSONDemo-Elasticsearch/pom.xml

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

66
<groupId>apijson.demo</groupId>
77
<artifactId>apijson-demo</artifactId>
8-
<version>6.1.0</version>
8+
<version>6.2.0</version>
99

1010
<name>APIJSONDemo-Elasticsearch</name>
1111
<description>Demo project for testing APIJSON server based on SpringBoot</description>
@@ -21,12 +21,12 @@
2121
<dependency>
2222
<groupId>com.github.Tencent</groupId>
2323
<artifactId>APIJSON</artifactId>
24-
<version>6.1.0</version>
24+
<version>6.2.0</version>
2525
</dependency>
2626
<dependency>
2727
<groupId>com.github.APIJSON</groupId>
2828
<artifactId>apijson-framework</artifactId>
29-
<version>6.1.0</version>
29+
<version>6.2.0</version>
3030
</dependency>
3131

3232
<!-- 需要用的数据库 JDBC 驱动 -->
@@ -52,10 +52,6 @@
5252
<plugin>
5353
<groupId>org.springframework.boot</groupId>
5454
<artifactId>spring-boot-maven-plugin</artifactId>
55-
<configuration>
56-
<fork>true</fork>
57-
<mainClass>apijson.demo.DemoApplication</mainClass>
58-
</configuration>
5955
<executions>
6056
<execution>
6157
<goals>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
* 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
2626
* @author Lemon
2727
*/
28-
public class DemoSQLConfig extends APIJSONSQLConfig {
28+
public class DemoSQLConfig extends APIJSONSQLConfig<Long> {
2929

3030
static {
3131
DEFAULT_DATABASE = DATABASE_ELASTICSEARCH; // TODO 默认数据库类型,改成你自己的

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy