@fastcar/core 0.2.61 → 0.2.63
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/src/FastCarApplication.ts +30 -9
- package/src/utils/ValidationUtil.ts +1 -3
- package/target/FastCarApplication.js +708 -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 -49
- 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 -96
- 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 +123 -124
- package/target/utils.js +25 -25
- package/test/unit/decorators-test.ts +3 -3
- package/target/src/FastCarApplication.js +0 -704
- package/target/src/annotation/Application.js +0 -45
- package/target/src/annotation/ExceptionMonitor.js +0 -16
- package/target/src/annotation/bind/AddRequireModule.js +0 -21
- package/target/src/annotation/bind/AliasInjection.js +0 -23
- package/target/src/annotation/bind/Autowired.js +0 -13
- package/target/src/annotation/bind/CallDependency.js +0 -23
- package/target/src/annotation/data/DBType.js +0 -11
- package/target/src/annotation/data/DS.js +0 -54
- package/target/src/annotation/data/DSIndex.js +0 -9
- package/target/src/annotation/data/Entity.js +0 -10
- package/target/src/annotation/data/Field.js +0 -18
- package/target/src/annotation/data/PrimaryKey.js +0 -9
- package/target/src/annotation/data/SqlSession.js +0 -9
- package/target/src/annotation/data/Table.js +0 -35
- package/target/src/annotation/data/Transactional.js +0 -52
- package/target/src/annotation/env/ApplicationSetting.js +0 -25
- package/target/src/annotation/env/BaseFilePath.js +0 -14
- package/target/src/annotation/env/BaseName.js +0 -9
- package/target/src/annotation/env/BasePath.js +0 -14
- package/target/src/annotation/env/ENV.js +0 -10
- package/target/src/annotation/env/ResourcePath.js +0 -9
- package/target/src/annotation/lifeCycle/AddLifeCycleItem.js +0 -18
- package/target/src/annotation/lifeCycle/ApplicationDestory.js +0 -15
- package/target/src/annotation/lifeCycle/ApplicationInit.js +0 -15
- package/target/src/annotation/lifeCycle/ApplicationRunner.js +0 -7
- package/target/src/annotation/lifeCycle/ApplicationStart.js +0 -24
- package/target/src/annotation/lifeCycle/ApplicationStop.js +0 -20
- package/target/src/annotation/property/Deprecate.js +0 -19
- package/target/src/annotation/property/NotImplemented.js +0 -8
- package/target/src/annotation/property/Override.js +0 -7
- package/target/src/annotation/property/Readonly.js +0 -16
- package/target/src/annotation/scan/ComponentInjection.js +0 -21
- package/target/src/annotation/scan/ComponentScan.js +0 -9
- package/target/src/annotation/scan/ComponentScanExclusion.js +0 -25
- package/target/src/annotation/scan/ComponentScanMust.js +0 -25
- package/target/src/annotation/scan/Hotter.js +0 -8
- package/target/src/annotation/stereotype/BeanName.js +0 -11
- package/target/src/annotation/stereotype/Component.js +0 -8
- package/target/src/annotation/stereotype/Configure.js +0 -14
- package/target/src/annotation/stereotype/Controller.js +0 -9
- package/target/src/annotation/stereotype/Injection.js +0 -12
- package/target/src/annotation/stereotype/Log.js +0 -22
- package/target/src/annotation/stereotype/Repository.js +0 -9
- package/target/src/annotation/stereotype/Service.js +0 -9
- package/target/src/annotation/valid/AddChildValid.js +0 -56
- package/target/src/annotation/valid/CustomType.js +0 -11
- package/target/src/annotation/valid/DefaultVal.js +0 -10
- package/target/src/annotation/valid/NotNull.js +0 -8
- package/target/src/annotation/valid/Rule.js +0 -100
- package/target/src/annotation/valid/Size.js +0 -10
- package/target/src/annotation/valid/Type.js +0 -10
- package/target/src/annotation/valid/ValidCustom.js +0 -17
- package/target/src/annotation/valid/ValidForm.js +0 -133
- package/target/src/annotation.js +0 -108
- package/target/src/config/ApplicationConfig.js +0 -2
- package/target/src/config/SysConfig.js +0 -19
- package/target/src/constant/AppStatusEnum.js +0 -9
- package/target/src/constant/BootPriority.js +0 -11
- package/target/src/constant/CommonConstant.js +0 -18
- package/target/src/constant/ComponentKind.js +0 -11
- package/target/src/constant/DataTypes.js +0 -19
- package/target/src/constant/FastCarMetaData.js +0 -31
- package/target/src/constant/LifeCycleModule.js +0 -9
- package/target/src/db.js +0 -49
- package/target/src/index.js +0 -21
- package/target/src/interface/ApplicationHook.js +0 -2
- package/target/src/interface/ApplicationInterface.js +0 -2
- package/target/src/interface/ApplicationRunnerService.js +0 -2
- package/target/src/interface/DataSourceManager.js +0 -2
- package/target/src/interface/Logger.js +0 -5
- package/target/src/model/BaseMapper.js +0 -103
- package/target/src/model/DataMap.js +0 -87
- package/target/src/model/FormRuleModel.js +0 -2
- package/target/src/model/ValidError.js +0 -5
- package/target/src/model/WinstonLogger.js +0 -97
- package/target/src/type/ComponentDesc.js +0 -2
- package/target/src/type/DesignMeta.js +0 -15
- package/target/src/type/FileHotterDesc.js +0 -2
- package/target/src/type/MapperType.js +0 -2
- package/target/src/type/ProcessType.js +0 -2
- package/target/src/type/SqlError.js +0 -5
- package/target/src/type/WinstonLoggerType.js +0 -9
- package/target/src/utils/ClassLoader.js +0 -65
- package/target/src/utils/ClassUtils.js +0 -35
- package/target/src/utils/CryptoUtil.js +0 -86
- package/target/src/utils/DataFormat.js +0 -88
- package/target/src/utils/DateUtil.js +0 -71
- package/target/src/utils/FileUtil.js +0 -153
- package/target/src/utils/FormatStr.js +0 -14
- package/target/src/utils/IPUtils.js +0 -34
- package/target/src/utils/Id.js +0 -9
- package/target/src/utils/Mix.js +0 -62
- package/target/src/utils/ReflectUtil.js +0 -22
- package/target/src/utils/TypeUtil.js +0 -53
- package/target/src/utils/ValidationUtil.js +0 -118
- package/target/src/utils.js +0 -25
- package/target/test/example/simple/app-test.js +0 -57
- package/target/test/example/simple/app.js +0 -116
- package/target/test/example/simple/component/StartRunner.js +0 -19
- package/target/test/example/simple/component/StopRunner.js +0 -23
- package/target/test/example/simple/config/EnvConfig.js +0 -16
- package/target/test/example/simple/config/HelloConfig.js +0 -16
- package/target/test/example/simple/config/HotConfig.js +0 -18
- package/target/test/example/simple/controller/AliasController.js +0 -17
- package/target/test/example/simple/controller/HelloController.js +0 -55
- package/target/test/example/simple/controller/NotFoundController.js +0 -36
- package/target/test/example/simple/noclude/excludeApp.js +0 -17
- package/target/test/example/simple/service/CallService.js +0 -24
- package/target/test/example/simple/service/HelloService.js +0 -18
- package/target/test/example/simple/service/LogService.js +0 -32
- package/target/test/multi/app.js +0 -29
- package/target/test/multi/service/aService.js +0 -33
- package/target/test/multi/service/bService.js +0 -35
- package/target/test/multi/service/cService.js +0 -40
- package/target/test/unit/dataMap-test.js +0 -35
- package/target/test/unit/decorators-test.js +0 -59
- package/target/test/unit/ds-test.js +0 -58
- package/target/test/unit/reflectMetadata-test.js +0 -27
- package/target/test/unit/valid-test.js +0 -99
- package/target/test/unit/winston-test.js +0 -15
- package/test/example/logs/fastcar-server.sys.log +0 -3
- package/test/example/logs/other-server.app.log +0 -0
- package/test/example/logs/other-server.sys.log +0 -0
- package/test/example/logs/other-server.sys1.log +0 -0
- package/test/example/logs/other-server.sys2.log +0 -0
- package/test/example/logs/other-server.sys3.log +0 -6
- package/test/example/logs/other-server.sys4.log +0 -0
- package/test/example/logs/other-server.sys5.log +0 -0
- package/test/example/logs/other-server.sys6.log +0 -2
- package/test/logs/logger.log +0 -0
- package/test/logs/sys.log +0 -227
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const FastCarApplication_1 = require("../FastCarApplication");
|
|
4
|
-
const ClassUtils_1 = require("../utils/ClassUtils");
|
|
5
|
-
const TypeUtil_1 = require("../utils/TypeUtil");
|
|
6
|
-
//基础服务的应用
|
|
7
|
-
function Application(target) {
|
|
8
|
-
return new Proxy(target, {
|
|
9
|
-
construct: (target, args) => {
|
|
10
|
-
let app = new FastCarApplication_1.default();
|
|
11
|
-
let appProxy = new target(...args);
|
|
12
|
-
Reflect.set(appProxy, "app", app);
|
|
13
|
-
let keys = ClassUtils_1.default.getProtoType(target);
|
|
14
|
-
for (let key of keys) {
|
|
15
|
-
if (key != "constructor") {
|
|
16
|
-
let desc = ClassUtils_1.default.getProtoDesc(target, key);
|
|
17
|
-
if (desc) {
|
|
18
|
-
let beforeFun = Object.getOwnPropertyDescriptor(FastCarApplication_1.default.prototype, key)?.value;
|
|
19
|
-
let afterFun = desc.value;
|
|
20
|
-
if (Reflect.has(app, key) && TypeUtil_1.default.isFunction(afterFun) && TypeUtil_1.default.isFunction(beforeFun)) {
|
|
21
|
-
let mixFn = async (...args) => {
|
|
22
|
-
let res;
|
|
23
|
-
if (TypeUtil_1.default.isPromise(beforeFun)) {
|
|
24
|
-
res = await Promise.resolve(Reflect.apply(beforeFun, app, args));
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
res = Reflect.apply(beforeFun, app, args);
|
|
28
|
-
}
|
|
29
|
-
TypeUtil_1.default.isPromise(afterFun) ? await Promise.resolve(Reflect.apply(afterFun, appProxy, args)) : Reflect.apply(afterFun, appProxy, args);
|
|
30
|
-
return res;
|
|
31
|
-
};
|
|
32
|
-
Reflect.defineProperty(app, key, Object.assign(desc, { value: mixFn }));
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
Reflect.defineProperty(app, key, desc);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
app.init();
|
|
41
|
-
return appProxy;
|
|
42
|
-
},
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
exports.default = Application;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const process = require("process");
|
|
4
|
-
//异常监听器
|
|
5
|
-
function ExceptionMonitor(target) {
|
|
6
|
-
process.on("uncaughtException", (err, origin) => {
|
|
7
|
-
console.error(`Caught exception: ${err.message}`);
|
|
8
|
-
console.error(`Exception origin: ${origin}`);
|
|
9
|
-
console.error(`stack: ${err.stack}`);
|
|
10
|
-
});
|
|
11
|
-
process.on("unhandledRejection", (reason, promise) => {
|
|
12
|
-
console.error("Unhandled Rejection at:", promise);
|
|
13
|
-
console.error("reason:", reason);
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
exports.default = ExceptionMonitor;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
require("reflect-metadata");
|
|
4
|
-
const FastCarMetaData_1 = require("../../constant/FastCarMetaData");
|
|
5
|
-
/***
|
|
6
|
-
* @version 1.0 依赖模块注入
|
|
7
|
-
*
|
|
8
|
-
*/
|
|
9
|
-
function AddRequireModule(target, m, alias) {
|
|
10
|
-
let relyname = FastCarMetaData_1.FastCarMetaData.IocModule;
|
|
11
|
-
if (Reflect.hasMetadata(relyname, target)) {
|
|
12
|
-
let iocMap = Reflect.getMetadata(relyname, target);
|
|
13
|
-
iocMap.set(m, alias);
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
let modules = new Map();
|
|
17
|
-
modules.set(m, alias);
|
|
18
|
-
Reflect.defineMetadata(relyname, modules, target);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
exports.default = AddRequireModule;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const CommonConstant_1 = require("../../constant/CommonConstant");
|
|
4
|
-
/***
|
|
5
|
-
* @version 1.0 根据别名注入依赖
|
|
6
|
-
*
|
|
7
|
-
*/
|
|
8
|
-
function AliasInjection(alias) {
|
|
9
|
-
return function (target, propertyKey) {
|
|
10
|
-
Reflect.defineProperty(target, propertyKey, {
|
|
11
|
-
get: () => {
|
|
12
|
-
let app = Reflect.get(global, CommonConstant_1.CommonConstant.FastcarApp);
|
|
13
|
-
if (!app.hasComponentByName(alias)) {
|
|
14
|
-
//找不到依赖组件异常
|
|
15
|
-
let injectionError = new Error(`Unsatisfied dependency expressed through [${propertyKey}] `);
|
|
16
|
-
throw injectionError;
|
|
17
|
-
}
|
|
18
|
-
return app.getComponentByName(alias);
|
|
19
|
-
},
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
exports.default = AliasInjection;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const CallDependency_1 = require("./CallDependency");
|
|
4
|
-
/***
|
|
5
|
-
* @version 1.0 说明哪些模块需要被加载
|
|
6
|
-
* @version 1.1 更改为和call类型一致
|
|
7
|
-
*
|
|
8
|
-
*/
|
|
9
|
-
function Autowired(target, propertyKey) {
|
|
10
|
-
// //反向找设计类型
|
|
11
|
-
(0, CallDependency_1.default)(target, propertyKey);
|
|
12
|
-
}
|
|
13
|
-
exports.default = Autowired;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const CommonConstant_1 = require("../../constant/CommonConstant");
|
|
4
|
-
const ReflectUtil_1 = require("../../utils/ReflectUtil");
|
|
5
|
-
/***
|
|
6
|
-
* @version 1.0 在使用该函数时进行调用 声明的类可以不是组件
|
|
7
|
-
*
|
|
8
|
-
*/
|
|
9
|
-
function CallDependency(target, propertyKey) {
|
|
10
|
-
Reflect.defineProperty(target, propertyKey, {
|
|
11
|
-
get: () => {
|
|
12
|
-
let key = ReflectUtil_1.default.getNameByPropertyKey(target, propertyKey);
|
|
13
|
-
let app = Reflect.get(global, CommonConstant_1.CommonConstant.FastcarApp);
|
|
14
|
-
if (!app.hasComponentByName(key)) {
|
|
15
|
-
//找不到依赖组件异常
|
|
16
|
-
let injectionError = new Error(`Unsatisfied dependency expressed through [${propertyKey}] `);
|
|
17
|
-
throw injectionError;
|
|
18
|
-
}
|
|
19
|
-
return app.getComponentByName(key);
|
|
20
|
-
},
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
exports.default = CallDependency;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
require("reflect-metadata");
|
|
4
|
-
const DesignMeta_1 = require("../../type/DesignMeta");
|
|
5
|
-
//字段名称 如果没有则为统一
|
|
6
|
-
function DBType(name) {
|
|
7
|
-
return function (target, propertyKey) {
|
|
8
|
-
Reflect.defineMetadata(DesignMeta_1.DesignMeta.dbType, name, target, propertyKey);
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
exports.default = DBType;
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
require("reflect-metadata");
|
|
4
|
-
const FastCarMetaData_1 = require("../../constant/FastCarMetaData");
|
|
5
|
-
const ClassUtils_1 = require("../../utils/ClassUtils");
|
|
6
|
-
const TypeUtil_1 = require("../../utils/TypeUtil");
|
|
7
|
-
const ValidationUtil_1 = require("../../utils/ValidationUtil");
|
|
8
|
-
//动态数据源获取 根据就近原则 传入参数-函数-类名
|
|
9
|
-
function DS(name) {
|
|
10
|
-
return function (target, methodName, descriptor) {
|
|
11
|
-
if (methodName && descriptor) {
|
|
12
|
-
const orignFunction = descriptor.value;
|
|
13
|
-
//定义数据源
|
|
14
|
-
Reflect.defineMetadata(FastCarMetaData_1.FastCarMetaData.DS, name, target, methodName);
|
|
15
|
-
//取出ds标记的位置 在编译前规避这个问题
|
|
16
|
-
const dsIndex = Reflect.getMetadata(FastCarMetaData_1.FastCarMetaData.DSIndex, target, methodName);
|
|
17
|
-
if (!ValidationUtil_1.default.isNumber(dsIndex)) {
|
|
18
|
-
throw new Error(`${methodName} function dynamic data source not found`);
|
|
19
|
-
}
|
|
20
|
-
descriptor.value = function (...args) {
|
|
21
|
-
let dsName = args[dsIndex];
|
|
22
|
-
if (!dsName) {
|
|
23
|
-
args[dsIndex] = name;
|
|
24
|
-
}
|
|
25
|
-
return Promise.resolve(Reflect.apply(orignFunction, this, args));
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
Reflect.defineMetadata(FastCarMetaData_1.FastCarMetaData.DS, name, target.prototype);
|
|
30
|
-
//找所有的方法 将符合要求的进行注入定义
|
|
31
|
-
let targetProto = target.prototype;
|
|
32
|
-
let keys = ClassUtils_1.default.getProtoType(target);
|
|
33
|
-
for (let key of keys) {
|
|
34
|
-
let dsIndex = Reflect.getMetadata(FastCarMetaData_1.FastCarMetaData.DSIndex, targetProto, key);
|
|
35
|
-
if (ValidationUtil_1.default.isNumber(dsIndex)) {
|
|
36
|
-
let originValue = Reflect.get(targetProto, key);
|
|
37
|
-
if (TypeUtil_1.default.isFunction(originValue)) {
|
|
38
|
-
Reflect.defineProperty(targetProto, key, {
|
|
39
|
-
value: function (...args) {
|
|
40
|
-
let dsName = args[dsIndex];
|
|
41
|
-
if (!dsName) {
|
|
42
|
-
let fnDSName = Reflect.getMetadata(FastCarMetaData_1.FastCarMetaData.DS, targetProto, key);
|
|
43
|
-
args[dsIndex] = fnDSName || name;
|
|
44
|
-
}
|
|
45
|
-
return Promise.resolve(Reflect.apply(originValue, this, args));
|
|
46
|
-
},
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
exports.default = DS;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
require("reflect-metadata");
|
|
4
|
-
const FastCarMetaData_1 = require("../../constant/FastCarMetaData");
|
|
5
|
-
//用于标记数据源位置
|
|
6
|
-
function DSIndex(target, name, index) {
|
|
7
|
-
Reflect.defineMetadata(FastCarMetaData_1.FastCarMetaData.DSIndex, index, target, name);
|
|
8
|
-
}
|
|
9
|
-
exports.default = DSIndex;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const DesignMeta_1 = require("../../type/DesignMeta");
|
|
4
|
-
//这是一个模板类 代表具体的映射关系
|
|
5
|
-
function Entity(className) {
|
|
6
|
-
return function (target) {
|
|
7
|
-
Reflect.defineMetadata(DesignMeta_1.DesignMeta.entity, className, target.prototype);
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
exports.default = Entity;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
require("reflect-metadata");
|
|
4
|
-
const DesignMeta_1 = require("../../type/DesignMeta");
|
|
5
|
-
//数据库列名称
|
|
6
|
-
function Field(name) {
|
|
7
|
-
return function (target, propertyKey) {
|
|
8
|
-
let fieldMap = Reflect.getMetadata(DesignMeta_1.DesignMeta.fieldMap, target);
|
|
9
|
-
if (!fieldMap) {
|
|
10
|
-
Reflect.defineMetadata(DesignMeta_1.DesignMeta.fieldMap, new Set([propertyKey]), target);
|
|
11
|
-
}
|
|
12
|
-
else {
|
|
13
|
-
fieldMap.add(propertyKey);
|
|
14
|
-
}
|
|
15
|
-
Reflect.defineMetadata(DesignMeta_1.DesignMeta.field, name, target, propertyKey);
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
exports.default = Field;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
require("reflect-metadata");
|
|
4
|
-
const DesignMeta_1 = require("../../type/DesignMeta");
|
|
5
|
-
//是否为主键
|
|
6
|
-
function PrimaryKey(target, propertyKey) {
|
|
7
|
-
Reflect.defineMetadata(DesignMeta_1.DesignMeta.primaryKey, true, target, propertyKey);
|
|
8
|
-
}
|
|
9
|
-
exports.default = PrimaryKey;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
require("reflect-metadata");
|
|
4
|
-
const DesignMeta_1 = require("../../type/DesignMeta");
|
|
5
|
-
//事务管理会话
|
|
6
|
-
function SqlSession(target, name, index) {
|
|
7
|
-
Reflect.defineMetadata(DesignMeta_1.DesignMeta.sqlSession, index, target, name);
|
|
8
|
-
}
|
|
9
|
-
exports.default = SqlSession;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
require("reflect-metadata");
|
|
4
|
-
const FastCarMetaData_1 = require("../../constant/FastCarMetaData");
|
|
5
|
-
const DesignMeta_1 = require("../../type/DesignMeta");
|
|
6
|
-
//表名称 不缺省
|
|
7
|
-
function Table(name) {
|
|
8
|
-
return function (target) {
|
|
9
|
-
const proto = target.prototype;
|
|
10
|
-
let fields = Reflect.getOwnMetadata(DesignMeta_1.DesignMeta.fieldMap, proto);
|
|
11
|
-
let mappingMap = new Map();
|
|
12
|
-
let dbFields = new Map();
|
|
13
|
-
fields.forEach((c) => {
|
|
14
|
-
let tsType = Reflect.getOwnMetadata(FastCarMetaData_1.FastCarMetaData.designType, proto, c);
|
|
15
|
-
let field = Reflect.getOwnMetadata(DesignMeta_1.DesignMeta.field, proto, c) || c;
|
|
16
|
-
let dbType = Reflect.getOwnMetadata(DesignMeta_1.DesignMeta.dbType, proto, c) || "varchar";
|
|
17
|
-
let primaryKey = !!Reflect.getOwnMetadata(DesignMeta_1.DesignMeta.primaryKey, proto, c);
|
|
18
|
-
let tsName = tsType.name;
|
|
19
|
-
let customeType = Reflect.getOwnMetadata(FastCarMetaData_1.FastCarMetaData.CustomType, proto, c);
|
|
20
|
-
const m = {
|
|
21
|
-
name: c,
|
|
22
|
-
type: customeType || tsName.toLowerCase(),
|
|
23
|
-
field,
|
|
24
|
-
dbType: dbType,
|
|
25
|
-
primaryKey, //是否为主键 默认为false
|
|
26
|
-
};
|
|
27
|
-
dbFields.set(field, c);
|
|
28
|
-
mappingMap.set(c, m);
|
|
29
|
-
});
|
|
30
|
-
Reflect.defineMetadata(DesignMeta_1.DesignMeta.dbFields, dbFields, target); //作用的列名
|
|
31
|
-
Reflect.defineMetadata(DesignMeta_1.DesignMeta.mapping, mappingMap, target); //映射关系
|
|
32
|
-
Reflect.defineMetadata(DesignMeta_1.DesignMeta.table, name, target); //注入表名
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
exports.default = Table;
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
require("reflect-metadata");
|
|
4
|
-
const CommonConstant_1 = require("../../constant/CommonConstant");
|
|
5
|
-
const DesignMeta_1 = require("../../type/DesignMeta");
|
|
6
|
-
const SqlError_1 = require("../../type/SqlError");
|
|
7
|
-
/**
|
|
8
|
-
* @version 1.0 事务管理 不建议多个事务的嵌套(避免长事务) 尽量做到一个方法一个事务
|
|
9
|
-
* */
|
|
10
|
-
function Transactional(driver = "MysqlDataSourceManager") {
|
|
11
|
-
return function (target, methodName, descriptor) {
|
|
12
|
-
const orignFunction = descriptor.value;
|
|
13
|
-
//在初始化时就应该检测是否注入了sessionID
|
|
14
|
-
const paramsIndex = Reflect.getOwnMetadata(DesignMeta_1.DesignMeta.sqlSession, target, methodName);
|
|
15
|
-
if (typeof paramsIndex != "number") {
|
|
16
|
-
throw new SqlError_1.default(`${methodName} needs to inject the SqlSession`);
|
|
17
|
-
}
|
|
18
|
-
descriptor.value = async function (...args) {
|
|
19
|
-
//创建会话id
|
|
20
|
-
let app = Reflect.get(global, CommonConstant_1.CommonConstant.FastcarApp);
|
|
21
|
-
let sysLogger = app.getSysLogger() || console;
|
|
22
|
-
let dsm = app.getComponentByName(driver);
|
|
23
|
-
if (!dsm) {
|
|
24
|
-
sysLogger.error(`DataSourceManager ${driver} not found`);
|
|
25
|
-
return Promise.reject(new SqlError_1.default(`DataSourceManager ${driver} not found`));
|
|
26
|
-
}
|
|
27
|
-
let sessionId = args[paramsIndex];
|
|
28
|
-
if (sessionId) {
|
|
29
|
-
return Promise.resolve(Reflect.apply(orignFunction, this, args));
|
|
30
|
-
}
|
|
31
|
-
let errFlag = false;
|
|
32
|
-
sessionId = dsm.createSession();
|
|
33
|
-
args[paramsIndex] = sessionId;
|
|
34
|
-
let res = null;
|
|
35
|
-
return new Promise((resolve, reject) => {
|
|
36
|
-
Reflect.apply(orignFunction, this, args)
|
|
37
|
-
.then((result) => {
|
|
38
|
-
res = result;
|
|
39
|
-
})
|
|
40
|
-
.catch((e) => {
|
|
41
|
-
sysLogger.error(e);
|
|
42
|
-
errFlag = true;
|
|
43
|
-
})
|
|
44
|
-
.finally(async () => {
|
|
45
|
-
await dsm.destorySession(sessionId, errFlag);
|
|
46
|
-
return !errFlag ? resolve(res) : reject(new SqlError_1.default(`${methodName} exec fail `));
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
};
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
exports.default = Transactional;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const CommonConstant_1 = require("../../constant/CommonConstant");
|
|
4
|
-
const FastCarApplication_1 = require("../../FastCarApplication");
|
|
5
|
-
//应用程序设置 具有最高权限
|
|
6
|
-
function ApplicationSetting(setting) {
|
|
7
|
-
return function (target) {
|
|
8
|
-
let fastcarSetting = Reflect.getMetadata(CommonConstant_1.CommonConstant.FastcarSetting, FastCarApplication_1.default.prototype);
|
|
9
|
-
if (!fastcarSetting) {
|
|
10
|
-
fastcarSetting = new Map();
|
|
11
|
-
}
|
|
12
|
-
Object.keys(setting).forEach((key) => {
|
|
13
|
-
let afterConfig = setting[key];
|
|
14
|
-
let beforeConfig = fastcarSetting.get(key);
|
|
15
|
-
if (beforeConfig) {
|
|
16
|
-
if (typeof beforeConfig == "object") {
|
|
17
|
-
afterConfig = Object.assign(beforeConfig, afterConfig);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
fastcarSetting.set(key, afterConfig);
|
|
21
|
-
});
|
|
22
|
-
Reflect.defineMetadata(CommonConstant_1.CommonConstant.FastcarSetting, fastcarSetting, FastCarApplication_1.default.prototype);
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
exports.default = ApplicationSetting;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const CommonConstant_1 = require("../../constant/CommonConstant");
|
|
4
|
-
const fs = require("fs");
|
|
5
|
-
//设置运行是的主路径
|
|
6
|
-
function BaseFilePath(name) {
|
|
7
|
-
return function (target) {
|
|
8
|
-
let stats = fs.statSync(name);
|
|
9
|
-
if (stats.isFile()) {
|
|
10
|
-
Reflect.set(target.prototype, CommonConstant_1.CommonConstant.BaseFileName, name);
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
exports.default = BaseFilePath;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const CommonConstant_1 = require("../../constant/CommonConstant");
|
|
4
|
-
function BaseName(name) {
|
|
5
|
-
return function (target) {
|
|
6
|
-
Reflect.set(target.prototype, CommonConstant_1.CommonConstant.BaseName, name);
|
|
7
|
-
};
|
|
8
|
-
}
|
|
9
|
-
exports.default = BaseName;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const CommonConstant_1 = require("../../constant/CommonConstant");
|
|
4
|
-
const fs = require("fs");
|
|
5
|
-
//设置运行是的主路径
|
|
6
|
-
function BasePath(name) {
|
|
7
|
-
return function (target) {
|
|
8
|
-
let stats = fs.statSync(name);
|
|
9
|
-
if (stats.isDirectory()) {
|
|
10
|
-
Reflect.set(target.prototype, CommonConstant_1.CommonConstant.BasePath, name);
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
exports.default = BasePath;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const CommonConstant_1 = require("../../constant/CommonConstant");
|
|
4
|
-
//设置初始化的env 注入在原始的application上面
|
|
5
|
-
function ENV(name) {
|
|
6
|
-
return function (target) {
|
|
7
|
-
Reflect.set(target.prototype, CommonConstant_1.CommonConstant.ENV, name);
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
exports.default = ENV;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const CommonConstant_1 = require("../../constant/CommonConstant");
|
|
4
|
-
function ResourcePath(name) {
|
|
5
|
-
return function (target) {
|
|
6
|
-
Reflect.set(target.prototype, CommonConstant_1.CommonConstant.ResourcePath, name);
|
|
7
|
-
};
|
|
8
|
-
}
|
|
9
|
-
exports.default = ResourcePath;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AddLifeCycleItem = void 0;
|
|
4
|
-
function AddLifeCycleItem(target, lifeCycle, item) {
|
|
5
|
-
let list = Reflect.getMetadata(lifeCycle, target);
|
|
6
|
-
if (!list) {
|
|
7
|
-
list = [];
|
|
8
|
-
}
|
|
9
|
-
let exist = list.some((fitem) => {
|
|
10
|
-
return item.exec == fitem.exec;
|
|
11
|
-
});
|
|
12
|
-
if (exist) {
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
list.push(item);
|
|
16
|
-
Reflect.defineMetadata(lifeCycle, list, target);
|
|
17
|
-
}
|
|
18
|
-
exports.AddLifeCycleItem = AddLifeCycleItem;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const BootPriority_1 = require("../../constant/BootPriority");
|
|
4
|
-
const LifeCycleModule_1 = require("../../constant/LifeCycleModule");
|
|
5
|
-
const AddLifeCycleItem_1 = require("./AddLifeCycleItem");
|
|
6
|
-
//启动时机
|
|
7
|
-
function ApplicationDestory(order = BootPriority_1.BootPriority.Sys) {
|
|
8
|
-
return function (target, method, value) {
|
|
9
|
-
(0, AddLifeCycleItem_1.AddLifeCycleItem)(target, LifeCycleModule_1.LifeCycleModule.ApplicationStop, {
|
|
10
|
-
order,
|
|
11
|
-
exec: method,
|
|
12
|
-
});
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
exports.default = ApplicationDestory;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const BootPriority_1 = require("../../constant/BootPriority");
|
|
4
|
-
const LifeCycleModule_1 = require("../../constant/LifeCycleModule");
|
|
5
|
-
const AddLifeCycleItem_1 = require("./AddLifeCycleItem");
|
|
6
|
-
//启动时机
|
|
7
|
-
function ApplicationInit(order = BootPriority_1.BootPriority.Sys) {
|
|
8
|
-
return function (target, method, value) {
|
|
9
|
-
(0, AddLifeCycleItem_1.AddLifeCycleItem)(target, LifeCycleModule_1.LifeCycleModule.ApplicationStart, {
|
|
10
|
-
order,
|
|
11
|
-
exec: method,
|
|
12
|
-
});
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
exports.default = ApplicationInit;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const BootPriority_1 = require("../../constant/BootPriority");
|
|
4
|
-
const LifeCycleModule_1 = require("../../constant/LifeCycleModule");
|
|
5
|
-
const AddLifeCycleItem_1 = require("./AddLifeCycleItem");
|
|
6
|
-
const ApplicationRunner_1 = require("./ApplicationRunner");
|
|
7
|
-
/****
|
|
8
|
-
* @version 1.0 在应用启动后自动执行
|
|
9
|
-
* @params order 排序 序号越小排在越前面 系统级的组件 如数据库等一般为0
|
|
10
|
-
* @params exec 执行方法
|
|
11
|
-
*/
|
|
12
|
-
function ApplicationStart(order = BootPriority_1.BootPriority.Sys, exec = "run") {
|
|
13
|
-
return function (target) {
|
|
14
|
-
if (!Reflect.has(target.prototype, exec)) {
|
|
15
|
-
throw new Error(`${target.name} has no implementation ${exec} method`);
|
|
16
|
-
}
|
|
17
|
-
(0, ApplicationRunner_1.default)(target);
|
|
18
|
-
(0, AddLifeCycleItem_1.AddLifeCycleItem)(target.prototype, LifeCycleModule_1.LifeCycleModule.ApplicationStart, {
|
|
19
|
-
order,
|
|
20
|
-
exec,
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
exports.default = ApplicationStart;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const BootPriority_1 = require("../../constant/BootPriority");
|
|
4
|
-
const LifeCycleModule_1 = require("../../constant/LifeCycleModule");
|
|
5
|
-
const AddLifeCycleItem_1 = require("./AddLifeCycleItem");
|
|
6
|
-
const ApplicationRunner_1 = require("./ApplicationRunner");
|
|
7
|
-
//在应用停止前触发
|
|
8
|
-
function ApplicationStop(order = BootPriority_1.BootPriority.Sys, exec = "run") {
|
|
9
|
-
return function (target) {
|
|
10
|
-
if (!Reflect.has(target.prototype, exec)) {
|
|
11
|
-
throw new Error(`${target.name} has no implementation ${exec} method`);
|
|
12
|
-
}
|
|
13
|
-
(0, ApplicationRunner_1.default)(target);
|
|
14
|
-
(0, AddLifeCycleItem_1.AddLifeCycleItem)(target.prototype, LifeCycleModule_1.LifeCycleModule.ApplicationStop, {
|
|
15
|
-
order,
|
|
16
|
-
exec,
|
|
17
|
-
});
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
exports.default = ApplicationStop;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const DEFAULT_MSG = "This function will be removed in future versions.";
|
|
4
|
-
/****
|
|
5
|
-
* @version 1.0 用于标记弃用
|
|
6
|
-
*/
|
|
7
|
-
function Deprecate(msg = DEFAULT_MSG) {
|
|
8
|
-
return function (target, prop, descriptor) {
|
|
9
|
-
console.warn(prop ? prop : Reflect.get(target, "name"), msg);
|
|
10
|
-
if (descriptor) {
|
|
11
|
-
const fn = descriptor.value;
|
|
12
|
-
descriptor.value = function (...args) {
|
|
13
|
-
console.warn(prop, msg);
|
|
14
|
-
return Reflect.apply(fn, this, args);
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
exports.default = Deprecate;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/**
|
|
4
|
-
* @version 1.0 用于标记只读 可作用于属性或者方法
|
|
5
|
-
*/
|
|
6
|
-
function Readonly(target, methodName, descriptor) {
|
|
7
|
-
if (!descriptor) {
|
|
8
|
-
Reflect.defineProperty(target, methodName, {
|
|
9
|
-
writable: false,
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
else {
|
|
13
|
-
descriptor.writable = false;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
exports.default = Readonly;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const path = require("path");
|
|
4
|
-
const fs = require("fs");
|
|
5
|
-
const FastCarMetaData_1 = require("../../constant/FastCarMetaData");
|
|
6
|
-
function ComponentInjection(target, ...names) {
|
|
7
|
-
let ScanPathList = FastCarMetaData_1.FastCarMetaData.ComponentScan;
|
|
8
|
-
let list = Reflect.get(target.prototype, ScanPathList) || [];
|
|
9
|
-
for (let name of names) {
|
|
10
|
-
//可支持绝对路径
|
|
11
|
-
let p = path.join(require.main?.path || process.cwd() || "", name);
|
|
12
|
-
if (fs.existsSync(name)) {
|
|
13
|
-
p = name;
|
|
14
|
-
}
|
|
15
|
-
if (!list.includes(p)) {
|
|
16
|
-
list.push(p);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
Reflect.set(target.prototype, ScanPathList, list);
|
|
20
|
-
}
|
|
21
|
-
exports.default = ComponentInjection;
|