midway-fatcms 0.0.1-beta.30 → 0.0.1-beta.31
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/config/config.default.d.ts +3 -0
- package/dist/config/config.default.js +189 -0
- package/dist/config/seed/aeskey.txt +1 -0
- package/dist/config/utils.d.ts +1 -0
- package/dist/config/utils.js +23 -0
- package/dist/configuration.d.ts +7 -0
- package/dist/configuration.js +113 -0
- package/dist/controller/base/BaseApiController.d.ts +37 -0
- package/dist/controller/base/BaseApiController.js +164 -0
- package/dist/controller/gateway/AnyApiGatewayController.d.ts +13 -0
- package/dist/controller/gateway/AnyApiGatewayController.js +55 -0
- package/dist/controller/gateway/AsyncTaskController.d.ts +20 -0
- package/dist/controller/gateway/AsyncTaskController.js +181 -0
- package/dist/controller/gateway/CrudMtdGatewayController.d.ts +21 -0
- package/dist/controller/gateway/CrudMtdGatewayController.js +119 -0
- package/dist/controller/gateway/CrudStdGatewayController.d.ts +38 -0
- package/dist/controller/gateway/CrudStdGatewayController.js +137 -0
- package/dist/controller/gateway/DocGatewayController.d.ts +27 -0
- package/dist/controller/gateway/DocGatewayController.js +179 -0
- package/dist/controller/gateway/FileController.d.ts +26 -0
- package/dist/controller/gateway/FileController.js +129 -0
- package/dist/controller/gateway/ProxyApiGatewayController.d.ts +18 -0
- package/dist/controller/gateway/ProxyApiGatewayController.js +78 -0
- package/dist/controller/gateway/PublicApiController.d.ts +27 -0
- package/dist/controller/gateway/PublicApiController.js +165 -0
- package/dist/controller/gateway/StaticController.d.ts +24 -0
- package/dist/controller/gateway/StaticController.js +288 -0
- package/dist/controller/helpers.controller.d.ts +39 -0
- package/dist/controller/helpers.controller.js +188 -0
- package/dist/controller/home.controller.d.ts +9 -0
- package/dist/controller/home.controller.js +72 -0
- package/dist/controller/manage/AnyApiMangeApi.d.ts +10 -0
- package/dist/controller/manage/AnyApiMangeApi.js +98 -0
- package/dist/controller/manage/AppLogMangeApi.d.ts +10 -0
- package/dist/controller/manage/AppLogMangeApi.js +88 -0
- package/dist/controller/manage/AppMangeApi.d.ts +10 -0
- package/dist/controller/manage/AppMangeApi.js +88 -0
- package/dist/controller/manage/AppPageMangeApi.d.ts +10 -0
- package/dist/controller/manage/AppPageMangeApi.js +87 -0
- package/dist/controller/manage/AppSchemaHistoryApi.d.ts +10 -0
- package/dist/controller/manage/AppSchemaHistoryApi.js +83 -0
- package/dist/controller/manage/CrudMethodsMangeApi.d.ts +10 -0
- package/dist/controller/manage/CrudMethodsMangeApi.js +84 -0
- package/dist/controller/manage/CrudStandardDesignApi.d.ts +38 -0
- package/dist/controller/manage/CrudStandardDesignApi.js +342 -0
- package/dist/controller/manage/DataDictManageApi.d.ts +15 -0
- package/dist/controller/manage/DataDictManageApi.js +133 -0
- package/dist/controller/manage/DeployManageApi.d.ts +19 -0
- package/dist/controller/manage/DeployManageApi.js +180 -0
- package/dist/controller/manage/DocLibManageApi.d.ts +10 -0
- package/dist/controller/manage/DocLibManageApi.js +104 -0
- package/dist/controller/manage/DocManageApi.d.ts +11 -0
- package/dist/controller/manage/DocManageApi.js +130 -0
- package/dist/controller/manage/FileManageApi.d.ts +13 -0
- package/dist/controller/manage/FileManageApi.js +77 -0
- package/dist/controller/manage/LowCodeTplManageApi.d.ts +13 -0
- package/dist/controller/manage/LowCodeTplManageApi.js +86 -0
- package/dist/controller/manage/MenuManageApi.d.ts +10 -0
- package/dist/controller/manage/MenuManageApi.js +93 -0
- package/dist/controller/manage/ProxyApiMangeApi.d.ts +10 -0
- package/dist/controller/manage/ProxyApiMangeApi.js +87 -0
- package/dist/controller/manage/SuperAdminManageApi.d.ts +24 -0
- package/dist/controller/manage/SuperAdminManageApi.js +153 -0
- package/dist/controller/manage/SysConfigMangeApi.d.ts +11 -0
- package/dist/controller/manage/SysConfigMangeApi.js +126 -0
- package/dist/controller/manage/SystemInfoManageApi.d.ts +12 -0
- package/dist/controller/manage/SystemInfoManageApi.js +72 -0
- package/dist/controller/manage/UserAccountManageApi.d.ts +14 -0
- package/dist/controller/manage/UserAccountManageApi.js +129 -0
- package/dist/controller/manage/WorkbenchMangeApi.d.ts +11 -0
- package/dist/controller/manage/WorkbenchMangeApi.js +103 -0
- package/dist/controller/myinfo/AuthController.d.ts +33 -0
- package/dist/controller/myinfo/AuthController.js +136 -0
- package/dist/controller/myinfo/MyInfoController.d.ts +13 -0
- package/dist/controller/myinfo/MyInfoController.js +51 -0
- package/dist/controller/render/AppRenderController.d.ts +11 -0
- package/dist/controller/render/AppRenderController.js +92 -0
- package/dist/controller/test.controller.d.ts +8 -0
- package/dist/controller/test.controller.js +51 -0
- package/dist/filter/default.filter.d.ts +7 -0
- package/dist/filter/default.filter.js +23 -0
- package/dist/filter/notfound.filter.d.ts +5 -0
- package/dist/filter/notfound.filter.js +20 -0
- package/dist/index.d.ts +102 -0
- package/dist/index.js +120 -0
- package/dist/interface.d.ts +27 -0
- package/dist/interface.js +3 -0
- package/dist/libs/crud-pro/CrudPro.d.ts +37 -0
- package/dist/libs/crud-pro/CrudPro.js +136 -0
- package/dist/libs/crud-pro/defaultConfigs.d.ts +4 -0
- package/dist/libs/crud-pro/defaultConfigs.js +15 -0
- package/dist/libs/crud-pro/exceptions.d.ts +104 -0
- package/dist/libs/crud-pro/exceptions.js +117 -0
- package/dist/libs/crud-pro/interfaces.d.ts +163 -0
- package/dist/libs/crud-pro/interfaces.js +12 -0
- package/dist/libs/crud-pro/models/ExecuteContext.d.ts +49 -0
- package/dist/libs/crud-pro/models/ExecuteContext.js +79 -0
- package/dist/libs/crud-pro/models/ExecuteContextFunc.d.ts +38 -0
- package/dist/libs/crud-pro/models/ExecuteContextFunc.js +72 -0
- package/dist/libs/crud-pro/models/FuncContext.d.ts +18 -0
- package/dist/libs/crud-pro/models/FuncContext.js +6 -0
- package/dist/libs/crud-pro/models/RequestCfgModel.d.ts +65 -0
- package/dist/libs/crud-pro/models/RequestCfgModel.js +81 -0
- package/dist/libs/crud-pro/models/RequestModel.d.ts +25 -0
- package/dist/libs/crud-pro/models/RequestModel.js +113 -0
- package/dist/libs/crud-pro/models/ResModel.d.ts +16 -0
- package/dist/libs/crud-pro/models/ResModel.js +2 -0
- package/dist/libs/crud-pro/models/ServiceHub.d.ts +20 -0
- package/dist/libs/crud-pro/models/ServiceHub.js +2 -0
- package/dist/libs/crud-pro/models/SqlCfgModel.d.ts +22 -0
- package/dist/libs/crud-pro/models/SqlCfgModel.js +40 -0
- package/dist/libs/crud-pro/models/SqlSegArg.d.ts +6 -0
- package/dist/libs/crud-pro/models/SqlSegArg.js +12 -0
- package/dist/libs/crud-pro/models/Transaction.d.ts +29 -0
- package/dist/libs/crud-pro/models/Transaction.js +67 -0
- package/dist/libs/crud-pro/models/TransactionMySQL.d.ts +28 -0
- package/dist/libs/crud-pro/models/TransactionMySQL.js +76 -0
- package/dist/libs/crud-pro/models/TransactionPostgres.d.ts +28 -0
- package/dist/libs/crud-pro/models/TransactionPostgres.js +85 -0
- package/dist/libs/crud-pro/models/TransactionSqlServer.d.ts +34 -0
- package/dist/libs/crud-pro/models/TransactionSqlServer.js +92 -0
- package/dist/libs/crud-pro/models/keys.d.ts +106 -0
- package/dist/libs/crud-pro/models/keys.js +149 -0
- package/dist/libs/crud-pro/services/CrudProCachedCfgService.d.ts +11 -0
- package/dist/libs/crud-pro/services/CrudProCachedCfgService.js +73 -0
- package/dist/libs/crud-pro/services/CrudProExecuteFuncService.d.ts +9 -0
- package/dist/libs/crud-pro/services/CrudProExecuteFuncService.js +112 -0
- package/dist/libs/crud-pro/services/CrudProExecuteSqlService.d.ts +17 -0
- package/dist/libs/crud-pro/services/CrudProExecuteSqlService.js +225 -0
- package/dist/libs/crud-pro/services/CrudProFieldUpdateService.d.ts +9 -0
- package/dist/libs/crud-pro/services/CrudProFieldUpdateService.js +51 -0
- package/dist/libs/crud-pro/services/CrudProFieldValidateService.d.ts +13 -0
- package/dist/libs/crud-pro/services/CrudProFieldValidateService.js +148 -0
- package/dist/libs/crud-pro/services/CrudProGenSqlCondition.d.ts +24 -0
- package/dist/libs/crud-pro/services/CrudProGenSqlCondition.js +340 -0
- package/dist/libs/crud-pro/services/CrudProGenSqlService.d.ts +25 -0
- package/dist/libs/crud-pro/services/CrudProGenSqlService.js +165 -0
- package/dist/libs/crud-pro/services/CrudProOriginToExecuteSql.d.ts +32 -0
- package/dist/libs/crud-pro/services/CrudProOriginToExecuteSql.js +334 -0
- package/dist/libs/crud-pro/services/CrudProServiceBase.d.ts +24 -0
- package/dist/libs/crud-pro/services/CrudProServiceBase.js +90 -0
- package/dist/libs/crud-pro/services/CrudProTableMetaService.d.ts +9 -0
- package/dist/libs/crud-pro/services/CrudProTableMetaService.js +78 -0
- package/dist/libs/crud-pro/services/CurdProServiceHub.d.ts +32 -0
- package/dist/libs/crud-pro/services/CurdProServiceHub.js +64 -0
- package/dist/libs/crud-pro/sql.txt +120 -0
- package/dist/libs/crud-pro/utils/CompareUtils.d.ts +9 -0
- package/dist/libs/crud-pro/utils/CompareUtils.js +25 -0
- package/dist/libs/crud-pro/utils/DatabaseName.d.ts +9 -0
- package/dist/libs/crud-pro/utils/DatabaseName.js +50 -0
- package/dist/libs/crud-pro/utils/DateTimeUtils.d.ts +7 -0
- package/dist/libs/crud-pro/utils/DateTimeUtils.js +21 -0
- package/dist/libs/crud-pro/utils/MemoryRefreshCache.d.ts +19 -0
- package/dist/libs/crud-pro/utils/MemoryRefreshCache.js +47 -0
- package/dist/libs/crud-pro/utils/MessageParseUtils.d.ts +5 -0
- package/dist/libs/crud-pro/utils/MessageParseUtils.js +33 -0
- package/dist/libs/crud-pro/utils/MixinUtils.d.ts +39 -0
- package/dist/libs/crud-pro/utils/MixinUtils.js +255 -0
- package/dist/libs/crud-pro/utils/ModelUtils.d.ts +11 -0
- package/dist/libs/crud-pro/utils/ModelUtils.js +49 -0
- package/dist/libs/crud-pro/utils/MultiKeyMap.d.ts +11 -0
- package/dist/libs/crud-pro/utils/MultiKeyMap.js +63 -0
- package/dist/libs/crud-pro/utils/SqlFuncUtils.d.ts +5 -0
- package/dist/libs/crud-pro/utils/SqlFuncUtils.js +29 -0
- package/dist/libs/crud-pro/utils/TypeUtils.d.ts +40 -0
- package/dist/libs/crud-pro/utils/TypeUtils.js +166 -0
- package/dist/libs/crud-pro/utils/ValidateUtils.d.ts +3 -0
- package/dist/libs/crud-pro/utils/ValidateUtils.js +165 -0
- package/dist/libs/crud-pro/utils/pool/MySQLUtils.d.ts +3 -0
- package/dist/libs/crud-pro/utils/pool/MySQLUtils.js +19 -0
- package/dist/libs/crud-pro/utils/pool/PostgresUtils.d.ts +3 -0
- package/dist/libs/crud-pro/utils/pool/PostgresUtils.js +20 -0
- package/dist/libs/crud-pro/utils/pool/SqlServerUtils.d.ts +3 -0
- package/dist/libs/crud-pro/utils/pool/SqlServerUtils.js +20 -0
- package/dist/libs/crud-pro/utils/sqlConvert/convertColumnName.d.ts +4 -0
- package/dist/libs/crud-pro/utils/sqlConvert/convertColumnName.js +21 -0
- package/dist/libs/crud-pro/utils/sqlConvert/convertMix.d.ts +3 -0
- package/dist/libs/crud-pro/utils/sqlConvert/convertMix.js +22 -0
- package/dist/libs/crud-pro/utils/sqlConvert/convertMsSql.d.ts +2 -0
- package/dist/libs/crud-pro/utils/sqlConvert/convertMsSql.js +11 -0
- package/dist/libs/crud-pro/utils/sqlConvert/convertPgSql.d.ts +2 -0
- package/dist/libs/crud-pro/utils/sqlConvert/convertPgSql.js +11 -0
- package/dist/libs/crud-pro/utils/sqlConvert/convertPgType.d.ts +2 -0
- package/dist/libs/crud-pro/utils/sqlConvert/convertPgType.js +128 -0
- package/dist/libs/global-config/global-config.d.ts +45 -0
- package/dist/libs/global-config/global-config.js +33 -0
- package/dist/libs/utils/common-dto.d.ts +18 -0
- package/dist/libs/utils/common-dto.js +40 -0
- package/dist/libs/utils/crypto-utils.d.ts +3 -0
- package/dist/libs/utils/crypto-utils.js +46 -0
- package/dist/libs/utils/errorToString.d.ts +2 -0
- package/dist/libs/utils/errorToString.js +57 -0
- package/dist/libs/utils/fatcms-request.d.ts +30 -0
- package/dist/libs/utils/fatcms-request.js +104 -0
- package/dist/libs/utils/functions.d.ts +5 -0
- package/dist/libs/utils/functions.js +68 -0
- package/dist/libs/utils/ordernum-utils.d.ts +2 -0
- package/dist/libs/utils/ordernum-utils.js +13 -0
- package/dist/libs/utils/parseConfig.d.ts +7 -0
- package/dist/libs/utils/parseConfig.js +44 -0
- package/dist/libs/utils/parseCreateSql.d.ts +5 -0
- package/dist/libs/utils/parseCreateSql.js +86 -0
- package/dist/libs/utils/render-utils.d.ts +28 -0
- package/dist/libs/utils/render-utils.js +135 -0
- package/dist/middleware/forbidden.middleware.d.ts +10 -0
- package/dist/middleware/forbidden.middleware.js +54 -0
- package/dist/middleware/global.middleware.d.ts +10 -0
- package/dist/middleware/global.middleware.js +266 -0
- package/dist/middleware/permission.middleware.d.ts +18 -0
- package/dist/middleware/permission.middleware.js +74 -0
- package/dist/middleware/tx.middleware.d.ts +9 -0
- package/dist/middleware/tx.middleware.js +40 -0
- package/dist/models/AsyncTaskModel.d.ts +74 -0
- package/dist/models/AsyncTaskModel.js +31 -0
- package/dist/models/RedisKeys.d.ts +14 -0
- package/dist/models/RedisKeys.js +17 -0
- package/dist/models/SystemEntities.d.ts +98 -0
- package/dist/models/SystemEntities.js +2 -0
- package/dist/models/SystemPerm.d.ts +95 -0
- package/dist/models/SystemPerm.js +100 -0
- package/dist/models/SystemTables.d.ts +25 -0
- package/dist/models/SystemTables.js +28 -0
- package/dist/models/bizmodels.d.ts +97 -0
- package/dist/models/bizmodels.js +39 -0
- package/dist/models/contextLogger.d.ts +25 -0
- package/dist/models/contextLogger.js +112 -0
- package/dist/models/devops.d.ts +12 -0
- package/dist/models/devops.js +19 -0
- package/dist/models/userSession.d.ts +61 -0
- package/dist/models/userSession.js +165 -0
- package/dist/schedule/anonymousContext.d.ts +14 -0
- package/dist/schedule/anonymousContext.js +59 -0
- package/dist/schedule/index.d.ts +4 -0
- package/dist/schedule/index.js +10 -0
- package/dist/schedule/runSchedule.d.ts +12 -0
- package/dist/schedule/runSchedule.js +68 -0
- package/dist/schedule/scheduleNames.d.ts +13 -0
- package/dist/schedule/scheduleNames.js +17 -0
- package/dist/service/AuthService.d.ts +70 -0
- package/dist/service/AuthService.js +251 -0
- package/dist/service/EnumInfoService.d.ts +30 -0
- package/dist/service/EnumInfoService.js +127 -0
- package/dist/service/FileCenterService.d.ts +43 -0
- package/dist/service/FileCenterService.js +351 -0
- package/dist/service/SysConfigService.d.ts +7 -0
- package/dist/service/SysConfigService.js +47 -0
- package/dist/service/UserAccountService.d.ts +23 -0
- package/dist/service/UserAccountService.js +107 -0
- package/dist/service/UserSessionService.d.ts +37 -0
- package/dist/service/UserSessionService.js +156 -0
- package/dist/service/VisitStatService.d.ts +14 -0
- package/dist/service/VisitStatService.js +158 -0
- package/dist/service/WorkbenchService.d.ts +52 -0
- package/dist/service/WorkbenchService.js +202 -0
- package/dist/service/anyapi/AnyApiSandboxService.d.ts +15 -0
- package/dist/service/anyapi/AnyApiSandboxService.js +122 -0
- package/dist/service/anyapi/AnyApiService.d.ts +27 -0
- package/dist/service/anyapi/AnyApiService.js +181 -0
- package/dist/service/asyncTask/AsyncTaskRunnerService.d.ts +50 -0
- package/dist/service/asyncTask/AsyncTaskRunnerService.js +287 -0
- package/dist/service/asyncTask/AsyncTaskService.d.ts +7 -0
- package/dist/service/asyncTask/AsyncTaskService.js +34 -0
- package/dist/service/asyncTask/handler/ExcelInfoModel.d.ts +10 -0
- package/dist/service/asyncTask/handler/ExcelInfoModel.js +2 -0
- package/dist/service/asyncTask/handler/ExportExcelAsyncTaskHandler.d.ts +7 -0
- package/dist/service/asyncTask/handler/ExportExcelAsyncTaskHandler.js +216 -0
- package/dist/service/asyncTask/handler/ExportExcelByInnerHttpHandler.d.ts +36 -0
- package/dist/service/asyncTask/handler/ExportExcelByInnerHttpHandler.js +139 -0
- package/dist/service/asyncTask/handler/ExportExcelByStdCrudHandler.d.ts +46 -0
- package/dist/service/asyncTask/handler/ExportExcelByStdCrudHandler.js +121 -0
- package/dist/service/base/ApiBaseService.d.ts +15 -0
- package/dist/service/base/ApiBaseService.js +50 -0
- package/dist/service/base/ApiRateLimiter.d.ts +10 -0
- package/dist/service/base/ApiRateLimiter.js +51 -0
- package/dist/service/base/BaseService.d.ts +41 -0
- package/dist/service/base/BaseService.js +101 -0
- package/dist/service/base/RedisCacheService.d.ts +20 -0
- package/dist/service/base/RedisCacheService.js +57 -0
- package/dist/service/crudstd/CrudStdActionService.d.ts +17 -0
- package/dist/service/crudstd/CrudStdActionService.js +32 -0
- package/dist/service/crudstd/CrudStdConstant.d.ts +58 -0
- package/dist/service/crudstd/CrudStdConstant.js +64 -0
- package/dist/service/crudstd/CrudStdRelationService.d.ts +10 -0
- package/dist/service/crudstd/CrudStdRelationService.js +85 -0
- package/dist/service/crudstd/CrudStdService.d.ts +57 -0
- package/dist/service/crudstd/CrudStdService.js +239 -0
- package/dist/service/curd/CrudProQuick.d.ts +44 -0
- package/dist/service/curd/CrudProQuick.js +147 -0
- package/dist/service/curd/CurdMixByAccountService.d.ts +9 -0
- package/dist/service/curd/CurdMixByAccountService.js +93 -0
- package/dist/service/curd/CurdMixByDictService.d.ts +13 -0
- package/dist/service/curd/CurdMixByDictService.js +114 -0
- package/dist/service/curd/CurdMixByLinkToCustomService.d.ts +31 -0
- package/dist/service/curd/CurdMixByLinkToCustomService.js +203 -0
- package/dist/service/curd/CurdMixBySysConfigService.d.ts +9 -0
- package/dist/service/curd/CurdMixBySysConfigService.js +80 -0
- package/dist/service/curd/CurdMixByWorkbenchService.d.ts +10 -0
- package/dist/service/curd/CurdMixByWorkbenchService.js +78 -0
- package/dist/service/curd/CurdMixService.d.ts +27 -0
- package/dist/service/curd/CurdMixService.js +100 -0
- package/dist/service/curd/CurdMixUtils.d.ts +51 -0
- package/dist/service/curd/CurdMixUtils.js +275 -0
- package/dist/service/curd/CurdProService.d.ts +32 -0
- package/dist/service/curd/CurdProService.js +210 -0
- package/dist/service/curd/fixCfgModel.d.ts +3 -0
- package/dist/service/curd/fixCfgModel.js +107 -0
- package/dist/service/proxyapi/ProxyApiLoadService.d.ts +21 -0
- package/dist/service/proxyapi/ProxyApiLoadService.js +167 -0
- package/dist/service/proxyapi/ProxyApiService.d.ts +60 -0
- package/dist/service/proxyapi/ProxyApiService.js +260 -0
- package/dist/service/proxyapi/ProxyApiUtils.d.ts +15 -0
- package/dist/service/proxyapi/ProxyApiUtils.js +34 -0
- package/dist/service/proxyapi/RouteHandler.d.ts +5 -0
- package/dist/service/proxyapi/RouteHandler.js +9 -0
- package/dist/service/proxyapi/RouteTrie.d.ts +12 -0
- package/dist/service/proxyapi/RouteTrie.js +63 -0
- package/dist/service/proxyapi/WeightedRandom.d.ts +9 -0
- package/dist/service/proxyapi/WeightedRandom.js +31 -0
- package/dist/service/proxyapi/WeightedRoundRobin.d.ts +8 -0
- package/dist/service/proxyapi/WeightedRoundRobin.js +32 -0
- package/dist/views/404_app.html +31 -0
- package/dist/views/404_workbench.html +34 -0
- package/dist/views/static/favicon.ico +0 -0
- package/package.json +1 -1
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ConnectionPool } from 'mssql';
|
|
2
|
+
import { IConnectionPool, IPoolConnectionClient } from '../interfaces';
|
|
3
|
+
interface ISqlServerConnection extends IPoolConnectionClient {
|
|
4
|
+
originConnection: ConnectionPool;
|
|
5
|
+
}
|
|
6
|
+
declare class TransactionSqlServer {
|
|
7
|
+
private isBeginTransaction;
|
|
8
|
+
private connectionMap;
|
|
9
|
+
private transactionMap;
|
|
10
|
+
/**
|
|
11
|
+
* 获取链接对象
|
|
12
|
+
* @param pool
|
|
13
|
+
*/
|
|
14
|
+
getTxConnection(pool: IConnectionPool): Promise<ISqlServerConnection>;
|
|
15
|
+
private connectAndCreateConnection;
|
|
16
|
+
/**
|
|
17
|
+
* 开始事务
|
|
18
|
+
*/
|
|
19
|
+
beginTx(): void;
|
|
20
|
+
/**
|
|
21
|
+
* 提交事务
|
|
22
|
+
*/
|
|
23
|
+
commitTx(): Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* 事务回滚
|
|
26
|
+
*/
|
|
27
|
+
rollbackTx(): Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* 释放连接
|
|
30
|
+
*/
|
|
31
|
+
releaseTx(): Promise<void>;
|
|
32
|
+
private beginTransaction;
|
|
33
|
+
}
|
|
34
|
+
export { TransactionSqlServer };
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TransactionSqlServer = void 0;
|
|
4
|
+
const mssql_1 = require("mssql");
|
|
5
|
+
class TransactionSqlServer {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.isBeginTransaction = false;
|
|
8
|
+
this.connectionMap = {};
|
|
9
|
+
this.transactionMap = {};
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* 获取链接对象
|
|
13
|
+
* @param pool
|
|
14
|
+
*/
|
|
15
|
+
async getTxConnection(pool) {
|
|
16
|
+
let connection = this.connectionMap[pool.poolName];
|
|
17
|
+
if (!connection) {
|
|
18
|
+
connection = await this.connectAndCreateConnection(pool);
|
|
19
|
+
this.connectionMap[pool.poolName] = connection;
|
|
20
|
+
// 开启了事务
|
|
21
|
+
if (this.isBeginTransaction) {
|
|
22
|
+
await this.beginTransaction(pool.poolName);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return connection;
|
|
26
|
+
}
|
|
27
|
+
async connectAndCreateConnection(pool) {
|
|
28
|
+
const poolInstance = pool.poolInstance;
|
|
29
|
+
const originConnection = await poolInstance.connect();
|
|
30
|
+
return {
|
|
31
|
+
originConnection,
|
|
32
|
+
query: (sql, values) => {
|
|
33
|
+
const request = new mssql_1.Request(originConnection);
|
|
34
|
+
if (Array.isArray(values)) {
|
|
35
|
+
for (let i = 0; i < values.length; i++) {
|
|
36
|
+
const index = i + 1;
|
|
37
|
+
const value = values[i];
|
|
38
|
+
request.input(`fatcms_ms${index}`, value);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return request.query(sql);
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* 开始事务
|
|
47
|
+
*/
|
|
48
|
+
beginTx() {
|
|
49
|
+
this.isBeginTransaction = true;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* 提交事务
|
|
53
|
+
*/
|
|
54
|
+
async commitTx() {
|
|
55
|
+
if (!this.isBeginTransaction) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const transactions = Object.values(this.transactionMap);
|
|
59
|
+
for (let i = 0; i < transactions.length; i++) {
|
|
60
|
+
const tmpTx = transactions[i];
|
|
61
|
+
await tmpTx.commit();
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* 事务回滚
|
|
66
|
+
*/
|
|
67
|
+
async rollbackTx() {
|
|
68
|
+
if (!this.isBeginTransaction) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
const transactions = Object.values(this.transactionMap);
|
|
72
|
+
for (let i = 0; i < transactions.length; i++) {
|
|
73
|
+
const tmpTx = transactions[i];
|
|
74
|
+
await tmpTx.rollback();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* 释放连接
|
|
79
|
+
*/
|
|
80
|
+
async releaseTx() {
|
|
81
|
+
this.connectionMap = {};
|
|
82
|
+
this.transactionMap = {};
|
|
83
|
+
}
|
|
84
|
+
async beginTransaction(poolName) {
|
|
85
|
+
const connection = this.connectionMap[poolName];
|
|
86
|
+
const originConnection = connection.originConnection;
|
|
87
|
+
const tmpTx = new mssql_1.Transaction(originConnection);
|
|
88
|
+
this.transactionMap[poolName] = tmpTx;
|
|
89
|
+
return await tmpTx.begin();
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
exports.TransactionSqlServer = TransactionSqlServer;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
export declare enum SqlDbType {
|
|
2
|
+
mysql = "mysql",
|
|
3
|
+
postgres = "postgres",
|
|
4
|
+
sqlserver = "sqlserver"
|
|
5
|
+
}
|
|
6
|
+
export declare enum KeysOfFunCtx {
|
|
7
|
+
FUNC_CTX = "$",
|
|
8
|
+
CURRENT_VALUE = "$current",
|
|
9
|
+
VISITOR = "visitor",
|
|
10
|
+
VISITOR_ATTR = "visitor.",
|
|
11
|
+
REQUEST = "req.",
|
|
12
|
+
RESULT = "res."
|
|
13
|
+
}
|
|
14
|
+
export declare enum KeysOfAuthType {
|
|
15
|
+
free = "free",
|
|
16
|
+
login = "login",
|
|
17
|
+
byRoleCode = "byRoleCode",
|
|
18
|
+
byFuncCode = "byFuncCode"
|
|
19
|
+
}
|
|
20
|
+
export declare enum KeysOfValidators {
|
|
21
|
+
REQUIRED = "required",
|
|
22
|
+
BOOLEAN = "boolean",
|
|
23
|
+
OBJECT = "object",
|
|
24
|
+
ARRAY = "array",
|
|
25
|
+
ARRAY_STRING = "array:string",
|
|
26
|
+
ARRAY_NUMBER = "array:number",
|
|
27
|
+
STRING = "string",
|
|
28
|
+
EMAIL = "email",
|
|
29
|
+
NAME = "name",
|
|
30
|
+
PHONE_CN = "phone:cn",
|
|
31
|
+
INTEGER = "integer",
|
|
32
|
+
NUMBER = "number",
|
|
33
|
+
NUMERIC = "numeric",
|
|
34
|
+
MOMENT = "moment:",
|
|
35
|
+
SCALE = "scale:",
|
|
36
|
+
LENGTH = "length:",
|
|
37
|
+
REG_EXP = "regexp:",
|
|
38
|
+
ENUM = "enum:"
|
|
39
|
+
}
|
|
40
|
+
export declare enum KeyOfCrudTypes {
|
|
41
|
+
SELECT = "SELECT",
|
|
42
|
+
UPDATE = "UPDATE",
|
|
43
|
+
INSERT = "INSERT",
|
|
44
|
+
DELETE = "DELETE",
|
|
45
|
+
NOT_CRUD = "NOT_CRUD",
|
|
46
|
+
EMPTY_SQL = "EMPTY_SQL",
|
|
47
|
+
SYS_QUERY = "SYS_QUERY"
|
|
48
|
+
}
|
|
49
|
+
export declare enum KeysOfSimpleSQL {
|
|
50
|
+
SIMPLE_QUERY = "SIMPLE_QUERY",
|
|
51
|
+
SIMPLE_QUERY_ONE = "SIMPLE_QUERY_ONE",
|
|
52
|
+
SIMPLE_QUERY_PAGE = "SIMPLE_QUERY_PAGE",
|
|
53
|
+
SIMPLE_QUERY_COUNT = "SIMPLE_QUERY_COUNT",
|
|
54
|
+
SIMPLE_UPDATE = "SIMPLE_UPDATE",
|
|
55
|
+
SIMPLE_INSERT = "SIMPLE_INSERT",
|
|
56
|
+
SIMPLE_DELETE = "SIMPLE_DELETE",
|
|
57
|
+
SIMPLE_INSERT_ON_DUPLICATE_UPDATE = "SIMPLE_INSERT_ON_DUPLICATE_UPDATE",
|
|
58
|
+
SIMPLE_INSERT_OR_UPDATE = "SIMPLE_INSERT_OR_UPDATE",
|
|
59
|
+
CUSTOM = "CUSTOM"
|
|
60
|
+
}
|
|
61
|
+
export declare enum KeysOfSqlResPicker {
|
|
62
|
+
UPDATE_RESULT = "UPDATE_RESULT",
|
|
63
|
+
RESULT_FIRST_ROW = "RESULT_FIRST_ROW",
|
|
64
|
+
RESULT_TOTAL_COUNT = "RESULT_TOTAL_COUNT",
|
|
65
|
+
RESULT_ONE_VALUE = "RESULT_ONE_VALUE"
|
|
66
|
+
}
|
|
67
|
+
export declare const KeysOfCustomSQL: {
|
|
68
|
+
SQL_COLUMNS: string;
|
|
69
|
+
SQL_TABLE: string;
|
|
70
|
+
SQL_OFFSET_LIMIT: string;
|
|
71
|
+
SQL_ORDER_BYS: string;
|
|
72
|
+
SQL_AS_WHERE: string;
|
|
73
|
+
SQL_AS_UPDATE: string;
|
|
74
|
+
SQL_AS_INSERT_KEYS: string;
|
|
75
|
+
SQL_AS_INSERT_VALUES: string;
|
|
76
|
+
SQL_GET_DATA_ATTR_START: string;
|
|
77
|
+
SQL_GET_CONDITION_ATTR_START: string;
|
|
78
|
+
SQL_PICK_RES_AS_NUMBER: string;
|
|
79
|
+
SQL_PICK_RES_AS_STRING: string;
|
|
80
|
+
SQL_FUNCTION: string;
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* 查询条件中允许出现的关键词
|
|
84
|
+
* 与MongoDB的语法完全一致
|
|
85
|
+
*/
|
|
86
|
+
export declare const KeysOfConditions: {
|
|
87
|
+
$OR: string;
|
|
88
|
+
$NE: string;
|
|
89
|
+
$LT: string;
|
|
90
|
+
$LTE: string;
|
|
91
|
+
$GT: string;
|
|
92
|
+
$GTE: string;
|
|
93
|
+
$IN: string;
|
|
94
|
+
$NIN: string;
|
|
95
|
+
$NOT_NULL: string;
|
|
96
|
+
$NULL: string;
|
|
97
|
+
$RANGE: string;
|
|
98
|
+
$LIKE: string;
|
|
99
|
+
$NOT_LIKE: string;
|
|
100
|
+
$LIKE_INCLUDE: string;
|
|
101
|
+
$NOT_LIKE_INCLUDE: string;
|
|
102
|
+
$MATCH: string;
|
|
103
|
+
$MATCH_BOOL: string;
|
|
104
|
+
COMPARE_KEYS: Set<string>;
|
|
105
|
+
ALL_KEYS: Set<string>;
|
|
106
|
+
};
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.KeysOfConditions = exports.KeysOfCustomSQL = exports.KeysOfSqlResPicker = exports.KeysOfSimpleSQL = exports.KeyOfCrudTypes = exports.KeysOfValidators = exports.KeysOfAuthType = exports.KeysOfFunCtx = exports.SqlDbType = void 0;
|
|
4
|
+
var SqlDbType;
|
|
5
|
+
(function (SqlDbType) {
|
|
6
|
+
SqlDbType["mysql"] = "mysql";
|
|
7
|
+
SqlDbType["postgres"] = "postgres";
|
|
8
|
+
SqlDbType["sqlserver"] = "sqlserver";
|
|
9
|
+
})(SqlDbType = exports.SqlDbType || (exports.SqlDbType = {}));
|
|
10
|
+
var KeysOfFunCtx;
|
|
11
|
+
(function (KeysOfFunCtx) {
|
|
12
|
+
KeysOfFunCtx["FUNC_CTX"] = "$";
|
|
13
|
+
KeysOfFunCtx["CURRENT_VALUE"] = "$current";
|
|
14
|
+
KeysOfFunCtx["VISITOR"] = "visitor";
|
|
15
|
+
KeysOfFunCtx["VISITOR_ATTR"] = "visitor.";
|
|
16
|
+
KeysOfFunCtx["REQUEST"] = "req.";
|
|
17
|
+
KeysOfFunCtx["RESULT"] = "res.";
|
|
18
|
+
})(KeysOfFunCtx = exports.KeysOfFunCtx || (exports.KeysOfFunCtx = {}));
|
|
19
|
+
//鉴权类型;free无需鉴权,login仅登录即可,byRoleCode校验角色,byFuncCode校验功能点
|
|
20
|
+
var KeysOfAuthType;
|
|
21
|
+
(function (KeysOfAuthType) {
|
|
22
|
+
KeysOfAuthType["free"] = "free";
|
|
23
|
+
KeysOfAuthType["login"] = "login";
|
|
24
|
+
KeysOfAuthType["byRoleCode"] = "byRoleCode";
|
|
25
|
+
KeysOfAuthType["byFuncCode"] = "byFuncCode";
|
|
26
|
+
})(KeysOfAuthType = exports.KeysOfAuthType || (exports.KeysOfAuthType = {}));
|
|
27
|
+
var KeysOfValidators;
|
|
28
|
+
(function (KeysOfValidators) {
|
|
29
|
+
KeysOfValidators["REQUIRED"] = "required";
|
|
30
|
+
KeysOfValidators["BOOLEAN"] = "boolean";
|
|
31
|
+
KeysOfValidators["OBJECT"] = "object";
|
|
32
|
+
KeysOfValidators["ARRAY"] = "array";
|
|
33
|
+
KeysOfValidators["ARRAY_STRING"] = "array:string";
|
|
34
|
+
KeysOfValidators["ARRAY_NUMBER"] = "array:number";
|
|
35
|
+
KeysOfValidators["STRING"] = "string";
|
|
36
|
+
KeysOfValidators["EMAIL"] = "email";
|
|
37
|
+
KeysOfValidators["NAME"] = "name";
|
|
38
|
+
KeysOfValidators["PHONE_CN"] = "phone:cn";
|
|
39
|
+
KeysOfValidators["INTEGER"] = "integer";
|
|
40
|
+
KeysOfValidators["NUMBER"] = "number";
|
|
41
|
+
KeysOfValidators["NUMERIC"] = "numeric";
|
|
42
|
+
KeysOfValidators["MOMENT"] = "moment:";
|
|
43
|
+
KeysOfValidators["SCALE"] = "scale:";
|
|
44
|
+
KeysOfValidators["LENGTH"] = "length:";
|
|
45
|
+
KeysOfValidators["REG_EXP"] = "regexp:";
|
|
46
|
+
KeysOfValidators["ENUM"] = "enum:";
|
|
47
|
+
})(KeysOfValidators = exports.KeysOfValidators || (exports.KeysOfValidators = {}));
|
|
48
|
+
var KeyOfCrudTypes;
|
|
49
|
+
(function (KeyOfCrudTypes) {
|
|
50
|
+
KeyOfCrudTypes["SELECT"] = "SELECT";
|
|
51
|
+
KeyOfCrudTypes["UPDATE"] = "UPDATE";
|
|
52
|
+
KeyOfCrudTypes["INSERT"] = "INSERT";
|
|
53
|
+
KeyOfCrudTypes["DELETE"] = "DELETE";
|
|
54
|
+
KeyOfCrudTypes["NOT_CRUD"] = "NOT_CRUD";
|
|
55
|
+
KeyOfCrudTypes["EMPTY_SQL"] = "EMPTY_SQL";
|
|
56
|
+
KeyOfCrudTypes["SYS_QUERY"] = "SYS_QUERY";
|
|
57
|
+
})(KeyOfCrudTypes = exports.KeyOfCrudTypes || (exports.KeyOfCrudTypes = {}));
|
|
58
|
+
var KeysOfSimpleSQL;
|
|
59
|
+
(function (KeysOfSimpleSQL) {
|
|
60
|
+
KeysOfSimpleSQL["SIMPLE_QUERY"] = "SIMPLE_QUERY";
|
|
61
|
+
KeysOfSimpleSQL["SIMPLE_QUERY_ONE"] = "SIMPLE_QUERY_ONE";
|
|
62
|
+
KeysOfSimpleSQL["SIMPLE_QUERY_PAGE"] = "SIMPLE_QUERY_PAGE";
|
|
63
|
+
KeysOfSimpleSQL["SIMPLE_QUERY_COUNT"] = "SIMPLE_QUERY_COUNT";
|
|
64
|
+
KeysOfSimpleSQL["SIMPLE_UPDATE"] = "SIMPLE_UPDATE";
|
|
65
|
+
KeysOfSimpleSQL["SIMPLE_INSERT"] = "SIMPLE_INSERT";
|
|
66
|
+
KeysOfSimpleSQL["SIMPLE_DELETE"] = "SIMPLE_DELETE";
|
|
67
|
+
KeysOfSimpleSQL["SIMPLE_INSERT_ON_DUPLICATE_UPDATE"] = "SIMPLE_INSERT_ON_DUPLICATE_UPDATE";
|
|
68
|
+
KeysOfSimpleSQL["SIMPLE_INSERT_OR_UPDATE"] = "SIMPLE_INSERT_OR_UPDATE";
|
|
69
|
+
KeysOfSimpleSQL["CUSTOM"] = "CUSTOM";
|
|
70
|
+
})(KeysOfSimpleSQL = exports.KeysOfSimpleSQL || (exports.KeysOfSimpleSQL = {}));
|
|
71
|
+
var KeysOfSqlResPicker;
|
|
72
|
+
(function (KeysOfSqlResPicker) {
|
|
73
|
+
KeysOfSqlResPicker["UPDATE_RESULT"] = "UPDATE_RESULT";
|
|
74
|
+
KeysOfSqlResPicker["RESULT_FIRST_ROW"] = "RESULT_FIRST_ROW";
|
|
75
|
+
KeysOfSqlResPicker["RESULT_TOTAL_COUNT"] = "RESULT_TOTAL_COUNT";
|
|
76
|
+
KeysOfSqlResPicker["RESULT_ONE_VALUE"] = "RESULT_ONE_VALUE";
|
|
77
|
+
})(KeysOfSqlResPicker = exports.KeysOfSqlResPicker || (exports.KeysOfSqlResPicker = {}));
|
|
78
|
+
exports.KeysOfCustomSQL = {
|
|
79
|
+
SQL_COLUMNS: '@@columns',
|
|
80
|
+
SQL_TABLE: '@@table',
|
|
81
|
+
SQL_OFFSET_LIMIT: '@@offsetLimit',
|
|
82
|
+
SQL_ORDER_BYS: '@@orderBys',
|
|
83
|
+
SQL_AS_WHERE: '@@asWhere:',
|
|
84
|
+
SQL_AS_UPDATE: '@@asUpdate:',
|
|
85
|
+
SQL_AS_INSERT_KEYS: '@@asInsertKeys:',
|
|
86
|
+
SQL_AS_INSERT_VALUES: '@@asInsertValues:',
|
|
87
|
+
// 从Req中取值:单独取Data中的某个字段:获取单个值。
|
|
88
|
+
SQL_GET_DATA_ATTR_START: '@@data',
|
|
89
|
+
SQL_GET_CONDITION_ATTR_START: '@@condition',
|
|
90
|
+
// 从Res中取值
|
|
91
|
+
SQL_PICK_RES_AS_NUMBER: '@@pickResAsNumber:',
|
|
92
|
+
SQL_PICK_RES_AS_STRING: '@@pickResAsString:',
|
|
93
|
+
// 使用java函数:获取单个值
|
|
94
|
+
SQL_FUNCTION: '@@function:', // @@function:aaa
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* 查询条件中允许出现的关键词
|
|
98
|
+
* 与MongoDB的语法完全一致
|
|
99
|
+
*/
|
|
100
|
+
exports.KeysOfConditions = {
|
|
101
|
+
$OR: '$or',
|
|
102
|
+
$NE: '$ne',
|
|
103
|
+
$LT: '$lt',
|
|
104
|
+
$LTE: '$lte',
|
|
105
|
+
$GT: '$gt',
|
|
106
|
+
$GTE: '$gte',
|
|
107
|
+
$IN: '$in',
|
|
108
|
+
$NIN: '$nin',
|
|
109
|
+
$NOT_NULL: '$notNull',
|
|
110
|
+
$NULL: '$null',
|
|
111
|
+
$RANGE: '$range',
|
|
112
|
+
$LIKE: '$like',
|
|
113
|
+
$NOT_LIKE: '$notLike',
|
|
114
|
+
$LIKE_INCLUDE: '$likeInclude',
|
|
115
|
+
$NOT_LIKE_INCLUDE: '$notLikeInclude',
|
|
116
|
+
$MATCH: '$match',
|
|
117
|
+
$MATCH_BOOL: '$matchBool',
|
|
118
|
+
COMPARE_KEYS: new Set([]),
|
|
119
|
+
ALL_KEYS: new Set([]),
|
|
120
|
+
};
|
|
121
|
+
function initKeysOfConditions() {
|
|
122
|
+
const addIgnoreCase = (keys, key) => {
|
|
123
|
+
keys.add(key);
|
|
124
|
+
keys.add(key.toUpperCase());
|
|
125
|
+
keys.add(key.toLowerCase());
|
|
126
|
+
};
|
|
127
|
+
// 比较操作符, 支持忽略大小写
|
|
128
|
+
exports.KeysOfConditions.COMPARE_KEYS = new Set([]);
|
|
129
|
+
addIgnoreCase(exports.KeysOfConditions.COMPARE_KEYS, exports.KeysOfConditions.$NE);
|
|
130
|
+
addIgnoreCase(exports.KeysOfConditions.COMPARE_KEYS, exports.KeysOfConditions.$LT);
|
|
131
|
+
addIgnoreCase(exports.KeysOfConditions.COMPARE_KEYS, exports.KeysOfConditions.$LTE);
|
|
132
|
+
addIgnoreCase(exports.KeysOfConditions.COMPARE_KEYS, exports.KeysOfConditions.$GT);
|
|
133
|
+
addIgnoreCase(exports.KeysOfConditions.COMPARE_KEYS, exports.KeysOfConditions.$GTE);
|
|
134
|
+
addIgnoreCase(exports.KeysOfConditions.COMPARE_KEYS, exports.KeysOfConditions.$IN);
|
|
135
|
+
addIgnoreCase(exports.KeysOfConditions.COMPARE_KEYS, exports.KeysOfConditions.$NIN);
|
|
136
|
+
addIgnoreCase(exports.KeysOfConditions.COMPARE_KEYS, exports.KeysOfConditions.$LIKE);
|
|
137
|
+
addIgnoreCase(exports.KeysOfConditions.COMPARE_KEYS, exports.KeysOfConditions.$LIKE_INCLUDE);
|
|
138
|
+
addIgnoreCase(exports.KeysOfConditions.COMPARE_KEYS, exports.KeysOfConditions.$NOT_LIKE);
|
|
139
|
+
addIgnoreCase(exports.KeysOfConditions.COMPARE_KEYS, exports.KeysOfConditions.$NOT_LIKE_INCLUDE);
|
|
140
|
+
addIgnoreCase(exports.KeysOfConditions.COMPARE_KEYS, exports.KeysOfConditions.$MATCH);
|
|
141
|
+
addIgnoreCase(exports.KeysOfConditions.COMPARE_KEYS, exports.KeysOfConditions.$MATCH_BOOL);
|
|
142
|
+
addIgnoreCase(exports.KeysOfConditions.COMPARE_KEYS, exports.KeysOfConditions.$RANGE);
|
|
143
|
+
addIgnoreCase(exports.KeysOfConditions.COMPARE_KEYS, exports.KeysOfConditions.$NULL);
|
|
144
|
+
addIgnoreCase(exports.KeysOfConditions.COMPARE_KEYS, exports.KeysOfConditions.$NOT_NULL);
|
|
145
|
+
// 所有操作符
|
|
146
|
+
exports.KeysOfConditions.ALL_KEYS = new Set([...exports.KeysOfConditions.COMPARE_KEYS]);
|
|
147
|
+
addIgnoreCase(exports.KeysOfConditions.ALL_KEYS, exports.KeysOfConditions.$OR);
|
|
148
|
+
}
|
|
149
|
+
initKeysOfConditions();
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { CrudProServiceBase } from './CrudProServiceBase';
|
|
2
|
+
import { IRequestCfgModel } from '../interfaces';
|
|
3
|
+
import { ICurdProServiceHub } from '../models/ServiceHub';
|
|
4
|
+
declare class CrudProCachedCfgService extends CrudProServiceBase {
|
|
5
|
+
constructor(serviceHub: ICurdProServiceHub);
|
|
6
|
+
getCachedCfgByMethod(method: string, isEnableCache: boolean): Promise<IRequestCfgModel | null>;
|
|
7
|
+
private getCachedCfgByMethodInner;
|
|
8
|
+
private loadMethodInfo;
|
|
9
|
+
private loadMethodInfoList;
|
|
10
|
+
}
|
|
11
|
+
export { CrudProCachedCfgService };
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CrudProCachedCfgService = void 0;
|
|
4
|
+
const humps_1 = require("humps");
|
|
5
|
+
const CrudProServiceBase_1 = require("./CrudProServiceBase");
|
|
6
|
+
const MixinUtils_1 = require("../utils/MixinUtils");
|
|
7
|
+
const convertMix_1 = require("../utils/sqlConvert/convertMix");
|
|
8
|
+
const MemoryRefreshCache_1 = require("../utils/MemoryRefreshCache");
|
|
9
|
+
const methodCache = new MemoryRefreshCache_1.default();
|
|
10
|
+
function parseMethodInfo(methodInfo) {
|
|
11
|
+
const row = (0, humps_1.camelizeKeys)(methodInfo); //转换成驼峰
|
|
12
|
+
const configObject = MixinUtils_1.MixinUtils.parseJsonObject(row.moreConfig) || {};
|
|
13
|
+
const sqlCfgList = MixinUtils_1.MixinUtils.parseJsonObject(row.sqlCfgList) || [];
|
|
14
|
+
return { ...configObject, ...row, sqlCfgList };
|
|
15
|
+
}
|
|
16
|
+
class CrudProCachedCfgService extends CrudProServiceBase_1.CrudProServiceBase {
|
|
17
|
+
constructor(serviceHub) {
|
|
18
|
+
super(serviceHub);
|
|
19
|
+
}
|
|
20
|
+
async getCachedCfgByMethod(method, isEnableCache) {
|
|
21
|
+
const methodInfo = await this.getCachedCfgByMethodInner(method, isEnableCache);
|
|
22
|
+
if (!methodInfo) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
return { ...methodInfo };
|
|
26
|
+
}
|
|
27
|
+
async getCachedCfgByMethodInner(method, isEnableCache) {
|
|
28
|
+
// 不使用缓存
|
|
29
|
+
if (!isEnableCache) {
|
|
30
|
+
return await this.loadMethodInfo(method);
|
|
31
|
+
}
|
|
32
|
+
methodCache.setProps({
|
|
33
|
+
keepTime: 1000 * 60 * 2,
|
|
34
|
+
requestFn: () => this.loadMethodInfoList(),
|
|
35
|
+
getKeyFn: item => item.method,
|
|
36
|
+
});
|
|
37
|
+
const methodInfo = await methodCache.getItem(method);
|
|
38
|
+
if (methodInfo) {
|
|
39
|
+
return methodInfo;
|
|
40
|
+
}
|
|
41
|
+
return await this.loadMethodInfo(method);
|
|
42
|
+
}
|
|
43
|
+
async loadMethodInfo(method) {
|
|
44
|
+
const { methodsTableName, sysDatabaseName, sysDatabaseDbType } = this.getContextCfg();
|
|
45
|
+
const sql = `select * from ${methodsTableName} where method = ? `; // 全部加载到内存
|
|
46
|
+
const baseInfo = {
|
|
47
|
+
sqlTable: methodsTableName,
|
|
48
|
+
sqlDatabase: sysDatabaseName,
|
|
49
|
+
sqlDbType: sysDatabaseDbType,
|
|
50
|
+
};
|
|
51
|
+
const queryRes = await this.executeUnsafeQuery(baseInfo, sql, [method]);
|
|
52
|
+
const rows2 = (0, convertMix_1.pickAndConvertRowsByMix)(queryRes, sysDatabaseDbType);
|
|
53
|
+
if (rows2.length > 0) {
|
|
54
|
+
return parseMethodInfo(rows2[0]);
|
|
55
|
+
}
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
async loadMethodInfoList() {
|
|
59
|
+
const { methodsTableName, sysDatabaseName, sysDatabaseDbType } = this.getContextCfg();
|
|
60
|
+
const sql = `select * from ${methodsTableName}`; // 全部加载到内存
|
|
61
|
+
const baseInfo = {
|
|
62
|
+
sqlTable: methodsTableName,
|
|
63
|
+
sqlDatabase: sysDatabaseName,
|
|
64
|
+
sqlDbType: sysDatabaseDbType,
|
|
65
|
+
};
|
|
66
|
+
const queryRes = await this.executeUnsafeQuery(baseInfo, sql);
|
|
67
|
+
const rows2 = (0, convertMix_1.pickAndConvertRowsByMix)(queryRes, sysDatabaseDbType);
|
|
68
|
+
return rows2.map(row => {
|
|
69
|
+
return parseMethodInfo(row);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
exports.CrudProCachedCfgService = CrudProCachedCfgService;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CrudProServiceBase } from './CrudProServiceBase';
|
|
2
|
+
import { IFuncCfgModel } from '../interfaces';
|
|
3
|
+
import { FuncContext } from '../models/FuncContext';
|
|
4
|
+
declare class CrudProExecuteFuncService extends CrudProServiceBase {
|
|
5
|
+
executeFuncCfg(funCfg: IFuncCfgModel, funcContext: FuncContext): any;
|
|
6
|
+
private pickContextValue;
|
|
7
|
+
private getFunctionParamValues;
|
|
8
|
+
}
|
|
9
|
+
export { CrudProExecuteFuncService };
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CrudProExecuteFuncService = void 0;
|
|
4
|
+
const CrudProServiceBase_1 = require("./CrudProServiceBase");
|
|
5
|
+
const TypeUtils_1 = require("../utils/TypeUtils");
|
|
6
|
+
const MixinUtils_1 = require("../utils/MixinUtils");
|
|
7
|
+
const _ = require("lodash");
|
|
8
|
+
const exceptions_1 = require("../exceptions");
|
|
9
|
+
const keys_1 = require("../models/keys");
|
|
10
|
+
const { isNil, isNumeric } = TypeUtils_1.TypeUtils;
|
|
11
|
+
const { isEmpty } = MixinUtils_1.MixinUtils;
|
|
12
|
+
function isNotNil(obj) {
|
|
13
|
+
return !isNil(obj);
|
|
14
|
+
}
|
|
15
|
+
class CrudProExecuteFuncService extends CrudProServiceBase_1.CrudProServiceBase {
|
|
16
|
+
executeFuncCfg(funCfg, funcContext) {
|
|
17
|
+
if (isNil(funCfg)) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
if (funCfg.___PLAIN_OBJECT___ === true) {
|
|
21
|
+
return funCfg;
|
|
22
|
+
}
|
|
23
|
+
if (isNotNil(funCfg.const)) {
|
|
24
|
+
return funCfg.const;
|
|
25
|
+
}
|
|
26
|
+
if (isNotNil(funCfg.constString)) {
|
|
27
|
+
return '' + funCfg.constString;
|
|
28
|
+
}
|
|
29
|
+
if (isNotNil(funCfg.constNumber) && isNumeric(funCfg.constNumber)) {
|
|
30
|
+
return Number(funCfg.constNumber);
|
|
31
|
+
}
|
|
32
|
+
if (isNotNil(funCfg.constBool)) {
|
|
33
|
+
return Boolean(funCfg.constBool);
|
|
34
|
+
}
|
|
35
|
+
if (isNotNil(funCfg.context)) {
|
|
36
|
+
return this.pickContextValue(funCfg.context, funcContext);
|
|
37
|
+
}
|
|
38
|
+
if (isNotNil(funCfg.contextAsString)) {
|
|
39
|
+
return '' + this.pickContextValue(funCfg.contextAsString, funcContext);
|
|
40
|
+
}
|
|
41
|
+
if (isNotNil(funCfg.contextAsNumber)) {
|
|
42
|
+
return Number(this.pickContextValue(funCfg.contextAsNumber, funcContext));
|
|
43
|
+
}
|
|
44
|
+
if (isNotNil(funCfg.contextAsBool)) {
|
|
45
|
+
return Boolean(this.pickContextValue(funCfg.contextAsBool, funcContext));
|
|
46
|
+
}
|
|
47
|
+
if (isNotNil(funCfg.functionName)) {
|
|
48
|
+
const func = this.getExecuteFunction(funCfg.functionName);
|
|
49
|
+
if (!func) {
|
|
50
|
+
throw new exceptions_1.CommonException(exceptions_1.Exceptions.RUN_FUNCTION_NOT_FOUND, funCfg.functionName);
|
|
51
|
+
}
|
|
52
|
+
const functionParamValues = this.getFunctionParamValues(funCfg.functionParams, funcContext);
|
|
53
|
+
return func.apply(funcContext, functionParamValues);
|
|
54
|
+
}
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
pickContextValue(pickString, funcCtx) {
|
|
58
|
+
var _a;
|
|
59
|
+
if (!pickString) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
if (pickString === keys_1.KeysOfFunCtx.FUNC_CTX) {
|
|
63
|
+
return funcCtx;
|
|
64
|
+
}
|
|
65
|
+
if (pickString === keys_1.KeysOfFunCtx.CURRENT_VALUE) {
|
|
66
|
+
return funcCtx.currentValue;
|
|
67
|
+
}
|
|
68
|
+
// 例如:accountId, 访问此变量,用户必须登录。
|
|
69
|
+
if (pickString.startsWith(keys_1.KeysOfFunCtx.VISITOR_ATTR)) {
|
|
70
|
+
const reqModel = funcCtx === null || funcCtx === void 0 ? void 0 : funcCtx.reqModel;
|
|
71
|
+
const attrValue = _.get(reqModel, pickString); // visitor.nickName
|
|
72
|
+
if (isNil(attrValue)) {
|
|
73
|
+
throw new exceptions_1.CommonException(exceptions_1.Exceptions.RUN_PICK_ERR_VISITOR_NULL, '获取用户ID失败, 可能用户没有登陆');
|
|
74
|
+
}
|
|
75
|
+
return attrValue;
|
|
76
|
+
}
|
|
77
|
+
// 例如:accountId, 访问此变量,用户必须登录。
|
|
78
|
+
if (pickString === keys_1.KeysOfFunCtx.VISITOR) {
|
|
79
|
+
const visitor = (_a = funcCtx === null || funcCtx === void 0 ? void 0 : funcCtx.reqModel) === null || _a === void 0 ? void 0 : _a.visitor;
|
|
80
|
+
if (isNil(visitor)) {
|
|
81
|
+
throw new exceptions_1.CommonException(exceptions_1.Exceptions.RUN_PICK_ERR_VISITOR_NULL, '获取用户对象失败, 可能用户没有登陆');
|
|
82
|
+
}
|
|
83
|
+
return visitor;
|
|
84
|
+
}
|
|
85
|
+
// 例如: req.data.name
|
|
86
|
+
if (pickString.startsWith(keys_1.KeysOfFunCtx.REQUEST)) {
|
|
87
|
+
const reqExpress = pickString.substring(keys_1.KeysOfFunCtx.REQUEST.length);
|
|
88
|
+
return _.get(funcCtx.reqModel, reqExpress);
|
|
89
|
+
}
|
|
90
|
+
// 例如: res.total_count
|
|
91
|
+
if (pickString.startsWith(keys_1.KeysOfFunCtx.RESULT)) {
|
|
92
|
+
const reqExpress = pickString.substring(keys_1.KeysOfFunCtx.RESULT.length);
|
|
93
|
+
return _.get(funcCtx.resModel, reqExpress);
|
|
94
|
+
}
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
getFunctionParamValues(functionParams, funcContext) {
|
|
98
|
+
if (isNil(functionParams) || isEmpty(functionParams)) {
|
|
99
|
+
return [];
|
|
100
|
+
}
|
|
101
|
+
return functionParams.map(p => {
|
|
102
|
+
if (typeof p === 'undefined' || p === null) {
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
if (typeof p === 'string' || typeof p === 'number' || typeof p === 'boolean') {
|
|
106
|
+
return p;
|
|
107
|
+
}
|
|
108
|
+
return this.executeFuncCfg(p, funcContext);
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
exports.CrudProExecuteFuncService = CrudProExecuteFuncService;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { CrudProServiceBase } from './CrudProServiceBase';
|
|
2
|
+
declare class CrudProExecuteSqlService extends CrudProServiceBase {
|
|
3
|
+
executeSqlCfgModels(): Promise<void>;
|
|
4
|
+
private executeSqlCfgModel;
|
|
5
|
+
private handleExecuteSqlArgsByResModel;
|
|
6
|
+
private executeSqlCfgModelPreCheck;
|
|
7
|
+
private assertByValidate;
|
|
8
|
+
/**
|
|
9
|
+
* 判断此SQL是否需要执行
|
|
10
|
+
* @param sqlCfgModel
|
|
11
|
+
* @param exeCtx
|
|
12
|
+
* @private
|
|
13
|
+
*/
|
|
14
|
+
private isNeedExecute;
|
|
15
|
+
private toQueryResByResPicker;
|
|
16
|
+
}
|
|
17
|
+
export { CrudProExecuteSqlService };
|