Skip to content

Commit 1afd82a

Browse files
committed
Java:更新 APIAuto
1 parent d8ab218 commit 1afd82a

File tree

3 files changed

+42
-62
lines changed

3 files changed

+42
-62
lines changed

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

Lines changed: 1 addition & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -43,56 +43,6 @@ var CodeUtil = {
4343
thirdParty: 'YAPI',
4444
thirdPartyApiMap: null, // {}
4545

46-
parseUri: function (method, isReq) {
47-
method = method || 'get';
48-
var isRestful = true;
49-
50-
if (method.startsWith("/")) {
51-
method = method.substring(1);
52-
}
53-
54-
if (method.endsWith("/")) {
55-
method = method.substring(0, method.length - 1);
56-
}
57-
58-
var startName = null;
59-
var tag = null;
60-
61-
var mIndex = method.lastIndexOf('/');
62-
if (mIndex < 0) {
63-
isRestful = APIJSON_METHODS.indexOf(method) < 0;
64-
}
65-
else if (APIJSON_METHODS.indexOf(method.substring(mIndex+1)) >= 0) {
66-
isRestful = false;
67-
method = method.substring(mIndex+1);
68-
}
69-
else {
70-
var suffix = method.substring(mIndex + 1);
71-
method = method.substring(0, mIndex);
72-
73-
mIndex = method.lastIndexOf("/");
74-
if (mIndex >= 0) {
75-
method = method.substring(mIndex+1);
76-
}
77-
78-
isRestful = APIJSON_METHODS.indexOf(method) < 0;
79-
80-
if (isReq && ! isRestful) {
81-
tag = suffix;
82-
var tbl = tag.endsWith("[]") ? tag.substring(0, tag.length - 2) : tag;
83-
if (JSONObject.isTableKey(tbl)) {
84-
startName = method == 'put' || method == 'delete' ? tbl : tag;
85-
}
86-
}
87-
}
88-
89-
return {
90-
method,
91-
isRestful,
92-
tag,
93-
table: startName
94-
}
95-
},
9646

9747
/**生成JSON的注释 TODO 提取 // 单行注释,补充到 TestRecord 的 standard 中,文档也是有版本的
9848
* @param reqStr //已格式化的JSON String
@@ -109,7 +59,7 @@ var CodeUtil = {
10959

11060
var reqObj = JSON5.parse(reqStr);
11161

112-
var methodInfo = CodeUtil.parseUri(method, isReq) || {};
62+
var methodInfo = JSONObject.parseUri(method, isReq) || {};
11363
var method = methodInfo.method;
11464
var isRestful = methodInfo.isRestful;
11565
var tag = methodInfo.tag;

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

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,13 @@ var JSONObject = {
6262
},
6363

6464
isAPIJSONPath: function (method) {
65-
if (method == null) {
66-
return false;
67-
}
65+
var info = JSONObject.parseUri(method, true)
66+
return info != null && info.isRestful != true;
67+
},
68+
69+
parseUri: function (method, isReq) {
70+
method = method || 'get';
71+
var isRestful = true;
6872

6973
if (method.startsWith("/")) {
7074
method = method.substring(1);
@@ -74,17 +78,43 @@ var JSONObject = {
7478
method = method.substring(0, method.length - 1);
7579
}
7680

77-
var mIndex = method.indexOf('/');
81+
var startName = null;
82+
var tag = null;
83+
84+
var mIndex = method.lastIndexOf('/');
7885
if (mIndex < 0) {
79-
return true;
86+
isRestful = APIJSON_METHODS.indexOf(method) < 0;
8087
}
81-
82-
if (APIJSON_METHODS.indexOf(method.substring(0, mIndex)) >= 0) {
83-
mIndex = method.substring(mIndex + 1).indexOf("/");
84-
return mIndex < 0;
88+
else if (APIJSON_METHODS.indexOf(method.substring(mIndex+1)) >= 0) {
89+
isRestful = false;
90+
method = method.substring(mIndex+1);
91+
}
92+
else {
93+
var suffix = method.substring(mIndex + 1);
94+
method = method.substring(0, mIndex);
95+
96+
mIndex = method.lastIndexOf("/");
97+
if (mIndex >= 0) {
98+
method = method.substring(mIndex+1);
99+
}
100+
101+
isRestful = APIJSON_METHODS.indexOf(method) < 0;
102+
103+
if (isReq && ! isRestful) {
104+
tag = suffix;
105+
var tbl = tag.endsWith("[]") ? tag.substring(0, tag.length - 2) : tag;
106+
if (JSONObject.isTableKey(tbl)) {
107+
startName = method == 'put' || method == 'delete' ? tbl : tag;
108+
}
109+
}
85110
}
86111

87-
return false;
112+
return {
113+
method,
114+
isRestful,
115+
tag,
116+
table: startName
117+
}
88118
}
89119

90120
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,7 @@
696696
host: '',
697697
database: 'MYSQL', // 查文档必须,除非后端提供默认配置接口 // 用后端默认的,避免用户总是没有配置就问为什么没有生成文档和注释 'MYSQL',// 'POSTGRESQL',
698698
schema: 'sys', // 查文档必须,除非后端提供默认配置接口 // 用后端默认的,避免用户总是没有配置就问为什么没有生成文档和注释 'sys',
699-
server: 'http://localhost:8080', // 'http://apijson.cn:9090', // Chrome 90+ 跨域问题非常难搞,开发模式启动都不行了 'http://apijson.org:9090', //apijson.cn
699+
server: 'http://apijson.cn:9090', // Chrome 90+ 跨域问题非常难搞,开发模式启动都不行了 'http://apijson.org:9090', //apijson.cn
700700
// server: 'http://47.74.39.68:9090', // apijson.org
701701
thirdParty: 'SWAGGER /v2/api-docs', //apijson.cn
702702
// thirdParty: 'RAP /repository/joined /repository/get',

0 commit comments

Comments
 (0)