GeezerVison is showing github.com — 升级自身, apijson-framework 至 5.1.1,升级 apijson-router 至 1.0.1;解决 PostgreS… · hpdx/APIJSON-Demo@6e288c7
File treeExpand file treeCollapse file tree Open diff view settings APIJSONBoot-MultiDataSource src/main/java/apijson/demo
Some content is hiddenLarge Commits have some content hidden by default. Use the searchbox below for content that may be hidden. Dismiss bannerExpand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboard Collapse file Copy file name to clipboard Collapse file Copy file name to clipboard Collapse file Copy file name to clipboard Collapse file Copy file name to clipboardExpand all lines: APIJSON-Java-Server/APIJSONBoot-MultiDataSource/pom.xml +20-13Lines changed: 20 additions & 13 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 5 | 5 |
| 6 | 6 | <groupId>apijson.boot</groupId> | 7 | 7 | <artifactId>apijson-boot-multi-datasource</artifactId> | 8 | | - <version>5.1.0</version> | | 8 | + <version>5.1.1</version> | 9 | 9 | <!-- <packaging>jar</packaging> --> | 10 | 10 |
| 11 | 11 | <name>APIJSONBoot-MultiDataSource</name> | | 18 | 18 | </properties> | 19 | 19 |
| 20 | 20 | <dependencies> | | 21 | + <!-- JDK 11+ 需要,否则启动报错 NoClassDefFoundError: javax/activation/UnsupportedDataTypeException --> | | 22 | + <dependency> | | 23 | + <groupId>javax.activation</groupId> | | 24 | + <artifactId>activation</artifactId> | | 25 | + <version>1.1.1</version> | | 26 | + </dependency> | | 27 | + | 21 | 28 | <!-- APIJSON 需要用的依赖库,1.2.0 以上 --> | 22 | 29 | <dependency> | 23 | 30 | <groupId>com.alibaba</groupId> | | 32 | 39 | <version>4.0.1</version> | 33 | 40 | </dependency> | 34 | 41 |
| 35 | | - <!-- 单元测试:可使用 libs 目录的 unitauto-java.jar 和 unitauto-jar.jar 来替代,两种方式二选一 | | 42 | + <!-- 单元测试:可使用 libs 目录的 unitauto-java.jar 和 unitauto-jar.jar 来替代,两种方式二选一 | 36 | 43 | <<<<<<<<< --> | 37 | 44 | <dependency> | 38 | 45 | <groupId>com.github.TommyLemon</groupId> | | 47 | 54 | <dependency> | 48 | 55 | <groupId>io.github.classgraph</groupId> | 49 | 56 | <artifactId>classgraph</artifactId> | 50 | | - <version>4.8.87</version> | | 57 | + <version>4.8.146</version> | 51 | 58 | </dependency> | 52 | 59 | <!-- 单元测试:可使用 libs 目录的 unitauto-java.jar 和 unitauto-jar.jar 来替代,两种方式二选一 >>>>>>>>> --> | 53 | 60 |
| 54 | 61 |
| 55 | 62 | <!-- 可使用 libs 目录的 apijson-orm.jar, apijson-framework.jar, apijson-column.jar 来替代,两种方式二选一 <<<<<<<<<< --> | 56 | | - <dependency> | | 63 | + <!-- <dependency> | 57 | 64 | <groupId>com.github.Tencent</groupId> | 58 | 65 | <artifactId>APIJSON</artifactId> | 59 | 66 | <version>5.1.0</version> | 60 | 67 | </dependency> | 61 | 68 | <dependency> | 62 | 69 | <groupId>com.github.APIJSON</groupId> | 63 | 70 | <artifactId>apijson-framework</artifactId> | 64 | | - <version>5.1.0</version> | | 71 | + <version>5.1.1</version> | 65 | 72 | </dependency> | 66 | 73 | <dependency> | 67 | 74 | <groupId>com.github.APIJSON</groupId> | | 71 | 78 | <dependency> | 72 | 79 | <groupId>com.github.APIJSON</groupId> | 73 | 80 | <artifactId>apijson-router</artifactId> | 74 | | - <version>1.0.0</version> | 75 | | - </dependency> | | 81 | + <version>1.0.1</version> | | 82 | + </dependency> --> | 76 | 83 | <!-- 可使用 libs 目录的 apijson-orm.jar, apijson-framework.jar, apijson-column.jar 来替代,两种方式二选一 >>>>>>>>>> --> | 77 | 84 |
| 78 | 85 | <!-- 需要用的数据库 JDBC 驱动 --> | 79 | 86 | <dependency> | 80 | 87 | <groupId>mysql</groupId> | 81 | 88 | <artifactId>mysql-connector-java</artifactId> | 82 | | - <version>8.0.27</version> | | 89 | + <version>8.0.29</version> | 83 | 90 | </dependency> | 84 | 91 | <dependency> | 85 | 92 | <groupId>org.postgresql</groupId> | 86 | 93 | <artifactId>postgresql</artifactId> | 87 | | - <version>42.2.18</version> | | 94 | + <version>42.3.4</version> | 88 | 95 | </dependency> | 89 | 96 | <dependency> | 90 | 97 | <groupId>net.sourceforge.jtds</groupId> | | 99 | 106 | <dependency> | 100 | 107 | <groupId>org.springframework.boot</groupId> | 101 | 108 | <artifactId>spring-boot-starter-web</artifactId> | 102 | | - <version>2.4.2</version> | | 109 | + <version>2.6.7</version> | 103 | 110 | </dependency> | 104 | 111 |
| 105 | 112 | <!-- 需要用的 HikariCP 数据库连接池库,3.1.0 以上 --> | 106 | 113 | <dependency> | 107 | 114 | <groupId>com.zaxxer</groupId> | 108 | 115 | <artifactId>HikariCP</artifactId> | 109 | | - <version>3.1.0</version> | | 116 | + <version>5.0.1</version> | 110 | 117 | </dependency> | 111 | 118 |
| 112 | 119 | <!-- 需要用的 Druid 数据库连接池库,1.0.29 以上 --> | 113 | 120 | <dependency> | 114 | 121 | <groupId>com.alibaba</groupId> | 115 | 122 | <artifactId>druid</artifactId> | 116 | | - <version>1.0.29</version> | | 123 | + <version>1.2.9</version> | 117 | 124 | </dependency> | 118 | | - | | 125 | + | 119 | 126 | </dependencies> | 120 | 127 |
| 121 | 128 | <build> | |
Collapse file Copy file name to clipboardExpand all lines: APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/java/apijson/demo/DemoSQLConfig.java +12-9Lines changed: 12 additions & 9 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 37 | 37 |
| 38 | 38 | /**SQL配置 | 39 | 39 | * TiDB 用法和 MySQL 一致 | 40 | | - * 具体见详细的说明文档 C.开发说明 C-1-1.修改数据库链接 | | 40 | + * 具体见详细的说明文档 C.开发说明 C-1-1.修改数据库链接 | 41 | 41 | * 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 | 42 | 42 | * @author Lemon | 43 | 43 | */ | @@ -52,7 +52,7 @@ public DemoSQLConfig(RequestMethod method, String table) { | 52 | 52 |
| 53 | 53 | static { | 54 | 54 | DEFAULT_DATABASE = DATABASE_MYSQL; //TODO 默认数据库类型,改成你自己的。TiDB, MariaDB, OceanBase 这类兼容 MySQL 的可当做 MySQL 使用 | 55 | | - DEFAULT_SCHEMA = "sys"; //TODO 默认数据库名/模式,改成你自己的,默认情况是 MySQL: sys, PostgreSQL: public, SQL Server: dbo, Oracle: | | 55 | + DEFAULT_SCHEMA = "sys"; //TODO 默认数据库名/模式,改成你自己的,默认情况是 MySQL: sys, PostgreSQL: sys, SQL Server: dbo, Oracle: | 56 | 56 |
| 57 | 57 | //表名和数据库不一致的,需要配置映射关系。只使用 APIJSONORM 时才需要; | 58 | 58 | //这个 Demo 用了 apijson-framework 且调用了 APIJSONApplication.init | @@ -97,7 +97,11 @@ public String getUserIdKey(String database, String schema, String datasource, St | 97 | 97 | // } | 98 | 98 | }; | 99 | 99 |
| 100 | | - // 自定义原始 SQL 片段,其它功能满足不了时才用它,只有 RAW_MAP 配置了的 key 才允许前端传 | | 100 | + // PostgreSQL 表结构相关 SQL 函数,用于 APIAuto 查询和展示文档 | | 101 | + SQL_FUNCTION_MAP.put("obj_description", ""); | | 102 | + SQL_FUNCTION_MAP.put("col_description", ""); | | 103 | + | | 104 | + // 自定义原始 SQL 片段,其它功能满足不了时才用它,只有 RAW_MAP 配置了的 key 才允许前端传 | 101 | 105 | RAW_MAP.put("`to`.`id`", ""); // 空字符串 "" 表示用 key 的值 `to`.`id` | 102 | 106 | RAW_MAP.put("to.momentId", "`to`.`momentId`"); // 最终以 `to`.`userId` 拼接 SQL,相比以上写法可以让前端写起来更简单 | 103 | 107 | RAW_MAP.put("(`Comment`.`userId`=`to`.`userId`)", ""); // 已经是一个条件表达式了,用 () 包裹是为了避免 JSON 中的 key 拼接在前面导致 SQL 出错 | @@ -106,9 +110,8 @@ public String getUserIdKey(String database, String schema, String datasource, St | 106 | 110 | RAW_MAP.put("substring_index(substring_index(content,',',1),',',-1)", ""); // APIAuto 不支持 ',可以用 Postman 测 | 107 | 111 | RAW_MAP.put("substring_index(substring_index(content,'.',1),'.',-1) AS subContent", ""); // APIAuto 不支持 ',可以用 Postman 测 | 108 | 112 | RAW_MAP.put("commentWhereItem1","(`Comment`.`userId` = 38710 AND `Comment`.`momentId` = 470)"); | 109 | | - RAW_MAP.put("to_days(now())-to_days(`date`)<=7",""); // 给 @having 使用 | 110 | | - RAW_MAP.put("sexShowStr","CASE sex WHEN 0 THEN '男' WHEN 1 THEN '女' ELSE '其它' END"); // 给 @having 使用 | 111 | | - | | 113 | + RAW_MAP.put("to_days(now())-to_days(`date`)<=7", ""); // 给 @having 使用 | | 114 | + RAW_MAP.put("sexShowStr", "CASE sex WHEN 0 THEN '男' WHEN 1 THEN '女' ELSE '其它' END"); // 给 @having 使用 | 112 | 115 |
| 113 | 116 | // 取消注释支持 !key 反选字段 和 字段名映射,需要先依赖插件 https://github.com/APIJSON/apijson-column | 114 | 117 |
| @@ -286,7 +289,7 @@ public String getDBPassword() { | 286 | 289 | // preparedValueList.add(value); | 287 | 290 | // } | 288 | 291 | // return "to_date(" + (isPrepared() ? "?" : getSQLValue(value)) + ",'yyyy-mm-dd hh24:mi:ss')"; | 289 | | - // } | | 292 | + // } | 290 | 293 | // catch (Throwable e) { | 291 | 294 | // if (Log.DEBUG) { | 292 | 295 | // e.printStackTrace(); | @@ -295,8 +298,8 @@ public String getDBPassword() { | 295 | 298 | // } | 296 | 299 | // return super.getValue(value); | 297 | 300 | // } | 298 | | - | 299 | | - | | 301 | + | | 302 | + | 300 | 303 | @Override | 301 | 304 | protected void onGetCrossJoinString(Join j) throws UnsupportedOperationException { | 302 | 305 | // 开启 CROSS JOIN 笛卡尔积联表 super.onGetCrossJoinString(j); | |
Collapse file Copy file name to clipboardExpand all lines: APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/resources/static/js/main.js +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 2994 | 2994 | 'randomId': 0, | 2995 | 2995 | '@order': 'date-', | 2996 | 2996 | '@column': 'id,userId,documentId,duration,minDuration,maxDuration,response' + (this.isMLEnabled ? ',standard' : ''), | 2997 | | - '@having': this.isMLEnabled ? 'length(standard)>2' : null //用 MySQL 5.6 '@having': this.isMLEnabled ? 'json_length(standard)>0' : null | | 2997 | + 'len{}': this.isMLEnabled ? 'length(standard)>2' : null //用 MySQL 5.6 '@having': this.isMLEnabled ? 'json_length(standard)>0' : null | 2998 | 2998 | } | 2999 | 2999 | }, | 3000 | 3000 | '@role': 'LOGIN' | @@ -6248,7 +6248,7 @@ Content-Type: ` + contentType) + (StringUtil.isEmpty(headerStr, true) ? '' : hea | 6248 | 6248 | 'host': this.getBaseUrl(), | 6249 | 6249 | '@order': 'date-', | 6250 | 6250 | '@column': 'id,userId,testAccountId,documentId,randomId,duration,minDuration,maxDuration,response' + (this.isMLEnabled ? ',standard' : ''), | 6251 | | - '@having': this.isMLEnabled ? 'length(standard)>2' : null // '@having': this.isMLEnabled ? 'json_length(standard)>0' : null | | 6251 | + 'len{}': this.isMLEnabled ? 'length(standard)>2' : null // '@having': this.isMLEnabled ? 'json_length(standard)>0' : null | 6252 | 6252 | } | 6253 | 6253 | }, {}, function (url, res, err) { | 6254 | 6254 | App.onResponse(url, res, err) | |
Collapse file Copy file name to clipboard Collapse file Copy file name to clipboard Collapse file Copy file name to clipboard
|