generate-dac 1.0.5 → 1.0.6
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/dist/DAC_Utils.js +21 -0
- package/dist/utils/excel-utils.js +7 -1
- package/package.json +1 -1
- package/src/DAC_Utils.ts +26 -2
- package/src/utils/excel-utils.ts +9 -2
package/dist/DAC_Utils.js
CHANGED
|
@@ -36,6 +36,14 @@ function get_SqlDbType(type) {
|
|
|
36
36
|
sqlType: 'int'
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
|
+
if (type === 'date') {
|
|
40
|
+
return {
|
|
41
|
+
type: 'Date',
|
|
42
|
+
codeType: 'DateTime',
|
|
43
|
+
codeGetMethodType: 'GetDateTime',
|
|
44
|
+
sqlType: 'date'
|
|
45
|
+
};
|
|
46
|
+
}
|
|
39
47
|
if (type === 'money') {
|
|
40
48
|
return {
|
|
41
49
|
type: 'Money',
|
|
@@ -64,6 +72,18 @@ function get_SqlDbType(type) {
|
|
|
64
72
|
sqlType: "nvarchar(".concat(length_1, ")")
|
|
65
73
|
};
|
|
66
74
|
}
|
|
75
|
+
var decimalReg = /Decimal\(([^\(\)]+)\)/i;
|
|
76
|
+
if (decimalReg.test(type)) {
|
|
77
|
+
var match = decimalReg.exec(type);
|
|
78
|
+
var length_2 = match ? match[1] : 250;
|
|
79
|
+
return {
|
|
80
|
+
type: 'Decimal',
|
|
81
|
+
option: length_2,
|
|
82
|
+
codeType: 'decimal',
|
|
83
|
+
codeGetMethodType: 'GetDecimal',
|
|
84
|
+
sqlType: "decimal(".concat(length_2, ")")
|
|
85
|
+
};
|
|
86
|
+
}
|
|
67
87
|
if (/DateTime/i.test(type)) {
|
|
68
88
|
return {
|
|
69
89
|
type: 'DateTime',
|
|
@@ -455,6 +475,7 @@ function DAC_Generate_From_XLSX(filePath, sheetIndex) {
|
|
|
455
475
|
var outputFolder = (0, file_utils_1.get_filename_without_extension)(filePath);
|
|
456
476
|
console.log("DAC_Generate_From_XLSX: ".concat(outputFolder).yellow);
|
|
457
477
|
var sheets = (0, excel_utils_1.json_read_all_sheets_from_excel)(filePath, { sheetIndex: sheetIndex, transformColumnName: true });
|
|
478
|
+
(0, excel_utils_1.json_to_file)(filePath.replace('xlsx', 'json'), sheets);
|
|
458
479
|
var schemas = [];
|
|
459
480
|
var stores = [];
|
|
460
481
|
var dropTables = [];
|
|
@@ -86,9 +86,15 @@ function json_read_all_sheets_from_excel(path, options) {
|
|
|
86
86
|
}
|
|
87
87
|
tmps_2.push(tmp);
|
|
88
88
|
});
|
|
89
|
+
if (options && options.disableClean) {
|
|
90
|
+
return {
|
|
91
|
+
name: sheetName,
|
|
92
|
+
data: tmps_2
|
|
93
|
+
};
|
|
94
|
+
}
|
|
89
95
|
return {
|
|
90
96
|
name: sheetName,
|
|
91
|
-
data: tmps_2
|
|
97
|
+
data: array_clean_data(tmps_2)
|
|
92
98
|
};
|
|
93
99
|
}
|
|
94
100
|
}
|
package/package.json
CHANGED
package/src/DAC_Utils.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import dayjs from "dayjs";
|
|
2
|
-
import { SheetData, json_read_all_sheets_from_excel} from "./utils/excel-utils";
|
|
2
|
+
import { SheetData, json_read_all_sheets_from_excel, json_to_file} from "./utils/excel-utils";
|
|
3
3
|
import { str_className, str_plural } from "./utils/str-utils";
|
|
4
4
|
import { ColumnSchema } from "./interface";
|
|
5
5
|
import { __parent_dir, dir_create, file_exists, get_filename_without_extension, str_to_file, text_from_file } from "./utils/file_utils";
|
|
@@ -27,7 +27,7 @@ export function binding_template(content: string, data: any){
|
|
|
27
27
|
return result;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
export type SqlDbTypeType = '' | 'Int' | 'TinyInt' | 'NVarChar' | 'DateTime' | 'Bit' | 'Money';
|
|
30
|
+
export type SqlDbTypeType = '' | 'Int' | 'TinyInt' | 'NVarChar' | 'DateTime' | 'Bit' | 'Money' | 'Decimal' | 'Date';
|
|
31
31
|
export type CSharpType = 'int' | 'string' | 'DateTime' | 'bool' | 'decimal';
|
|
32
32
|
export type CShareGetMethodType = '' | 'GetDateTime' | 'GetInt32' | 'GetBoolean' | 'GetString' | 'GetByte' | 'GetDecimal';
|
|
33
33
|
|
|
@@ -52,6 +52,15 @@ export function get_SqlDbType(type: string): SqlDbType{
|
|
|
52
52
|
};
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
+
if(type === 'date'){
|
|
56
|
+
return {
|
|
57
|
+
type: 'Date',
|
|
58
|
+
codeType: 'DateTime',
|
|
59
|
+
codeGetMethodType: 'GetDateTime',
|
|
60
|
+
sqlType: 'date'
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
55
64
|
if(type === 'money'){
|
|
56
65
|
return {
|
|
57
66
|
type: 'Money',
|
|
@@ -82,6 +91,19 @@ export function get_SqlDbType(type: string): SqlDbType{
|
|
|
82
91
|
};
|
|
83
92
|
}
|
|
84
93
|
|
|
94
|
+
const decimalReg = /Decimal\(([^\(\)]+)\)/i;
|
|
95
|
+
if(decimalReg.test(type)){
|
|
96
|
+
const match = decimalReg.exec(type);
|
|
97
|
+
const length = match ? match[1] : 250;
|
|
98
|
+
return {
|
|
99
|
+
type: 'Decimal',
|
|
100
|
+
option: length,
|
|
101
|
+
codeType: 'decimal',
|
|
102
|
+
codeGetMethodType: 'GetDecimal',
|
|
103
|
+
sqlType: `decimal(${length})`
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
85
107
|
if(/DateTime/i.test(type)){
|
|
86
108
|
return {
|
|
87
109
|
type: 'DateTime',
|
|
@@ -600,6 +622,8 @@ export function DAC_Generate_From_XLSX(filePath: string, sheetIndex: number = 0)
|
|
|
600
622
|
|
|
601
623
|
const sheets: SheetData[] = json_read_all_sheets_from_excel(filePath, { sheetIndex: sheetIndex, transformColumnName: true });
|
|
602
624
|
|
|
625
|
+
json_to_file(filePath.replace('xlsx', 'json'), sheets);
|
|
626
|
+
|
|
603
627
|
const schemas: string[] = [];
|
|
604
628
|
const stores: string[] = [];
|
|
605
629
|
const dropTables: string[] = [];
|
package/src/utils/excel-utils.ts
CHANGED
|
@@ -113,10 +113,17 @@ export function json_read_all_sheets_from_excel(path: string, options?: Json_rea
|
|
|
113
113
|
tmps.push(tmp);
|
|
114
114
|
});
|
|
115
115
|
|
|
116
|
+
if(options && options.disableClean){
|
|
117
|
+
return {
|
|
118
|
+
name: sheetName,
|
|
119
|
+
data: tmps
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
|
|
116
123
|
return {
|
|
117
124
|
name: sheetName,
|
|
118
|
-
data: tmps
|
|
119
|
-
}
|
|
125
|
+
data: array_clean_data(tmps)
|
|
126
|
+
}
|
|
120
127
|
}
|
|
121
128
|
}
|
|
122
129
|
|