Skip to content

Commit a1c8be5

Browse files
committed
Java:MultiDataSource 更新 APIAuto;DemoSQLExecutor 新增 isHideColumn 的说明
1 parent f9e49be commit a1c8be5

File tree

8 files changed

+6398
-6040
lines changed

8 files changed

+6398
-6040
lines changed

APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/java/apijson/boot/DemoApplication.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ public static void main(String[] args) throws Exception {
248248
unitauto.Log.DEBUG = Log.DEBUG = true;
249249
APIJSONParser.IS_PRINT_BIG_LOG = true;
250250
APIJSONApplication.init();
251+
System.out.println("\n\n<<<<<<<<< 本 Demo 在 resources/static 内置了 APIAuto,Chrome/Firefox 打开 http://localhost:8080 即可调试(端口号根据项目配置而定) ^_^ >>>>>>>>>\n");
251252
}
252253

253254
// SpringBoot 2.x 自定义端口方式

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,4 +105,11 @@ public Connection getConnection(SQLConfig config) throws Exception {
105105
// return ColumnUtil.compatOutputKey(super.getKey(config, rs, rsmd, tablePosition, table, columnIndex, childMap), config.getTable(), config.getMethod());
106106
// }
107107

108+
// 不需要隐藏字段这个功能时,取消注释来提升性能
109+
// @Override
110+
// protected boolean isHideColumn(SQLConfig config, ResultSet rs, ResultSetMetaData rsmd, int tablePosition,
111+
// JSONObject table, int columnIndex, Map<String, JSONObject> childMap) throws SQLException {
112+
// return false;
113+
// }
114+
108115
}

APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/resources/static/apijson/CodeUtil.js

Lines changed: 253 additions & 118 deletions
Large diffs are not rendered by default.

APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/resources/static/apijson/JSONRequest.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
const TAG_REQUEST_UTIL = 'RequestUtil';
2222

23-
var URL_BASE = "http://localhost:8080"; // 基地址
23+
var URL_BASE = "http://localhost:8080"; // "http://apijson.cn:8080";// 基地址
2424
var URL_GET = URL_BASE + "/get"; // 常规获取数据方式
2525
var URL_HEAD = URL_BASE + "/head"; // 检查,默认是非空检查,返回数据总数
2626
var URL_GETS = URL_BASE + "/gets"; // 通过POST来GET数据,不显示请求内容和返回结果,一般用于对安全要求比较高的请求

APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/resources/static/apijson/JSONResponse.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ var JSONResponse = {
484484
if (type != typeof real) { //类型改变
485485
return {
486486
code: JSONResponse.COMPARE_TYPE_CHANGE,
487-
msg: '值改变',
487+
msg: '值类型改变',
488488
path: folder,
489489
value: real
490490
};
@@ -1037,7 +1037,7 @@ var JSONResponse = {
10371037
// log('updateStandard for k2 in values[0] = ' + k2 + ' >>');
10381038
if (realKeys.indexOf(k2) < 0) {
10391039
// log('updateStandard Object.keys(real).indexOf(k2) < 0 >> real[k2] = null;');
1040-
real[k2] = null; //TODO delete real[k2] ? 避免多出来 key: null 这种
1040+
delete real[k2]; // real[k2] = null; //TODO delete real[k2] ? 避免多出来 key: null 这种
10411041
}
10421042
}
10431043

APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/resources/static/index.html

Lines changed: 96 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@
159159
</svg>
160160
</a>
161161
</div>
162-
<div v-show="isTestCaseShow" style="bottom: 4px; padding: 4px 13px 0px 10px; position: absolute; width: 100%; text-align: right; background-color: white; z-index: 100">
162+
<div v-show="isTestCaseShow && ! isLocalShow" style="bottom: 4px; padding: 4px 13px 0px 10px; position: absolute; width: 100%; text-align: right; background-color: white; z-index: 100">
163163
<a >搜索</a>
164164
<input id="vTestCaseSearch" v-model="testCaseSearch" style="min-width: 60px; display: inline-flex; text-align: center" @keyup="doOnKeyUp(event, 'testCase', true)" />
165165
<button @click="pageDown('testCase')">上一页</button>
@@ -193,7 +193,72 @@
193193
<div v-show="! isPreviewEnabled" style="width: 100%;height: 100%;position: absolute;display: flex;flex-grow: 1" >
194194
<textarea id="vComment" style="width: 100%; height: 100%; position: absolute; z-index: 0; color: darkseagreen; background-color: white;" wrap="off" disabled>
195195
</textarea>
196-
<textarea id="vInput" @keyup="onChange(true)" style="width: 100%;height: 100%; position: absolute; z-index: 100; background: #0000;" wrap="off" >
196+
<textarea v-show="! isEditResponse" id="vWarning" style="width: 100%; height: 100%; position: absolute; z-index: 0; color: orangered; background-color: #0000;" wrap="off" disabled>
197+
</textarea>
198+
<textarea id="vInput" @keyup="onChange(true)" style="width: 100%;height: 100%; position: absolute; z-index: 100; background: #0000;" wrap="off" placeholder="{ // 根对象,可在内部加 format,tag,version,@role,@database,@schema,@datasource,@explain,@cache 等全局关键词键值对
199+
'[]': { // 数组,可在内部加 count,page,query,join 等关键词键值对
200+
'count': 5, // 每页数量
201+
'page': 0, // 分页页码
202+
'join': '</User/id@', // 多表连接:LEFT JOIN User,同一层级必须有 'User':{ 'id@':'/../..' }
203+
'Moment': { // 动态
204+
'@order': 'date+', // 排序方式:+升序,-降序
205+
'@column': 'id,userId;date_format(date,%Y-%m-%d %H:%m)', // 返回字段,可传 字段(:别名)、SQL 函数(:别名,用分号 ; 隔开)、表达式,以及部分 SQL 关键词
206+
'@explain': true, // 性能分析:true-开启 false-关闭,返回执行的 SQL 及查询计划
207+
'content~': 'o', // 正则匹配 < content: String(300)? 内容
208+
'userId!': 82001, // 都不符合 < userId: Int(15), 用户id
209+
'@combine': 'userId!,content~' // 条件组合,| 可省略。合并同类,外层按照 & | ! 顺序,内层按传参顺序组合成 (key0 & key1 & key6 & 其它key) & (key2 | key3 | key7) & !(key4 | key5)
210+
},
211+
'User': { // 用户公开信息表。 对安全要求高,不想泄漏真实名称。对外名称为 User
212+
'id@': '/Moment/userId', // 引用赋值,从对象父级开始的相对(缺省)路径 < id: Int(15), 唯一标识
213+
'@column': 'id,name,head' // 返回字段,可传 字段(:别名)、SQL 函数(:别名,用分号 ; 隔开)、表达式,以及部分 SQL 关键词
214+
},
215+
'[]': { // 数组,可在内部加 count,page,query,join 等关键词键值对
216+
'count': 6, // 每页数量
217+
'join': '@/User/id@', // 多表连接:APP JOIN User,同一层级必须有 'User':{ 'id@':'/../..' }
218+
'Comment': { // 评论
219+
'@order': 'date-', // 排序方式:+升序,-降序
220+
'momentId@': '[]/Moment/id' // 引用赋值,从最外层开始的绝对(完整)路径 < momentId: Int(15), 动态id
221+
},
222+
'User': { // 用户公开信息表。 对安全要求高,不想泄漏真实名称。对外名称为 User
223+
'id@': '/Comment/userId', // 引用赋值,从对象父级开始的相对(缺省)路径 < id: Int(15), 唯一标识
224+
'@column': 'DISTINCT id,name;concat(%,name,%):concat' // 返回字段,可传 字段(:别名)、SQL 函数(:别名,用分号 ; 隔开)、表达式,以及部分 SQL 关键词
225+
}
226+
}
227+
}
228+
}
229+
230+
/*
231+
JSON 右侧可以写行注释,两个空格加两个斜杆 ' //' 开头;
232+
JSON 下方可以写段注释,'/*' 开头 '*/' 结尾,都在每行最前,
233+
段注释可以是普通文本或 Markdown 格式文本,一般用于枚举值等额外说明。
234+
235+
### 例如一个表格
236+
开发流程 | 传统方式 | APIJSON
237+
--- | --- | ---
238+
实现接口 | 写代码 + 写文档 | 都不用写
239+
兼容旧版 | v2, v3.. 接口 | 都不用写
240+
241+
### 例如一段代码
242+
```js
243+
// 前端解析并打印 Response JSON
244+
var list = data['[]'] || []
245+
for (var i = 0; i < list.length; i ++) {
246+
console.log('[]/' + i + '=' + JSON.stringify(list[i]))
247+
}
248+
```
249+
250+
### 例如一张图片
251+
![](http://apijson.cn/images/logo-big.png)
252+
253+
## 快捷键
254+
Ctrl + I 或 Command + I 格式化 JSON
255+
256+
#### 右上角设置项 > 预览请求输入框,显示对应的预览效果
257+
*/
258+
259+
260+
261+
" >
197262
{
198263
"User": {
199264
"id": 82001
@@ -204,6 +269,19 @@
204269
}
205270
}
206271
}
272+
273+
/*
274+
以上 JSON 文本支持 JSON5 格式。清空文本内容可查看规则。
275+
注释可省略。行注释前必须有两个空格;段注释必须在 JSON 下方。
276+
277+
## 快捷键
278+
Ctrl + I 或 Command + I 格式化 JSON
279+
280+
#### 右上角设置项 > 预览请求输入框,显示对应的预览效果
281+
*/
282+
283+
284+
207285
</textarea>
208286
</div>
209287
<div id="vRequestMarkdown" v-show="isPreviewEnabled" style="width: 100%;height: 100%;position: relative;"></div>
@@ -224,7 +302,7 @@
224302
</a>
225303
<a v-show="(currentRemoteItem || {}).Document != null" class="hint--top @cli-tool" data-hint="添加" style="font-size:xx-large; margin-bottom: 2px; color: black;"
226304
href="javascript:void(0)" @click="if(isRandomListShow || isRandomSubListShow) { randomTestTitle = null; isRandomListShow = false; isRandomSubListShow = false; } else { showExport(true, true, true) }"> + </a>
227-
<a v-show="false" href="javascript:void(0)" style="font-size: small;" class="hint--top" data-hint="共享" @click="showExport(true, true)">
305+
<a v-show="false" href="javascript:void(0)" style="font-size: small;" class="hint--top" data-hint="上传/共享" @click="showExport(true, true)">
228306
<svg class="icon">
229307
<use xlink:href="svg/icon.svg#share"></use>
230308
</svg>
@@ -314,16 +392,16 @@
314392
placeholder="# 常用:
315393
RANDOM_IN(val0:Any, val1:Any ...) // 从选项内随机取值
316394
RANDOM_INT(min:Integer, max:Integer) // 从范围内随机取整数
317-
RANDOM_DB(min:Integer, max:Integer) // 从数据库随机取值
395+
RANDOM_DB(min:Integer, max:Integer, table:String, column:String) // 从数据库随机取值
318396
RANDOM_NUM(min:Number, max:Number, precision:Integer) // 从范围内随机取小数
319397
RANDOM_STR(minLength:Integer, maxLength:Integer, regexp:String) // 从长度范围内随机取字符串
320398
ORDER_IN(val0:Any, val1:Any ...) // 从选项内顺序取值
321399
ORDER_INT(min:Integer, max:Integer) // 从范围内顺序取整数
322-
ORDER_DB(min:Integer, max:Integer) // 从数据库顺序取值
400+
ORDER_DB(min:Integer, max:Integer, table:String, column:String) // 从数据库顺序取值
323401
其中 RANDOM 开头的是随机函数;ORDER 开头的是顺序函数,可以使用 + - 升降序 和 step 跨步,例如 ORDER_IN-(1, 2, 3) 降序取值,ORDER_INT+3(0, 100) 间隔 step = 3 位来升序取整数。
324402
# 模板:
325403
format: ORDER_IN(true, false, null, undefined) // 从选项中顺序取值
326-
User/id id>: RANDOM_DB() // 用 id> 替换 User 内的 id,从数据库随机取值
404+
User/id: RANDOM_DB() // 从数据库随机取值,等价于 User/id: RANDOM_DB(null, null, 'User', 'id')
327405
[]/page: Math.round(100*Math.random()) // 通过 JavaScript 代码来自定义 [] 内的 page
328406
">
329407
User/id: RANDOM_INT(82001, 82020) // 随机整数
@@ -345,7 +423,8 @@
345423
</svg>
346424
</a>
347425
</div>
348-
<textarea id="vHeader" @keyup="onChange(true)" style="width: 100%;height: 100%;" wrap="off" placeholder="Authorization: Basic YWRtaW46YWRtaW4= // 示例,支持单行注释"></textarea>
426+
<textarea id="vHeader" @keyup="onChange(true)" style="width: 100%;height: 100%;" wrap="off" placeholder="Authorization: Basic YWRtaW46YWRtaW4= // 示例,支持单行注释
427+
My-Header: 'Secret' + Math.random() // 示例,代码执行结果作为实际值,值为 fun(arg0, arg1..) 等包含函数名与括号的格式 "></textarea>
349428
</div>
350429

351430
</div>
@@ -379,7 +458,7 @@
379458
<use xlink:href="svg/icon.svg#save"></use>
380459
</svg>
381460
</a>
382-
<ul class="historys pop" style="width: 240px">
461+
<ul class="historys pop" style="width: 304px"> <!-- 没必要太长,遮挡范围过大 // 490 刚好与 URL 输入框左对齐 -->
383462
<li v-for="(his, index) in historys">
384463
<a href="javascript:void(0)" @click="restore(his, his.response)" > {{his.name}}</a>
385464

@@ -422,7 +501,7 @@
422501
</svg>
423502
</a>
424503

425-
<a href="javascript:void(0)" class="hint--top" data-hint="共享" @click="showExport(true, true)">
504+
<a href="javascript:void(0)" class="hint--top" data-hint="上传/共享" @click="showExport(true, true)">
426505
<svg class="icon">
427506
<use xlink:href="svg/icon.svg#share"></use>
428507
</svg>
@@ -722,6 +801,7 @@
722801
<script type="text/javascript" language="JavaScript" charset="UTF-8" src="apijson/JSONResponse.js" ></script>
723802
<script type="text/javascript" language="JavaScript" charset="UTF-8" src="apijson/CodeUtil.js" ></script>
724803
<!-- 必须在main.js前 TODO 可能有冲突,代码写入vue文件? >>>>>>>>>>>>>>>> -->
804+
<script src="https://unpkg.com/json5@^2.0.0/dist/index.min.js"></script>
725805

726806

727807
<script src="js/main.js"></script>
@@ -735,6 +815,7 @@
735815
var vSend = document.getElementById("vSend");
736816

737817
var vInput = document.getElementById("vInput");
818+
var vWarning = document.getElementById("vWarning");
738819
var vComment = document.getElementById("vComment");
739820
var vHeader = document.getElementById("vHeader");
740821
var vRandom = document.getElementById("vRandom");
@@ -766,6 +847,8 @@
766847
function onScrollChanged() {
767848
$(vComment).scrollLeft(vInput.scrollLeft);
768849
$(vComment).scrollTop(vInput.scrollTop);
850+
$(vWarning).scrollLeft(vInput.scrollLeft);
851+
$(vWarning).scrollTop(vInput.scrollTop);
769852
}
770853

771854
//vComment跟随vInput滚动,避免JSON重叠"露馅"
@@ -780,8 +863,11 @@
780863
$(vUrl).on('scroll', onURLScrollChanged);
781864

782865

783-
784866
function markdownToHTML(md, isRequest) {
867+
if (editormd == null) {
868+
return;
869+
}
870+
785871
if (isRequest) {
786872
vRequestMarkdown.innerHTML = '';
787873
}

0 commit comments

Comments
 (0)