midway-fatcms 0.0.1-beta.4 → 0.0.1-beta.40
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/.eslintrc.json +14 -0
- package/.prettierrc.js +4 -0
- package/README.md +7 -0
- package/dist/config/config.default.js +58 -15
- package/dist/config/seed/aeskey.txt +1 -1
- package/dist/configuration.d.ts +1 -0
- package/dist/configuration.js +33 -9
- package/dist/controller/base/BaseApiController.d.ts +7 -1
- package/dist/controller/base/BaseApiController.js +32 -6
- package/dist/controller/gateway/AsyncTaskController.d.ts +20 -0
- package/dist/controller/gateway/AsyncTaskController.js +181 -0
- package/dist/controller/gateway/CrudMtdGatewayController.d.ts +3 -3
- package/dist/controller/gateway/CrudMtdGatewayController.js +9 -6
- package/dist/controller/gateway/DocGatewayController.js +14 -9
- package/dist/controller/gateway/FileController.d.ts +3 -2
- package/dist/controller/gateway/PublicApiController.js +4 -6
- package/dist/controller/gateway/StaticController.d.ts +0 -1
- package/dist/controller/gateway/StaticController.js +40 -39
- package/dist/controller/helpers.controller.d.ts +1 -1
- package/dist/controller/home.controller.js +4 -3
- package/dist/controller/manage/AnyApiMangeApi.js +2 -2
- package/dist/controller/manage/AppLogMangeApi.js +2 -2
- package/dist/controller/manage/AppMangeApi.js +2 -2
- package/dist/controller/manage/AppPageMangeApi.js +2 -2
- package/dist/controller/manage/AppSchemaHistoryApi.js +2 -2
- package/dist/controller/manage/CrudMethodsMangeApi.js +2 -2
- package/dist/controller/manage/CrudStandardDesignApi.d.ts +1 -1
- package/dist/controller/manage/CrudStandardDesignApi.js +86 -83
- package/dist/controller/manage/DataDictManageApi.d.ts +1 -1
- package/dist/controller/manage/DataDictManageApi.js +1 -1
- package/dist/controller/manage/DeployManageApi.d.ts +1 -1
- package/dist/controller/manage/DeployManageApi.js +38 -34
- package/dist/controller/manage/DocLibManageApi.js +2 -2
- package/dist/controller/manage/DocManageApi.js +2 -2
- package/dist/controller/manage/FileManageApi.js +1 -1
- package/dist/controller/manage/LowCodeTplManageApi.js +2 -2
- package/dist/controller/manage/MenuManageApi.js +2 -2
- package/dist/controller/manage/ProxyApiMangeApi.js +2 -2
- package/dist/controller/manage/SuperAdminManageApi.d.ts +2 -2
- package/dist/controller/manage/SuperAdminManageApi.js +12 -8
- package/dist/controller/manage/SysConfigMangeApi.d.ts +1 -1
- package/dist/controller/manage/SysConfigMangeApi.js +8 -6
- package/dist/controller/manage/SystemInfoManageApi.d.ts +1 -1
- package/dist/controller/manage/SystemInfoManageApi.js +7 -1
- package/dist/controller/manage/UserAccountManageApi.d.ts +2 -2
- package/dist/controller/manage/UserAccountManageApi.js +7 -2
- package/dist/controller/manage/WorkbenchMangeApi.js +3 -3
- package/dist/controller/myinfo/AuthController.d.ts +0 -4
- package/dist/controller/myinfo/AuthController.js +1 -54
- package/dist/controller/render/AppRenderController.js +12 -5
- package/dist/controller/test.controller.d.ts +1 -1
- package/dist/controller/test.controller.js +5 -5
- package/dist/index.d.ts +35 -4
- package/dist/index.js +35 -4
- package/dist/libs/crud-pro/CrudPro.d.ts +1 -0
- package/dist/libs/crud-pro/CrudPro.js +5 -0
- package/dist/libs/crud-pro/defaultConfigs.js +2 -0
- package/dist/libs/crud-pro/interfaces.d.ts +7 -1
- package/dist/libs/crud-pro/models/ExecuteContext.d.ts +12 -5
- package/dist/libs/crud-pro/models/ExecuteContextFunc.d.ts +8 -1
- package/dist/libs/crud-pro/models/ExecuteContextFunc.js +8 -0
- package/dist/libs/crud-pro/models/RequestCfgModel.d.ts +1 -1
- 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/SqlCfgModel.d.ts +1 -1
- package/dist/libs/crud-pro/models/TransactionSqlServer.js +1 -1
- package/dist/libs/crud-pro/services/CrudProCachedCfgService.d.ts +1 -0
- package/dist/libs/crud-pro/services/CrudProCachedCfgService.js +27 -15
- package/dist/libs/crud-pro/services/CrudProExecuteSqlService.js +17 -19
- package/dist/libs/crud-pro/services/CrudProGenSqlCondition.d.ts +1 -1
- package/dist/libs/crud-pro/services/CrudProGenSqlCondition.js +10 -12
- package/dist/libs/crud-pro/services/CrudProGenSqlService.js +14 -23
- package/dist/libs/crud-pro/services/CrudProOriginToExecuteSql.js +7 -6
- package/dist/libs/crud-pro/services/CrudProServiceBase.d.ts +2 -6
- package/dist/libs/crud-pro/services/CrudProServiceBase.js +15 -3
- package/dist/libs/crud-pro/services/CrudProTableMetaService.d.ts +1 -0
- package/dist/libs/crud-pro/services/CrudProTableMetaService.js +32 -7
- package/dist/libs/crud-pro/sql.txt +120 -120
- package/dist/libs/crud-pro/utils/DatabaseName.js +24 -3
- package/dist/libs/crud-pro/utils/MixinUtils.js +1 -1
- package/dist/libs/crud-pro/utils/ValidateUtils.js +1 -1
- package/dist/libs/crud-pro/utils/sqlConvert/convertColumnName.js +2 -2
- 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/global-config/global-config.d.ts +45 -0
- package/dist/libs/global-config/global-config.js +33 -0
- package/dist/libs/utils/errorToString.d.ts +2 -0
- package/dist/libs/utils/errorToString.js +57 -0
- package/dist/libs/utils/fatcms-request.js +2 -2
- package/dist/libs/utils/functions.d.ts +2 -1
- package/dist/libs/utils/functions.js +6 -1
- package/dist/middleware/forbidden.middleware.js +4 -20
- package/dist/middleware/global.middleware.js +30 -10
- package/dist/middleware/permission.middleware.js +1 -1
- 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 +8 -1
- package/dist/models/SystemEntities.js +7 -0
- package/dist/models/SystemTables.d.ts +1 -3
- package/dist/models/SystemTables.js +2 -4
- package/dist/models/bizmodels.d.ts +28 -0
- package/dist/models/bizmodels.js +6 -1
- package/dist/schedule/anonymousContext.d.ts +14 -0
- package/dist/schedule/anonymousContext.js +59 -0
- package/dist/schedule/index.d.ts +4 -3
- package/dist/schedule/index.js +8 -67
- 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.js +8 -5
- package/dist/service/EnumInfoService.js +9 -5
- package/dist/service/FileCenterService.js +13 -9
- package/dist/service/SysConfigService.d.ts +1 -1
- package/dist/service/SysConfigService.js +4 -2
- package/dist/service/UserAccountService.js +10 -6
- package/dist/service/UserSessionService.d.ts +21 -0
- package/dist/service/UserSessionService.js +73 -2
- package/dist/service/VisitStatService.d.ts +1 -1
- package/dist/service/VisitStatService.js +20 -27
- package/dist/service/WorkbenchService.d.ts +33 -0
- package/dist/service/WorkbenchService.js +70 -12
- package/dist/service/anyapi/AnyApiSandboxService.js +12 -12
- package/dist/service/anyapi/AnyApiService.js +4 -2
- 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/BaseService.d.ts +12 -0
- package/dist/service/base/BaseService.js +22 -0
- package/dist/service/base/RedisCacheService.d.ts +7 -0
- package/dist/service/base/RedisCacheService.js +7 -0
- package/dist/service/crudstd/CrudStdService.d.ts +8 -1
- package/dist/service/crudstd/CrudStdService.js +63 -6
- package/dist/service/curd/CrudProQuick.d.ts +44 -0
- package/dist/service/curd/CrudProQuick.js +147 -0
- package/dist/service/curd/CurdMixByAccountService.d.ts +4 -4
- package/dist/service/curd/CurdMixByAccountService.js +12 -6
- package/dist/service/curd/CurdMixByDictService.d.ts +4 -4
- package/dist/service/curd/CurdMixByDictService.js +10 -7
- package/dist/service/curd/CurdMixByLinkToCustomService.d.ts +13 -4
- package/dist/service/curd/CurdMixByLinkToCustomService.js +73 -24
- package/dist/service/curd/CurdMixBySysConfigService.d.ts +3 -3
- package/dist/service/curd/CurdMixBySysConfigService.js +4 -2
- package/dist/service/curd/CurdMixByWorkbenchService.d.ts +3 -3
- package/dist/service/curd/CurdMixByWorkbenchService.js +4 -2
- package/dist/service/curd/CurdMixService.d.ts +13 -3
- package/dist/service/curd/CurdMixService.js +26 -2
- package/dist/service/curd/CurdMixUtils.d.ts +27 -4
- package/dist/service/curd/CurdMixUtils.js +115 -41
- package/dist/service/curd/CurdProService.d.ts +3 -10
- package/dist/service/curd/CurdProService.js +36 -148
- package/dist/service/curd/fixCfgModel.d.ts +3 -0
- package/dist/service/curd/fixCfgModel.js +107 -0
- package/dist/service/proxyapi/ProxyApiLoadService.js +7 -4
- package/dist/service/proxyapi/ProxyApiService.js +28 -7
- package/dist/views/404_app.html +31 -31
- package/dist/views/404_workbench.html +34 -34
- package/package.json +25 -24
- package/tsconfig.json +32 -0
- package/dist/controller/medstatistic/MedAdminController.d.ts +0 -35
- package/dist/controller/medstatistic/MedAdminController.js +0 -205
- package/dist/controller/medstatistic/MedClientController.d.ts +0 -28
- package/dist/controller/medstatistic/MedClientController.js +0 -188
- package/dist/controller/medstatistic/MedMessageService.d.ts +0 -19
- package/dist/controller/medstatistic/MedMessageService.js +0 -95
- package/dist/controller/medstatistic/MedScoreService.d.ts +0 -21
- package/dist/controller/medstatistic/MedScoreService.js +0 -107
- package/dist/controller/medstatistic/constants.d.ts +0 -32
- package/dist/controller/medstatistic/constants.js +0 -43
- package/src/config/config.default.ts +0 -172
- package/src/config/seed/aeskey.txt +0 -1
- package/src/config/utils.ts +0 -23
- package/src/configuration.ts +0 -83
- package/src/controller/base/BaseApiController.ts +0 -145
- package/src/controller/gateway/AnyApiGatewayController.ts +0 -33
- package/src/controller/gateway/CrudMtdGatewayController.ts +0 -107
- package/src/controller/gateway/CrudStdGatewayController.ts +0 -101
- package/src/controller/gateway/DocGatewayController.ts +0 -165
- package/src/controller/gateway/FileController.ts +0 -110
- package/src/controller/gateway/ProxyApiGatewayController.ts +0 -47
- package/src/controller/gateway/PublicApiController.ts +0 -145
- package/src/controller/gateway/StaticController.ts +0 -328
- package/src/controller/helpers.controller.ts +0 -161
- package/src/controller/home.controller.ts +0 -71
- 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 -353
- package/src/controller/manage/DataDictManageApi.ts +0 -78
- package/src/controller/manage/DeployManageApi.ts +0 -179
- 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 -63
- package/src/controller/manage/ProxyApiMangeApi.ts +0 -52
- package/src/controller/manage/SuperAdminManageApi.ts +0 -138
- package/src/controller/manage/SysConfigMangeApi.ts +0 -95
- package/src/controller/manage/SystemInfoManageApi.ts +0 -48
- package/src/controller/manage/UserAccountManageApi.ts +0 -88
- package/src/controller/manage/WorkbenchMangeApi.ts +0 -72
- package/src/controller/medstatistic/MedAdminController.ts +0 -221
- package/src/controller/medstatistic/MedClientController.ts +0 -188
- package/src/controller/medstatistic/MedMessageService.ts +0 -89
- package/src/controller/medstatistic/MedScoreService.ts +0 -108
- package/src/controller/medstatistic/constants.ts +0 -63
- package/src/controller/myinfo/AuthController.ts +0 -174
- package/src/controller/myinfo/MyInfoController.ts +0 -32
- package/src/controller/render/AppRenderController.ts +0 -76
- 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 -71
- package/src/interface.ts +0 -31
- package/src/libs/crud-pro/CrudPro.ts +0 -158
- package/src/libs/crud-pro/defaultConfigs.ts +0 -13
- package/src/libs/crud-pro/exceptions.ts +0 -124
- package/src/libs/crud-pro/interfaces.ts +0 -183
- package/src/libs/crud-pro/models/ExecuteContext.ts +0 -111
- package/src/libs/crud-pro/models/ExecuteContextFunc.ts +0 -86
- 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/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 -74
- 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 -107
- package/src/libs/crud-pro/models/keys.ts +0 -159
- package/src/libs/crud-pro/services/CrudProCachedCfgService.ts +0 -75
- package/src/libs/crud-pro/services/CrudProExecuteFuncService.ts +0 -128
- package/src/libs/crud-pro/services/CrudProExecuteSqlService.ts +0 -279
- 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 -373
- package/src/libs/crud-pro/services/CrudProGenSqlService.ts +0 -202
- package/src/libs/crud-pro/services/CrudProOriginToExecuteSql.ts +0 -397
- package/src/libs/crud-pro/services/CrudProServiceBase.ts +0 -98
- package/src/libs/crud-pro/services/CrudProTableMetaService.ts +0 -59
- 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 -40
- 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 -167
- 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/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/utils/common-dto.ts +0 -52
- package/src/libs/utils/crypto-utils.ts +0 -52
- package/src/libs/utils/fatcms-request.ts +0 -115
- package/src/libs/utils/functions.ts +0 -67
- package/src/libs/utils/ordernum-utils.ts +0 -18
- package/src/libs/utils/parseConfig.ts +0 -62
- package/src/libs/utils/parseCreateSql.ts +0 -91
- package/src/libs/utils/render-utils.ts +0 -184
- package/src/middleware/forbidden.middleware.ts +0 -71
- package/src/middleware/global.middleware.ts +0 -278
- package/src/middleware/permission.middleware.ts +0 -81
- package/src/middleware/tx.middleware.ts +0 -30
- package/src/models/SystemEntities.ts +0 -115
- package/src/models/SystemPerm.ts +0 -105
- package/src/models/SystemTables.ts +0 -30
- package/src/models/bizmodels.ts +0 -89
- package/src/models/contextLogger.ts +0 -132
- package/src/models/devops.ts +0 -17
- package/src/models/userSession.ts +0 -216
- package/src/schedule/index.ts +0 -73
- package/src/service/AuthService.ts +0 -270
- package/src/service/EnumInfoService.ts +0 -129
- package/src/service/FileCenterService.ts +0 -394
- package/src/service/SysConfigService.ts +0 -34
- package/src/service/UserAccountService.ts +0 -100
- package/src/service/UserSessionService.ts +0 -81
- package/src/service/VisitStatService.ts +0 -179
- package/src/service/WorkbenchService.ts +0 -160
- package/src/service/anyapi/AnyApiSandboxService.ts +0 -121
- package/src/service/anyapi/AnyApiService.ts +0 -184
- package/src/service/base/ApiBaseService.ts +0 -42
- package/src/service/base/ApiRateLimiter.ts +0 -59
- package/src/service/base/BaseService.ts +0 -74
- 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 -188
- package/src/service/curd/CurdMixByAccountService.ts +0 -83
- package/src/service/curd/CurdMixByDictService.ts +0 -113
- package/src/service/curd/CurdMixByLinkToCustomService.ts +0 -167
- package/src/service/curd/CurdMixBySysConfigService.ts +0 -78
- package/src/service/curd/CurdMixByWorkbenchService.ts +0 -68
- package/src/service/curd/CurdMixService.ts +0 -65
- package/src/service/curd/CurdMixUtils.ts +0 -248
- package/src/service/curd/CurdProService.ts +0 -379
- package/src/service/proxyapi/ProxyApiLoadService.ts +0 -165
- 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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ColumnRelation } from '../../libs/crud-pro/interfaces';
|
|
2
|
-
import {
|
|
2
|
+
import { HandleExecuteContextType } from '../../libs/crud-pro/models/ExecuteContext';
|
|
3
3
|
import { MultiKeyMap } from '../../libs/crud-pro/utils/MultiKeyMap';
|
|
4
4
|
declare enum RelatedType {
|
|
5
5
|
dict = "dict",
|
|
@@ -13,9 +13,25 @@ declare class CrudMixUtils {
|
|
|
13
13
|
private readonly relatedType;
|
|
14
14
|
constructor(relatedType: RelatedType);
|
|
15
15
|
private getColumnsRelation;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
/**
|
|
17
|
+
* 从执行上下文,获取所有的关联关系
|
|
18
|
+
* @param exeCtxType
|
|
19
|
+
* @returns
|
|
20
|
+
*/
|
|
21
|
+
pickColumnRelations(exeCtxType: HandleExecuteContextType): ColumnRelation[];
|
|
22
|
+
/**
|
|
23
|
+
* 从执行上下文,获取所有的关联关系的代码
|
|
24
|
+
* @param exeCtx
|
|
25
|
+
* @returns
|
|
26
|
+
*/
|
|
27
|
+
pickColumnRelationCodes(exeCtx: HandleExecuteContextType): string[];
|
|
28
|
+
/**
|
|
29
|
+
* 遍历每一行,每一个关联列
|
|
30
|
+
* @param exeCtxType
|
|
31
|
+
* @param func
|
|
32
|
+
* @returns
|
|
33
|
+
*/
|
|
34
|
+
forEachRowAndColumnsRelation(exeCtxType: HandleExecuteContextType, func: FuncRowColumnRelation): void;
|
|
19
35
|
copyColumnRelationToRow(row: any, multiKeyMap: MultiKeyMap, columnRelation: ColumnRelation): void;
|
|
20
36
|
/**
|
|
21
37
|
* 无relatedCode模式
|
|
@@ -24,5 +40,12 @@ declare class CrudMixUtils {
|
|
|
24
40
|
* @param columnRelation
|
|
25
41
|
*/
|
|
26
42
|
copyColumnRelationToRowNoRelatedCode(row: any, map: Map<string, any>, columnRelation: ColumnRelation): void;
|
|
43
|
+
/**
|
|
44
|
+
* 专门COPY用户信息到row上面。无relatedCode模式
|
|
45
|
+
* @param row
|
|
46
|
+
* @param map
|
|
47
|
+
* @param columnRelation
|
|
48
|
+
*/
|
|
49
|
+
copyUserInfoToRowNoRelatedCode(row: any, map: Map<string, any>, columnRelation: ColumnRelation): void;
|
|
27
50
|
}
|
|
28
51
|
export { CrudMixUtils, RelatedType, FuncRowColumnRelation };
|
|
@@ -24,6 +24,11 @@ function getColumnsRelationAll(sqlCfg, cfgModel) {
|
|
|
24
24
|
}
|
|
25
25
|
return [];
|
|
26
26
|
}
|
|
27
|
+
const forEachColumnsRelation = (row, columnsRelation, func) => {
|
|
28
|
+
for (let i = 0; i < columnsRelation.length; i++) {
|
|
29
|
+
func(row, columnsRelation[i]);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
27
32
|
function copyBySingleSourceValue(row, sourceValue, targetColumns, getValue) {
|
|
28
33
|
// const codeObject = map.get(sourceValue);
|
|
29
34
|
const codeObject = getValue(sourceValue);
|
|
@@ -33,53 +38,60 @@ function copyBySingleSourceValue(row, sourceValue, targetColumns, getValue) {
|
|
|
33
38
|
if (Array.isArray(targetColumns)) {
|
|
34
39
|
for (let i = 0; i < targetColumns.length; i++) {
|
|
35
40
|
const targetColumn = targetColumns[i];
|
|
36
|
-
const toStr = targetColumn.to.replace('[$ARRAY_INDEX]',
|
|
37
|
-
if (targetColumn.from ===
|
|
41
|
+
const toStr = targetColumn.to.replace('[$ARRAY_INDEX]', '');
|
|
42
|
+
if (targetColumn.from === '*') {
|
|
38
43
|
_.set(row, toStr, codeObject);
|
|
39
44
|
}
|
|
40
45
|
else {
|
|
41
46
|
const dictAttrValue = _.get(codeObject, targetColumn.from);
|
|
42
|
-
if (typeof dictAttrValue !==
|
|
47
|
+
if (typeof dictAttrValue !== 'undefined' && dictAttrValue !== null) {
|
|
43
48
|
_.set(row, toStr, dictAttrValue);
|
|
44
49
|
}
|
|
45
50
|
}
|
|
46
51
|
}
|
|
47
52
|
}
|
|
48
53
|
}
|
|
49
|
-
function
|
|
50
|
-
let
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
const
|
|
54
|
-
if (
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
const dictAttrValue = _.get(codeObject, targetColumn.from);
|
|
70
|
-
if (typeof dictAttrValue !== "undefined" && dictAttrValue !== null) {
|
|
71
|
-
const toStr = targetColumn.to.replace('$ARRAY_INDEX', `${codeIndex}`);
|
|
72
|
-
_.set(row, toStr, dictAttrValue);
|
|
73
|
-
isSetArray = true;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
54
|
+
function copyByArraySourceValueInner(row, codes, targetColumns, getValue, resultObj) {
|
|
55
|
+
for (let codeIndex = 0; codeIndex < codes.length; codeIndex++) {
|
|
56
|
+
const code = codes[codeIndex];
|
|
57
|
+
// const codeObject = map.get(code);
|
|
58
|
+
const codeObject = getValue(code);
|
|
59
|
+
if (codeObject) {
|
|
60
|
+
if (Array.isArray(targetColumns)) {
|
|
61
|
+
for (let i = 0; i < targetColumns.length; i++) {
|
|
62
|
+
const targetColumn = targetColumns[i];
|
|
63
|
+
if (targetColumn.from === '*') {
|
|
64
|
+
const toStr = targetColumn.to.replace('$ARRAY_INDEX', `${codeIndex}`);
|
|
65
|
+
_.set(row, toStr, codeObject);
|
|
66
|
+
resultObj.isSetArray = true;
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
const dictAttrValue = _.get(codeObject, targetColumn.from);
|
|
70
|
+
if (typeof dictAttrValue !== 'undefined' && dictAttrValue !== null) {
|
|
71
|
+
const toStr = targetColumn.to.replace('$ARRAY_INDEX', `${codeIndex}`);
|
|
72
|
+
_.set(row, toStr, dictAttrValue);
|
|
73
|
+
resultObj.isSetArray = true;
|
|
76
74
|
}
|
|
77
75
|
}
|
|
78
76
|
}
|
|
79
77
|
}
|
|
80
78
|
}
|
|
81
79
|
}
|
|
82
|
-
|
|
80
|
+
}
|
|
81
|
+
function copyByArraySourceValue(row, sourceValue, targetColumns, getValue) {
|
|
82
|
+
const resultObj = { isSetArray: false };
|
|
83
|
+
// 支持关联JSON数组。使用 字符串存储的类型
|
|
84
|
+
if (typeof sourceValue === 'string' && sourceValue.startsWith('[') && sourceValue.endsWith(']')) {
|
|
85
|
+
const codes = (0, functions_1.parseJsonObject)(sourceValue);
|
|
86
|
+
if (Array.isArray(codes)) {
|
|
87
|
+
copyByArraySourceValueInner(row, codes, targetColumns, getValue, resultObj);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
else if (Array.isArray(sourceValue)) {
|
|
91
|
+
// 直接使用JSON或者postgres的数组存储的类型
|
|
92
|
+
copyByArraySourceValueInner(row, sourceValue, targetColumns, getValue, resultObj);
|
|
93
|
+
}
|
|
94
|
+
return resultObj.isSetArray;
|
|
83
95
|
}
|
|
84
96
|
class CrudMixUtils {
|
|
85
97
|
constructor(relatedType) {
|
|
@@ -90,8 +102,21 @@ class CrudMixUtils {
|
|
|
90
102
|
const relatedType = this.relatedType;
|
|
91
103
|
return ss.filter(s => s.relatedType === relatedType);
|
|
92
104
|
}
|
|
93
|
-
|
|
105
|
+
/**
|
|
106
|
+
* 从执行上下文,获取所有的关联关系
|
|
107
|
+
* @param exeCtxType
|
|
108
|
+
* @returns
|
|
109
|
+
*/
|
|
110
|
+
pickColumnRelations(exeCtxType) {
|
|
111
|
+
// 自定义的关联关系
|
|
112
|
+
const customExeCtx = exeCtxType;
|
|
113
|
+
if (customExeCtx.isCustomContext) {
|
|
114
|
+
const customExeCtx = exeCtxType;
|
|
115
|
+
return customExeCtx.columnsRelation;
|
|
116
|
+
}
|
|
117
|
+
// 默认的执行上下文
|
|
94
118
|
const relationResult = [];
|
|
119
|
+
const exeCtx = exeCtxType;
|
|
95
120
|
const cfgModel = exeCtx.getCfgModel();
|
|
96
121
|
const sqlModels = exeCtx.getSqlCfgModels();
|
|
97
122
|
if (Array.isArray(sqlModels) && sqlModels.length > 0) {
|
|
@@ -113,6 +138,11 @@ class CrudMixUtils {
|
|
|
113
138
|
return `${obj.relatedCode}_${obj.relatedType}_${obj.sourceColumn}_${JSON.stringify(obj.targetColumns)}`;
|
|
114
139
|
});
|
|
115
140
|
}
|
|
141
|
+
/**
|
|
142
|
+
* 从执行上下文,获取所有的关联关系的代码
|
|
143
|
+
* @param exeCtx
|
|
144
|
+
* @returns
|
|
145
|
+
*/
|
|
116
146
|
pickColumnRelationCodes(exeCtx) {
|
|
117
147
|
const relationResult = this.pickColumnRelations(exeCtx);
|
|
118
148
|
const codes = relationResult.map(e => e.relatedCode);
|
|
@@ -121,15 +151,29 @@ class CrudMixUtils {
|
|
|
121
151
|
}
|
|
122
152
|
return [...new Set(codes)]; // 去重
|
|
123
153
|
}
|
|
124
|
-
|
|
154
|
+
/**
|
|
155
|
+
* 遍历每一行,每一个关联列
|
|
156
|
+
* @param exeCtxType
|
|
157
|
+
* @param func
|
|
158
|
+
* @returns
|
|
159
|
+
*/
|
|
160
|
+
forEachRowAndColumnsRelation(exeCtxType, func) {
|
|
161
|
+
// 自定义的关联关系
|
|
162
|
+
const customExeCtx = exeCtxType;
|
|
163
|
+
if (customExeCtx.isCustomContext) {
|
|
164
|
+
const rows = customExeCtx.rows || [];
|
|
165
|
+
const columnsRelation = customExeCtx.columnsRelation;
|
|
166
|
+
for (let index = 0; index < rows.length; index++) {
|
|
167
|
+
const row = rows[index];
|
|
168
|
+
forEachColumnsRelation(row, columnsRelation, func);
|
|
169
|
+
}
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
// 默认的执行上下文
|
|
173
|
+
const exeCtx = exeCtxType;
|
|
125
174
|
const sqlCfgList = exeCtx.getSqlCfgModels();
|
|
126
175
|
const resModel = exeCtx.getResModel();
|
|
127
176
|
const cfgModel = exeCtx.getCfgModel();
|
|
128
|
-
const forEachColumnsRelation = (row, columnsRelation) => {
|
|
129
|
-
for (let i = 0; i < columnsRelation.length; i++) {
|
|
130
|
-
func(row, columnsRelation[i]);
|
|
131
|
-
}
|
|
132
|
-
};
|
|
133
177
|
for (let i = 0; i < sqlCfgList.length; i++) {
|
|
134
178
|
const sqlCfg = sqlCfgList[i];
|
|
135
179
|
// 只有Select语句需要
|
|
@@ -140,12 +184,12 @@ class CrudMixUtils {
|
|
|
140
184
|
if (Array.isArray(resValue) && isNotEmpty(resValue)) {
|
|
141
185
|
// 多行查询时
|
|
142
186
|
for (const row of resValue) {
|
|
143
|
-
forEachColumnsRelation(row, columnsRelation);
|
|
187
|
+
forEachColumnsRelation(row, columnsRelation, func);
|
|
144
188
|
}
|
|
145
189
|
}
|
|
146
190
|
else if (typeof resValue === 'object' && isNotEmpty(resValue)) {
|
|
147
191
|
// 单行查询时
|
|
148
|
-
forEachColumnsRelation(resValue, columnsRelation);
|
|
192
|
+
forEachColumnsRelation(resValue, columnsRelation, func);
|
|
149
193
|
}
|
|
150
194
|
}
|
|
151
195
|
}
|
|
@@ -187,7 +231,37 @@ class CrudMixUtils {
|
|
|
187
231
|
if (!map) {
|
|
188
232
|
return null;
|
|
189
233
|
}
|
|
190
|
-
if (typeof map.get ===
|
|
234
|
+
if (typeof map.get === 'function') {
|
|
235
|
+
return map.get(`${code}`);
|
|
236
|
+
}
|
|
237
|
+
return map[code];
|
|
238
|
+
};
|
|
239
|
+
const isSetArray = copyByArraySourceValue(row, sourceValue, targetColumns, getValue);
|
|
240
|
+
if (!isSetArray) {
|
|
241
|
+
copyBySingleSourceValue(row, sourceValue, targetColumns, getValue);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* 专门COPY用户信息到row上面。无relatedCode模式
|
|
246
|
+
* @param row
|
|
247
|
+
* @param map
|
|
248
|
+
* @param columnRelation
|
|
249
|
+
*/
|
|
250
|
+
copyUserInfoToRowNoRelatedCode(row, map, columnRelation) {
|
|
251
|
+
const { targetColumns } = columnRelation;
|
|
252
|
+
if (!targetColumns) {
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
const tmpSourceColumn = '__fatcmsUserAccountId__';
|
|
256
|
+
const sourceValue = _.get(row, tmpSourceColumn);
|
|
257
|
+
if (!sourceValue) {
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
const getValue = (code) => {
|
|
261
|
+
if (!map) {
|
|
262
|
+
return null;
|
|
263
|
+
}
|
|
264
|
+
if (typeof map.get === 'function') {
|
|
191
265
|
return map.get(`${code}`);
|
|
192
266
|
}
|
|
193
267
|
return map[code];
|
|
@@ -5,14 +5,7 @@ import { ExecuteContext, IExecuteContextHandler } from '../../libs/crud-pro/mode
|
|
|
5
5
|
import { RelatedType } from './CurdMixUtils';
|
|
6
6
|
import { BaseService } from '../base/BaseService';
|
|
7
7
|
import { IRequestCfgModel2 } from '../../models/bizmodels';
|
|
8
|
-
|
|
9
|
-
private readonly sqlDatabase;
|
|
10
|
-
private readonly sqlDdType;
|
|
11
|
-
private readonly curdProService;
|
|
12
|
-
constructor(sqlDatabase: string, sqlDdType: SqlDbType, curdProService: CurdProService);
|
|
13
|
-
getOne(reqJson: IRequestModel, sqlTable: string): Promise<any>;
|
|
14
|
-
getList(reqJson: IRequestModel, sqlTable: string): Promise<any[]>;
|
|
15
|
-
}
|
|
8
|
+
import { CrudProQuick } from '../../service/curd/CrudProQuick';
|
|
16
9
|
export declare class CurdProService extends BaseService {
|
|
17
10
|
protected ctx: Context;
|
|
18
11
|
private mysql2Config;
|
|
@@ -21,6 +14,7 @@ export declare class CurdProService extends BaseService {
|
|
|
21
14
|
private crudProCfg;
|
|
22
15
|
private responseCfgHandlers;
|
|
23
16
|
setResponseCfgHandlers(key: RelatedType, handler: IExecuteContextHandler): void;
|
|
17
|
+
getResponseCfgHandlers(): Record<RelatedType, IExecuteContextHandler>;
|
|
24
18
|
/**
|
|
25
19
|
* Execute级别:每次调用都会产生新的
|
|
26
20
|
* @private
|
|
@@ -33,7 +27,6 @@ export declare class CurdProService extends BaseService {
|
|
|
33
27
|
executeCrud(reqJson: IRequestModel): Promise<ExecuteContext>;
|
|
34
28
|
executeSQL(sqlCfgModel: ISqlCfgModel): Promise<any>;
|
|
35
29
|
executeCrudByCfg(reqJson: IRequestModel, cfgModel: IRequestCfgModel2): Promise<ExecuteContext>;
|
|
36
|
-
|
|
37
|
-
getBbUtil(database: string, sqlDdType: SqlDbType): DBUtils;
|
|
30
|
+
getBbUtil(sqlDatabase: string, sqlDbType: SqlDbType, sqlTable?: string): CrudProQuick;
|
|
38
31
|
getCachedCfgByMethod(method: string): Promise<IRequestCfgModel>;
|
|
39
32
|
}
|
|
@@ -9,7 +9,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.CurdProService =
|
|
12
|
+
exports.CurdProService = void 0;
|
|
13
13
|
const _ = require("lodash");
|
|
14
14
|
const core_1 = require("@midwayjs/core");
|
|
15
15
|
const CrudPro_1 = require("../../libs/crud-pro/CrudPro");
|
|
@@ -20,7 +20,9 @@ const keys_1 = require("../../libs/crud-pro/models/keys");
|
|
|
20
20
|
const exceptions_1 = require("../../libs/crud-pro/exceptions");
|
|
21
21
|
const ExecuteContextFunc_1 = require("../../libs/crud-pro/models/ExecuteContextFunc");
|
|
22
22
|
const BaseService_1 = require("../base/BaseService");
|
|
23
|
-
const
|
|
23
|
+
const CrudProQuick_1 = require("../../service/curd/CrudProQuick");
|
|
24
|
+
const fixCfgModel_1 = require("./fixCfgModel");
|
|
25
|
+
const global_config_1 = require("../../libs/global-config/global-config");
|
|
24
26
|
function toVisitor(ctx) {
|
|
25
27
|
const workbenchInfo = ctx.workbenchInfo;
|
|
26
28
|
const userSession = ctx.userSession;
|
|
@@ -61,27 +63,30 @@ class MyContextFunc extends ExecuteContextFunc_1.BaseExecuteContextFunc {
|
|
|
61
63
|
}
|
|
62
64
|
async getConnectionPool(sqlCfgModel) {
|
|
63
65
|
if (!sqlCfgModel.sqlDatabase) {
|
|
64
|
-
console.error('查询语句中未指定数据库', sqlCfgModel.executeSql);
|
|
66
|
+
console.error('[MyContextFunc]查询语句中未指定数据库', sqlCfgModel.executeSql);
|
|
65
67
|
throw new exceptions_1.CommonException(exceptions_1.Exceptions.DB_QUERY_PARAM_EMPTY, '查询语句中未指定数据库');
|
|
66
68
|
}
|
|
67
69
|
const dataBaseName = sqlCfgModel.sqlDatabase;
|
|
68
|
-
const
|
|
69
|
-
if (
|
|
70
|
+
const sqlDbType = sqlCfgModel.sqlDbType;
|
|
71
|
+
if (sqlDbType === keys_1.SqlDbType.postgres) {
|
|
70
72
|
const dbConfig = _.get(this.postgres2Config, dataBaseName);
|
|
71
73
|
if (!dbConfig) {
|
|
74
|
+
console.error('[MyContextFunc]postgres配置中不存在此数据库', JSON.stringify(sqlCfgModel));
|
|
72
75
|
throw new exceptions_1.CommonException(exceptions_1.Exceptions.DB_NOT_FOUND, 'postgres配置中不存在此数据库:' + dataBaseName);
|
|
73
76
|
}
|
|
74
77
|
return (0, PostgresUtils_1.getConnectionPool)(dataBaseName, dbConfig);
|
|
75
78
|
}
|
|
76
|
-
if (
|
|
79
|
+
if (sqlDbType === keys_1.SqlDbType.sqlserver) {
|
|
77
80
|
const dbConfig = _.get(this.sqlserver2Config, dataBaseName);
|
|
78
81
|
if (!dbConfig) {
|
|
82
|
+
console.error('[MyContextFunc]sqlserver配置中不存在此数据库', JSON.stringify(sqlCfgModel));
|
|
79
83
|
throw new exceptions_1.CommonException(exceptions_1.Exceptions.DB_NOT_FOUND, 'sqlserver配置中不存在此数据库:' + dataBaseName);
|
|
80
84
|
}
|
|
81
85
|
return (0, SqlServerUtils_1.getConnectionPool)(dataBaseName, dbConfig);
|
|
82
86
|
}
|
|
83
87
|
const dbConfig = _.get(this.mysql2Config, dataBaseName);
|
|
84
88
|
if (!dbConfig) {
|
|
89
|
+
console.error('[MyContextFunc]MySQL配置中不存在此数据库', JSON.stringify(sqlCfgModel));
|
|
85
90
|
throw new exceptions_1.CommonException(exceptions_1.Exceptions.DB_NOT_FOUND, 'MySQL配置中不存在此数据库:' + dataBaseName);
|
|
86
91
|
}
|
|
87
92
|
return (0, MySQLUtils_1.getConnectionPool)(dataBaseName, dbConfig);
|
|
@@ -96,43 +101,19 @@ class MyContextFunc extends ExecuteContextFunc_1.BaseExecuteContextFunc {
|
|
|
96
101
|
}
|
|
97
102
|
return null;
|
|
98
103
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
sqlDatabase: this.sqlDatabase,
|
|
111
|
-
sqlDdType: this.sqlDdType,
|
|
112
|
-
updateCfg: {},
|
|
113
|
-
};
|
|
114
|
-
const res = await this.curdProService.executeCrudByCfg(reqJson, cfgModel);
|
|
115
|
-
return res.getOneObj();
|
|
116
|
-
}
|
|
117
|
-
async getList(reqJson, sqlTable) {
|
|
118
|
-
const cfgModel = {
|
|
119
|
-
sqlTable,
|
|
120
|
-
sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_QUERY,
|
|
121
|
-
sqlDatabase: this.sqlDatabase,
|
|
122
|
-
sqlDdType: this.sqlDdType,
|
|
123
|
-
updateCfg: {},
|
|
124
|
-
};
|
|
125
|
-
const res = await this.curdProService.executeCrudByCfg(reqJson, cfgModel);
|
|
126
|
-
return res.getResRows();
|
|
104
|
+
/**
|
|
105
|
+
* 在执行之前可以根据业务需要修改需要执行的内容
|
|
106
|
+
* @param reqJson
|
|
107
|
+
* @param cfgJson
|
|
108
|
+
*/
|
|
109
|
+
async beforeExecuteSQLList(reqJson, cfgJson) {
|
|
110
|
+
const { bizUpdateCfgModelForCrudPro } = global_config_1.GLOBAL_STATIC_CONFIG.getConfig();
|
|
111
|
+
if (typeof bizUpdateCfgModelForCrudPro === 'function') {
|
|
112
|
+
await bizUpdateCfgModelForCrudPro(reqJson, cfgJson);
|
|
113
|
+
}
|
|
114
|
+
return Promise.resolve();
|
|
127
115
|
}
|
|
128
116
|
}
|
|
129
|
-
exports.DBUtils = DBUtils;
|
|
130
|
-
function isSimpleQuery(sqlSimpleName) {
|
|
131
|
-
return sqlSimpleName === keys_1.KeysOfSimpleSQL.SIMPLE_QUERY ||
|
|
132
|
-
sqlSimpleName === keys_1.KeysOfSimpleSQL.SIMPLE_QUERY_COUNT ||
|
|
133
|
-
sqlSimpleName === keys_1.KeysOfSimpleSQL.SIMPLE_QUERY_PAGE ||
|
|
134
|
-
sqlSimpleName === keys_1.KeysOfSimpleSQL.SIMPLE_QUERY_ONE;
|
|
135
|
-
}
|
|
136
117
|
let CurdProService = class CurdProService extends BaseService_1.BaseService {
|
|
137
118
|
constructor() {
|
|
138
119
|
super(...arguments);
|
|
@@ -141,6 +122,9 @@ let CurdProService = class CurdProService extends BaseService_1.BaseService {
|
|
|
141
122
|
setResponseCfgHandlers(key, handler) {
|
|
142
123
|
this.responseCfgHandlers[key] = handler;
|
|
143
124
|
}
|
|
125
|
+
getResponseCfgHandlers() {
|
|
126
|
+
return this.responseCfgHandlers;
|
|
127
|
+
}
|
|
144
128
|
/**
|
|
145
129
|
* Execute级别:每次调用都会产生新的
|
|
146
130
|
* @private
|
|
@@ -152,11 +136,15 @@ let CurdProService = class CurdProService extends BaseService_1.BaseService {
|
|
|
152
136
|
crudPro.transaction = this.ctx.transaction;
|
|
153
137
|
crudPro.logger = this.getContextLogger();
|
|
154
138
|
crudPro.visitor = visitor;
|
|
155
|
-
|
|
139
|
+
const crudProCfg = this.crudProCfg || {};
|
|
140
|
+
const { SystemDbName, SystemDbType } = global_config_1.GLOBAL_STATIC_CONFIG.getConfig();
|
|
141
|
+
crudProCfg.sysDatabaseName = SystemDbName;
|
|
142
|
+
crudProCfg.sysDatabaseDbType = SystemDbType;
|
|
143
|
+
crudPro.contextCfg = crudProCfg;
|
|
156
144
|
crudPro.contextFunc = new MyContextFunc({
|
|
157
145
|
mysql2Config: this.mysql2Config,
|
|
158
146
|
postgres2Config: this.postgres2Config,
|
|
159
|
-
sqlserver2Config: this.sqlserver2Config
|
|
147
|
+
sqlserver2Config: this.sqlserver2Config,
|
|
160
148
|
}, this.responseCfgHandlers);
|
|
161
149
|
return crudPro;
|
|
162
150
|
}
|
|
@@ -181,114 +169,14 @@ let CurdProService = class CurdProService extends BaseService_1.BaseService {
|
|
|
181
169
|
// 直接执行一个请求
|
|
182
170
|
async executeCrudByCfg(reqJson, cfgModel) {
|
|
183
171
|
this.logInfo('executeCrudByCfg', cfgModel);
|
|
184
|
-
if (!cfgModel.method) {
|
|
185
|
-
const req = this.ctx.req;
|
|
186
|
-
if (req) {
|
|
187
|
-
cfgModel.method = `${req.method}:${req.url}`;
|
|
188
|
-
}
|
|
189
|
-
else {
|
|
190
|
-
cfgModel.method = 'anonymous';
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
if (!cfgModel.updateCfg) {
|
|
194
|
-
cfgModel.updateCfg = {};
|
|
195
|
-
}
|
|
196
|
-
// 应用标准的updateCfg
|
|
197
|
-
this.applyStandardUpdateCfg(cfgModel);
|
|
198
172
|
const curdPro = this.getCrudPro();
|
|
173
|
+
// 应用标准的updateCfg。
|
|
174
|
+
(0, fixCfgModel_1.fixCfgModel)(cfgModel);
|
|
199
175
|
return await curdPro.executeCrudByCfg(reqJson, cfgModel);
|
|
200
176
|
}
|
|
201
|
-
|
|
202
|
-
const
|
|
203
|
-
|
|
204
|
-
const enableStandardUpdateCfgCondition = cfgModel.enableStandardUpdateCfgCondition; // 用于设置condition字段
|
|
205
|
-
// 彻底关闭
|
|
206
|
-
if (enableStandardUpdateCfg === false) {
|
|
207
|
-
return;
|
|
208
|
-
}
|
|
209
|
-
const getDataCfgArray = () => {
|
|
210
|
-
// 明确有配置
|
|
211
|
-
if (Array.isArray(enableStandardUpdateCfg)) {
|
|
212
|
-
if (enableStandardUpdateCfg.includes('null')) {
|
|
213
|
-
return [];
|
|
214
|
-
}
|
|
215
|
-
return enableStandardUpdateCfg;
|
|
216
|
-
}
|
|
217
|
-
// update 、insert 添加 by
|
|
218
|
-
return ['by']; // 创建/修改语句默认添加by
|
|
219
|
-
};
|
|
220
|
-
const getConditionCfgArray = () => {
|
|
221
|
-
// 明确有配置
|
|
222
|
-
if (Array.isArray(enableStandardUpdateCfgCondition)) {
|
|
223
|
-
if (enableStandardUpdateCfgCondition.includes('null')) {
|
|
224
|
-
return [];
|
|
225
|
-
}
|
|
226
|
-
return enableStandardUpdateCfgCondition;
|
|
227
|
-
}
|
|
228
|
-
return [];
|
|
229
|
-
};
|
|
230
|
-
const dataCfgArray = getDataCfgArray();
|
|
231
|
-
const conditionCfgArray = getConditionCfgArray();
|
|
232
|
-
const mapping = {
|
|
233
|
-
'condition.created_by': { contextAsString: bizmodels_1.CTX_VISITOR_ID },
|
|
234
|
-
'condition.created_account_type': { contextAsString: bizmodels_1.CTX_VISITOR_ACCOUNT_TYPE },
|
|
235
|
-
'data.created_by': { contextAsString: bizmodels_1.CTX_VISITOR_ID },
|
|
236
|
-
'data.created_avatar': { contextAsString: bizmodels_1.CTX_VISITOR_AVATAR },
|
|
237
|
-
'data.created_nickname': { contextAsString: bizmodels_1.CTX_VISITOR_NICKNAME },
|
|
238
|
-
'data.created_account_type': { contextAsString: bizmodels_1.CTX_VISITOR_ACCOUNT_TYPE },
|
|
239
|
-
'data.modified_by': { contextAsString: bizmodels_1.CTX_VISITOR_ID },
|
|
240
|
-
'data.modified_avatar': { contextAsString: bizmodels_1.CTX_VISITOR_AVATAR },
|
|
241
|
-
'data.modified_nickname': { contextAsString: bizmodels_1.CTX_VISITOR_NICKNAME },
|
|
242
|
-
'data.modified_account_type': { contextAsString: bizmodels_1.CTX_VISITOR_ACCOUNT_TYPE },
|
|
243
|
-
};
|
|
244
|
-
const buildUpdateCfgBy = (cfgArray, prefix) => {
|
|
245
|
-
const obj = {};
|
|
246
|
-
if (Array.isArray(cfgArray)) {
|
|
247
|
-
for (let i = 0; i < cfgArray.length; i++) {
|
|
248
|
-
const suffix = cfgArray[i];
|
|
249
|
-
if (suffix) {
|
|
250
|
-
const key = `${prefix}_${suffix}`;
|
|
251
|
-
obj[key] = mapping[key];
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
return obj;
|
|
256
|
-
};
|
|
257
|
-
// 查询语句
|
|
258
|
-
if (isSimpleQuery(sqlSimpleName)) {
|
|
259
|
-
const updateCfgObj = buildUpdateCfgBy(conditionCfgArray, 'condition.created'); // 查询用户本人创建的
|
|
260
|
-
Object.assign(cfgModel.updateCfg, updateCfgObj);
|
|
261
|
-
}
|
|
262
|
-
// 删除语句
|
|
263
|
-
if (sqlSimpleName === keys_1.KeysOfSimpleSQL.SIMPLE_DELETE) {
|
|
264
|
-
const updateCfgObj = buildUpdateCfgBy(conditionCfgArray, 'condition.created'); // 删除用户本人创建的
|
|
265
|
-
Object.assign(cfgModel.updateCfg, updateCfgObj);
|
|
266
|
-
}
|
|
267
|
-
// 插入语句
|
|
268
|
-
if (sqlSimpleName === keys_1.KeysOfSimpleSQL.SIMPLE_INSERT) {
|
|
269
|
-
const updateCfgObj1 = buildUpdateCfgBy(dataCfgArray, 'data.created');
|
|
270
|
-
Object.assign(cfgModel.updateCfg, updateCfgObj1);
|
|
271
|
-
}
|
|
272
|
-
// 更新语句
|
|
273
|
-
if (sqlSimpleName === keys_1.KeysOfSimpleSQL.SIMPLE_UPDATE) {
|
|
274
|
-
const updateCfgObj1 = buildUpdateCfgBy(dataCfgArray, 'data.modified');
|
|
275
|
-
const updateCfgObj2 = buildUpdateCfgBy(conditionCfgArray, 'condition.created'); // 更新用户本人创建的
|
|
276
|
-
Object.assign(cfgModel.updateCfg, updateCfgObj1);
|
|
277
|
-
Object.assign(cfgModel.updateCfg, updateCfgObj2);
|
|
278
|
-
}
|
|
279
|
-
// 插入或更新
|
|
280
|
-
if (sqlSimpleName === keys_1.KeysOfSimpleSQL.SIMPLE_INSERT_OR_UPDATE ||
|
|
281
|
-
sqlSimpleName === keys_1.KeysOfSimpleSQL.SIMPLE_INSERT_ON_DUPLICATE_UPDATE) {
|
|
282
|
-
const updateCfgObj1 = buildUpdateCfgBy(dataCfgArray, 'data.created');
|
|
283
|
-
const updateCfgObj2 = buildUpdateCfgBy(dataCfgArray, 'data.modified');
|
|
284
|
-
const updateCfgObj3 = buildUpdateCfgBy(conditionCfgArray, 'condition.created'); // 更新用户本人创建的
|
|
285
|
-
Object.assign(cfgModel.updateCfg, updateCfgObj1);
|
|
286
|
-
Object.assign(cfgModel.updateCfg, updateCfgObj2);
|
|
287
|
-
Object.assign(cfgModel.updateCfg, updateCfgObj3);
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
getBbUtil(database, sqlDdType) {
|
|
291
|
-
return new DBUtils(database, sqlDdType, this);
|
|
177
|
+
getBbUtil(sqlDatabase, sqlDbType, sqlTable) {
|
|
178
|
+
const curdPro = this.getCrudPro();
|
|
179
|
+
return new CrudProQuick_1.CrudProQuick(curdPro, sqlDatabase, sqlDbType, sqlTable);
|
|
292
180
|
}
|
|
293
181
|
async getCachedCfgByMethod(method) {
|
|
294
182
|
const curdPro = this.getCrudPro();
|