@fastcar/core 0.2.60 → 0.2.61
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 +2 -4
- package/src/model/WinstonLogger.ts +4 -3
- package/src/utils/ClassLoader.ts +1 -1
- package/src/utils/ValidationUtil.ts +10 -1
- package/target/FastCarApplication.js +692 -692
- package/target/annotation/Application.js +45 -45
- package/target/annotation/ExceptionMonitor.js +16 -16
- package/target/annotation/bind/AddRequireModule.js +21 -21
- package/target/annotation/bind/AliasInjection.js +23 -23
- package/target/annotation/bind/Autowired.js +13 -13
- package/target/annotation/bind/CallDependency.js +23 -23
- package/target/annotation/data/DBType.js +11 -11
- package/target/annotation/data/DS.js +54 -54
- package/target/annotation/data/DSIndex.js +9 -9
- package/target/annotation/data/Entity.js +10 -10
- package/target/annotation/data/Field.js +18 -18
- package/target/annotation/data/PrimaryKey.js +9 -9
- package/target/annotation/data/SqlSession.js +9 -9
- package/target/annotation/data/Table.js +35 -35
- package/target/annotation/data/Transactional.js +52 -52
- package/target/annotation/env/ApplicationSetting.js +25 -25
- package/target/annotation/env/BaseFilePath.js +14 -14
- package/target/annotation/env/BaseName.js +9 -9
- package/target/annotation/env/BasePath.js +14 -14
- package/target/annotation/env/ENV.js +10 -10
- package/target/annotation/env/ResourcePath.js +9 -9
- package/target/annotation/lifeCycle/AddLifeCycleItem.js +18 -18
- package/target/annotation/lifeCycle/ApplicationDestory.js +15 -15
- package/target/annotation/lifeCycle/ApplicationInit.js +15 -15
- package/target/annotation/lifeCycle/ApplicationRunner.js +7 -7
- package/target/annotation/lifeCycle/ApplicationStart.js +24 -24
- package/target/annotation/lifeCycle/ApplicationStop.js +20 -20
- package/target/annotation/property/Deprecate.js +19 -19
- package/target/annotation/property/NotImplemented.js +8 -8
- package/target/annotation/property/Override.js +7 -7
- package/target/annotation/property/Readonly.js +16 -16
- package/target/annotation/scan/ComponentInjection.js +21 -21
- package/target/annotation/scan/ComponentScan.js +9 -9
- package/target/annotation/scan/ComponentScanExclusion.js +25 -25
- package/target/annotation/scan/ComponentScanMust.js +25 -25
- package/target/annotation/scan/Hotter.js +8 -8
- package/target/annotation/stereotype/BeanName.js +11 -11
- package/target/annotation/stereotype/Component.js +8 -8
- package/target/annotation/stereotype/Configure.js +14 -14
- package/target/annotation/stereotype/Controller.js +9 -9
- package/target/annotation/stereotype/Injection.js +12 -12
- package/target/annotation/stereotype/Log.js +17 -17
- package/target/annotation/stereotype/Repository.js +9 -9
- package/target/annotation/stereotype/Service.js +9 -9
- package/target/annotation/valid/AddChildValid.js +56 -56
- package/target/annotation/valid/CustomType.js +11 -11
- package/target/annotation/valid/DefaultVal.js +10 -10
- package/target/annotation/valid/NotNull.js +8 -8
- package/target/annotation/valid/Rule.js +100 -100
- package/target/annotation/valid/Size.js +10 -10
- package/target/annotation/valid/Type.js +10 -10
- package/target/annotation/valid/ValidCustom.js +17 -17
- package/target/annotation/valid/ValidForm.js +133 -133
- package/target/annotation.js +108 -108
- package/target/config/ApplicationConfig.js +2 -2
- package/target/config/SysConfig.js +19 -19
- package/target/constant/AppStatusEnum.js +9 -9
- package/target/constant/BootPriority.js +11 -11
- package/target/constant/CommonConstant.js +18 -18
- package/target/constant/ComponentKind.js +11 -11
- package/target/constant/DataTypes.js +19 -19
- package/target/constant/FastCarMetaData.js +31 -31
- package/target/constant/LifeCycleModule.js +9 -9
- package/target/db.js +49 -48
- package/target/index.js +21 -21
- package/target/interface/ApplicationHook.js +2 -2
- package/target/interface/ApplicationInterface.js +2 -2
- package/target/interface/ApplicationRunnerService.js +2 -2
- package/target/interface/DataSourceManager.js +2 -2
- package/target/interface/Logger.js +5 -5
- package/target/model/BaseMapper.js +98 -98
- package/target/model/DataMap.js +87 -87
- package/target/model/FormRuleModel.js +2 -2
- package/target/model/ValidError.js +5 -5
- package/target/model/WinstonLogger.js +96 -95
- package/target/src/FastCarApplication.js +704 -0
- package/target/src/annotation/Application.js +45 -0
- package/target/src/annotation/ExceptionMonitor.js +16 -0
- package/target/src/annotation/bind/AddRequireModule.js +21 -0
- package/target/src/annotation/bind/AliasInjection.js +23 -0
- package/target/src/annotation/bind/Autowired.js +13 -0
- package/target/src/annotation/bind/CallDependency.js +23 -0
- package/target/src/annotation/data/DBType.js +11 -0
- package/target/src/annotation/data/DS.js +54 -0
- package/target/src/annotation/data/DSIndex.js +9 -0
- package/target/src/annotation/data/Entity.js +10 -0
- package/target/src/annotation/data/Field.js +18 -0
- package/target/src/annotation/data/PrimaryKey.js +9 -0
- package/target/src/annotation/data/SqlSession.js +9 -0
- package/target/src/annotation/data/Table.js +35 -0
- package/target/src/annotation/data/Transactional.js +52 -0
- package/target/src/annotation/env/ApplicationSetting.js +25 -0
- package/target/src/annotation/env/BaseFilePath.js +14 -0
- package/target/src/annotation/env/BaseName.js +9 -0
- package/target/src/annotation/env/BasePath.js +14 -0
- package/target/src/annotation/env/ENV.js +10 -0
- package/target/src/annotation/env/ResourcePath.js +9 -0
- package/target/src/annotation/lifeCycle/AddLifeCycleItem.js +18 -0
- package/target/src/annotation/lifeCycle/ApplicationDestory.js +15 -0
- package/target/src/annotation/lifeCycle/ApplicationInit.js +15 -0
- package/target/src/annotation/lifeCycle/ApplicationRunner.js +7 -0
- package/target/src/annotation/lifeCycle/ApplicationStart.js +24 -0
- package/target/src/annotation/lifeCycle/ApplicationStop.js +20 -0
- package/target/src/annotation/property/Deprecate.js +19 -0
- package/target/src/annotation/property/NotImplemented.js +8 -0
- package/target/src/annotation/property/Override.js +7 -0
- package/target/src/annotation/property/Readonly.js +16 -0
- package/target/src/annotation/scan/ComponentInjection.js +21 -0
- package/target/src/annotation/scan/ComponentScan.js +9 -0
- package/target/src/annotation/scan/ComponentScanExclusion.js +25 -0
- package/target/src/annotation/scan/ComponentScanMust.js +25 -0
- package/target/src/annotation/scan/Hotter.js +8 -0
- package/target/src/annotation/stereotype/BeanName.js +11 -0
- package/target/src/annotation/stereotype/Component.js +8 -0
- package/target/src/annotation/stereotype/Configure.js +14 -0
- package/target/src/annotation/stereotype/Controller.js +9 -0
- package/target/src/annotation/stereotype/Injection.js +12 -0
- package/target/src/annotation/stereotype/Log.js +22 -0
- package/target/src/annotation/stereotype/Repository.js +9 -0
- package/target/src/annotation/stereotype/Service.js +9 -0
- package/target/src/annotation/valid/AddChildValid.js +56 -0
- package/target/src/annotation/valid/CustomType.js +11 -0
- package/target/src/annotation/valid/DefaultVal.js +10 -0
- package/target/src/annotation/valid/NotNull.js +8 -0
- package/target/src/annotation/valid/Rule.js +100 -0
- package/target/src/annotation/valid/Size.js +10 -0
- package/target/src/annotation/valid/Type.js +10 -0
- package/target/src/annotation/valid/ValidCustom.js +17 -0
- package/target/src/annotation/valid/ValidForm.js +133 -0
- package/target/src/annotation.js +108 -0
- package/target/src/config/ApplicationConfig.js +2 -0
- package/target/src/config/SysConfig.js +19 -0
- package/target/src/constant/AppStatusEnum.js +9 -0
- package/target/src/constant/BootPriority.js +11 -0
- package/target/src/constant/CommonConstant.js +18 -0
- package/target/src/constant/ComponentKind.js +11 -0
- package/target/src/constant/DataTypes.js +19 -0
- package/target/src/constant/FastCarMetaData.js +31 -0
- package/target/src/constant/LifeCycleModule.js +9 -0
- package/target/src/db.js +49 -0
- package/target/src/index.js +21 -0
- package/target/src/interface/ApplicationHook.js +2 -0
- package/target/src/interface/ApplicationInterface.js +2 -0
- package/target/src/interface/ApplicationRunnerService.js +2 -0
- package/target/src/interface/DataSourceManager.js +2 -0
- package/target/src/interface/Logger.js +5 -0
- package/target/src/model/BaseMapper.js +103 -0
- package/target/src/model/DataMap.js +87 -0
- package/target/src/model/FormRuleModel.js +2 -0
- package/target/src/model/ValidError.js +5 -0
- package/target/src/model/WinstonLogger.js +97 -0
- package/target/src/type/ComponentDesc.js +2 -0
- package/target/src/type/DesignMeta.js +15 -0
- package/target/src/type/FileHotterDesc.js +2 -0
- package/target/src/type/MapperType.js +2 -0
- package/target/src/type/ProcessType.js +2 -0
- package/target/src/type/SqlError.js +5 -0
- package/target/src/type/WinstonLoggerType.js +9 -0
- package/target/src/utils/ClassLoader.js +65 -0
- package/target/src/utils/ClassUtils.js +35 -0
- package/target/src/utils/CryptoUtil.js +86 -0
- package/target/src/utils/DataFormat.js +88 -0
- package/target/src/utils/DateUtil.js +71 -0
- package/target/src/utils/FileUtil.js +153 -0
- package/target/src/utils/FormatStr.js +14 -0
- package/target/src/utils/IPUtils.js +34 -0
- package/target/src/utils/Id.js +9 -0
- package/target/src/utils/Mix.js +62 -0
- package/target/src/utils/ReflectUtil.js +22 -0
- package/target/src/utils/TypeUtil.js +53 -0
- package/target/src/utils/ValidationUtil.js +118 -0
- package/target/src/utils.js +25 -0
- package/target/test/example/simple/app-test.js +57 -0
- package/target/test/example/simple/app.js +116 -0
- package/target/test/example/simple/component/StartRunner.js +19 -0
- package/target/test/example/simple/component/StopRunner.js +23 -0
- package/target/test/example/simple/config/EnvConfig.js +16 -0
- package/target/test/example/simple/config/HelloConfig.js +16 -0
- package/target/test/example/simple/config/HotConfig.js +18 -0
- package/target/test/example/simple/controller/AliasController.js +17 -0
- package/target/test/example/simple/controller/HelloController.js +55 -0
- package/target/test/example/simple/controller/NotFoundController.js +36 -0
- package/target/test/example/simple/noclude/excludeApp.js +17 -0
- package/target/test/example/simple/service/CallService.js +24 -0
- package/target/test/example/simple/service/HelloService.js +18 -0
- package/target/test/example/simple/service/LogService.js +32 -0
- package/target/test/multi/app.js +29 -0
- package/target/test/multi/service/aService.js +33 -0
- package/target/test/multi/service/bService.js +35 -0
- package/target/test/multi/service/cService.js +40 -0
- package/target/test/unit/dataMap-test.js +35 -0
- package/target/test/unit/decorators-test.js +59 -0
- package/target/test/unit/ds-test.js +58 -0
- package/target/test/unit/reflectMetadata-test.js +27 -0
- package/target/test/unit/valid-test.js +99 -0
- package/target/test/unit/winston-test.js +15 -0
- package/target/type/ComponentDesc.js +2 -2
- package/target/type/DesignMeta.js +15 -15
- package/target/type/FileHotterDesc.js +2 -2
- package/target/type/MapperType.js +2 -2
- package/target/type/ProcessType.js +2 -2
- package/target/type/SqlError.js +5 -5
- package/target/type/WinstonLoggerType.js +9 -9
- package/target/utils/ClassLoader.js +65 -65
- package/target/utils/ClassUtils.js +35 -35
- package/target/utils/CryptoUtil.js +86 -86
- package/target/utils/DataFormat.js +88 -88
- package/target/utils/DateUtil.js +71 -71
- package/target/utils/FileUtil.js +153 -153
- package/target/utils/FormatStr.js +14 -14
- package/target/utils/IPUtils.js +34 -34
- package/target/utils/Id.js +9 -9
- package/target/utils/Mix.js +62 -62
- package/target/utils/ReflectUtil.js +22 -22
- package/target/utils/TypeUtil.js +53 -53
- package/target/utils/ValidationUtil.js +124 -118
- package/target/utils.js +25 -25
- package/test/unit/decorators-test.ts +3 -3
- package/test/unit/logs/sys.log +0 -24
package/target/utils/TypeUtil.js
CHANGED
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const FileUtil_1 = require("./FileUtil");
|
|
4
|
-
const BasicTypes = ["boolean", "number", "string"];
|
|
5
|
-
class TypeUtil {
|
|
6
|
-
static isFunction(f) {
|
|
7
|
-
let typeName = typeof f;
|
|
8
|
-
return typeName == "function";
|
|
9
|
-
}
|
|
10
|
-
static isClass(f) {
|
|
11
|
-
if (f.prototype === undefined) {
|
|
12
|
-
return false;
|
|
13
|
-
}
|
|
14
|
-
if (!f.prototype.constructor) {
|
|
15
|
-
return false;
|
|
16
|
-
}
|
|
17
|
-
return TypeUtil.isFunction(f);
|
|
18
|
-
}
|
|
19
|
-
static isString(str) {
|
|
20
|
-
let typeName = typeof str;
|
|
21
|
-
return typeName == "string";
|
|
22
|
-
}
|
|
23
|
-
static isObject(f) {
|
|
24
|
-
let typeName = typeof f;
|
|
25
|
-
return typeName == "object";
|
|
26
|
-
}
|
|
27
|
-
//忽略.d.ts文件
|
|
28
|
-
static isTSORJS(fp) {
|
|
29
|
-
let suffix = FileUtil_1.default.getSuffix(fp);
|
|
30
|
-
return ["ts", "js"].includes(suffix) && !fp.endsWith(".d.ts");
|
|
31
|
-
}
|
|
32
|
-
static isPromise(f) {
|
|
33
|
-
return f.constructor.name === "AsyncFunction";
|
|
34
|
-
}
|
|
35
|
-
static isArray(value) {
|
|
36
|
-
return Array.isArray(value);
|
|
37
|
-
}
|
|
38
|
-
static isDate(value) {
|
|
39
|
-
return value instanceof Date;
|
|
40
|
-
}
|
|
41
|
-
//是否为基本类型
|
|
42
|
-
static isBasic(name) {
|
|
43
|
-
let fname = name.toLowerCase();
|
|
44
|
-
return BasicTypes.includes(fname);
|
|
45
|
-
}
|
|
46
|
-
static isMap(value) {
|
|
47
|
-
return value instanceof Map;
|
|
48
|
-
}
|
|
49
|
-
static isSet(value) {
|
|
50
|
-
return value instanceof Set;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
exports.default = TypeUtil;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const FileUtil_1 = require("./FileUtil");
|
|
4
|
+
const BasicTypes = ["boolean", "number", "string"];
|
|
5
|
+
class TypeUtil {
|
|
6
|
+
static isFunction(f) {
|
|
7
|
+
let typeName = typeof f;
|
|
8
|
+
return typeName == "function";
|
|
9
|
+
}
|
|
10
|
+
static isClass(f) {
|
|
11
|
+
if (f.prototype === undefined) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
if (!f.prototype.constructor) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
return TypeUtil.isFunction(f);
|
|
18
|
+
}
|
|
19
|
+
static isString(str) {
|
|
20
|
+
let typeName = typeof str;
|
|
21
|
+
return typeName == "string";
|
|
22
|
+
}
|
|
23
|
+
static isObject(f) {
|
|
24
|
+
let typeName = typeof f;
|
|
25
|
+
return typeName == "object";
|
|
26
|
+
}
|
|
27
|
+
//忽略.d.ts文件
|
|
28
|
+
static isTSORJS(fp) {
|
|
29
|
+
let suffix = FileUtil_1.default.getSuffix(fp);
|
|
30
|
+
return ["ts", "js"].includes(suffix) && !fp.endsWith(".d.ts");
|
|
31
|
+
}
|
|
32
|
+
static isPromise(f) {
|
|
33
|
+
return f.constructor.name === "AsyncFunction";
|
|
34
|
+
}
|
|
35
|
+
static isArray(value) {
|
|
36
|
+
return Array.isArray(value);
|
|
37
|
+
}
|
|
38
|
+
static isDate(value) {
|
|
39
|
+
return value instanceof Date;
|
|
40
|
+
}
|
|
41
|
+
//是否为基本类型
|
|
42
|
+
static isBasic(name) {
|
|
43
|
+
let fname = name.toLowerCase();
|
|
44
|
+
return BasicTypes.includes(fname);
|
|
45
|
+
}
|
|
46
|
+
static isMap(value) {
|
|
47
|
+
return value instanceof Map;
|
|
48
|
+
}
|
|
49
|
+
static isSet(value) {
|
|
50
|
+
return value instanceof Set;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.default = TypeUtil;
|
|
@@ -1,118 +1,124 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const TypeUtil_1 = require("./TypeUtil");
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
case "
|
|
97
|
-
formatFun = ValidationUtil.
|
|
98
|
-
break;
|
|
99
|
-
}
|
|
100
|
-
case "
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const TypeUtil_1 = require("./TypeUtil");
|
|
4
|
+
const NumberRegex = /^[0-9]+$/;
|
|
5
|
+
//类型校验器
|
|
6
|
+
class ValidationUtil {
|
|
7
|
+
//是否为空
|
|
8
|
+
static isNotNull(param) {
|
|
9
|
+
if (param != undefined && param != null) {
|
|
10
|
+
if (TypeUtil_1.default.isString(param)) {
|
|
11
|
+
return param.length > 0;
|
|
12
|
+
}
|
|
13
|
+
if (TypeUtil_1.default.isObject(param)) {
|
|
14
|
+
if (TypeUtil_1.default.isDate(param) || TypeUtil_1.default.isMap(param) || TypeUtil_1.default.isSet(param)) {
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
return Reflect.ownKeys(param).length > 0;
|
|
18
|
+
}
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
static isNull(param) {
|
|
26
|
+
return !ValidationUtil.isNotNull(param);
|
|
27
|
+
}
|
|
28
|
+
//修改数字的判断方法
|
|
29
|
+
static isNumber(param) {
|
|
30
|
+
return NumberRegex.test(param);
|
|
31
|
+
}
|
|
32
|
+
static isString(param) {
|
|
33
|
+
return typeof param === "string";
|
|
34
|
+
}
|
|
35
|
+
static isBoolean(param) {
|
|
36
|
+
return typeof param === "boolean";
|
|
37
|
+
}
|
|
38
|
+
static isDate(param) {
|
|
39
|
+
return param instanceof Date;
|
|
40
|
+
}
|
|
41
|
+
static isObject(param) {
|
|
42
|
+
return typeof param == "object";
|
|
43
|
+
}
|
|
44
|
+
// poaram >= value
|
|
45
|
+
static isNotMinSize(param, value) {
|
|
46
|
+
if (ValidationUtil.isString(param)) {
|
|
47
|
+
return param.length >= value;
|
|
48
|
+
}
|
|
49
|
+
if (ValidationUtil.isNumber(param)) {
|
|
50
|
+
return param >= value;
|
|
51
|
+
}
|
|
52
|
+
if (ValidationUtil.isBoolean(param)) {
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
//修正数组的判断
|
|
56
|
+
if (Array.isArray(param)) {
|
|
57
|
+
return param.length >= value;
|
|
58
|
+
}
|
|
59
|
+
let v = ValidationUtil.isNotNull(param) ? param.toString() : "";
|
|
60
|
+
return v.length >= value;
|
|
61
|
+
}
|
|
62
|
+
static isNotMaxSize(param, value) {
|
|
63
|
+
return !ValidationUtil.isNotMinSize(param, value + 1);
|
|
64
|
+
}
|
|
65
|
+
static isArray(param, type) {
|
|
66
|
+
if (!Array.isArray(param)) {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
//修正校验数组的错误
|
|
70
|
+
if (type.startsWith("array")) {
|
|
71
|
+
type = type.replace(/array/, "");
|
|
72
|
+
}
|
|
73
|
+
let checkFun = this.getCheckFun(type);
|
|
74
|
+
if (checkFun) {
|
|
75
|
+
return param.every((item) => {
|
|
76
|
+
return Reflect.apply(checkFun, ValidationUtil, [item]);
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
static getCheckFun(type) {
|
|
82
|
+
//判定类型
|
|
83
|
+
if (type.startsWith("array")) {
|
|
84
|
+
return ValidationUtil.isArray;
|
|
85
|
+
}
|
|
86
|
+
let formatFun = null;
|
|
87
|
+
switch (type) {
|
|
88
|
+
case "string": {
|
|
89
|
+
formatFun = ValidationUtil.isString;
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
case "boolean": {
|
|
93
|
+
formatFun = ValidationUtil.isBoolean;
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
case "object": {
|
|
97
|
+
formatFun = ValidationUtil.isObject;
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
case "int":
|
|
101
|
+
case "float":
|
|
102
|
+
case "number": {
|
|
103
|
+
formatFun = ValidationUtil.isNumber;
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
case "date": {
|
|
107
|
+
formatFun = ValidationUtil.isDate;
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
default: {
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return formatFun;
|
|
115
|
+
}
|
|
116
|
+
static checkType(param, type) {
|
|
117
|
+
let formatFun = ValidationUtil.getCheckFun(type);
|
|
118
|
+
if (!formatFun) {
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
return Reflect.apply(formatFun, ValidationUtil, [param, type]);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
exports.default = ValidationUtil;
|
package/target/utils.js
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.IPUtils = exports.MixTool = exports.ClassLoader = exports.ClassUtils = exports.FormatStr = exports.ValidationUtil = exports.TypeUtil = exports.FileUtil = exports.CryptoUtil = exports.DataFormat = exports.DateUtil = void 0;
|
|
4
|
-
const ClassLoader_1 = require("./utils/ClassLoader");
|
|
5
|
-
exports.ClassLoader = ClassLoader_1.default;
|
|
6
|
-
const ClassUtils_1 = require("./utils/ClassUtils");
|
|
7
|
-
exports.ClassUtils = ClassUtils_1.default;
|
|
8
|
-
const CryptoUtil_1 = require("./utils/CryptoUtil");
|
|
9
|
-
exports.CryptoUtil = CryptoUtil_1.default;
|
|
10
|
-
const DataFormat_1 = require("./utils/DataFormat");
|
|
11
|
-
exports.DataFormat = DataFormat_1.default;
|
|
12
|
-
const DateUtil_1 = require("./utils/DateUtil");
|
|
13
|
-
exports.DateUtil = DateUtil_1.default;
|
|
14
|
-
const FileUtil_1 = require("./utils/FileUtil");
|
|
15
|
-
exports.FileUtil = FileUtil_1.default;
|
|
16
|
-
const FormatStr_1 = require("./utils/FormatStr");
|
|
17
|
-
exports.FormatStr = FormatStr_1.default;
|
|
18
|
-
const Mix_1 = require("./utils/Mix");
|
|
19
|
-
exports.MixTool = Mix_1.default;
|
|
20
|
-
const TypeUtil_1 = require("./utils/TypeUtil");
|
|
21
|
-
exports.TypeUtil = TypeUtil_1.default;
|
|
22
|
-
const ValidationUtil_1 = require("./utils/ValidationUtil");
|
|
23
|
-
exports.ValidationUtil = ValidationUtil_1.default;
|
|
24
|
-
const IPUtils_1 = require("./utils/IPUtils");
|
|
25
|
-
exports.IPUtils = IPUtils_1.default;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IPUtils = exports.MixTool = exports.ClassLoader = exports.ClassUtils = exports.FormatStr = exports.ValidationUtil = exports.TypeUtil = exports.FileUtil = exports.CryptoUtil = exports.DataFormat = exports.DateUtil = void 0;
|
|
4
|
+
const ClassLoader_1 = require("./utils/ClassLoader");
|
|
5
|
+
exports.ClassLoader = ClassLoader_1.default;
|
|
6
|
+
const ClassUtils_1 = require("./utils/ClassUtils");
|
|
7
|
+
exports.ClassUtils = ClassUtils_1.default;
|
|
8
|
+
const CryptoUtil_1 = require("./utils/CryptoUtil");
|
|
9
|
+
exports.CryptoUtil = CryptoUtil_1.default;
|
|
10
|
+
const DataFormat_1 = require("./utils/DataFormat");
|
|
11
|
+
exports.DataFormat = DataFormat_1.default;
|
|
12
|
+
const DateUtil_1 = require("./utils/DateUtil");
|
|
13
|
+
exports.DateUtil = DateUtil_1.default;
|
|
14
|
+
const FileUtil_1 = require("./utils/FileUtil");
|
|
15
|
+
exports.FileUtil = FileUtil_1.default;
|
|
16
|
+
const FormatStr_1 = require("./utils/FormatStr");
|
|
17
|
+
exports.FormatStr = FormatStr_1.default;
|
|
18
|
+
const Mix_1 = require("./utils/Mix");
|
|
19
|
+
exports.MixTool = Mix_1.default;
|
|
20
|
+
const TypeUtil_1 = require("./utils/TypeUtil");
|
|
21
|
+
exports.TypeUtil = TypeUtil_1.default;
|
|
22
|
+
const ValidationUtil_1 = require("./utils/ValidationUtil");
|
|
23
|
+
exports.ValidationUtil = ValidationUtil_1.default;
|
|
24
|
+
const IPUtils_1 = require("./utils/IPUtils");
|
|
25
|
+
exports.IPUtils = IPUtils_1.default;
|
|
@@ -5,7 +5,7 @@ describe("装饰器测试", () => {
|
|
|
5
5
|
it("只读装饰器测试", () => {
|
|
6
6
|
class TestModel {
|
|
7
7
|
@Readonly
|
|
8
|
-
info
|
|
8
|
+
info!: string;
|
|
9
9
|
|
|
10
10
|
@Readonly
|
|
11
11
|
setInfo(s: string) {
|
|
@@ -25,13 +25,13 @@ describe("装饰器测试", () => {
|
|
|
25
25
|
class TestModel {
|
|
26
26
|
@Deprecate("hello is Deprecate")
|
|
27
27
|
async hello() {
|
|
28
|
-
return new Promise(resolve => {
|
|
28
|
+
return new Promise((resolve) => {
|
|
29
29
|
resolve("hello is Deprecate");
|
|
30
30
|
});
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
new TestModel().hello().then(res => {
|
|
34
|
+
new TestModel().hello().then((res) => {
|
|
35
35
|
console.log(res);
|
|
36
36
|
});
|
|
37
37
|
});
|
package/test/unit/logs/sys.log
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
{"timestamp":"2022-09-09 10:58:51.75","level":"INFO","label":"sys","message":"Start scanning component"}
|
|
2
|
-
{"timestamp":"2022-09-09 10:58:51.78","level":"INFO","label":"sys","message":"Complete component scan"}
|
|
3
|
-
{"timestamp":"2022-09-09 10:58:51.78","level":"INFO","label":"sys","message":"Call application initialization method"}
|
|
4
|
-
{"timestamp":"2022-09-09 10:58:51.80","level":"INFO","label":"sys","message":"start server app is run"}
|
|
5
|
-
{"timestamp":"2022-09-09 10:58:51.81","level":"INFO","label":"sys","message":"version 1.0.0"}
|
|
6
|
-
{"timestamp":"2022-09-09 10:58:51.84","level":"INFO","label":"sys","message":"exit reason","splat":"[\"beforeExit exit\"]"}
|
|
7
|
-
{"timestamp":"2022-09-09 11:11:48.302","level":"INFO","label":"sys","message":"Start scanning component"}
|
|
8
|
-
{"timestamp":"2022-09-09 11:11:48.305","level":"INFO","label":"sys","message":"Complete component scan"}
|
|
9
|
-
{"timestamp":"2022-09-09 11:11:48.306","level":"INFO","label":"sys","message":"Call application initialization method"}
|
|
10
|
-
{"timestamp":"2022-09-09 11:11:48.308","level":"INFO","label":"sys","message":"start server app is run"}
|
|
11
|
-
{"timestamp":"2022-09-09 11:11:48.309","level":"INFO","label":"sys","message":"version 1.0.0"}
|
|
12
|
-
{"timestamp":"2022-09-09 11:11:48.322","level":"INFO","label":"sys","message":"exit reason","splat":"[\"beforeExit exit\"]"}
|
|
13
|
-
{"timestamp":"2022-09-09 11:12:01.418","level":"INFO","label":"sys","message":"Start scanning component"}
|
|
14
|
-
{"timestamp":"2022-09-09 11:12:01.421","level":"INFO","label":"sys","message":"Complete component scan"}
|
|
15
|
-
{"timestamp":"2022-09-09 11:12:01.422","level":"INFO","label":"sys","message":"Call application initialization method"}
|
|
16
|
-
{"timestamp":"2022-09-09 11:12:01.424","level":"INFO","label":"sys","message":"start server app is run"}
|
|
17
|
-
{"timestamp":"2022-09-09 11:12:01.424","level":"INFO","label":"sys","message":"version 1.0.0"}
|
|
18
|
-
{"timestamp":"2022-09-09 11:12:01.427","level":"INFO","label":"sys","message":"exit reason","splat":"[\"beforeExit exit\"]"}
|
|
19
|
-
{"timestamp":"2022-09-09 11:17:03.161","level":"INFO","label":"sys","message":"Start scanning component"}
|
|
20
|
-
{"timestamp":"2022-09-09 11:17:03.164","level":"INFO","label":"sys","message":"Complete component scan"}
|
|
21
|
-
{"timestamp":"2022-09-09 11:17:03.905","level":"INFO","label":"sys","message":"Call application initialization method"}
|
|
22
|
-
{"timestamp":"2022-09-09 11:17:03.907","level":"INFO","label":"sys","message":"start server app is run"}
|
|
23
|
-
{"timestamp":"2022-09-09 11:17:03.908","level":"INFO","label":"sys","message":"version 1.0.0"}
|
|
24
|
-
{"timestamp":"2022-09-09 11:17:03.911","level":"INFO","label":"sys","message":"exit reason","splat":"[\"beforeExit exit\"]"}
|