@fastcar/core 0.2.64 → 0.3.0
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/README.md +5 -2
- package/annotation.d.ts +3 -0
- package/index.d.ts +57 -50
- package/package.json +4 -4
- package/src/FastCarApplication.ts +184 -123
- package/src/annotation/Application.ts +3 -1
- package/src/annotation/bind/AddInjectionService.ts +17 -0
- package/src/annotation/bind/AddRequireModule.ts +1 -1
- package/src/annotation/bind/AliasInjection.ts +8 -15
- package/src/annotation/bind/Autowired.ts +1 -1
- package/src/annotation/bind/CallDependency.ts +7 -17
- package/src/annotation/bind/DemandInjection.ts +16 -0
- package/src/annotation/stereotype/Log.ts +13 -9
- package/src/annotation/stereotype/Value.ts +5 -0
- package/src/annotation.ts +2 -0
- package/src/constant/FastCarMetaData.ts +2 -0
- package/src/model/WinstonLogger.ts +1 -1
- package/src/type/ClassConstructor.ts +5 -0
- package/src/type/ComponentDesc.ts +13 -0
- package/src/type/FileHotterDesc.ts +6 -0
- package/src/utils/ClassLoader.ts +2 -1
- package/target/FastCarApplication.js +764 -708
- package/target/annotation/Application.js +46 -45
- package/target/annotation/ExceptionMonitor.js +16 -16
- package/target/annotation/bind/AddInjectionService.js +16 -0
- package/target/annotation/bind/AddRequireModule.js +21 -21
- package/target/annotation/bind/AliasInjection.js +19 -23
- package/target/annotation/bind/Autowired.js +13 -13
- package/target/annotation/bind/CallDependency.js +16 -23
- package/target/annotation/bind/DemandInjection.js +15 -0
- 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 +17 -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 +19 -17
- package/target/annotation/stereotype/Repository.js +9 -9
- package/target/annotation/stereotype/Service.js +9 -9
- package/target/annotation/stereotype/Value.js +5 -0
- 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 +99 -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 +110 -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 +33 -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 +103 -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 +98 -96
- package/target/type/ClassConstructor.js +2 -0
- package/target/type/ComponentDesc.js +9 -2
- package/target/type/DesignMeta.js +15 -15
- package/target/type/FileHotterDesc.js +9 -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 +66 -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 +8 -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 -123
- package/target/utils.js +25 -25
- package/test/example/logs/fastcar-server.app.log +0 -0
- package/test/example/logs/fastcar-server.sys.log +10 -0
- package/test/example/logs/fastcar-server.sys1.log +8 -0
- package/test/example/logs/fastcar-server.sys2.log +11 -0
- package/test/example/logs/fastcar-server.sys3.log +0 -0
- package/test/example/logs/other-server.app.log +0 -0
- package/test/example/logs/other-server.sys.log +5 -0
- package/test/example/logs/sys.log +0 -0
- package/test/example/logs/sys1.log +0 -0
- package/test/example/resource/application.yml +2 -0
- package/test/example/resource/hello.yml +1 -1
- package/test/example/simple/app-test.ts +2 -1
- package/test/example/simple/app.ts +16 -16
- package/test/example/simple/service/CallService.ts +2 -0
- package/test/example/simple/service/HelloService.ts +2 -0
- package/test/unit/sys2.log +6 -0
- package/test/unit/sys3.log +6 -0
- package/test/unit/sys4.log +6 -0
- package/test/unit/sys5.log +6 -0
- package/test/unit/sys6.log +6 -0
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
let
|
|
12
|
-
let
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
let
|
|
16
|
-
let
|
|
17
|
-
let
|
|
18
|
-
let
|
|
19
|
-
let
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
Reflect.defineMetadata(DesignMeta_1.DesignMeta.
|
|
32
|
-
Reflect.defineMetadata(DesignMeta_1.DesignMeta.
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = Table;
|
|
4
|
+
require("reflect-metadata");
|
|
5
|
+
const FastCarMetaData_1 = require("../../constant/FastCarMetaData");
|
|
6
|
+
const DesignMeta_1 = require("../../type/DesignMeta");
|
|
7
|
+
//表名称 不缺省
|
|
8
|
+
function Table(name) {
|
|
9
|
+
return function (target) {
|
|
10
|
+
const proto = target.prototype;
|
|
11
|
+
let fields = Reflect.getOwnMetadata(DesignMeta_1.DesignMeta.fieldMap, proto);
|
|
12
|
+
let mappingMap = new Map();
|
|
13
|
+
let dbFields = new Map();
|
|
14
|
+
fields.forEach((c) => {
|
|
15
|
+
let tsType = Reflect.getOwnMetadata(FastCarMetaData_1.FastCarMetaData.designType, proto, c);
|
|
16
|
+
let field = Reflect.getOwnMetadata(DesignMeta_1.DesignMeta.field, proto, c) || c;
|
|
17
|
+
let dbType = Reflect.getOwnMetadata(DesignMeta_1.DesignMeta.dbType, proto, c) || "varchar";
|
|
18
|
+
let primaryKey = !!Reflect.getOwnMetadata(DesignMeta_1.DesignMeta.primaryKey, proto, c);
|
|
19
|
+
let tsName = tsType.name;
|
|
20
|
+
let customeType = Reflect.getOwnMetadata(FastCarMetaData_1.FastCarMetaData.CustomType, proto, c);
|
|
21
|
+
const m = {
|
|
22
|
+
name: c, //变量名称
|
|
23
|
+
type: customeType || tsName.toLowerCase(), //ts类型
|
|
24
|
+
field, //数据库列名
|
|
25
|
+
dbType: dbType, //数据类型
|
|
26
|
+
primaryKey, //是否为主键 默认为false
|
|
27
|
+
};
|
|
28
|
+
dbFields.set(field, c);
|
|
29
|
+
mappingMap.set(c, m);
|
|
30
|
+
});
|
|
31
|
+
Reflect.defineMetadata(DesignMeta_1.DesignMeta.dbFields, dbFields, target); //作用的列名
|
|
32
|
+
Reflect.defineMetadata(DesignMeta_1.DesignMeta.mapping, mappingMap, target); //映射关系
|
|
33
|
+
Reflect.defineMetadata(DesignMeta_1.DesignMeta.table, name, target); //注入表名
|
|
34
|
+
};
|
|
35
|
+
}
|
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
*
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
let
|
|
22
|
-
let
|
|
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
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = Transactional;
|
|
4
|
+
require("reflect-metadata");
|
|
5
|
+
const CommonConstant_1 = require("../../constant/CommonConstant");
|
|
6
|
+
const DesignMeta_1 = require("../../type/DesignMeta");
|
|
7
|
+
const SqlError_1 = require("../../type/SqlError");
|
|
8
|
+
/**
|
|
9
|
+
* @version 1.0 事务管理 不建议多个事务的嵌套(避免长事务) 尽量做到一个方法一个事务
|
|
10
|
+
* */
|
|
11
|
+
function Transactional(driver = "MysqlDataSourceManager") {
|
|
12
|
+
return function (target, methodName, descriptor) {
|
|
13
|
+
const orignFunction = descriptor.value;
|
|
14
|
+
//在初始化时就应该检测是否注入了sessionID
|
|
15
|
+
const paramsIndex = Reflect.getOwnMetadata(DesignMeta_1.DesignMeta.sqlSession, target, methodName);
|
|
16
|
+
if (typeof paramsIndex != "number") {
|
|
17
|
+
throw new SqlError_1.default(`${methodName} needs to inject the SqlSession`);
|
|
18
|
+
}
|
|
19
|
+
descriptor.value = async function (...args) {
|
|
20
|
+
//创建会话id
|
|
21
|
+
let app = Reflect.get(global, CommonConstant_1.CommonConstant.FastcarApp);
|
|
22
|
+
let sysLogger = app.getSysLogger() || console;
|
|
23
|
+
let dsm = app.getComponentByName(driver);
|
|
24
|
+
if (!dsm) {
|
|
25
|
+
sysLogger.error(`DataSourceManager ${driver} not found`);
|
|
26
|
+
return Promise.reject(new SqlError_1.default(`DataSourceManager ${driver} not found`));
|
|
27
|
+
}
|
|
28
|
+
let sessionId = args[paramsIndex];
|
|
29
|
+
if (sessionId) {
|
|
30
|
+
return Promise.resolve(Reflect.apply(orignFunction, this, args));
|
|
31
|
+
}
|
|
32
|
+
let errFlag = false;
|
|
33
|
+
sessionId = dsm.createSession();
|
|
34
|
+
args[paramsIndex] = sessionId;
|
|
35
|
+
let res = null;
|
|
36
|
+
return new Promise((resolve, reject) => {
|
|
37
|
+
Reflect.apply(orignFunction, this, args)
|
|
38
|
+
.then((result) => {
|
|
39
|
+
res = result;
|
|
40
|
+
})
|
|
41
|
+
.catch((e) => {
|
|
42
|
+
sysLogger.error(e);
|
|
43
|
+
errFlag = true;
|
|
44
|
+
})
|
|
45
|
+
.finally(async () => {
|
|
46
|
+
await dsm.destorySession(sessionId, errFlag);
|
|
47
|
+
return !errFlag ? resolve(res) : reject(new SqlError_1.default(`${methodName} exec fail `));
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
}
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
let
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = ApplicationSetting;
|
|
4
|
+
const CommonConstant_1 = require("../../constant/CommonConstant");
|
|
5
|
+
const FastCarApplication_1 = require("../../FastCarApplication");
|
|
6
|
+
//应用程序设置 具有最高权限
|
|
7
|
+
function ApplicationSetting(setting) {
|
|
8
|
+
return function (target) {
|
|
9
|
+
let fastcarSetting = Reflect.getMetadata(CommonConstant_1.CommonConstant.FastcarSetting, FastCarApplication_1.default.prototype);
|
|
10
|
+
if (!fastcarSetting) {
|
|
11
|
+
fastcarSetting = new Map();
|
|
12
|
+
}
|
|
13
|
+
Object.keys(setting).forEach((key) => {
|
|
14
|
+
let afterConfig = setting[key];
|
|
15
|
+
let beforeConfig = fastcarSetting.get(key);
|
|
16
|
+
if (beforeConfig) {
|
|
17
|
+
if (typeof beforeConfig == "object") {
|
|
18
|
+
afterConfig = Object.assign(beforeConfig, afterConfig);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
fastcarSetting.set(key, afterConfig);
|
|
22
|
+
});
|
|
23
|
+
Reflect.defineMetadata(CommonConstant_1.CommonConstant.FastcarSetting, fastcarSetting, FastCarApplication_1.default.prototype);
|
|
24
|
+
};
|
|
25
|
+
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = BaseFilePath;
|
|
4
|
+
const CommonConstant_1 = require("../../constant/CommonConstant");
|
|
5
|
+
const fs = require("fs");
|
|
6
|
+
//设置运行是的主路径
|
|
7
|
+
function BaseFilePath(name) {
|
|
8
|
+
return function (target) {
|
|
9
|
+
let stats = fs.statSync(name);
|
|
10
|
+
if (stats.isFile()) {
|
|
11
|
+
Reflect.set(target.prototype, CommonConstant_1.CommonConstant.BaseFileName, name);
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = BaseName;
|
|
4
|
+
const CommonConstant_1 = require("../../constant/CommonConstant");
|
|
5
|
+
function BaseName(name) {
|
|
6
|
+
return function (target) {
|
|
7
|
+
Reflect.set(target.prototype, CommonConstant_1.CommonConstant.BaseName, name);
|
|
8
|
+
};
|
|
9
|
+
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = BasePath;
|
|
4
|
+
const CommonConstant_1 = require("../../constant/CommonConstant");
|
|
5
|
+
const fs = require("fs");
|
|
6
|
+
//设置运行是的主路径
|
|
7
|
+
function BasePath(name) {
|
|
8
|
+
return function (target) {
|
|
9
|
+
let stats = fs.statSync(name);
|
|
10
|
+
if (stats.isDirectory()) {
|
|
11
|
+
Reflect.set(target.prototype, CommonConstant_1.CommonConstant.BasePath, name);
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = ENV;
|
|
4
|
+
const CommonConstant_1 = require("../../constant/CommonConstant");
|
|
5
|
+
//设置初始化的env 注入在原始的application上面
|
|
6
|
+
function ENV(name) {
|
|
7
|
+
return function (target) {
|
|
8
|
+
Reflect.set(target.prototype, CommonConstant_1.CommonConstant.ENV, name);
|
|
9
|
+
};
|
|
10
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = ResourcePath;
|
|
4
|
+
const CommonConstant_1 = require("../../constant/CommonConstant");
|
|
5
|
+
function ResourcePath(name) {
|
|
6
|
+
return function (target) {
|
|
7
|
+
Reflect.set(target.prototype, CommonConstant_1.CommonConstant.ResourcePath, name);
|
|
8
|
+
};
|
|
9
|
+
}
|
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AddLifeCycleItem =
|
|
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
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AddLifeCycleItem = AddLifeCycleItem;
|
|
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
|
+
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = ApplicationDestory;
|
|
4
|
+
const BootPriority_1 = require("../../constant/BootPriority");
|
|
5
|
+
const LifeCycleModule_1 = require("../../constant/LifeCycleModule");
|
|
6
|
+
const AddLifeCycleItem_1 = require("./AddLifeCycleItem");
|
|
7
|
+
//启动时机
|
|
8
|
+
function ApplicationDestory(order = BootPriority_1.BootPriority.Sys) {
|
|
9
|
+
return function (target, method, value) {
|
|
10
|
+
(0, AddLifeCycleItem_1.AddLifeCycleItem)(target, LifeCycleModule_1.LifeCycleModule.ApplicationStop, {
|
|
11
|
+
order,
|
|
12
|
+
exec: method,
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = ApplicationInit;
|
|
4
|
+
const BootPriority_1 = require("../../constant/BootPriority");
|
|
5
|
+
const LifeCycleModule_1 = require("../../constant/LifeCycleModule");
|
|
6
|
+
const AddLifeCycleItem_1 = require("./AddLifeCycleItem");
|
|
7
|
+
//启动时机
|
|
8
|
+
function ApplicationInit(order = BootPriority_1.BootPriority.Sys) {
|
|
9
|
+
return function (target, method, value) {
|
|
10
|
+
(0, AddLifeCycleItem_1.AddLifeCycleItem)(target, LifeCycleModule_1.LifeCycleModule.ApplicationStart, {
|
|
11
|
+
order,
|
|
12
|
+
exec: method,
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = ApplicationRunner;
|
|
4
|
+
const Component_1 = require("../stereotype/Component");
|
|
5
|
+
function ApplicationRunner(target) {
|
|
6
|
+
(0, Component_1.default)(target);
|
|
7
|
+
}
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
* @
|
|
10
|
-
* @params
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
(0,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = ApplicationStart;
|
|
4
|
+
const BootPriority_1 = require("../../constant/BootPriority");
|
|
5
|
+
const LifeCycleModule_1 = require("../../constant/LifeCycleModule");
|
|
6
|
+
const AddLifeCycleItem_1 = require("./AddLifeCycleItem");
|
|
7
|
+
const ApplicationRunner_1 = require("./ApplicationRunner");
|
|
8
|
+
/****
|
|
9
|
+
* @version 1.0 在应用启动后自动执行
|
|
10
|
+
* @params order 排序 序号越小排在越前面 系统级的组件 如数据库等一般为0
|
|
11
|
+
* @params exec 执行方法
|
|
12
|
+
*/
|
|
13
|
+
function ApplicationStart(order = BootPriority_1.BootPriority.Sys, exec = "run") {
|
|
14
|
+
return function (target) {
|
|
15
|
+
if (!Reflect.has(target.prototype, exec)) {
|
|
16
|
+
throw new Error(`${target.name} has no implementation ${exec} method`);
|
|
17
|
+
}
|
|
18
|
+
(0, ApplicationRunner_1.default)(target);
|
|
19
|
+
(0, AddLifeCycleItem_1.AddLifeCycleItem)(target.prototype, LifeCycleModule_1.LifeCycleModule.ApplicationStart, {
|
|
20
|
+
order,
|
|
21
|
+
exec,
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
(0,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = ApplicationStop;
|
|
4
|
+
const BootPriority_1 = require("../../constant/BootPriority");
|
|
5
|
+
const LifeCycleModule_1 = require("../../constant/LifeCycleModule");
|
|
6
|
+
const AddLifeCycleItem_1 = require("./AddLifeCycleItem");
|
|
7
|
+
const ApplicationRunner_1 = require("./ApplicationRunner");
|
|
8
|
+
//在应用停止前触发
|
|
9
|
+
function ApplicationStop(order = BootPriority_1.BootPriority.Sys, exec = "run") {
|
|
10
|
+
return function (target) {
|
|
11
|
+
if (!Reflect.has(target.prototype, exec)) {
|
|
12
|
+
throw new Error(`${target.name} has no implementation ${exec} method`);
|
|
13
|
+
}
|
|
14
|
+
(0, ApplicationRunner_1.default)(target);
|
|
15
|
+
(0, AddLifeCycleItem_1.AddLifeCycleItem)(target.prototype, LifeCycleModule_1.LifeCycleModule.ApplicationStop, {
|
|
16
|
+
order,
|
|
17
|
+
exec,
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
descriptor.value
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = Deprecate;
|
|
4
|
+
const DEFAULT_MSG = "This function will be removed in future versions.";
|
|
5
|
+
/****
|
|
6
|
+
* @version 1.0 用于标记弃用
|
|
7
|
+
*/
|
|
8
|
+
function Deprecate(msg = DEFAULT_MSG) {
|
|
9
|
+
return function (target, prop, descriptor) {
|
|
10
|
+
console.warn(prop ? prop : Reflect.get(target, "name"), msg);
|
|
11
|
+
if (descriptor) {
|
|
12
|
+
const fn = descriptor.value;
|
|
13
|
+
descriptor.value = function (...args) {
|
|
14
|
+
console.warn(prop, msg);
|
|
15
|
+
return Reflect.apply(fn, this, args);
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
*
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = NotImplemented;
|
|
4
|
+
/***
|
|
5
|
+
* @version 1.0 不实现说明
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
function NotImplemented(target, name, descriptor) { }
|