@fastcar/core 0.2.38
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/LICENSE +20 -0
- package/README.md +379 -0
- package/annotation.d.ts +157 -0
- package/db.d.ts +272 -0
- package/index.d.ts +262 -0
- package/package.json +53 -0
- package/src/FastCarApplication.ts +761 -0
- package/src/annotation/Application.ts +46 -0
- package/src/annotation/ExceptionMonitor.ts +15 -0
- package/src/annotation/bind/AddRequireModule.ts +18 -0
- package/src/annotation/bind/AliasInjection.ts +24 -0
- package/src/annotation/bind/Autowired.ts +11 -0
- package/src/annotation/bind/CallDependency.ts +24 -0
- package/src/annotation/data/DBType.ts +9 -0
- package/src/annotation/data/DS.ts +58 -0
- package/src/annotation/data/DSIndex.ts +7 -0
- package/src/annotation/data/Entity.ts +8 -0
- package/src/annotation/data/Field.ts +15 -0
- package/src/annotation/data/PrimaryKey.ts +7 -0
- package/src/annotation/data/SqlSession.ts +7 -0
- package/src/annotation/data/Table.ts +37 -0
- package/src/annotation/data/Transactional.ts +60 -0
- package/src/annotation/env/ApplicationSetting.ts +24 -0
- package/src/annotation/env/BaseFilePath.ts +12 -0
- package/src/annotation/env/BasePath.ts +12 -0
- package/src/annotation/env/ENV.ts +8 -0
- package/src/annotation/env/ResourcePath.ts +7 -0
- package/src/annotation/lifeCycle/AddLifeCycleItem.ts +25 -0
- package/src/annotation/lifeCycle/ApplicationDestory.ts +13 -0
- package/src/annotation/lifeCycle/ApplicationInit.ts +13 -0
- package/src/annotation/lifeCycle/ApplicationRunner.ts +5 -0
- package/src/annotation/lifeCycle/ApplicationStart.ts +23 -0
- package/src/annotation/lifeCycle/ApplicationStop.ts +18 -0
- package/src/annotation/property/Deprecate.ts +17 -0
- package/src/annotation/property/NotImplemented.ts +5 -0
- package/src/annotation/property/Override.ts +4 -0
- package/src/annotation/property/Readonly.ts +12 -0
- package/src/annotation/scan/ComponentInjection.ts +22 -0
- package/src/annotation/scan/ComponentScan.ts +7 -0
- package/src/annotation/scan/ComponentScanExclusion.ts +26 -0
- package/src/annotation/scan/Hotter.ts +6 -0
- package/src/annotation/stereotype/BeanName.ts +9 -0
- package/src/annotation/stereotype/Component.ts +6 -0
- package/src/annotation/stereotype/Configure.ts +12 -0
- package/src/annotation/stereotype/Controller.ts +7 -0
- package/src/annotation/stereotype/Injection.ts +10 -0
- package/src/annotation/stereotype/Log.ts +17 -0
- package/src/annotation/stereotype/Repository.ts +7 -0
- package/src/annotation/stereotype/Service.ts +7 -0
- package/src/annotation/valid/AddChildValid.ts +61 -0
- package/src/annotation/valid/DefaultVal.ts +8 -0
- package/src/annotation/valid/NotNull.ts +7 -0
- package/src/annotation/valid/Rule.ts +104 -0
- package/src/annotation/valid/Size.ts +13 -0
- package/src/annotation/valid/Type.ts +8 -0
- package/src/annotation/valid/ValidCustom.ts +21 -0
- package/src/annotation/valid/ValidForm.ts +146 -0
- package/src/annotation.ts +103 -0
- package/src/config/ApplicationConfig.ts +5 -0
- package/src/config/SysConfig.ts +28 -0
- package/src/constant/AppStatusEnum.ts +5 -0
- package/src/constant/BootPriority.ts +7 -0
- package/src/constant/CommonConstant.ts +14 -0
- package/src/constant/ComponentKind.ts +7 -0
- package/src/constant/DataTypes.ts +15 -0
- package/src/constant/FastCarMetaData.ts +25 -0
- package/src/constant/LifeCycleModule.ts +5 -0
- package/src/db.ts +182 -0
- package/src/index.ts +11 -0
- package/src/interface/ApplicationHook.ts +9 -0
- package/src/interface/ApplicationRunnerService.ts +3 -0
- package/src/interface/DataSourceManager.ts +14 -0
- package/src/interface/Logger.ts +9 -0
- package/src/model/BaseMapper.ts +115 -0
- package/src/model/DataMap.ts +103 -0
- package/src/model/FormRuleModel.ts +23 -0
- package/src/model/ValidError.ts +1 -0
- package/src/model/WinstonLogger.ts +119 -0
- package/src/type/ComponentDesc.ts +5 -0
- package/src/type/DesignMeta.ts +11 -0
- package/src/type/FileHotterDesc.ts +4 -0
- package/src/type/MapperType.ts +8 -0
- package/src/type/ProcessType.ts +12 -0
- package/src/type/SqlError.ts +3 -0
- package/src/type/WinstonLoggerType.ts +18 -0
- package/src/utils/ClassLoader.ts +72 -0
- package/src/utils/ClassUtils.ts +38 -0
- package/src/utils/CryptoUtil.ts +106 -0
- package/src/utils/DataFormat.ts +97 -0
- package/src/utils/DateUtil.ts +85 -0
- package/src/utils/FileUtil.ts +172 -0
- package/src/utils/FormatStr.ts +13 -0
- package/src/utils/Mix.ts +69 -0
- package/src/utils/ReflectUtil.ts +22 -0
- package/src/utils/TypeUtil.ts +56 -0
- package/src/utils/ValidationUtil.ts +138 -0
- package/src/utils.ts +13 -0
- package/target/FastCarApplication.js +661 -0
- package/target/annotation/AddRequireModule.js +21 -0
- package/target/annotation/Application.js +45 -0
- package/target/annotation/Autowired.js +15 -0
- package/target/annotation/Calldependency.js +18 -0
- package/target/annotation/ExceptionMonitor.js +16 -0
- package/target/annotation/bind/AddRequireModule.js +21 -0
- package/target/annotation/bind/AliasInjection.js +23 -0
- package/target/annotation/bind/Autowired.js +13 -0
- package/target/annotation/bind/CallDependency.js +23 -0
- package/target/annotation/data/DBType.js +11 -0
- package/target/annotation/data/DS.js +54 -0
- package/target/annotation/data/DSIndex.js +9 -0
- package/target/annotation/data/Entity.js +10 -0
- package/target/annotation/data/Field.js +18 -0
- package/target/annotation/data/PrimaryKey.js +9 -0
- package/target/annotation/data/SqlSession.js +9 -0
- package/target/annotation/data/Table.js +34 -0
- package/target/annotation/data/Transactional.js +52 -0
- package/target/annotation/env/ApplicationSetting.js +25 -0
- package/target/annotation/env/BaseFilePath.js +14 -0
- package/target/annotation/env/BasePath.js +14 -0
- package/target/annotation/env/ENV.js +10 -0
- package/target/annotation/env/ResourcePath.js +9 -0
- package/target/annotation/lifeCycle/AddLifeCycleItem.js +18 -0
- package/target/annotation/lifeCycle/ApplicationDestory.js +15 -0
- package/target/annotation/lifeCycle/ApplicationInit.js +15 -0
- package/target/annotation/lifeCycle/ApplicationRunner.js +7 -0
- package/target/annotation/lifeCycle/ApplicationStart.js +24 -0
- package/target/annotation/lifeCycle/ApplicationStop.js +20 -0
- package/target/annotation/property/Deprecate.js +19 -0
- package/target/annotation/property/NotImplemented.js +8 -0
- package/target/annotation/property/Override.js +7 -0
- package/target/annotation/property/Readonly.js +16 -0
- package/target/annotation/scan/ComponentInjection.js +21 -0
- package/target/annotation/scan/ComponentScan.js +9 -0
- package/target/annotation/scan/ComponentScanExclusion.js +25 -0
- package/target/annotation/scan/Hotter.js +8 -0
- package/target/annotation/stereotype/BeanName.js +11 -0
- package/target/annotation/stereotype/Component.js +8 -0
- package/target/annotation/stereotype/Configure.js +14 -0
- package/target/annotation/stereotype/Controller.js +9 -0
- package/target/annotation/stereotype/Injection.js +12 -0
- package/target/annotation/stereotype/Log.js +16 -0
- package/target/annotation/stereotype/Repository.js +9 -0
- package/target/annotation/stereotype/Service.js +9 -0
- package/target/annotation/valid/AddChildValid.js +56 -0
- package/target/annotation/valid/DefaultVal.js +10 -0
- package/target/annotation/valid/NotNull.js +8 -0
- package/target/annotation/valid/Rule.js +100 -0
- package/target/annotation/valid/Size.js +10 -0
- package/target/annotation/valid/Type.js +10 -0
- package/target/annotation/valid/ValidCustom.js +17 -0
- package/target/annotation/valid/ValidForm.js +131 -0
- package/target/annotation.js +101 -0
- package/target/config/ApplicationConfig.js +2 -0
- package/target/config/SysConfig.js +19 -0
- package/target/constant/AppStatusEnum.js +9 -0
- package/target/constant/BootPriority.js +11 -0
- package/target/constant/CommonConstant.js +16 -0
- package/target/constant/ComponentKind.js +11 -0
- package/target/constant/DataTypes.js +19 -0
- package/target/constant/FastCarMetaData.js +29 -0
- package/target/constant/LifeCycleModule.js +9 -0
- package/target/db.js +46 -0
- package/target/index.js +21 -0
- package/target/interface/ApplicationHook.js +2 -0
- package/target/interface/ApplicationRunnerService.js +2 -0
- package/target/interface/DataSourceManager.js +2 -0
- package/target/interface/Logger.js +5 -0
- package/target/model/BaseMapper.js +98 -0
- package/target/model/DataMap.js +87 -0
- package/target/model/FormRuleModel.js +2 -0
- package/target/model/ValidError.js +5 -0
- package/target/model/WinstonLogger.js +95 -0
- package/target/type/ComponentDesc.js +2 -0
- package/target/type/DesignMeta.js +15 -0
- package/target/type/FileHotterDesc.js +2 -0
- package/target/type/MapperType.js +2 -0
- package/target/type/ProcessType.js +2 -0
- package/target/type/SqlError.js +5 -0
- package/target/type/WinstonLoggerType.js +9 -0
- package/target/utils/ClassUtils.js +35 -0
- package/target/utils/CryptoUtil.js +84 -0
- package/target/utils/DataFormat.js +84 -0
- package/target/utils/DateUtil.js +71 -0
- package/target/utils/FileUtil.js +153 -0
- package/target/utils/FormatStr.js +14 -0
- package/target/utils/Mix.js +62 -0
- package/target/utils/ReflectUtil.js +22 -0
- package/target/utils/TypeUtil.js +47 -0
- package/target/utils/ValidationUtil.js +118 -0
- package/target/utils/classLoader.js +65 -0
- package/target/utils.js +23 -0
- package/test/example/logs/app.log +0 -0
- package/test/example/logs/logger.log +12 -0
- package/test/example/logs/logger1.log +12 -0
- package/test/example/logs/logger2.log +12 -0
- package/test/example/logs/logger3.log +12 -0
- package/test/example/logs/logger4.log +12 -0
- package/test/example/logs/logger5.log +6 -0
- package/test/example/logs/sys.log +7 -0
- package/test/example/logs/sys1.log +14 -0
- package/test/example/logs/sys10.log +12 -0
- package/test/example/logs/sys11.log +5 -0
- package/test/example/logs/sys13.log +5 -0
- package/test/example/logs/sys2.log +3 -0
- package/test/example/logs/sys4.log +15 -0
- package/test/example/logs/sys5.log +9 -0
- package/test/example/logs/sys6.log +10 -0
- package/test/example/logs/sys7.log +15 -0
- package/test/example/logs/sys8.log +11 -0
- package/test/example/logs/sys9.log +10 -0
- package/test/example/resource/application-test.yml +0 -0
- package/test/example/resource/application.yml +7 -0
- package/test/example/resource/evnconfig-test.yml +1 -0
- package/test/example/resource/hello.yml +1 -0
- package/test/example/simple/app.ts +99 -0
- package/test/example/simple/component/StartRunner.ts +10 -0
- package/test/example/simple/component/StopRunner.ts +14 -0
- package/test/example/simple/config/EnvConfig.ts +6 -0
- package/test/example/simple/config/HelloConfig.ts +8 -0
- package/test/example/simple/controller/AliasController.ts +6 -0
- package/test/example/simple/controller/HelloController.ts +39 -0
- package/test/example/simple/controller/NotFoundController.ts +20 -0
- package/test/example/simple/service/CallService.ts +11 -0
- package/test/example/simple/service/HelloService.ts +10 -0
- package/test/example/simple/service/LogService.ts +19 -0
- package/test/logs/logger.log +0 -0
- package/test/logs/sys.log +227 -0
- package/test/multi/app.ts +15 -0
- package/test/multi/service/aService.ts +16 -0
- package/test/multi/service/bService.ts +18 -0
- package/test/multi/service/cService.ts +21 -0
- package/test/unit/dataMap-test.ts +48 -0
- package/test/unit/decorators-test.ts +38 -0
- package/test/unit/ds-test.ts +33 -0
- package/test/unit/logs/sys.log +24 -0
- package/test/unit/reflectMetadata-test.ts +15 -0
- package/test/unit/valid-test.ts +65 -0
- package/test/unit/winston-test.ts +15 -0
- package/utils.d.ts +166 -0
package/db.d.ts
ADDED
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
export enum OperatorEnum {
|
|
2
|
+
eq = "=",
|
|
3
|
+
neq = "!=",
|
|
4
|
+
gt = ">",
|
|
5
|
+
gte = ">=",
|
|
6
|
+
lt = "<",
|
|
7
|
+
lte = "<=",
|
|
8
|
+
like = "LIKE",
|
|
9
|
+
in = "IN",
|
|
10
|
+
isNUll = "ISNULL",
|
|
11
|
+
isNotNull = "IS NOT NULL",
|
|
12
|
+
inc = "+", //累加
|
|
13
|
+
dec = "-", //累减
|
|
14
|
+
multiply = "*", //累乘
|
|
15
|
+
division = "/", //累除
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export enum JoinEnum {
|
|
19
|
+
and = "AND",
|
|
20
|
+
or = "OR",
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export enum OrderEnum {
|
|
24
|
+
asc = "ASC",
|
|
25
|
+
desc = "DESC",
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export type SqlValue = number | string | number[] | string[] | boolean | boolean[] | null | Date;
|
|
29
|
+
|
|
30
|
+
//where表达式
|
|
31
|
+
type SqlExpression =
|
|
32
|
+
| {
|
|
33
|
+
[key: string]: { [key: string]: SqlValue };
|
|
34
|
+
}
|
|
35
|
+
| SqlValue;
|
|
36
|
+
|
|
37
|
+
export type SqlWhere = { [key: string]: SqlExpression | SqlWhere };
|
|
38
|
+
|
|
39
|
+
export type RowData = {
|
|
40
|
+
[key: string]: SqlValue | { operate: string; value: SqlValue };
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export type OrderType = { [key: string]: OrderEnum };
|
|
44
|
+
|
|
45
|
+
export type SqlDelete = {
|
|
46
|
+
where?: SqlWhere; //查询条件
|
|
47
|
+
limit?: number; //限制行数
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export type SqlQuery = {
|
|
51
|
+
where?: SqlWhere; //查询条件
|
|
52
|
+
fields?: string[]; //查询出来的元素
|
|
53
|
+
groups?: string[]; //分组排序
|
|
54
|
+
orders?: OrderType; //排序
|
|
55
|
+
limit?: number; //限制行数
|
|
56
|
+
offest?: number; //偏移量
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export type SqlUpdate = {
|
|
60
|
+
where?: SqlWhere; //查询条件
|
|
61
|
+
row: RowData;
|
|
62
|
+
limit?: number; //限制行数
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export type RowType = {
|
|
66
|
+
sql: string;
|
|
67
|
+
args: any[];
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export interface DBMapper<T> {
|
|
71
|
+
/***
|
|
72
|
+
* @version 1.0 更新或者添加记录多条记录(一般用于整条记录的更新)
|
|
73
|
+
*/
|
|
74
|
+
saveORUpdate(rows: T | T[], ds?: string, sessionId?: string): Promise<number | string>;
|
|
75
|
+
|
|
76
|
+
/***
|
|
77
|
+
* @version 1.0 插入单条记录返回主键
|
|
78
|
+
*/
|
|
79
|
+
saveOne(row: T, ds?: string, sessionId?: string): Promise<number | string>;
|
|
80
|
+
|
|
81
|
+
/***
|
|
82
|
+
* @version 1.0 批量插入记录
|
|
83
|
+
*/
|
|
84
|
+
saveList(rows: T[], ds?: string, sessionId?: string): Promise<boolean>;
|
|
85
|
+
|
|
86
|
+
/***
|
|
87
|
+
* @version 1.0 更新记录
|
|
88
|
+
*
|
|
89
|
+
*/
|
|
90
|
+
update({ row, where, limit }: SqlUpdate, ds?: string, sessionId?: string): Promise<boolean>;
|
|
91
|
+
|
|
92
|
+
/****
|
|
93
|
+
* @version 1.0 更新一条数据
|
|
94
|
+
*
|
|
95
|
+
*/
|
|
96
|
+
updateOne(sqlUpdate: SqlUpdate, ds?: string, sessionId?: string): Promise<boolean>;
|
|
97
|
+
|
|
98
|
+
/***
|
|
99
|
+
* @version 1.0 根据实体类的主键来更新数据
|
|
100
|
+
*
|
|
101
|
+
*/
|
|
102
|
+
updateByPrimaryKey(row: T, ds?: string, sessionId?: string): Promise<boolean>;
|
|
103
|
+
|
|
104
|
+
/***
|
|
105
|
+
* @version 1.0 根据条件进行查找
|
|
106
|
+
*/
|
|
107
|
+
select(conditions: SqlQuery, ds?: string, sessionId?: string): Promise<T[]>;
|
|
108
|
+
|
|
109
|
+
/***
|
|
110
|
+
* @version 1.0 查询单个对象
|
|
111
|
+
*
|
|
112
|
+
*/
|
|
113
|
+
selectOne(conditions?: SqlQuery, ds?: string, sessionId?: string): Promise<T | null>;
|
|
114
|
+
|
|
115
|
+
/***
|
|
116
|
+
* @version 1.0 通过主键查找对象
|
|
117
|
+
*
|
|
118
|
+
*/
|
|
119
|
+
selectByPrimaryKey(row: T, ds?: string, sessionId?: string): Promise<T | null>;
|
|
120
|
+
|
|
121
|
+
/***
|
|
122
|
+
* @version 1.0 判定是否存在
|
|
123
|
+
*
|
|
124
|
+
*/
|
|
125
|
+
exist(where: SqlWhere, ds?: string, sessionId?: string): Promise<boolean>;
|
|
126
|
+
|
|
127
|
+
/***
|
|
128
|
+
* @version 1.0 统计符合条件的记录
|
|
129
|
+
*/
|
|
130
|
+
count(where: SqlWhere, ds?: string, sessionId?: string): Promise<number>;
|
|
131
|
+
|
|
132
|
+
/***
|
|
133
|
+
* @version 1.0 按照条件删除记录
|
|
134
|
+
*/
|
|
135
|
+
delete(conditions: SqlDelete, ds?: string, sessionId?: string): Promise<boolean>;
|
|
136
|
+
|
|
137
|
+
/***
|
|
138
|
+
* @version 1.0 删除某条记录
|
|
139
|
+
*/
|
|
140
|
+
deleteOne(where: SqlWhere, ds?: string, sessionId?: string): Promise<boolean>;
|
|
141
|
+
|
|
142
|
+
/***
|
|
143
|
+
* @version 1.0 删除某条记录根据主键
|
|
144
|
+
*/
|
|
145
|
+
deleteByPrimaryKey(row: T, ds?: string, sessionId?: string): Promise<boolean>;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export class BaseMapper<T extends Object> implements DBMapper<T> {
|
|
149
|
+
protected tableName: string;
|
|
150
|
+
protected classZ: any; //映射的原型类
|
|
151
|
+
protected mappingMap: Map<string, MapperType>; //代码别名-映射关系
|
|
152
|
+
protected mappingList: MapperType[];
|
|
153
|
+
protected dbFields: Map<string, string>; //数据库别名-代码别名
|
|
154
|
+
|
|
155
|
+
protected getFieldName(name: string): string;
|
|
156
|
+
|
|
157
|
+
//格式化数据库数据转化为程序设计内的
|
|
158
|
+
protected setRow(rowData: Object): T;
|
|
159
|
+
|
|
160
|
+
protected setRows(rowDataList: Object[]): T[];
|
|
161
|
+
|
|
162
|
+
/***
|
|
163
|
+
* @version 1.0 更新或者添加记录多条记录(一般用于整条记录的更新)
|
|
164
|
+
*/
|
|
165
|
+
saveORUpdate(rows: T | T[], ds?: string, sessionId?: string): Promise<number | string>;
|
|
166
|
+
|
|
167
|
+
/***
|
|
168
|
+
* @version 1.0 插入单条记录返回主键
|
|
169
|
+
*/
|
|
170
|
+
saveOne(row: T, ds?: string, sessionId?: string): Promise<number | string>;
|
|
171
|
+
|
|
172
|
+
/***
|
|
173
|
+
* @version 1.0 批量插入记录
|
|
174
|
+
*/
|
|
175
|
+
saveList(rows: T[], ds?: string, sessionId?: string): Promise<boolean>;
|
|
176
|
+
|
|
177
|
+
/***
|
|
178
|
+
* @version 1.0 更新记录
|
|
179
|
+
*
|
|
180
|
+
*/
|
|
181
|
+
update({ row, where, limit }: SqlUpdate, ds?: string, sessionId?: string): Promise<boolean>;
|
|
182
|
+
|
|
183
|
+
/****
|
|
184
|
+
* @version 1.0 更新一条数据
|
|
185
|
+
*
|
|
186
|
+
*/
|
|
187
|
+
updateOne(sqlUpdate: SqlUpdate, ds?: string, sessionId?: string): Promise<boolean>;
|
|
188
|
+
|
|
189
|
+
/***
|
|
190
|
+
* @version 1.0 根据实体类的主键来更新数据
|
|
191
|
+
*
|
|
192
|
+
*/
|
|
193
|
+
updateByPrimaryKey(row: T, ds?: string, sessionId?: string): Promise<boolean>;
|
|
194
|
+
|
|
195
|
+
/***
|
|
196
|
+
* @version 1.0 根据条件进行查找
|
|
197
|
+
*/
|
|
198
|
+
select(conditions: SqlQuery, ds?: string, sessionId?: string): Promise<T[]>;
|
|
199
|
+
|
|
200
|
+
/***
|
|
201
|
+
* @version 1.0 查询单个对象
|
|
202
|
+
*
|
|
203
|
+
*/
|
|
204
|
+
selectOne(conditions?: SqlQuery, ds?: string, sessionId?: string): Promise<T | null>;
|
|
205
|
+
|
|
206
|
+
/***
|
|
207
|
+
* @version 1.0 通过主键查找对象
|
|
208
|
+
*
|
|
209
|
+
*/
|
|
210
|
+
selectByPrimaryKey(row: T, ds?: string, sessionId?: string): Promise<T | null>;
|
|
211
|
+
|
|
212
|
+
/***
|
|
213
|
+
* @version 1.0 判定是否存在
|
|
214
|
+
*
|
|
215
|
+
*/
|
|
216
|
+
exist(where: SqlWhere, ds?: string, sessionId?: string): Promise<boolean>;
|
|
217
|
+
|
|
218
|
+
/***
|
|
219
|
+
* @version 1.0 统计符合条件的记录
|
|
220
|
+
*/
|
|
221
|
+
count(where: SqlWhere, ds?: string, sessionId?: string): Promise<number>;
|
|
222
|
+
|
|
223
|
+
/***
|
|
224
|
+
* @version 1.0 按照条件删除记录
|
|
225
|
+
*/
|
|
226
|
+
delete(conditions: SqlDelete, ds?: string, sessionId?: string): Promise<boolean>;
|
|
227
|
+
|
|
228
|
+
/***
|
|
229
|
+
* @version 1.0 删除某条记录
|
|
230
|
+
*/
|
|
231
|
+
deleteOne(where: SqlWhere, ds?: string, sessionId?: string): Promise<boolean>;
|
|
232
|
+
|
|
233
|
+
/***
|
|
234
|
+
* @version 1.0 删除某条记录根据主键
|
|
235
|
+
*/
|
|
236
|
+
deleteByPrimaryKey(row: T, ds?: string, sessionId?: string): Promise<boolean>;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
export type MapperType = {
|
|
240
|
+
name: string; //量变名称
|
|
241
|
+
type: string; //类型
|
|
242
|
+
field: string; //数据库列名
|
|
243
|
+
dbType: string; //数据类型
|
|
244
|
+
primaryKey?: boolean; //是否为主键 默认为false
|
|
245
|
+
serialize?: Function; //序列化对象方法
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
export enum DesignMeta {
|
|
249
|
+
table = "db:table", //表名
|
|
250
|
+
field = "db:field", //列名
|
|
251
|
+
fieldMap = "db:fieldMap", //注入列名集合
|
|
252
|
+
dbType = "db:dbType", //数据类型
|
|
253
|
+
primaryKey = "db:primaryKey", //主键类型
|
|
254
|
+
entity = "db:entity", //实例化的数据库类
|
|
255
|
+
mapping = "db:mapping", //映射描述
|
|
256
|
+
dbFields = "db:fields", //数据库名-ts名
|
|
257
|
+
sqlSession = "SqlSession", //sql会话
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
export interface DataSourceManager {
|
|
261
|
+
createSession(): string;
|
|
262
|
+
|
|
263
|
+
destorySession(sessionId: string, status: boolean): void;
|
|
264
|
+
|
|
265
|
+
destorySession(sessionId: string, status: boolean): Promise<void>;
|
|
266
|
+
|
|
267
|
+
start(): void;
|
|
268
|
+
|
|
269
|
+
stop(): void;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
export class SqlError extends Error {}
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
import * as Events from "events";
|
|
2
|
+
import { ApplicationConfig } from "./src/config/ApplicationConfig";
|
|
3
|
+
import { ComponentKind } from "./src/constant/ComponentKind";
|
|
4
|
+
import { LifeCycleModule } from "./src/constant/LifeCycleModule";
|
|
5
|
+
import { FIELDTYPE } from "./src/model/DataMap";
|
|
6
|
+
import { ProcessType } from "./src/type/ProcessType";
|
|
7
|
+
|
|
8
|
+
declare type ComponentDesc = {
|
|
9
|
+
id: string;
|
|
10
|
+
name: string;
|
|
11
|
+
path: string;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export * from "./src/config/SysConfig";
|
|
15
|
+
|
|
16
|
+
export * from "./src/config/ApplicationConfig";
|
|
17
|
+
|
|
18
|
+
export * from "./src/constant/LifeCycleModule";
|
|
19
|
+
|
|
20
|
+
export * from "./src/constant/ComponentKind";
|
|
21
|
+
|
|
22
|
+
export * from "./src/constant/BootPriority";
|
|
23
|
+
|
|
24
|
+
//元数据加载模块
|
|
25
|
+
export * from "./src/constant/FastCarMetaData";
|
|
26
|
+
|
|
27
|
+
//自定义常量模块
|
|
28
|
+
export * from "./src/constant/CommonConstant";
|
|
29
|
+
|
|
30
|
+
//生命周期约定
|
|
31
|
+
export * from "./src/interface/ApplicationHook";
|
|
32
|
+
|
|
33
|
+
export { FIELDTYPE } from "./src/model/DataMap";
|
|
34
|
+
|
|
35
|
+
export abstract class Logger {
|
|
36
|
+
abstract info(...args: any[]): void;
|
|
37
|
+
|
|
38
|
+
abstract debug(...args: any[]): void;
|
|
39
|
+
|
|
40
|
+
abstract warn(...args: any[]): void;
|
|
41
|
+
|
|
42
|
+
abstract error(...args: any[]): void;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export class FastCarApplication extends Events {
|
|
46
|
+
/***
|
|
47
|
+
* @version 1.0 根据原型加载注入的方法
|
|
48
|
+
*
|
|
49
|
+
*/
|
|
50
|
+
getInjectionUniqueKey(target: Object): string;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* @version 1.0 自身作为一个组件注入进去
|
|
54
|
+
*/
|
|
55
|
+
loadSelf(): void;
|
|
56
|
+
|
|
57
|
+
/***
|
|
58
|
+
* @version 1.0 热更新组件
|
|
59
|
+
*/
|
|
60
|
+
addHot(): void;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* @version 1.0 获取资源路径
|
|
64
|
+
*/
|
|
65
|
+
getResourcePath(): string;
|
|
66
|
+
|
|
67
|
+
/***
|
|
68
|
+
* @version 1.0 获取项目的基本路径
|
|
69
|
+
*
|
|
70
|
+
*/
|
|
71
|
+
getBasePath(): string;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* @version 1.0 加载系统配置 加载顺序为 default json < yaml < env
|
|
75
|
+
*
|
|
76
|
+
*/
|
|
77
|
+
loadSysConfig(): void;
|
|
78
|
+
|
|
79
|
+
setSetting(key: string | symbol, value: any): void;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* @version 1.0 获取自定义设置 设置优先级 配置自定义>系统配置>初始化
|
|
83
|
+
* @param key
|
|
84
|
+
*/
|
|
85
|
+
getSetting(key: string | symbol): any;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* @version 1.0 获取应用配置
|
|
89
|
+
* @return
|
|
90
|
+
*/
|
|
91
|
+
getapplicationConfig(): ApplicationConfig;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* @version 1.0 扫描组件
|
|
95
|
+
*/
|
|
96
|
+
loadClass(): void;
|
|
97
|
+
|
|
98
|
+
/***
|
|
99
|
+
* @version 1.0 装配单个模块
|
|
100
|
+
* @deprecated 修改为主动查找时装配
|
|
101
|
+
*/
|
|
102
|
+
injectionModule(instance: any, instanceName: string | symbol): void;
|
|
103
|
+
|
|
104
|
+
/***
|
|
105
|
+
* @version 1.0 根据名称获取组件的加载情况
|
|
106
|
+
*
|
|
107
|
+
*/
|
|
108
|
+
getComponentDetailByName(name: string | symbol): ComponentDesc | undefined;
|
|
109
|
+
|
|
110
|
+
/***
|
|
111
|
+
* @version 1.0 根据原型获取组件的加载信息
|
|
112
|
+
*
|
|
113
|
+
*/
|
|
114
|
+
getComponentDetailByTarget(target: Object): ComponentDesc | undefined;
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* @version 1.0 加载需要注入的类
|
|
118
|
+
* @deprecated 修改为主动查找时装配
|
|
119
|
+
*/
|
|
120
|
+
loadInjectionModule(): void;
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* @version 1.0 根据类型获取组件
|
|
124
|
+
* @param name
|
|
125
|
+
* @return
|
|
126
|
+
*/
|
|
127
|
+
getComponentByType(name: ComponentKind): any[];
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* @version 1.0 获取全部的组件列表
|
|
131
|
+
* @return
|
|
132
|
+
*/
|
|
133
|
+
getComponentList(): any[];
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* @version 1.0 根据名称组件
|
|
137
|
+
* @param name
|
|
138
|
+
*/
|
|
139
|
+
getComponentByName(name: string | symbol): any;
|
|
140
|
+
|
|
141
|
+
/***
|
|
142
|
+
* @version 1.0 根据原型获取实例
|
|
143
|
+
*/
|
|
144
|
+
getComponentByTarget(target: Object): any;
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* @version 1.0 获取组件详情列表
|
|
148
|
+
*
|
|
149
|
+
*/
|
|
150
|
+
getComponentDetailsList(): ComponentDesc[];
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* @version 1.0 开启日志系统
|
|
154
|
+
*/
|
|
155
|
+
startLog(): void;
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* @version 1.0 初始化应用
|
|
159
|
+
*/
|
|
160
|
+
init(): void;
|
|
161
|
+
|
|
162
|
+
/***
|
|
163
|
+
* @version 1.0 退出事件监听
|
|
164
|
+
*
|
|
165
|
+
*/
|
|
166
|
+
addExitEvent(): void;
|
|
167
|
+
|
|
168
|
+
/***
|
|
169
|
+
* @version 1.0 异常事件进行监听 不至于程序异常直接退出
|
|
170
|
+
*/
|
|
171
|
+
addExecptionEvent(): void;
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* @version 1.0 自动调用方法
|
|
175
|
+
* @param name
|
|
176
|
+
*/
|
|
177
|
+
automaticRun(name: LifeCycleModule): void;
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* @version 1.0 开启应用前执行的操作 加载配置,扫描组件,注入依赖组件
|
|
181
|
+
*/
|
|
182
|
+
beforeStartServer(): void;
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* @version 1.0 启动服务
|
|
186
|
+
*/
|
|
187
|
+
startServer(): void;
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* @version 1.0 停止服务前自动调用服务
|
|
191
|
+
*/
|
|
192
|
+
beforeStopServer(): void;
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* @version 1.0 停止服务
|
|
196
|
+
*/
|
|
197
|
+
stopServer(): void;
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* @version 1.0 获取app名称
|
|
201
|
+
*/
|
|
202
|
+
getApplicationName(): string;
|
|
203
|
+
|
|
204
|
+
/***
|
|
205
|
+
* @version 1.0 获取系统日志
|
|
206
|
+
*
|
|
207
|
+
*/
|
|
208
|
+
getSysLogger(): Logger;
|
|
209
|
+
|
|
210
|
+
/***
|
|
211
|
+
* @version 0.2.11 根据名称获取logger
|
|
212
|
+
*
|
|
213
|
+
*/
|
|
214
|
+
getLogger(category?: string): Logger;
|
|
215
|
+
|
|
216
|
+
/***
|
|
217
|
+
* @version 1.0 获取文件内容
|
|
218
|
+
*/
|
|
219
|
+
getFileContent(fp: string): string;
|
|
220
|
+
|
|
221
|
+
/***
|
|
222
|
+
* @version 1.0 是否支持热更
|
|
223
|
+
*
|
|
224
|
+
*/
|
|
225
|
+
isHotter(): boolean;
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* @version 1.0 指定热更新文件
|
|
229
|
+
*
|
|
230
|
+
*/
|
|
231
|
+
specifyHotUpdate(fp: string): void;
|
|
232
|
+
|
|
233
|
+
/***
|
|
234
|
+
* @version 1.0 获取进程的信息
|
|
235
|
+
*
|
|
236
|
+
*/
|
|
237
|
+
getMemoryUsage(): ProcessType;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
//校验错误
|
|
241
|
+
export class ValidError {
|
|
242
|
+
message?: string;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
export class DataMap<K, V extends Object> extends Map<K, V> {
|
|
246
|
+
toValues(): V[];
|
|
247
|
+
|
|
248
|
+
toKeys(): K[];
|
|
249
|
+
|
|
250
|
+
//构造一个字典对象
|
|
251
|
+
toObject(): { [key: string]: V };
|
|
252
|
+
|
|
253
|
+
//自定义排序 支持多个排序
|
|
254
|
+
sort(sorts?: FIELDTYPE[], list?: V[]): V[];
|
|
255
|
+
|
|
256
|
+
/***
|
|
257
|
+
* @version 1.0 查找属性名称
|
|
258
|
+
* @params atts代表属性键值对匹配
|
|
259
|
+
*
|
|
260
|
+
*/
|
|
261
|
+
findByAtts(atts: { [key: string]: any }): V[];
|
|
262
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@fastcar/core",
|
|
3
|
+
"version": "0.2.38",
|
|
4
|
+
"homepage": "https://github.com/williamDazhangyu/fast-car",
|
|
5
|
+
"main": "target/index.js",
|
|
6
|
+
"author": "william_zhong",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"types": "index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": "./target/index.js",
|
|
11
|
+
"./annotation": "./target/annotation.js",
|
|
12
|
+
"./utils": "./target/utils.js",
|
|
13
|
+
"./db": "./target/db.js"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"src",
|
|
17
|
+
"target",
|
|
18
|
+
"test",
|
|
19
|
+
"index.d.ts",
|
|
20
|
+
"annotation.d.ts",
|
|
21
|
+
"db.d.ts",
|
|
22
|
+
"utils.d.ts",
|
|
23
|
+
"LICENSE"
|
|
24
|
+
],
|
|
25
|
+
"keywords": [
|
|
26
|
+
"ioc",
|
|
27
|
+
"spring",
|
|
28
|
+
"node",
|
|
29
|
+
"fastcar-core"
|
|
30
|
+
],
|
|
31
|
+
"engines": {
|
|
32
|
+
"node": ">=16"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"reflect-metadata": "^0.1.13",
|
|
36
|
+
"winston": "^3.6.0",
|
|
37
|
+
"yaml": "^1.10.2"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@types/mocha": "^9.0.0",
|
|
41
|
+
"@types/node": "^16.11.7",
|
|
42
|
+
"@types/reflect-metadata": "^0.1.0",
|
|
43
|
+
"@types/yaml": "^1.9.7",
|
|
44
|
+
"typescript": "^4.4.2"
|
|
45
|
+
},
|
|
46
|
+
"repository": {
|
|
47
|
+
"type": "git",
|
|
48
|
+
"url": "https://github.com/williamDazhangyu/fast-car.git"
|
|
49
|
+
},
|
|
50
|
+
"scripts": {
|
|
51
|
+
"build": "tsc"
|
|
52
|
+
}
|
|
53
|
+
}
|