midway-fatcms 0.0.1-beta.5 → 0.0.1-beta.50
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 +25 -13
- package/dist/config/seed/aeskey.txt +1 -1
- package/dist/configuration.d.ts +1 -0
- package/dist/configuration.js +35 -11
- 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/CrudStdGatewayController.js +8 -16
- 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 +9 -1
- package/dist/controller/manage/CrudStandardDesignApi.js +135 -79
- 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 +1 -1
- package/dist/controller/manage/UserAccountManageApi.js +9 -4
- 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 +10 -0
- package/dist/index.js +10 -0
- 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/Transaction.d.ts +1 -0
- package/dist/libs/crud-pro/models/Transaction.js +7 -0
- 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 +60 -0
- package/dist/libs/global-config/global-config.js +35 -0
- package/dist/libs/utils/base64.d.ts +9 -0
- package/dist/libs/utils/base64.js +42 -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 +12 -3
- package/dist/libs/utils/parseCreateSql.d.ts +6 -1
- package/dist/libs/utils/parseCreateSql.js +2 -1
- package/dist/middleware/forbidden.middleware.js +6 -22
- package/dist/middleware/global.middleware.js +30 -10
- package/dist/middleware/permission.middleware.js +1 -1
- package/dist/middleware/rediscache.middleware.d.ts +3 -0
- package/dist/middleware/rediscache.middleware.js +77 -0
- package/dist/middleware/redislock.middleware.d.ts +7 -0
- package/dist/middleware/redislock.middleware.js +72 -0
- package/dist/models/AsyncTaskModel.d.ts +74 -0
- package/dist/models/AsyncTaskModel.js +31 -0
- package/dist/models/RedisKeys.d.ts +15 -0
- package/dist/models/RedisKeys.js +18 -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 +30 -0
- package/dist/models/bizmodels.js +6 -1
- package/dist/models/userSession.d.ts +1 -0
- 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 +22 -0
- package/dist/service/UserSessionService.js +74 -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 +141 -0
- package/dist/service/asyncTask/handler/ExportExcelByStdCrudHandler.d.ts +46 -0
- package/dist/service/asyncTask/handler/ExportExcelByStdCrudHandler.js +135 -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/CrudStdRelationService.js +63 -36
- package/dist/service/crudstd/CrudStdService.d.ts +21 -5
- package/dist/service/crudstd/CrudStdService.js +135 -21
- 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 +11 -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 +16 -5
- package/dist/service/curd/CurdMixService.js +26 -2
- package/dist/service/curd/CurdMixUtils.d.ts +27 -4
- package/dist/service/curd/CurdMixUtils.js +117 -41
- package/dist/service/curd/CurdProService.d.ts +3 -10
- package/dist/service/curd/CurdProService.js +38 -148
- package/dist/service/curd/fixCfgModel.d.ts +3 -0
- package/dist/service/curd/fixCfgModel.js +103 -0
- package/dist/service/proxyapi/ProxyApiLoadService.js +7 -4
- package/dist/service/proxyapi/ProxyApiService.d.ts +1 -0
- package/dist/service/proxyapi/ProxyApiService.js +43 -9
- package/dist/views/404_app.html +31 -31
- package/dist/views/404_workbench.html +34 -34
- package/package.json +28 -24
- package/tsconfig.json +32 -0
- 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/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 -99
- 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
|
@@ -19,8 +19,33 @@ const devops_1 = require("../../models/devops");
|
|
|
19
19
|
const exceptions_1 = require("../../libs/crud-pro/exceptions");
|
|
20
20
|
const RedisCacheService_1 = require("../base/RedisCacheService");
|
|
21
21
|
const DatabaseName_1 = require("../../libs/crud-pro/utils/DatabaseName");
|
|
22
|
+
const global_config_1 = require("../../libs/global-config/global-config");
|
|
23
|
+
const RedisKeys_1 = require("../../models/RedisKeys");
|
|
22
24
|
const linkToCustomMixUtils = new CurdMixUtils_1.CrudMixUtils(CurdMixUtils_1.RelatedType.linkToCustom);
|
|
23
25
|
const TMP_CTX_KEY = _.uniqueId('CurdMixByLinkToCustomService');
|
|
26
|
+
function toMapObject(rows, fieldsArr) {
|
|
27
|
+
const valueKey = fieldsArr[0];
|
|
28
|
+
const labelKey = fieldsArr[1];
|
|
29
|
+
const isObjectMode = fieldsArr.length > 2 || labelKey === '*';
|
|
30
|
+
const map = new Map();
|
|
31
|
+
for (let i = 0; i < rows.length; i++) {
|
|
32
|
+
const rowObj = rows[i];
|
|
33
|
+
const value = rowObj[valueKey];
|
|
34
|
+
if (typeof value !== 'undefined') {
|
|
35
|
+
const valueStr = '' + value;
|
|
36
|
+
if (isObjectMode) {
|
|
37
|
+
map.set(valueStr, rowObj);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
const label = rowObj[labelKey];
|
|
41
|
+
if (label) {
|
|
42
|
+
map.set(valueStr, label);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return map;
|
|
48
|
+
}
|
|
24
49
|
let CurdMixByLinkToCustomService = class CurdMixByLinkToCustomService {
|
|
25
50
|
async handleExecuteContextPrepare(executeContext) {
|
|
26
51
|
const relations = linkToCustomMixUtils.pickColumnRelations(executeContext);
|
|
@@ -43,8 +68,8 @@ let CurdMixByLinkToCustomService = class CurdMixByLinkToCustomService {
|
|
|
43
68
|
if (!Array.isArray(targetColumns) || targetColumns.length === 0) {
|
|
44
69
|
columnRelation.targetColumns = [
|
|
45
70
|
{
|
|
46
|
-
|
|
47
|
-
|
|
71
|
+
from: '*',
|
|
72
|
+
to: `${sourceColumn}_info[$ARRAY_INDEX]`,
|
|
48
73
|
},
|
|
49
74
|
];
|
|
50
75
|
}
|
|
@@ -54,7 +79,7 @@ let CurdMixByLinkToCustomService = class CurdMixByLinkToCustomService {
|
|
|
54
79
|
});
|
|
55
80
|
}
|
|
56
81
|
async queryInfoByLinkToCustom(code) {
|
|
57
|
-
const cacheKey =
|
|
82
|
+
const cacheKey = RedisKeys_1.RedisKeys.LINK_TO_CUSTOM_PREFIX + code;
|
|
58
83
|
let values;
|
|
59
84
|
const expireSecond = 2 * 60; // 2分钟
|
|
60
85
|
const enumMap = await this.redisCacheService.getJsonObject(cacheKey);
|
|
@@ -68,11 +93,16 @@ let CurdMixByLinkToCustomService = class CurdMixByLinkToCustomService {
|
|
|
68
93
|
* code形如:mysql_________fatcms~~~sys_perm_role~~~role_code,role_name,xxx_name
|
|
69
94
|
* code形如:fatcms~~~sys_perm_role~~~role_code,role_name,xxx_name
|
|
70
95
|
* code形如:fatcms~~~sys_perm_role~~~id,*
|
|
96
|
+
* code形如:GET_BY_CRUD_METHOD~~~GetActiveLineEnum~~~id,*
|
|
97
|
+
* code形如:GET_BY_CRUD_METHOD~~~GetActiveLineEnum~~~id,name
|
|
71
98
|
* 【数据库】~~~【表名】~~~【value】,【label】,【style】
|
|
72
99
|
* @param code
|
|
73
100
|
* @private
|
|
74
101
|
*/
|
|
75
102
|
async queryInfoByLinkToCustomImpl(code) {
|
|
103
|
+
if (code.startsWith('GET_BY_CRUD_METHOD')) {
|
|
104
|
+
return this.queryInfoByLinkToCustomByCrudMethod(code);
|
|
105
|
+
}
|
|
76
106
|
const arr = code
|
|
77
107
|
.split('~~~')
|
|
78
108
|
.map(s => s.trim())
|
|
@@ -89,46 +119,65 @@ let CurdMixByLinkToCustomService = class CurdMixByLinkToCustomService {
|
|
|
89
119
|
if (fieldsArr.length < 2) {
|
|
90
120
|
throw new devops_1.BizException('linkToCustom枚举值查询字符串,fields字段必须符合固定格式', exceptions_1.Exceptions.CFG_ERROR);
|
|
91
121
|
}
|
|
92
|
-
const valueKey = fieldsArr[0];
|
|
93
122
|
const labelKey = fieldsArr[1];
|
|
94
|
-
const isObjectMode = fieldsArr.length > 2 || labelKey === "*";
|
|
95
123
|
const res1 = await this.curdProService.executeCrudByCfg({
|
|
96
124
|
condition: {},
|
|
97
|
-
columns: labelKey ===
|
|
125
|
+
columns: labelKey === '*' ? null : fields,
|
|
98
126
|
limit: 4000,
|
|
99
127
|
offset: 0,
|
|
100
128
|
}, {
|
|
101
129
|
sqlTable,
|
|
102
130
|
sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_QUERY,
|
|
103
131
|
sqlDatabase: dbName,
|
|
104
|
-
|
|
132
|
+
sqlDbType: dbType,
|
|
105
133
|
maxLimit: 4000,
|
|
106
134
|
});
|
|
107
135
|
const rows = res1.getResRows();
|
|
108
|
-
const map =
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
136
|
+
const map = toMapObject(rows, fieldsArr);
|
|
137
|
+
return map;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
*
|
|
141
|
+
* @param code
|
|
142
|
+
* code形如:GET_BY_CRUD_METHOD~~~GetActiveLineEnum~~~id,*
|
|
143
|
+
* code形如:GET_BY_CRUD_METHOD~~~GetActiveLineEnum~~~id,name
|
|
144
|
+
*/
|
|
145
|
+
async queryInfoByLinkToCustomByCrudMethod(code) {
|
|
146
|
+
const arr = code
|
|
147
|
+
.split('~~~')
|
|
148
|
+
.map(s => s.trim())
|
|
149
|
+
.filter(Boolean);
|
|
150
|
+
if (arr.length !== 3) {
|
|
151
|
+
throw new devops_1.BizException('linkToCustom枚举值查询字符串,必须符合固定格式。', exceptions_1.Exceptions.CFG_ERROR);
|
|
152
|
+
}
|
|
153
|
+
const [prefix, methodCode, fields] = arr;
|
|
154
|
+
const fieldsArr = fields
|
|
155
|
+
.split(',')
|
|
156
|
+
.map(s => s.trim())
|
|
157
|
+
.filter(Boolean);
|
|
158
|
+
if (fieldsArr.length < 2) {
|
|
159
|
+
throw new devops_1.BizException(`linkToCustom枚举值查询字符串,fields字段必须符合固定格式。${prefix}`, exceptions_1.Exceptions.CFG_ERROR);
|
|
160
|
+
}
|
|
161
|
+
const methodInfo = (await this.curdProService.getCachedCfgByMethod(methodCode));
|
|
162
|
+
if (!methodInfo || methodInfo.status !== 1) {
|
|
163
|
+
throw new Error('接口不存在或已下线: ' + methodCode);
|
|
124
164
|
}
|
|
165
|
+
const cfgModel = methodInfo;
|
|
166
|
+
const { dbType, dbName } = (0, DatabaseName_1.parseDatabaseName)(cfgModel.sqlDatabase);
|
|
167
|
+
cfgModel.sqlDatabase = dbName;
|
|
168
|
+
cfgModel.sqlDbType = dbType;
|
|
169
|
+
const reqJson = {};
|
|
170
|
+
await global_config_1.GLOBAL_STATIC_CONFIG.getConfig().bizUpdateCfgModelForCrudMtd(reqJson, cfgModel, methodInfo, this.ctx);
|
|
171
|
+
const exeCtx = await this.curdProService.executeCrudByCfg(reqJson, cfgModel);
|
|
172
|
+
const rows = exeCtx.getResRows();
|
|
173
|
+
const map = toMapObject(rows, fieldsArr);
|
|
125
174
|
return map;
|
|
126
175
|
}
|
|
127
176
|
async loadInfoByLinkToCustomMap(relations) {
|
|
128
177
|
const bigMap = new Map();
|
|
129
178
|
for (let i = 0; i < relations.length; i++) {
|
|
130
179
|
const relation = relations[i];
|
|
131
|
-
const code = relation.relatedCode ||
|
|
180
|
+
const code = relation.relatedCode || '';
|
|
132
181
|
const codeTrim = code.trim();
|
|
133
182
|
const map = await this.queryInfoByLinkToCustom(codeTrim);
|
|
134
183
|
bigMap.set(codeTrim, map);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Context } from '@midwayjs/koa';
|
|
2
2
|
import { CurdProService } from './CurdProService';
|
|
3
|
-
import {
|
|
3
|
+
import { HandleExecuteContextType, IExecuteContextHandler } from '../../libs/crud-pro/models/ExecuteContext';
|
|
4
4
|
export declare class CurdMixBySysConfigService implements IExecuteContextHandler {
|
|
5
5
|
ctx: Context;
|
|
6
6
|
protected curdProService: CurdProService;
|
|
7
|
-
handleExecuteContextPrepare(executeContext:
|
|
8
|
-
handleExecuteContext(executeContext:
|
|
7
|
+
handleExecuteContextPrepare(executeContext: HandleExecuteContextType): Promise<void>;
|
|
8
|
+
handleExecuteContext(executeContext: HandleExecuteContextType): Promise<void>;
|
|
9
9
|
}
|
|
@@ -18,10 +18,12 @@ const SystemTables_1 = require("../../models/SystemTables");
|
|
|
18
18
|
const keys_1 = require("../../libs/crud-pro/models/keys");
|
|
19
19
|
const MultiKeyMap_1 = require("../../libs/crud-pro/utils/MultiKeyMap");
|
|
20
20
|
const parseConfig_1 = require("../../libs/utils/parseConfig");
|
|
21
|
+
const global_config_1 = require("../../libs/global-config/global-config");
|
|
21
22
|
const dictMixUtils = new CurdMixUtils_1.CrudMixUtils(CurdMixUtils_1.RelatedType.sysCfgEnum);
|
|
22
23
|
const TMP_CTX_KEY = _.uniqueId('CurdMixBySysConfigService');
|
|
23
24
|
let CurdMixBySysConfigService = class CurdMixBySysConfigService {
|
|
24
25
|
async handleExecuteContextPrepare(executeContext) {
|
|
26
|
+
const { SystemDbName, SystemDbType } = global_config_1.GLOBAL_STATIC_CONFIG.getConfig();
|
|
25
27
|
const codes = dictMixUtils.pickColumnRelationCodes(executeContext);
|
|
26
28
|
if (!codes || codes.length === 0) {
|
|
27
29
|
return;
|
|
@@ -31,8 +33,8 @@ let CurdMixBySysConfigService = class CurdMixBySysConfigService {
|
|
|
31
33
|
}, {
|
|
32
34
|
sqlTable: SystemTables_1.SystemTables.sys_configs,
|
|
33
35
|
sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_QUERY,
|
|
34
|
-
sqlDatabase:
|
|
35
|
-
|
|
36
|
+
sqlDatabase: SystemDbName,
|
|
37
|
+
sqlDbType: SystemDbType,
|
|
36
38
|
});
|
|
37
39
|
const rows = res1.getResRows();
|
|
38
40
|
const multiKeyMap = new MultiKeyMap_1.MultiKeyMap();
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Context } from '@midwayjs/koa';
|
|
2
2
|
import { CurdProService } from './CurdProService';
|
|
3
|
-
import {
|
|
3
|
+
import { HandleExecuteContextType, IExecuteContextHandler } from '../../libs/crud-pro/models/ExecuteContext';
|
|
4
4
|
export declare class CurdMixByWorkbenchService implements IExecuteContextHandler {
|
|
5
5
|
ctx: Context;
|
|
6
6
|
protected curdProService: CurdProService;
|
|
7
7
|
private loadWorkbenchListMap;
|
|
8
|
-
handleExecuteContextPrepare(executeContext:
|
|
9
|
-
handleExecuteContext(executeContext:
|
|
8
|
+
handleExecuteContextPrepare(executeContext: HandleExecuteContextType): Promise<void>;
|
|
9
|
+
handleExecuteContext(executeContext: HandleExecuteContextType): Promise<void>;
|
|
10
10
|
}
|
|
@@ -18,6 +18,7 @@ const CurdMixUtils_1 = require("./CurdMixUtils");
|
|
|
18
18
|
const SystemTables_1 = require("../../models/SystemTables");
|
|
19
19
|
const keys_1 = require("../../libs/crud-pro/models/keys");
|
|
20
20
|
const MixinUtils_1 = require("../../libs/crud-pro/utils/MixinUtils");
|
|
21
|
+
const global_config_1 = require("../../libs/global-config/global-config");
|
|
21
22
|
const lruCache = new lru_cache_1.LRUCache({
|
|
22
23
|
max: 500,
|
|
23
24
|
ttl: 1000 * 60 * 5,
|
|
@@ -27,6 +28,7 @@ const workbenchMixUtils = new CurdMixUtils_1.CrudMixUtils(CurdMixUtils_1.Related
|
|
|
27
28
|
const TMP_CTX_KEY = _.uniqueId('CurdMixByWorkbenchService');
|
|
28
29
|
let CurdMixByWorkbenchService = class CurdMixByWorkbenchService {
|
|
29
30
|
async loadWorkbenchListMap() {
|
|
31
|
+
const { SystemDbName, SystemDbType } = global_config_1.GLOBAL_STATIC_CONFIG.getConfig();
|
|
30
32
|
let workbenchListMap = lruCache.get('workbenchListMap');
|
|
31
33
|
if (!workbenchListMap) {
|
|
32
34
|
const reqJson = {
|
|
@@ -36,8 +38,8 @@ let CurdMixByWorkbenchService = class CurdMixByWorkbenchService {
|
|
|
36
38
|
const res = await this.curdProService.executeCrudByCfg(reqJson, {
|
|
37
39
|
sqlTable: SystemTables_1.SystemTables.sys_workbench,
|
|
38
40
|
sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_QUERY,
|
|
39
|
-
sqlDatabase:
|
|
40
|
-
|
|
41
|
+
sqlDatabase: SystemDbName,
|
|
42
|
+
sqlDbType: SystemDbType,
|
|
41
43
|
});
|
|
42
44
|
const workbenchList = res.getResRows();
|
|
43
45
|
workbenchListMap = MixinUtils_1.MixinUtils.toNewMap(workbenchList, (obj) => obj.workbench_code);
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import { IRequestCfgModel, IRequestModel, ISqlCfgModel } from '../../libs/crud-pro/interfaces';
|
|
1
|
+
import { ColumnRelation, IRequestCfgModel, IRequestModel, ISqlCfgModel } from '../../libs/crud-pro/interfaces';
|
|
2
2
|
import { IRequestCfgModel2 } from '../../models/bizmodels';
|
|
3
|
-
import { SqlDbType } from
|
|
3
|
+
import { SqlDbType } from '../../libs/crud-pro/models/keys';
|
|
4
|
+
import { ExecuteContext } from '../../libs/crud-pro/models/ExecuteContext';
|
|
5
|
+
export interface ILinkColumnRelationParam {
|
|
6
|
+
columnsRelations: ColumnRelation[];
|
|
7
|
+
}
|
|
4
8
|
export declare class CurdMixService {
|
|
5
9
|
private curdProService;
|
|
6
10
|
private curdMixByDictService;
|
|
@@ -9,9 +13,16 @@ export declare class CurdMixService {
|
|
|
9
13
|
private curdMixByWorkbenchService;
|
|
10
14
|
private curdMixByLinkToCustomService;
|
|
11
15
|
private prepare;
|
|
12
|
-
executeCrudByCfg(reqJson: IRequestModel, cfgModel: IRequestCfgModel2): Promise<
|
|
13
|
-
getBbUtil(
|
|
16
|
+
executeCrudByCfg(reqJson: IRequestModel, cfgModel: IRequestCfgModel2): Promise<ExecuteContext>;
|
|
17
|
+
getBbUtil(sqlDatabase: string, sqlDbType: SqlDbType, sqlTable?: string): import("./CrudProQuick").CrudProQuick;
|
|
14
18
|
executeSQL(sqlCfgModel: ISqlCfgModel): Promise<any>;
|
|
15
|
-
executeCrud(reqJson: IRequestModel): Promise<
|
|
19
|
+
executeCrud(reqJson: IRequestModel): Promise<ExecuteContext>;
|
|
16
20
|
getCachedCfgByMethod(method: string): Promise<IRequestCfgModel>;
|
|
21
|
+
/**
|
|
22
|
+
* 根据配置的关联关系,直接关联数据
|
|
23
|
+
* @param rows
|
|
24
|
+
* @param param
|
|
25
|
+
* @returns
|
|
26
|
+
*/
|
|
27
|
+
linkColumnRelationDatas(rows: any[], param: ILinkColumnRelationParam): Promise<void>;
|
|
17
28
|
}
|
|
@@ -30,9 +30,9 @@ let CurdMixService = class CurdMixService {
|
|
|
30
30
|
this.prepare();
|
|
31
31
|
return this.curdProService.executeCrudByCfg(reqJson, cfgModel);
|
|
32
32
|
}
|
|
33
|
-
getBbUtil(
|
|
33
|
+
getBbUtil(sqlDatabase, sqlDbType, sqlTable) {
|
|
34
34
|
this.prepare();
|
|
35
|
-
return this.curdProService.getBbUtil(
|
|
35
|
+
return this.curdProService.getBbUtil(sqlDatabase, sqlDbType, sqlTable);
|
|
36
36
|
}
|
|
37
37
|
async executeSQL(sqlCfgModel) {
|
|
38
38
|
this.prepare();
|
|
@@ -45,6 +45,30 @@ let CurdMixService = class CurdMixService {
|
|
|
45
45
|
async getCachedCfgByMethod(method) {
|
|
46
46
|
return this.curdProService.getCachedCfgByMethod(method);
|
|
47
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* 根据配置的关联关系,直接关联数据
|
|
50
|
+
* @param rows
|
|
51
|
+
* @param param
|
|
52
|
+
* @returns
|
|
53
|
+
*/
|
|
54
|
+
async linkColumnRelationDatas(rows, param) {
|
|
55
|
+
if (!Array.isArray(rows) || rows.length === 0) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
this.prepare();
|
|
59
|
+
const exeCtx = {
|
|
60
|
+
rows,
|
|
61
|
+
columnsRelation: param.columnsRelations,
|
|
62
|
+
isCustomContext: true,
|
|
63
|
+
};
|
|
64
|
+
const responseCfgHandlers = this.curdProService.getResponseCfgHandlers();
|
|
65
|
+
const handlers = Object.values(responseCfgHandlers);
|
|
66
|
+
for (let i = 0; i < handlers.length; i++) {
|
|
67
|
+
const handler = handlers[i];
|
|
68
|
+
await handler.handleExecuteContextPrepare(exeCtx);
|
|
69
|
+
await handler.handleExecuteContext(exeCtx);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
48
72
|
};
|
|
49
73
|
__decorate([
|
|
50
74
|
(0, core_1.Inject)(),
|
|
@@ -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 };
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.RelatedType = exports.CrudMixUtils = void 0;
|
|
4
4
|
const keys_1 = require("../../libs/crud-pro/models/keys");
|
|
5
5
|
const MixinUtils_1 = require("../../libs/crud-pro/utils/MixinUtils");
|
|
6
|
+
const global_config_1 = require("../../libs/global-config/global-config");
|
|
6
7
|
const _ = require("lodash");
|
|
7
8
|
const functions_1 = require("../../libs/utils/functions");
|
|
8
9
|
var RelatedType;
|
|
@@ -24,6 +25,11 @@ function getColumnsRelationAll(sqlCfg, cfgModel) {
|
|
|
24
25
|
}
|
|
25
26
|
return [];
|
|
26
27
|
}
|
|
28
|
+
const forEachColumnsRelation = (row, columnsRelation, func) => {
|
|
29
|
+
for (let i = 0; i < columnsRelation.length; i++) {
|
|
30
|
+
func(row, columnsRelation[i]);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
27
33
|
function copyBySingleSourceValue(row, sourceValue, targetColumns, getValue) {
|
|
28
34
|
// const codeObject = map.get(sourceValue);
|
|
29
35
|
const codeObject = getValue(sourceValue);
|
|
@@ -33,53 +39,60 @@ function copyBySingleSourceValue(row, sourceValue, targetColumns, getValue) {
|
|
|
33
39
|
if (Array.isArray(targetColumns)) {
|
|
34
40
|
for (let i = 0; i < targetColumns.length; i++) {
|
|
35
41
|
const targetColumn = targetColumns[i];
|
|
36
|
-
const toStr = targetColumn.to.replace('[$ARRAY_INDEX]',
|
|
37
|
-
if (targetColumn.from ===
|
|
42
|
+
const toStr = targetColumn.to.replace('[$ARRAY_INDEX]', '');
|
|
43
|
+
if (targetColumn.from === '*') {
|
|
38
44
|
_.set(row, toStr, codeObject);
|
|
39
45
|
}
|
|
40
46
|
else {
|
|
41
47
|
const dictAttrValue = _.get(codeObject, targetColumn.from);
|
|
42
|
-
if (typeof dictAttrValue !==
|
|
48
|
+
if (typeof dictAttrValue !== 'undefined' && dictAttrValue !== null) {
|
|
43
49
|
_.set(row, toStr, dictAttrValue);
|
|
44
50
|
}
|
|
45
51
|
}
|
|
46
52
|
}
|
|
47
53
|
}
|
|
48
54
|
}
|
|
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
|
-
}
|
|
55
|
+
function copyByArraySourceValueInner(row, codes, targetColumns, getValue, resultObj) {
|
|
56
|
+
for (let codeIndex = 0; codeIndex < codes.length; codeIndex++) {
|
|
57
|
+
const code = codes[codeIndex];
|
|
58
|
+
// const codeObject = map.get(code);
|
|
59
|
+
const codeObject = getValue(code);
|
|
60
|
+
if (codeObject) {
|
|
61
|
+
if (Array.isArray(targetColumns)) {
|
|
62
|
+
for (let i = 0; i < targetColumns.length; i++) {
|
|
63
|
+
const targetColumn = targetColumns[i];
|
|
64
|
+
if (targetColumn.from === '*') {
|
|
65
|
+
const toStr = targetColumn.to.replace('$ARRAY_INDEX', `${codeIndex}`);
|
|
66
|
+
_.set(row, toStr, codeObject);
|
|
67
|
+
resultObj.isSetArray = true;
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
const dictAttrValue = _.get(codeObject, targetColumn.from);
|
|
71
|
+
if (typeof dictAttrValue !== 'undefined' && dictAttrValue !== null) {
|
|
72
|
+
const toStr = targetColumn.to.replace('$ARRAY_INDEX', `${codeIndex}`);
|
|
73
|
+
_.set(row, toStr, dictAttrValue);
|
|
74
|
+
resultObj.isSetArray = true;
|
|
76
75
|
}
|
|
77
76
|
}
|
|
78
77
|
}
|
|
79
78
|
}
|
|
80
79
|
}
|
|
81
80
|
}
|
|
82
|
-
|
|
81
|
+
}
|
|
82
|
+
function copyByArraySourceValue(row, sourceValue, targetColumns, getValue) {
|
|
83
|
+
const resultObj = { isSetArray: false };
|
|
84
|
+
// 支持关联JSON数组。使用 字符串存储的类型
|
|
85
|
+
if (typeof sourceValue === 'string' && sourceValue.startsWith('[') && sourceValue.endsWith(']')) {
|
|
86
|
+
const codes = (0, functions_1.parseJsonObject)(sourceValue);
|
|
87
|
+
if (Array.isArray(codes)) {
|
|
88
|
+
copyByArraySourceValueInner(row, codes, targetColumns, getValue, resultObj);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
else if (Array.isArray(sourceValue)) {
|
|
92
|
+
// 直接使用JSON或者postgres的数组存储的类型
|
|
93
|
+
copyByArraySourceValueInner(row, sourceValue, targetColumns, getValue, resultObj);
|
|
94
|
+
}
|
|
95
|
+
return resultObj.isSetArray;
|
|
83
96
|
}
|
|
84
97
|
class CrudMixUtils {
|
|
85
98
|
constructor(relatedType) {
|
|
@@ -90,8 +103,21 @@ class CrudMixUtils {
|
|
|
90
103
|
const relatedType = this.relatedType;
|
|
91
104
|
return ss.filter(s => s.relatedType === relatedType);
|
|
92
105
|
}
|
|
93
|
-
|
|
106
|
+
/**
|
|
107
|
+
* 从执行上下文,获取所有的关联关系
|
|
108
|
+
* @param exeCtxType
|
|
109
|
+
* @returns
|
|
110
|
+
*/
|
|
111
|
+
pickColumnRelations(exeCtxType) {
|
|
112
|
+
// 自定义的关联关系
|
|
113
|
+
const customExeCtx = exeCtxType;
|
|
114
|
+
if (customExeCtx.isCustomContext) {
|
|
115
|
+
const customExeCtx = exeCtxType;
|
|
116
|
+
return customExeCtx.columnsRelation;
|
|
117
|
+
}
|
|
118
|
+
// 默认的执行上下文
|
|
94
119
|
const relationResult = [];
|
|
120
|
+
const exeCtx = exeCtxType;
|
|
95
121
|
const cfgModel = exeCtx.getCfgModel();
|
|
96
122
|
const sqlModels = exeCtx.getSqlCfgModels();
|
|
97
123
|
if (Array.isArray(sqlModels) && sqlModels.length > 0) {
|
|
@@ -113,6 +139,11 @@ class CrudMixUtils {
|
|
|
113
139
|
return `${obj.relatedCode}_${obj.relatedType}_${obj.sourceColumn}_${JSON.stringify(obj.targetColumns)}`;
|
|
114
140
|
});
|
|
115
141
|
}
|
|
142
|
+
/**
|
|
143
|
+
* 从执行上下文,获取所有的关联关系的代码
|
|
144
|
+
* @param exeCtx
|
|
145
|
+
* @returns
|
|
146
|
+
*/
|
|
116
147
|
pickColumnRelationCodes(exeCtx) {
|
|
117
148
|
const relationResult = this.pickColumnRelations(exeCtx);
|
|
118
149
|
const codes = relationResult.map(e => e.relatedCode);
|
|
@@ -121,15 +152,29 @@ class CrudMixUtils {
|
|
|
121
152
|
}
|
|
122
153
|
return [...new Set(codes)]; // 去重
|
|
123
154
|
}
|
|
124
|
-
|
|
155
|
+
/**
|
|
156
|
+
* 遍历每一行,每一个关联列
|
|
157
|
+
* @param exeCtxType
|
|
158
|
+
* @param func
|
|
159
|
+
* @returns
|
|
160
|
+
*/
|
|
161
|
+
forEachRowAndColumnsRelation(exeCtxType, func) {
|
|
162
|
+
// 自定义的关联关系
|
|
163
|
+
const customExeCtx = exeCtxType;
|
|
164
|
+
if (customExeCtx.isCustomContext) {
|
|
165
|
+
const rows = customExeCtx.rows || [];
|
|
166
|
+
const columnsRelation = customExeCtx.columnsRelation;
|
|
167
|
+
for (let index = 0; index < rows.length; index++) {
|
|
168
|
+
const row = rows[index];
|
|
169
|
+
forEachColumnsRelation(row, columnsRelation, func);
|
|
170
|
+
}
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
// 默认的执行上下文
|
|
174
|
+
const exeCtx = exeCtxType;
|
|
125
175
|
const sqlCfgList = exeCtx.getSqlCfgModels();
|
|
126
176
|
const resModel = exeCtx.getResModel();
|
|
127
177
|
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
178
|
for (let i = 0; i < sqlCfgList.length; i++) {
|
|
134
179
|
const sqlCfg = sqlCfgList[i];
|
|
135
180
|
// 只有Select语句需要
|
|
@@ -140,12 +185,12 @@ class CrudMixUtils {
|
|
|
140
185
|
if (Array.isArray(resValue) && isNotEmpty(resValue)) {
|
|
141
186
|
// 多行查询时
|
|
142
187
|
for (const row of resValue) {
|
|
143
|
-
forEachColumnsRelation(row, columnsRelation);
|
|
188
|
+
forEachColumnsRelation(row, columnsRelation, func);
|
|
144
189
|
}
|
|
145
190
|
}
|
|
146
191
|
else if (typeof resValue === 'object' && isNotEmpty(resValue)) {
|
|
147
192
|
// 单行查询时
|
|
148
|
-
forEachColumnsRelation(resValue, columnsRelation);
|
|
193
|
+
forEachColumnsRelation(resValue, columnsRelation, func);
|
|
149
194
|
}
|
|
150
195
|
}
|
|
151
196
|
}
|
|
@@ -187,7 +232,7 @@ class CrudMixUtils {
|
|
|
187
232
|
if (!map) {
|
|
188
233
|
return null;
|
|
189
234
|
}
|
|
190
|
-
if (typeof map.get ===
|
|
235
|
+
if (typeof map.get === 'function') {
|
|
191
236
|
return map.get(`${code}`);
|
|
192
237
|
}
|
|
193
238
|
return map[code];
|
|
@@ -197,5 +242,36 @@ class CrudMixUtils {
|
|
|
197
242
|
copyBySingleSourceValue(row, sourceValue, targetColumns, getValue);
|
|
198
243
|
}
|
|
199
244
|
}
|
|
245
|
+
/**
|
|
246
|
+
* 专门COPY用户信息到row上面。无relatedCode模式
|
|
247
|
+
* @param row
|
|
248
|
+
* @param map
|
|
249
|
+
* @param columnRelation
|
|
250
|
+
*/
|
|
251
|
+
copyUserInfoToRowNoRelatedCode(row, map, columnRelation) {
|
|
252
|
+
const { targetColumns, sourceColumn } = columnRelation;
|
|
253
|
+
if (!targetColumns) {
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
const accountId = _.get(row, sourceColumn);
|
|
257
|
+
if (!accountId) {
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
const { toFatcmsUserAccountId } = global_config_1.GLOBAL_STATIC_CONFIG.getConfig();
|
|
261
|
+
const fatcmsUserAccountId = toFatcmsUserAccountId(accountId);
|
|
262
|
+
const getValue = (code) => {
|
|
263
|
+
if (!map) {
|
|
264
|
+
return null;
|
|
265
|
+
}
|
|
266
|
+
if (typeof map.get === 'function') {
|
|
267
|
+
return map.get(`${code}`);
|
|
268
|
+
}
|
|
269
|
+
return map[code];
|
|
270
|
+
};
|
|
271
|
+
const isSetArray = copyByArraySourceValue(row, fatcmsUserAccountId, targetColumns, getValue);
|
|
272
|
+
if (!isSetArray) {
|
|
273
|
+
copyBySingleSourceValue(row, fatcmsUserAccountId, targetColumns, getValue);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
200
276
|
}
|
|
201
277
|
exports.CrudMixUtils = CrudMixUtils;
|
|
@@ -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
|
}
|