vue2server7 2.3.0 → 2.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/test/{2.js → 3.js} +15 -20
- package/test/NotepadNext-v0.13-win64.zip +0 -0
package/package.json
CHANGED
package/test/{2.js → 3.js}
RENAMED
|
@@ -2,7 +2,7 @@ const fs = require("fs");
|
|
|
2
2
|
|
|
3
3
|
const content = fs.readFileSync("input.txt", "utf8");
|
|
4
4
|
|
|
5
|
-
// Java → TS
|
|
5
|
+
// Java → TS 类型
|
|
6
6
|
function javaToTsType(javaType) {
|
|
7
7
|
const map = {
|
|
8
8
|
String: "string",
|
|
@@ -19,7 +19,7 @@ function javaToTsType(javaType) {
|
|
|
19
19
|
return map[javaType] || "any";
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
//
|
|
22
|
+
// 默认值
|
|
23
23
|
function defaultValue(tsType) {
|
|
24
24
|
switch (tsType) {
|
|
25
25
|
case "string":
|
|
@@ -33,7 +33,6 @@ function defaultValue(tsType) {
|
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
// 匹配注解 + 字段
|
|
37
36
|
const regex =
|
|
38
37
|
/@ApiModelProperty\s*\(\s*value\s*=\s*"([^"]+)"[^)]*\)\s*[\r\n]+\s*private\s+(\w+)\s+(\w+)\s*;/g;
|
|
39
38
|
|
|
@@ -51,30 +50,26 @@ while ((match = regex.exec(content)) !== null) {
|
|
|
51
50
|
const tsType = javaToTsType(javaType);
|
|
52
51
|
|
|
53
52
|
// JSON
|
|
54
|
-
jsonResult.push({
|
|
55
|
-
field,
|
|
56
|
-
label
|
|
57
|
-
});
|
|
53
|
+
jsonResult.push({ field, label });
|
|
58
54
|
|
|
59
55
|
// TS
|
|
60
56
|
tsFields.push(` /** ${label} */\n ${field}: ${tsType};`);
|
|
61
57
|
|
|
62
|
-
// JS
|
|
63
|
-
formFields.push(` ${field}: ${defaultValue(tsType)}`);
|
|
58
|
+
// JS 表单对象(带注释)
|
|
59
|
+
formFields.push(` /** ${label} */\n ${field}: ${defaultValue(tsType)}`);
|
|
64
60
|
}
|
|
65
61
|
|
|
66
|
-
//
|
|
62
|
+
// 写文件
|
|
67
63
|
fs.writeFileSync("output.json", JSON.stringify(jsonResult, null, 2));
|
|
68
64
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
65
|
+
fs.writeFileSync(
|
|
66
|
+
"model.ts",
|
|
67
|
+
`export interface Model {\n${tsFields.join("\n\n")}\n}\n`
|
|
68
|
+
);
|
|
72
69
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
70
|
+
fs.writeFileSync(
|
|
71
|
+
"form.js",
|
|
72
|
+
`export const formModel = {\n${formFields.join(",\n\n")}\n};\n`
|
|
73
|
+
);
|
|
76
74
|
|
|
77
|
-
console.log("✅
|
|
78
|
-
console.log(" - output.json");
|
|
79
|
-
console.log(" - model.ts");
|
|
80
|
-
console.log(" - form.js");
|
|
75
|
+
console.log("✅ 已生成 output.json / model.ts / form.js");
|
|
Binary file
|