midway-fatcms 0.0.1-beta.26 → 0.0.1-beta.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/controller/home.controller.js +2 -1
- package/dist/controller/render/AppRenderController.js +2 -1
- package/dist/models/bizmodels.d.ts +1 -0
- package/dist/service/asyncTask/handler/ExportExcelAsyncTaskHandler.js +1 -1
- package/dist/service/crudstd/CrudStdService.d.ts +0 -6
- package/dist/service/crudstd/CrudStdService.js +13 -33
- package/package.json +1 -5
- package/src/config/config.default.ts +0 -207
- package/src/config/seed/aeskey.txt +0 -1
- package/src/config/utils.ts +0 -22
- package/src/configuration.ts +0 -109
- package/src/controller/base/BaseApiController.ts +0 -170
- package/src/controller/gateway/AnyApiGatewayController.ts +0 -33
- package/src/controller/gateway/AsyncTaskController.ts +0 -157
- package/src/controller/gateway/CrudMtdGatewayController.ts +0 -111
- package/src/controller/gateway/CrudStdGatewayController.ts +0 -101
- package/src/controller/gateway/DocGatewayController.ts +0 -173
- package/src/controller/gateway/FileController.ts +0 -109
- package/src/controller/gateway/ProxyApiGatewayController.ts +0 -47
- package/src/controller/gateway/PublicApiController.ts +0 -142
- package/src/controller/gateway/StaticController.ts +0 -298
- package/src/controller/helpers.controller.ts +0 -161
- package/src/controller/home.controller.ts +0 -64
- package/src/controller/manage/AnyApiMangeApi.ts +0 -66
- package/src/controller/manage/AppLogMangeApi.ts +0 -53
- package/src/controller/manage/AppMangeApi.ts +0 -53
- package/src/controller/manage/AppPageMangeApi.ts +0 -52
- package/src/controller/manage/AppSchemaHistoryApi.ts +0 -49
- package/src/controller/manage/CrudMethodsMangeApi.ts +0 -49
- package/src/controller/manage/CrudStandardDesignApi.ts +0 -346
- package/src/controller/manage/DataDictManageApi.ts +0 -78
- package/src/controller/manage/DeployManageApi.ts +0 -175
- package/src/controller/manage/DocLibManageApi.ts +0 -69
- package/src/controller/manage/DocManageApi.ts +0 -99
- package/src/controller/manage/FileManageApi.ts +0 -45
- package/src/controller/manage/LowCodeTplManageApi.ts +0 -52
- package/src/controller/manage/MenuManageApi.ts +0 -58
- package/src/controller/manage/ProxyApiMangeApi.ts +0 -52
- package/src/controller/manage/SuperAdminManageApi.ts +0 -139
- package/src/controller/manage/SysConfigMangeApi.ts +0 -95
- package/src/controller/manage/SystemInfoManageApi.ts +0 -53
- package/src/controller/manage/UserAccountManageApi.ts +0 -94
- package/src/controller/manage/WorkbenchMangeApi.ts +0 -72
- package/src/controller/myinfo/AuthController.ts +0 -108
- package/src/controller/myinfo/MyInfoController.ts +0 -32
- package/src/controller/render/AppRenderController.ts +0 -79
- package/src/controller/test.controller.ts +0 -37
- package/src/filter/default.filter.ts +0 -13
- package/src/filter/notfound.filter.ts +0 -10
- package/src/index.ts +0 -106
- package/src/interface.ts +0 -31
- package/src/libs/crud-pro/CrudPro.ts +0 -165
- package/src/libs/crud-pro/defaultConfigs.ts +0 -15
- package/src/libs/crud-pro/exceptions.ts +0 -124
- package/src/libs/crud-pro/interfaces.ts +0 -190
- package/src/libs/crud-pro/models/ExecuteContext.ts +0 -120
- package/src/libs/crud-pro/models/ExecuteContextFunc.ts +0 -96
- package/src/libs/crud-pro/models/FuncContext.ts +0 -21
- package/src/libs/crud-pro/models/RequestCfgModel.ts +0 -141
- package/src/libs/crud-pro/models/RequestModel.ts +0 -141
- package/src/libs/crud-pro/models/ResModel.ts +0 -19
- package/src/libs/crud-pro/models/ServiceHub.ts +0 -32
- package/src/libs/crud-pro/models/SqlCfgModel.ts +0 -52
- package/src/libs/crud-pro/models/SqlSegArg.ts +0 -13
- package/src/libs/crud-pro/models/Transaction.ts +0 -73
- package/src/libs/crud-pro/models/TransactionMySQL.ts +0 -79
- package/src/libs/crud-pro/models/TransactionPostgres.ts +0 -91
- package/src/libs/crud-pro/models/TransactionSqlServer.ts +0 -102
- package/src/libs/crud-pro/models/keys.ts +0 -159
- package/src/libs/crud-pro/services/CrudProCachedCfgService.ts +0 -83
- package/src/libs/crud-pro/services/CrudProExecuteFuncService.ts +0 -128
- package/src/libs/crud-pro/services/CrudProExecuteSqlService.ts +0 -262
- package/src/libs/crud-pro/services/CrudProFieldUpdateService.ts +0 -60
- package/src/libs/crud-pro/services/CrudProFieldValidateService.ts +0 -180
- package/src/libs/crud-pro/services/CrudProGenSqlCondition.ts +0 -354
- package/src/libs/crud-pro/services/CrudProGenSqlService.ts +0 -185
- package/src/libs/crud-pro/services/CrudProOriginToExecuteSql.ts +0 -393
- package/src/libs/crud-pro/services/CrudProServiceBase.ts +0 -94
- package/src/libs/crud-pro/services/CrudProTableMetaService.ts +0 -86
- package/src/libs/crud-pro/services/CurdProServiceHub.ts +0 -92
- package/src/libs/crud-pro/sql.txt +0 -120
- package/src/libs/crud-pro/utils/CompareUtils.ts +0 -23
- package/src/libs/crud-pro/utils/DatabaseName.ts +0 -60
- package/src/libs/crud-pro/utils/DateTimeUtils.ts +0 -20
- package/src/libs/crud-pro/utils/MemoryRefreshCache.ts +0 -64
- package/src/libs/crud-pro/utils/MessageParseUtils.ts +0 -33
- package/src/libs/crud-pro/utils/MixinUtils.ts +0 -285
- package/src/libs/crud-pro/utils/ModelUtils.ts +0 -55
- package/src/libs/crud-pro/utils/MultiKeyMap.ts +0 -72
- package/src/libs/crud-pro/utils/SqlFuncUtils.ts +0 -29
- package/src/libs/crud-pro/utils/TypeUtils.ts +0 -188
- package/src/libs/crud-pro/utils/ValidateUtils.ts +0 -165
- package/src/libs/crud-pro/utils/pool/MySQLUtils.ts +0 -20
- package/src/libs/crud-pro/utils/pool/PostgresUtils.ts +0 -22
- package/src/libs/crud-pro/utils/pool/SqlServerUtils.ts +0 -22
- package/src/libs/crud-pro/utils/sqlConvert/convertColumnName.ts +0 -26
- package/src/libs/crud-pro/utils/sqlConvert/convertMix.ts +0 -26
- package/src/libs/crud-pro/utils/sqlConvert/convertMsSql.ts +0 -11
- package/src/libs/crud-pro/utils/sqlConvert/convertPgSql.ts +0 -11
- package/src/libs/crud-pro/utils/sqlConvert/convertPgType.ts +0 -129
- package/src/libs/global-config/global-config.ts +0 -78
- package/src/libs/utils/common-dto.ts +0 -52
- package/src/libs/utils/crypto-utils.ts +0 -50
- package/src/libs/utils/errorToString.ts +0 -61
- package/src/libs/utils/fatcms-request.ts +0 -103
- package/src/libs/utils/functions.ts +0 -73
- package/src/libs/utils/ordernum-utils.ts +0 -14
- package/src/libs/utils/parseConfig.ts +0 -54
- package/src/libs/utils/parseCreateSql.ts +0 -91
- package/src/libs/utils/render-utils.ts +0 -184
- package/src/middleware/forbidden.middleware.ts +0 -52
- package/src/middleware/global.middleware.ts +0 -280
- package/src/middleware/permission.middleware.ts +0 -80
- package/src/middleware/tx.middleware.ts +0 -30
- package/src/models/AsyncTaskModel.ts +0 -82
- package/src/models/RedisKeys.ts +0 -13
- package/src/models/SystemEntities.ts +0 -115
- package/src/models/SystemPerm.ts +0 -105
- package/src/models/SystemTables.ts +0 -27
- package/src/models/bizmodels.ts +0 -120
- package/src/models/contextLogger.ts +0 -132
- package/src/models/devops.ts +0 -17
- package/src/models/userSession.ts +0 -216
- package/src/schedule/anonymousContext.ts +0 -73
- package/src/schedule/index.ts +0 -12
- package/src/schedule/runSchedule.ts +0 -82
- package/src/schedule/scheduleNames.ts +0 -21
- package/src/service/AuthService.ts +0 -272
- package/src/service/EnumInfoService.ts +0 -130
- package/src/service/FileCenterService.ts +0 -395
- package/src/service/SysConfigService.ts +0 -37
- package/src/service/UserAccountService.ts +0 -107
- package/src/service/UserSessionService.ts +0 -78
- package/src/service/VisitStatService.ts +0 -166
- package/src/service/WorkbenchService.ts +0 -165
- package/src/service/anyapi/AnyApiSandboxService.ts +0 -121
- package/src/service/anyapi/AnyApiService.ts +0 -186
- package/src/service/asyncTask/AsyncTaskRunnerService.ts +0 -266
- package/src/service/asyncTask/AsyncTaskService.ts +0 -21
- package/src/service/asyncTask/handler/ExcelInfoModel.ts +0 -11
- package/src/service/asyncTask/handler/ExportExcelAsyncTaskHandler.ts +0 -245
- package/src/service/asyncTask/handler/ExportExcelByInnerHttpHandler.ts +0 -147
- package/src/service/asyncTask/handler/ExportExcelByStdCrudHandler.ts +0 -138
- package/src/service/base/ApiBaseService.ts +0 -42
- package/src/service/base/ApiRateLimiter.ts +0 -59
- package/src/service/base/BaseService.ts +0 -100
- package/src/service/base/RedisCacheService.ts +0 -38
- package/src/service/crudstd/CrudStdActionService.ts +0 -27
- package/src/service/crudstd/CrudStdConstant.ts +0 -62
- package/src/service/crudstd/CrudStdRelationService.ts +0 -78
- package/src/service/crudstd/CrudStdService.ts +0 -283
- package/src/service/curd/CrudProQuick.ts +0 -131
- package/src/service/curd/CurdMixByAccountService.ts +0 -90
- package/src/service/curd/CurdMixByDictService.ts +0 -114
- package/src/service/curd/CurdMixByLinkToCustomService.ts +0 -219
- package/src/service/curd/CurdMixBySysConfigService.ts +0 -78
- package/src/service/curd/CurdMixByWorkbenchService.ts +0 -71
- package/src/service/curd/CurdMixService.ts +0 -97
- package/src/service/curd/CurdMixUtils.ts +0 -311
- package/src/service/curd/CurdProService.ts +0 -229
- package/src/service/curd/fixCfgModel.ts +0 -139
- package/src/service/proxyapi/ProxyApiLoadService.ts +0 -174
- package/src/service/proxyapi/ProxyApiService.ts +0 -262
- package/src/service/proxyapi/ProxyApiUtils.ts +0 -32
- package/src/service/proxyapi/RouteHandler.ts +0 -8
- package/src/service/proxyapi/RouteTrie.ts +0 -74
- package/src/service/proxyapi/WeightedRandom.ts +0 -37
- package/src/service/proxyapi/WeightedRoundRobin.ts +0 -44
- package/src/views/404_app.html +0 -31
- package/src/views/404_workbench.html +0 -34
- package/src/views/static/favicon.ico +0 -0
package/src/index.ts
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
export { ContainerLifeCycle as Configuration } from './configuration';
|
|
2
|
-
export * from './controller/base/BaseApiController';
|
|
3
|
-
export * from './controller/gateway/AnyApiGatewayController';
|
|
4
|
-
export * from './controller/gateway/CrudMtdGatewayController';
|
|
5
|
-
export * from './controller/gateway/CrudStdGatewayController';
|
|
6
|
-
export * from './controller/gateway/DocGatewayController';
|
|
7
|
-
export * from './controller/gateway/FileController';
|
|
8
|
-
export * from './controller/gateway/ProxyApiGatewayController';
|
|
9
|
-
export * from './controller/gateway/PublicApiController';
|
|
10
|
-
export * from './controller/gateway/StaticController';
|
|
11
|
-
export * from './controller/gateway/AsyncTaskController';
|
|
12
|
-
export * from './controller/helpers.controller';
|
|
13
|
-
export * from './controller/home.controller';
|
|
14
|
-
export * from './controller/manage/AnyApiMangeApi';
|
|
15
|
-
export * from './controller/manage/AppLogMangeApi';
|
|
16
|
-
export * from './controller/manage/AppMangeApi';
|
|
17
|
-
export * from './controller/manage/AppPageMangeApi';
|
|
18
|
-
export * from './controller/manage/AppSchemaHistoryApi';
|
|
19
|
-
export * from './controller/manage/CrudMethodsMangeApi';
|
|
20
|
-
export * from './controller/manage/CrudStandardDesignApi';
|
|
21
|
-
export * from './controller/manage/DataDictManageApi';
|
|
22
|
-
export * from './controller/manage/DeployManageApi';
|
|
23
|
-
export * from './controller/manage/DocLibManageApi';
|
|
24
|
-
export * from './controller/manage/DocManageApi';
|
|
25
|
-
export * from './controller/manage/FileManageApi';
|
|
26
|
-
export * from './controller/manage/LowCodeTplManageApi';
|
|
27
|
-
export * from './controller/manage/MenuManageApi';
|
|
28
|
-
export * from './controller/manage/ProxyApiMangeApi';
|
|
29
|
-
export * from './controller/manage/SuperAdminManageApi';
|
|
30
|
-
export * from './controller/manage/SysConfigMangeApi';
|
|
31
|
-
export * from './controller/manage/SystemInfoManageApi';
|
|
32
|
-
export * from './controller/manage/UserAccountManageApi';
|
|
33
|
-
export * from './controller/manage/WorkbenchMangeApi';
|
|
34
|
-
export * from './controller/myinfo/AuthController';
|
|
35
|
-
export * from './controller/myinfo/MyInfoController';
|
|
36
|
-
export * from './controller/render/AppRenderController';
|
|
37
|
-
export * from './controller/test.controller';
|
|
38
|
-
export * from './filter/default.filter';
|
|
39
|
-
export * from './filter/notfound.filter';
|
|
40
|
-
export * from './middleware/forbidden.middleware';
|
|
41
|
-
export * from './middleware/global.middleware';
|
|
42
|
-
export * from './middleware/tx.middleware';
|
|
43
|
-
export * from './middleware/permission.middleware';
|
|
44
|
-
export * from './service/AuthService';
|
|
45
|
-
export * from './service/EnumInfoService';
|
|
46
|
-
export * from './service/FileCenterService';
|
|
47
|
-
export * from './service/SysConfigService';
|
|
48
|
-
export * from './service/UserAccountService';
|
|
49
|
-
export * from './service/UserSessionService';
|
|
50
|
-
export * from './service/VisitStatService';
|
|
51
|
-
export * from './service/WorkbenchService';
|
|
52
|
-
export * from './service/anyapi/AnyApiSandboxService';
|
|
53
|
-
export * from './service/anyapi/AnyApiService';
|
|
54
|
-
export * from './service/base/ApiBaseService';
|
|
55
|
-
export * from './service/base/BaseService';
|
|
56
|
-
export * from './service/base/RedisCacheService';
|
|
57
|
-
export * from './service/crudstd/CrudStdActionService';
|
|
58
|
-
export * from './service/crudstd/CrudStdRelationService';
|
|
59
|
-
export * from './service/crudstd/CrudStdService';
|
|
60
|
-
export * from './service/curd/CurdMixByAccountService';
|
|
61
|
-
export * from './service/curd/CurdMixByDictService';
|
|
62
|
-
export * from './service/curd/CurdMixByLinkToCustomService';
|
|
63
|
-
export * from './service/curd/CurdMixBySysConfigService';
|
|
64
|
-
export * from './service/curd/CurdMixByWorkbenchService';
|
|
65
|
-
export * from './service/curd/CurdMixService';
|
|
66
|
-
export * from './service/curd/CurdMixUtils';
|
|
67
|
-
export * from './service/curd/CurdProService';
|
|
68
|
-
export * from './service/curd/CrudProQuick';
|
|
69
|
-
export * from './service/proxyapi/ProxyApiLoadService';
|
|
70
|
-
export * from './service/proxyapi/ProxyApiService';
|
|
71
|
-
export * from './service/asyncTask/AsyncTaskService';
|
|
72
|
-
export * from './service/asyncTask/AsyncTaskRunnerService';
|
|
73
|
-
export * from './models/userSession';
|
|
74
|
-
export * from './models/bizmodels';
|
|
75
|
-
export * from './models/SystemEntities';
|
|
76
|
-
export * from './models/SystemPerm';
|
|
77
|
-
export * from './models/contextLogger';
|
|
78
|
-
export * from './models/devops';
|
|
79
|
-
export * from './models/SystemTables';
|
|
80
|
-
export * from './models/AsyncTaskModel';
|
|
81
|
-
export * from './schedule/index';
|
|
82
|
-
|
|
83
|
-
export * from './libs/utils/common-dto';
|
|
84
|
-
export * from './libs/utils/crypto-utils';
|
|
85
|
-
export * from './libs/utils/fatcms-request';
|
|
86
|
-
export * from './libs/utils/functions';
|
|
87
|
-
export * from './libs/utils/ordernum-utils';
|
|
88
|
-
export * from './libs/utils/parseConfig';
|
|
89
|
-
|
|
90
|
-
export * from './libs/crud-pro/CrudPro';
|
|
91
|
-
export * from './libs/crud-pro/defaultConfigs';
|
|
92
|
-
export * from './libs/crud-pro/exceptions';
|
|
93
|
-
export * from './libs/crud-pro/interfaces';
|
|
94
|
-
|
|
95
|
-
export * from './libs/crud-pro/models/ExecuteContext';
|
|
96
|
-
export * from './libs/crud-pro/models/FuncContext';
|
|
97
|
-
export * from './libs/crud-pro/models/RequestModel';
|
|
98
|
-
export * from './libs/crud-pro/models/SqlCfgModel';
|
|
99
|
-
export * from './libs/crud-pro/models/Transaction';
|
|
100
|
-
export * from './libs/crud-pro/models/keys';
|
|
101
|
-
export * from './libs/crud-pro/models/ExecuteContextFunc';
|
|
102
|
-
export * from './libs/crud-pro/models/RequestCfgModel';
|
|
103
|
-
export * from './libs/crud-pro/models/SqlSegArg';
|
|
104
|
-
export * from './libs/crud-pro/models/ResModel';
|
|
105
|
-
|
|
106
|
-
export * from './libs/global-config/global-config';
|
package/src/interface.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import '@midwayjs/core';
|
|
2
|
-
import { Transaction } from './libs/crud-pro/models/Transaction';
|
|
3
|
-
import { UserSessionInfo } from './models/userSession';
|
|
4
|
-
import { ContextLogger } from './models/contextLogger';
|
|
5
|
-
import { IWorkbenchEntity } from './models/SystemEntities';
|
|
6
|
-
|
|
7
|
-
declare module '@midwayjs/core' {
|
|
8
|
-
interface Context {
|
|
9
|
-
transaction: Transaction;
|
|
10
|
-
userSession: UserSessionInfo;
|
|
11
|
-
workbenchInfo: IWorkbenchEntity;
|
|
12
|
-
contextLogger: ContextLogger;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface ICacheService {
|
|
17
|
-
get: (key: string) => Promise<any>;
|
|
18
|
-
save: (key: string, value: any) => Promise<any>;
|
|
19
|
-
del: (key: string) => Promise<any>;
|
|
20
|
-
init: () => Promise<any>;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export interface IGetCacheParams {
|
|
24
|
-
namespace: string;
|
|
25
|
-
dirname: string;
|
|
26
|
-
keepMs?: number;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export interface IScheduleService {
|
|
30
|
-
runBySchedule: () => Promise<any>;
|
|
31
|
-
}
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
import { ICrudProCfg, ILogger, IRequestCfgModel, IRequestModel, ISqlCfgModel, IVisitor } from './interfaces';
|
|
2
|
-
import { ExecuteContext } from './models/ExecuteContext';
|
|
3
|
-
import { RequestModel } from './models/RequestModel';
|
|
4
|
-
import { CurdProServiceHub } from './services/CurdProServiceHub';
|
|
5
|
-
import { CommonException, Exceptions } from './exceptions';
|
|
6
|
-
import { RequestCfgModel } from './models/RequestCfgModel';
|
|
7
|
-
import { MixinUtils } from './utils/MixinUtils';
|
|
8
|
-
import { Transaction } from './models/Transaction';
|
|
9
|
-
import { IExecuteContextFunc } from './models/ExecuteContextFunc';
|
|
10
|
-
|
|
11
|
-
class CrudPro {
|
|
12
|
-
private readonly executeContext: ExecuteContext;
|
|
13
|
-
private readonly serviceHub: CurdProServiceHub;
|
|
14
|
-
|
|
15
|
-
constructor() {
|
|
16
|
-
this.executeContext = new ExecuteContext();
|
|
17
|
-
this.serviceHub = new CurdProServiceHub(this.executeContext);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
// 必填
|
|
21
|
-
set transaction(transaction: Transaction) {
|
|
22
|
-
this.executeContext.setTransaction(transaction);
|
|
23
|
-
}
|
|
24
|
-
// 必填
|
|
25
|
-
set logger(logger: ILogger) {
|
|
26
|
-
this.executeContext.setLogger(logger);
|
|
27
|
-
}
|
|
28
|
-
// 必填
|
|
29
|
-
set visitor(visitor: IVisitor) {
|
|
30
|
-
this.executeContext.setVisitor(visitor);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
set contextFunc(contextFunc: IExecuteContextFunc) {
|
|
34
|
-
contextFunc.setExecuteContext(this.executeContext);
|
|
35
|
-
this.executeContext.contextFunc = contextFunc;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
set contextCfg(contextCfg: ICrudProCfg) {
|
|
39
|
-
this.executeContext.setContextCfg(contextCfg);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* 直接执行一个SQL
|
|
44
|
-
* @param sqlCfgModel
|
|
45
|
-
*/
|
|
46
|
-
public async executeSQL(sqlCfgModel: ISqlCfgModel): Promise<any> {
|
|
47
|
-
const RES_NAME = 'executeResult';
|
|
48
|
-
|
|
49
|
-
const sqlCfgModel2 = {
|
|
50
|
-
resName: RES_NAME,
|
|
51
|
-
executeSql: '',
|
|
52
|
-
executeSqlArgs: [],
|
|
53
|
-
sqlDatabase: '',
|
|
54
|
-
...sqlCfgModel,
|
|
55
|
-
};
|
|
56
|
-
Object.assign(sqlCfgModel2, sqlCfgModel);
|
|
57
|
-
|
|
58
|
-
const cfgModel: IRequestCfgModel = {
|
|
59
|
-
method: `executeSQL:${sqlCfgModel2.executeSql}`,
|
|
60
|
-
sqlTable: '',
|
|
61
|
-
sqlSimpleName: null,
|
|
62
|
-
sqlDatabase: sqlCfgModel.sqlDatabase,
|
|
63
|
-
sqlCfgList: [sqlCfgModel2],
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
const ss = await this.executeCrudByCfg({}, cfgModel);
|
|
67
|
-
return ss.getResModelItem(RES_NAME);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* 从DB中读取配置
|
|
72
|
-
* @param reqJson
|
|
73
|
-
* @param isEnableCache
|
|
74
|
-
*/
|
|
75
|
-
public async executeCrud(reqJson: IRequestModel, isEnableCache: boolean): Promise<ExecuteContext> {
|
|
76
|
-
const cfgJson = await this.getCachedCfgByMethod(reqJson.method, isEnableCache);
|
|
77
|
-
if (!cfgJson) {
|
|
78
|
-
throw new CommonException(Exceptions.CFG_NOT_FOUND, reqJson.method);
|
|
79
|
-
}
|
|
80
|
-
return await this.executeCrudByCfg(reqJson, cfgJson);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* 核心执行函数,其他都是这个函数的变种
|
|
85
|
-
* @param reqJson
|
|
86
|
-
* @param cfgJson
|
|
87
|
-
*/
|
|
88
|
-
public async executeCrudByCfg(reqJson: IRequestModel, cfgJson: IRequestCfgModel): Promise<ExecuteContext> {
|
|
89
|
-
const logger = this.executeContext.getLogger();
|
|
90
|
-
logger.info('CurdPro executeCrudByCfg', cfgJson);
|
|
91
|
-
|
|
92
|
-
// 在执行之前可以根据业务需要修改需要执行的内容。
|
|
93
|
-
await this.beforeExecuteSQLList(reqJson, cfgJson);
|
|
94
|
-
|
|
95
|
-
const exeCtx = this.executeContext;
|
|
96
|
-
|
|
97
|
-
if (!cfgJson.method) {
|
|
98
|
-
throw new CommonException(Exceptions.CFG_METHOD_EMPTY, JSON.stringify(cfgJson));
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
reqJson.method = cfgJson.method;
|
|
102
|
-
|
|
103
|
-
const reqModel = new RequestModel(reqJson, this.executeContext.getVisitor());
|
|
104
|
-
const cfgModel = new RequestCfgModel(cfgJson);
|
|
105
|
-
|
|
106
|
-
exeCtx.setReqModel(reqModel);
|
|
107
|
-
exeCtx.setCfgModel(cfgModel);
|
|
108
|
-
|
|
109
|
-
// 参数校验
|
|
110
|
-
this.serviceHub.validateByAllow(cfgModel, reqModel);
|
|
111
|
-
this.serviceHub.validateByReject(cfgModel, reqModel);
|
|
112
|
-
this.serviceHub.validateByCfg(cfgModel, reqModel);
|
|
113
|
-
|
|
114
|
-
// 权限校验
|
|
115
|
-
await this.serviceHub.validateByAuthCfg(cfgModel, reqModel);
|
|
116
|
-
|
|
117
|
-
// 默认参数设置
|
|
118
|
-
await this.serviceHub.updateByCfg(cfgModel, reqModel);
|
|
119
|
-
|
|
120
|
-
// 生成SQL
|
|
121
|
-
await this.serviceHub.generateSQLList();
|
|
122
|
-
// 执行SQL
|
|
123
|
-
await this.executeSQLList();
|
|
124
|
-
// 执行SQL执行之后的的处理
|
|
125
|
-
await this.afterExecuteSQLList();
|
|
126
|
-
|
|
127
|
-
return exeCtx;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
public async getCachedCfgByMethod(method: string, isEnableCache: boolean): Promise<IRequestCfgModel> {
|
|
131
|
-
return this.serviceHub.getCachedCfgByMethod(method, isEnableCache);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
private async executeSQLList() {
|
|
135
|
-
try {
|
|
136
|
-
await this.serviceHub.executeSqlCfgModels();
|
|
137
|
-
} catch (e) {
|
|
138
|
-
const message = MixinUtils.getErrorMessage(e);
|
|
139
|
-
const logger = this.executeContext.getLogger();
|
|
140
|
-
logger.error('RUN_SQL_EXCEPTION', message);
|
|
141
|
-
throw this.parseRunSqlException(e || {});
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
private parseRunSqlException(e: any): CommonException {
|
|
146
|
-
const sqlMessage = '' + e.sqlMessage;
|
|
147
|
-
if (e.code === 'ER_DUP_ENTRY' && sqlMessage.startsWith('Duplicate entry')) {
|
|
148
|
-
return new CommonException(Exceptions.RUN_SQL_EXCEPTION_ER_DUP_ENTRY, '此对象实体已存在,不能创建重复对象');
|
|
149
|
-
}
|
|
150
|
-
if (e.code === 'ER_NO_SUCH_TABLE') {
|
|
151
|
-
return new CommonException(Exceptions.RUN_SQL_EXCEPTION_ER_NO_SUCH_TABLE, '查询的表不存在:' + sqlMessage);
|
|
152
|
-
}
|
|
153
|
-
return e;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
private async afterExecuteSQLList() {
|
|
157
|
-
return this.executeContext.contextFunc.afterExecuteSQLList();
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
private async beforeExecuteSQLList(reqJson: IRequestModel, cfgJson: IRequestCfgModel) {
|
|
161
|
-
return this.executeContext.contextFunc.beforeExecuteSQLList(reqJson, cfgJson);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
export { CrudPro };
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { ICrudProCfg } from './interfaces';
|
|
2
|
-
import { SqlDbType } from './models/keys';
|
|
3
|
-
|
|
4
|
-
export const defaultCrudProCfg: ICrudProCfg = {
|
|
5
|
-
sysDatabaseName: 'fatcms',
|
|
6
|
-
sysDatabaseDbType: SqlDbType.mysql, // 默认系统数据库名称,默认 mysql
|
|
7
|
-
sysConfigTableName: 'sys_configs', // 数据表:通用配置
|
|
8
|
-
dictItemTableName: 'sys_data_dict_item', // 数据表:数据字典,字典项。
|
|
9
|
-
methodsTableName: 'sys_crud_methods',
|
|
10
|
-
methodsCacheTime: 1000 * 60,
|
|
11
|
-
tableMetaCacheTime: 1000 * 3600 * 24 * 365, // 表格元信息缓存时间。 开发环境可以设置的短一些
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export const DEFAULT_MAX_LIMIT = 1000;
|
|
15
|
-
export const DEFAULT_LIMIT = 100;
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
export enum Exceptions {
|
|
2
|
-
NO_AUTH = 'NO_AUTH', // 没有权限
|
|
3
|
-
NOT_LOGIN = 'NOT_LOGIN', // 没有登陆
|
|
4
|
-
|
|
5
|
-
MUST_OBJECT = 'MUST_OBJECT',
|
|
6
|
-
MUST_NOT_EMPTY = 'MUST_NOT_EMPTY',
|
|
7
|
-
RUN_GET_COND_OR_DATA_JSONOBJECT = 'RUN_GET_COND_OR_DATA_JSONOBJECT',
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* MySQL配置中不存在此数据库
|
|
11
|
-
*/
|
|
12
|
-
DB_NOT_FOUND = 'DB_NOT_FOUND',
|
|
13
|
-
DB_QUERY_PARAM_EMPTY = 'DB_QUERY_PARAM_EMPTY',
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* 配置错误
|
|
17
|
-
*/
|
|
18
|
-
CFG_ERROR = 'CFG_ERROR',
|
|
19
|
-
CFG_NOT_FOUND = 'CFG_NOT_FOUND',
|
|
20
|
-
CFG_METHOD_EMPTY = 'CFG_METHOD_EMPTY',
|
|
21
|
-
CFG_AUTH_CODE_EMPTY = 'CFG_AUTH_CODE_EMPTY',
|
|
22
|
-
CFG_NOT_FOUND_FILE = 'CFG_NOT_FOUND_FILE',
|
|
23
|
-
CFG_NOT_FOUND_FUNCTION = 'CFG_NOT_FOUND_FUNCTION',
|
|
24
|
-
CFG_EMPTY_TABLE_NAME = 'CFG_EMPTY_TABLE_NAME',
|
|
25
|
-
CFG_EMPTY_SQL = 'CFG_EMPTY_SQL',
|
|
26
|
-
CFG_NOT_SUPPORT_PICK_BY_EXPRESS_SCRIPT = 'CFG_NOT_SUPPORT_PICK_BY_EXPRESS_SCRIPT',
|
|
27
|
-
CFG_NOT_SUPPORT_THE_SIMPLE_SQL = 'CFG_NOT_SUPPORT_THE_SIMPLE_SQL',
|
|
28
|
-
CFG_NOT_SUPPORT_THE_SQL = 'CFG_NOT_SUPPORT_THE_SQL',
|
|
29
|
-
CFG_GET_ATTR_NAME_EMPTY = 'CFG_GET_ATTR_NAME_EMPTY',
|
|
30
|
-
CFG_GET_ATTR_VALUE_ERROR = 'CFG_GET_ATTR_VALUE_ERROR',
|
|
31
|
-
CFG_IO_EXCEPTION_GET_CONFIG_BY_METHOD = 'CFG_IO_EXCEPTION_GET_CONFIG_BY_METHOD',
|
|
32
|
-
CFG_SQLSIMPLENAME_AND_SQLCUSTOMLIST_EMPTY = 'CFG_SQLSIMPLENAME_AND_SQLCUSTOMLIST_EMPTY',
|
|
33
|
-
CFG_VALIDATE_NOT_JSON_ARRAY = 'CFG_VALIDATE_NOT_JSON_ARRAY',
|
|
34
|
-
CFG_VALIDATE_LENGTH_ERROR = 'CFG_VALIDATE_LENGTH_ERROR',
|
|
35
|
-
CFG_VALIDATE_SCALE_ERROR = 'CFG_VALIDATE_SCALE_ERROR',
|
|
36
|
-
CFG_VALIDATE_ENUM_ERROR = 'CFG_VALIDATE_ENUM_ERROR',
|
|
37
|
-
CFG_VALIDATE_NOT_SUPPORT = 'CFG_VALIDATE_NOT_SUPPORT',
|
|
38
|
-
CFG_VALIDATE_CUSTOM_FUNCTION_EMPTY = 'CFG_VALIDATE_CUSTOM_FUNCTION_EMPTY',
|
|
39
|
-
CFG_VALIDATE_CUSTOM_FUNCTION_MUST_RETURN_BOOL = 'CFG_VALIDATE_CUSTOM_FUNCTION_MUST_RETURN_BOOL',
|
|
40
|
-
CFG_UPDATE_MUST_JSON_OBJECT = 'CFG_UPDATE_MUST_JSON_OBJECT',
|
|
41
|
-
CFG_CHECK_EXECUTE_WHEN_EMPTY = 'CFG_CHECK_EXECUTE_WHEN_EMPTY',
|
|
42
|
-
CFG_IS_NEED_EXECUTE_FUNC_MUST_RETURN_BOOL = 'CFG_IS_NEED_EXECUTE_FUNC_MUST_RETURN_BOOL',
|
|
43
|
-
CFG_GET_CONNECTION_NULL = 'CFG_GET_CONNECTION_NULL',
|
|
44
|
-
CFG_SQL_FUNCTION_EMPTY = 'CFG_SQL_FUNCTION_EMPTY',
|
|
45
|
-
CFG_SQL_CFG_EXECUTE_VALIDATE_EMPTY = 'CFG_SQL_CFG_EXECUTE_VALIDATE_EMPTY',
|
|
46
|
-
CFG_UPDATE_ITEM_MUST_FUNC_CFG = 'CFG_UPDATE_ITEM_MUST_FUNC_CFG',
|
|
47
|
-
CFG_PARSE_ERROR = 'CFG_PARSE_ERROR',
|
|
48
|
-
CFG_ERROR_POSTGRES_UNIQUE_COLUMNS_NULL = 'CFG_ERROR_POSTGRES_UNIQUE_COLUMNS_NULL',
|
|
49
|
-
CFG_UNIQUE_COLUMN_COUNT_MUST_ONE = 'CFG_UNIQUE_COLUMN_COUNT_MUST_ONE',
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* 数据传错
|
|
53
|
-
*/
|
|
54
|
-
DATA_GET_JSON_OBJECT_ERROR = 'DATA_GET_JSON_OBJECT_ERROR',
|
|
55
|
-
DATA_GET_DATA_EMPTY = 'DATA_GET_DATA_EMPTY',
|
|
56
|
-
DATA_GET_DATA_EMPTY_ON_UPDATE = 'DATA_GET_DATA_EMPTY_ON_UPDATE',
|
|
57
|
-
DATA_GET_DATA_EMPTY_ON_INSERT_KEYS = 'DATA_GET_DATA_EMPTY_ON_INSERT_KEYS',
|
|
58
|
-
DATA_GET_DATA_EMPTY_ON_INSERT_VALUES = 'DATA_GET_DATA_EMPTY_ON_INSERT_VALUES',
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* 请求的Method字段为空
|
|
62
|
-
*/
|
|
63
|
-
REQUEST_METHOD_EMPTY = 'REQUEST_METHOD_EMPTY', // 解析排序字段失败
|
|
64
|
-
REQUEST_MUST_JSON_OBJECT = 'REQUEST_MUST_JSON_OBJECT',
|
|
65
|
-
REQUEST_OR_PARAM_MUST_ARRAY = 'REQUEST_PARAM_MUST_ARRAY',
|
|
66
|
-
REQUEST_PARAM_MUST_BASIC_TYPE = 'REQUEST_PARAM_MUST_BASIC_TYPE',
|
|
67
|
-
REQUEST_PARAM_MUST_BASIC_TYPE_ARRAY = 'REQUEST_PARAM_MUST_BASIC_TYPE_ARRAY',
|
|
68
|
-
REQUEST_MODEL_PARSE_ORDER_BY_FAILED = 'REQUEST_MODEL_PARSE_ORDER_BY_FAILED', // 解析排序字段失败
|
|
69
|
-
REQUEST_PARAM_ERROR = 'REQUEST_PARAM_ERROR',
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* 执行错误
|
|
73
|
-
*/
|
|
74
|
-
RUN_EMBED_FUNC_ERR = 'RUN_EMBED_FUNC_ERR',
|
|
75
|
-
RUN_SQL_EXCEPTION = 'RUN_SQL_EXCEPTION',
|
|
76
|
-
RUN_SQL_EXCEPTION_ER_DUP_ENTRY = 'RUN_SQL_EXCEPTION_ER_DUP_ENTRY',
|
|
77
|
-
RUN_SQL_EXCEPTION_ER_NO_SUCH_TABLE = 'RUN_SQL_EXCEPTION_ER_NO_SUCH_TABLE',
|
|
78
|
-
RUN_IS_NEED_EXECUTE_ERR = 'RUN_IS_NEED_EXECUTE_ERR',
|
|
79
|
-
RUN_PICK_ERR_VISITOR_NULL = 'RUN_PICK_ERR_VISITOR_NULL',
|
|
80
|
-
RUN_PICK_ERR_VISITOR_FIELD = 'RUN_PICK_ERR_VISITOR_FIELD',
|
|
81
|
-
RUN_PICK_ERR_VISITOR_FIELD_NULL = 'RUN_PICK_ERR_VISITOR_FIELD_NULL',
|
|
82
|
-
RUN_EXECUTE_VALIDATE = 'RUN_EXECUTE_VALIDATE',
|
|
83
|
-
RUN_FUNCTION_NOT_FOUND = 'RUN_FUNCTION_NOT_FOUND',
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* 参数校验错误
|
|
87
|
-
*/
|
|
88
|
-
VALIDATE_ERR = 'VALIDATE_ERR',
|
|
89
|
-
VALIDATE_ALLOW_ERR = 'VALIDATE_ALLOW_ERR',
|
|
90
|
-
VALIDATE_REJECT_ERR = 'VALIDATE_REJECT_ERR',
|
|
91
|
-
VALIDATE_EXCEPTION = 'VALIDATE_EXCEPTION',
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* update异常
|
|
95
|
-
*/
|
|
96
|
-
UPDATE_EXCEPTION = 'UPDATE_EXCEPTION',
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* 类型转换错误
|
|
100
|
-
*/
|
|
101
|
-
CAST_JSON_ARRAY_ERROR = 'CAST_JSON_ARRAY_ERROR',
|
|
102
|
-
CAST_JSON_OBJECT_ERROR = 'CAST_JSON_OBJECT_ERROR',
|
|
103
|
-
CAST_TYPE_NOT_SUPPORT = 'CAST_TYPE_NOT_SUPPORT',
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* 其他异常
|
|
107
|
-
*/
|
|
108
|
-
OTHER_EXCEPTION = 'OTHER_EXCEPTION',
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
export class CommonException {
|
|
112
|
-
public code: string;
|
|
113
|
-
public message: string;
|
|
114
|
-
constructor(code: string, message?: any) {
|
|
115
|
-
this.code = code;
|
|
116
|
-
if (message) {
|
|
117
|
-
if (typeof message === 'object') {
|
|
118
|
-
this.message = JSON.stringify(message);
|
|
119
|
-
} else {
|
|
120
|
-
this.message = '' + message;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
// import { Pool as MysqlPool } from 'mysql2/promise';
|
|
2
|
-
// import { Pool as PostgresPool } from 'pg';
|
|
3
|
-
import { KeysOfAuthType, KeysOfSimpleSQL, KeysOfValidators, SqlDbType } from './models/keys';
|
|
4
|
-
|
|
5
|
-
export interface ICrudProCfg {
|
|
6
|
-
sysDatabaseName?: string; // 默认系统数据库名称,默认 fatcms
|
|
7
|
-
sysDatabaseDbType?: SqlDbType; // 默认系统数据库名称,默认 mysql
|
|
8
|
-
methodsTableName?: string; // 方法配置的表名,默认 sys_crud_methods
|
|
9
|
-
methodsCacheTime?: number; //内存缓存时间默认 1分钟
|
|
10
|
-
dictItemTableName?: string; // 字典项表名称,默认:sys_data_dict_item
|
|
11
|
-
sysConfigTableName?: string; // 字典项表名称,默认:sys_configs
|
|
12
|
-
tableMetaCacheTime?: number; // 表格元信息缓存时间
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export interface ITableMeta {
|
|
16
|
-
expiredTime: number; // 过期时间
|
|
17
|
-
tableColumns: string[]; // 表格所有字段
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export interface IConnectionPool {
|
|
21
|
-
dbType: SqlDbType;
|
|
22
|
-
poolName: string;
|
|
23
|
-
poolInstance: any; //MysqlPool | PostgresPool;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export interface IPoolConnectionClient {
|
|
27
|
-
query: (sql: string, values: any[]) => Promise<any[]>;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* 用户请求
|
|
32
|
-
*/
|
|
33
|
-
export interface IRequestModel {
|
|
34
|
-
method?: string;
|
|
35
|
-
columns?: string | string[]; // "columns": "id,name,age,sex,addr",
|
|
36
|
-
condition?: Record<string, any>; // 拼接查询条件
|
|
37
|
-
data?: Record<string, any>; //拼接update/insert语句的数据部分
|
|
38
|
-
orderBy?: string | IOrderByItem[];
|
|
39
|
-
limit?: number;
|
|
40
|
-
offset?: number;
|
|
41
|
-
pageSize?: number;
|
|
42
|
-
pageNo?: number;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
type IBasicType = boolean | string | number;
|
|
46
|
-
|
|
47
|
-
export interface ICompareCondition {
|
|
48
|
-
$gt?: IBasicType;
|
|
49
|
-
$gte?: IBasicType;
|
|
50
|
-
$lt?: IBasicType;
|
|
51
|
-
$lte?: IBasicType;
|
|
52
|
-
$ne?: IBasicType;
|
|
53
|
-
|
|
54
|
-
$in?: IRequestCondition[];
|
|
55
|
-
$nin?: IRequestCondition[];
|
|
56
|
-
$like?: IBasicType;
|
|
57
|
-
$match?: IBasicType;
|
|
58
|
-
$matchBool?: IBasicType;
|
|
59
|
-
$range?: number[];
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export interface IRequestCondition extends Record<string, any>, ICompareCondition {
|
|
63
|
-
$or?: IRequestCondition[];
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* 用户基本信息
|
|
68
|
-
*/
|
|
69
|
-
export interface IVisitor {
|
|
70
|
-
isLogin: boolean;
|
|
71
|
-
isSuperAdmin: boolean;
|
|
72
|
-
accountId: string;
|
|
73
|
-
nickName: string;
|
|
74
|
-
roleCodes: string[];
|
|
75
|
-
functionCodes: string[];
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* 系统只支持Dict和SysConfigEnum两种
|
|
80
|
-
* 实际配置时,可以配置其他的枚举值,但系统不处理,用户需要在自己的crudConfigFactory.afterExecuteSQLList进行处理
|
|
81
|
-
*/
|
|
82
|
-
export enum BasicRecordEnum {
|
|
83
|
-
dict = 'dict', // 关联数据字典
|
|
84
|
-
sysCfgEnum = 'sysCfgEnum', // 配置文件中,必须包含code一列,作为唯一键。
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export interface CopyAttr {
|
|
88
|
-
from: string;
|
|
89
|
-
to: string;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export interface ColumnRelation {
|
|
93
|
-
relatedType: any; // 如: dict
|
|
94
|
-
relatedCode?: string; // SexEnum
|
|
95
|
-
sourceColumn: string; // 从row中取值的字段名
|
|
96
|
-
targetColumns?: CopyAttr[]; //[{from:'label', to:'user_sex_text'}]
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* 基本响应配置
|
|
101
|
-
*/
|
|
102
|
-
export interface IBaseCfgModel {
|
|
103
|
-
sqlTable?: string; // 可以为空. originSql中不包含@@table时可以为空
|
|
104
|
-
sqlSchema?: string; // 可以为空
|
|
105
|
-
sqlDatabase?: string; // 可以为空,用此字段进行connection的选择和切换。配合getBizConnectionPool使用
|
|
106
|
-
sqlDbType?: SqlDbType; // 数据库类型,mysql(默认) 、postgres
|
|
107
|
-
maxLimit?: number; // 最大一次性返回的数量
|
|
108
|
-
columns?: string | string[]; // "columns": "id,name,age,sex,addr",
|
|
109
|
-
columnsRelation?: ColumnRelation[];
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
export type IFunctionParam = IFuncCfgModel | string | number | boolean | null;
|
|
113
|
-
export interface IFuncCfgModel extends Record<any, any> {
|
|
114
|
-
___PLAIN_OBJECT___?: boolean; // 本身就是一个对象
|
|
115
|
-
functionName?: string; // 函数名
|
|
116
|
-
functionParams?: IFunctionParam[]; // 函数参数
|
|
117
|
-
|
|
118
|
-
const?: any; // 常量,任意类型。可以是json对象
|
|
119
|
-
constString?: any; // 常量字符串
|
|
120
|
-
constNumber?: number; // 常量数字,任意形式, int,bigDecimal,bigInteger,字符串,等。
|
|
121
|
-
constBool?: boolean; // 常量bool值。与js的判断逻辑一致,false, null, 0 , "" 被认为是 false,其他认为是true
|
|
122
|
-
|
|
123
|
-
context?: string; // 从context中取值
|
|
124
|
-
contextAsString?: string; // 从context中取值
|
|
125
|
-
contextAsNumber?: string; // 从context中取值
|
|
126
|
-
contextAsBool?: string; // 从context中取值
|
|
127
|
-
|
|
128
|
-
message?: string; // 在校验阶段有用,其他阶段没有用
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
export interface ISqlCfgModel extends IBaseCfgModel {
|
|
132
|
-
resName?: string;
|
|
133
|
-
resPicker?: string;
|
|
134
|
-
originSql?: string; // 有特殊占位符的SQL, 原始的SQL
|
|
135
|
-
validate?: IFuncCfgModel; //执行前,进行校验,校验不通过就抛出异常. 校验函数可以返回 boolean或直接抛出异常
|
|
136
|
-
executeWhen?: IFuncCfgModel; //满足表达式的结果,才能执行。 默认:true 校验函数必须返回 boolean
|
|
137
|
-
executeSql?: string; // 可以运行的SQL。在postgres/sqlserver环境下也可以使用问号。
|
|
138
|
-
executeSqlArgs?: any[]; //可以运行的SQL的参数
|
|
139
|
-
crudType?: string;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* 自定义校验函数。如果不正确请抛出异常。{code:'xxx',message:'xxx'}
|
|
144
|
-
*/
|
|
145
|
-
export type ICustomValidateFunc = (value: string) => void;
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* validateCfg中允许的配置
|
|
149
|
-
*/
|
|
150
|
-
export type IValidatorCfgItem = IFuncCfgModel | KeysOfValidators | string | ICustomValidateFunc;
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* 接口响应配置
|
|
154
|
-
*/
|
|
155
|
-
export interface IRequestCfgModel extends IBaseCfgModel {
|
|
156
|
-
method?: string; // 不能为空
|
|
157
|
-
transactionEnable?: boolean; // 是否开启事务,默认不开启,每条语句都是autocommit
|
|
158
|
-
transactionIsolation?: number; // 事务隔离级别
|
|
159
|
-
sqlSimpleName?: KeysOfSimpleSQL; // 二选一 sqlSimpleName sqlCfgList;; sqlCfgList 优先级高于sqlSimpleName
|
|
160
|
-
sqlCfgList?: ISqlCfgModel[]; // 二选一 sqlSimpleName sqlCfgList;; sqlCfgList 优先级高于sqlSimpleName
|
|
161
|
-
updateCfg?: Record<string, IFuncCfgModel>;
|
|
162
|
-
allowCfg?: Record<string, string[]>;
|
|
163
|
-
rejectCfg?: Record<string, string[]>;
|
|
164
|
-
validateCfg?: Record<string, IValidatorCfgItem[]>;
|
|
165
|
-
authType?: KeysOfAuthType;
|
|
166
|
-
authConfig?: string | string[];
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
export interface IOrderByItem {
|
|
170
|
-
fieldName: string;
|
|
171
|
-
orderType: string;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
export interface ILimitOffset {
|
|
175
|
-
limit: number;
|
|
176
|
-
offset: number;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
export interface ILogger {
|
|
180
|
-
info(msg: any, ...args: any[]): void;
|
|
181
|
-
debug(msg: any, ...args: any[]): void;
|
|
182
|
-
error(msg: any, ...args: any[]): void;
|
|
183
|
-
warn(msg: any, ...args: any[]): void;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
export interface IExecuteUnsafeQueryCtx {
|
|
187
|
-
sqlTable: string;
|
|
188
|
-
sqlDatabase: string;
|
|
189
|
-
sqlDbType: SqlDbType;
|
|
190
|
-
}
|