midway-fatcms 0.0.1-beta.5 → 0.0.1-beta.51
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 +137 -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 +104 -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
|
@@ -10,6 +10,8 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.CrudStdService = exports.SPECIAL_SETTING_KEY = void 0;
|
|
13
|
+
/* eslint-disable prettier/prettier */
|
|
14
|
+
const _ = require("lodash");
|
|
13
15
|
const core_1 = require("@midwayjs/core");
|
|
14
16
|
const CurdMixService_1 = require("../curd/CurdMixService");
|
|
15
17
|
const keys_1 = require("../../libs/crud-pro/models/keys");
|
|
@@ -18,19 +20,34 @@ const devops_1 = require("../../models/devops");
|
|
|
18
20
|
const SystemTables_1 = require("../../models/SystemTables");
|
|
19
21
|
const CrudStdActionService_1 = require("./CrudStdActionService");
|
|
20
22
|
const CrudStdRelationService_1 = require("./CrudStdRelationService");
|
|
21
|
-
const _ = require("lodash");
|
|
22
23
|
const ApiBaseService_1 = require("../base/ApiBaseService");
|
|
23
24
|
const DatabaseName_1 = require("../../libs/crud-pro/utils/DatabaseName");
|
|
25
|
+
const global_config_1 = require("../../libs/global-config/global-config");
|
|
26
|
+
const MixinUtils_1 = require("../../libs/crud-pro/utils/MixinUtils");
|
|
24
27
|
exports.SPECIAL_SETTING_KEY = {
|
|
25
28
|
QUERY_LIST: 'QUERY_LIST',
|
|
26
29
|
QUERY_ONE: 'QUERY_ONE',
|
|
27
30
|
};
|
|
31
|
+
function getExecuteTableNameBySettingKey(appInfo, stdAction) {
|
|
32
|
+
const { settingKey } = stdAction || {};
|
|
33
|
+
const stdCrudCfgObj = appInfo.stdCrudCfgObj;
|
|
34
|
+
const actionsMap = appInfo.actionsMap || {};
|
|
35
|
+
const actionCfg = actionsMap[settingKey];
|
|
36
|
+
if (actionCfg) {
|
|
37
|
+
const mainTableName = _.get(actionCfg, 'component.props.mainTableName');
|
|
38
|
+
if (typeof mainTableName === 'string' && mainTableName.trim().length > 0) {
|
|
39
|
+
return mainTableName.trim();
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return stdCrudCfgObj.tableBaseInfo.tableName;
|
|
43
|
+
}
|
|
28
44
|
let CrudStdService = class CrudStdService extends ApiBaseService_1.ApiBaseService {
|
|
29
45
|
/**
|
|
30
46
|
* 执行普通CRUD
|
|
31
47
|
*/
|
|
32
|
-
async executeStdQuery(
|
|
33
|
-
const
|
|
48
|
+
async executeStdQuery(stdAction, params, sqlSimpleName) {
|
|
49
|
+
const appCode = stdAction.appCode;
|
|
50
|
+
const appInfo = await this.getParsedCrudStdAppForSettingKey(stdAction);
|
|
34
51
|
const stdCrudCfgObj = appInfo.stdCrudCfgObj;
|
|
35
52
|
if (!appInfo || appInfo.status !== 1) {
|
|
36
53
|
throw new devops_1.BizException('应用不存在或已下线:' + appCode);
|
|
@@ -39,9 +56,10 @@ let CrudStdService = class CrudStdService extends ApiBaseService_1.ApiBaseServic
|
|
|
39
56
|
const { dbType, dbName } = (0, DatabaseName_1.parseDatabaseName)(databaseName);
|
|
40
57
|
const cfgModel = {
|
|
41
58
|
sqlDatabase: dbName,
|
|
42
|
-
|
|
43
|
-
sqlTable:
|
|
59
|
+
sqlDbType: dbType,
|
|
60
|
+
sqlTable: getExecuteTableNameBySettingKey(appInfo, stdAction),
|
|
44
61
|
sqlSimpleName,
|
|
62
|
+
updateCfg: {}
|
|
45
63
|
};
|
|
46
64
|
// 接口返回最大值
|
|
47
65
|
const maxLimit = _.get(stdCrudCfgObj, 'othersSetting.values.maxLimit');
|
|
@@ -53,7 +71,18 @@ let CrudStdService = class CrudStdService extends ApiBaseService_1.ApiBaseServic
|
|
|
53
71
|
}
|
|
54
72
|
// 根据用户配置,设置关联查询的数据信息。
|
|
55
73
|
await this.crudStdRelationService.addCfgModelColumnsRelation(cfgModel, appInfo);
|
|
56
|
-
|
|
74
|
+
// 根据FilterValue参数,设置updateCfg
|
|
75
|
+
await this.fixCfgModelByFilterValue(params, cfgModel, appInfo, { dbType, dbName });
|
|
76
|
+
// 根据用户配置的keepSubmitData字段修改提交的数据
|
|
77
|
+
await this.fixSubmitDataByKeepSubmitData(params, cfgModel, appInfo, { dbType, dbName });
|
|
78
|
+
// 根据表结构的数据类型,修正数据类型
|
|
79
|
+
await this.fixDataFieldTypeBySqlTableField(params, cfgModel, appInfo, { dbType, dbName });
|
|
80
|
+
// 业务系统自定义的修改:查询前的查询条件:cfgModel
|
|
81
|
+
await global_config_1.GLOBAL_STATIC_CONFIG.getConfig().bizUpdateCfgModelForCrudStd(params, cfgModel, appInfo, this.ctx);
|
|
82
|
+
const crudExeCtx = await this.curdMixService.executeCrudByCfg(params, cfgModel);
|
|
83
|
+
// 业务系统自定义的修改:查询后的返回值。
|
|
84
|
+
await global_config_1.GLOBAL_STATIC_CONFIG.getConfig().bizUpdateExecuteContextForCrudStd(params, cfgModel, appInfo, this.ctx, crudExeCtx);
|
|
85
|
+
return crudExeCtx;
|
|
57
86
|
}
|
|
58
87
|
/**
|
|
59
88
|
* 获取appInfo 并且拿到当前settingKey相关的信息
|
|
@@ -61,7 +90,8 @@ let CrudStdService = class CrudStdService extends ApiBaseService_1.ApiBaseServic
|
|
|
61
90
|
* @param settingKey
|
|
62
91
|
* @private
|
|
63
92
|
*/
|
|
64
|
-
async getParsedCrudStdAppForSettingKey(
|
|
93
|
+
async getParsedCrudStdAppForSettingKey(stdAction) {
|
|
94
|
+
const { appCode, settingKey, buttonSettingKey } = stdAction || {};
|
|
65
95
|
if (!appCode) {
|
|
66
96
|
throw new devops_1.BizException('缺少参数:curdStdAppCode');
|
|
67
97
|
}
|
|
@@ -89,18 +119,20 @@ let CrudStdService = class CrudStdService extends ApiBaseService_1.ApiBaseServic
|
|
|
89
119
|
}
|
|
90
120
|
appInfo.settingKeyActionCfg = actionCfg;
|
|
91
121
|
}
|
|
122
|
+
if (buttonSettingKey) {
|
|
123
|
+
appInfo.buttonSettingKeyActionCfg = actionsMap[buttonSettingKey];
|
|
124
|
+
}
|
|
92
125
|
return appInfo;
|
|
93
126
|
}
|
|
94
127
|
/**
|
|
95
128
|
* 执行动作
|
|
96
|
-
* @param
|
|
97
|
-
* @param settingKey
|
|
129
|
+
* @param stdAction
|
|
98
130
|
* @param params
|
|
99
131
|
*/
|
|
100
|
-
async executeStdActionByReq(
|
|
101
|
-
const appInfo = await this.getParsedCrudStdAppForSettingKey(
|
|
132
|
+
async executeStdActionByReq(stdAction, params) {
|
|
133
|
+
const appInfo = await this.getParsedCrudStdAppForSettingKey(stdAction);
|
|
102
134
|
if (!appInfo || appInfo.status !== 1) {
|
|
103
|
-
throw new devops_1.BizException('应用不存在或已下线:' + appCode);
|
|
135
|
+
throw new devops_1.BizException('应用不存在或已下线:' + stdAction.appCode);
|
|
104
136
|
}
|
|
105
137
|
const actionsMap = appInfo.actionsMap;
|
|
106
138
|
const actionCfg = appInfo.settingKeyActionCfg;
|
|
@@ -112,21 +144,36 @@ let CrudStdService = class CrudStdService extends ApiBaseService_1.ApiBaseServic
|
|
|
112
144
|
* @private
|
|
113
145
|
*/
|
|
114
146
|
async getCrudStdAppInfo(appCode) {
|
|
147
|
+
const { SystemDbName, SystemDbType } = global_config_1.GLOBAL_STATIC_CONFIG.getConfig();
|
|
115
148
|
this.logInfo('getCrudStdAppInfo', appCode);
|
|
116
149
|
const ss = {
|
|
117
150
|
sqlTable: SystemTables_1.SystemTables.sys_app,
|
|
118
151
|
sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_QUERY_ONE,
|
|
119
|
-
sqlDatabase:
|
|
120
|
-
|
|
152
|
+
sqlDatabase: SystemDbName,
|
|
153
|
+
sqlDbType: SystemDbType,
|
|
121
154
|
};
|
|
122
155
|
return await this.curdMixService.executeCrudByCfg({ condition: { app_code: appCode } }, ss);
|
|
123
156
|
}
|
|
157
|
+
/**
|
|
158
|
+
* 查询APP信息
|
|
159
|
+
* @param appCode
|
|
160
|
+
* @private
|
|
161
|
+
*/
|
|
162
|
+
async getParsedCrudStdAppInfo(appCode) {
|
|
163
|
+
const cacheKey = "getParsedCrudStdAppInfo:" + appCode;
|
|
164
|
+
let appInfo = this.getFromCtxCache(cacheKey);
|
|
165
|
+
if (!appInfo) {
|
|
166
|
+
appInfo = await this.getParsedCrudStdAppInfoPrivate(appCode);
|
|
167
|
+
this.setToCtxCache(cacheKey, appInfo);
|
|
168
|
+
}
|
|
169
|
+
return appInfo;
|
|
170
|
+
}
|
|
124
171
|
/**
|
|
125
172
|
* 查询APP信息
|
|
126
173
|
* @param appCode
|
|
127
174
|
* @private
|
|
128
175
|
*/
|
|
129
|
-
async
|
|
176
|
+
async getParsedCrudStdAppInfoPrivate(appCode) {
|
|
130
177
|
const a = await this.getCrudStdAppInfo(appCode);
|
|
131
178
|
const { row } = a.getResModel();
|
|
132
179
|
if (!row) {
|
|
@@ -134,12 +181,7 @@ let CrudStdService = class CrudStdService extends ApiBaseService_1.ApiBaseServic
|
|
|
134
181
|
}
|
|
135
182
|
const { app_schema, ...others } = row;
|
|
136
183
|
const stdCrudCfgObj = (0, functions_1.parseJsonObject)(app_schema);
|
|
137
|
-
|
|
138
|
-
const actionsMap = {};
|
|
139
|
-
const keys = Object.keys(stdCrudCfgObj);
|
|
140
|
-
for (let i = 0; i < keys.length; i++) {
|
|
141
|
-
const key = keys[i];
|
|
142
|
-
const arrayCfg = stdCrudCfgObj[key];
|
|
184
|
+
const handleArrayCfg = (arrayCfg) => {
|
|
143
185
|
if (Array.isArray(arrayCfg)) {
|
|
144
186
|
for (let j = 0; j < arrayCfg.length; j++) {
|
|
145
187
|
const actionCfg = arrayCfg[j];
|
|
@@ -147,8 +189,18 @@ let CrudStdService = class CrudStdService extends ApiBaseService_1.ApiBaseServic
|
|
|
147
189
|
if (actionCfg.settingKey) {
|
|
148
190
|
actionsMap[actionCfg.settingKey] = actionCfg;
|
|
149
191
|
}
|
|
192
|
+
const submitButtonCfg = _.get(actionCfg, 'component.props.submitButtonCfg');
|
|
193
|
+
handleArrayCfg(submitButtonCfg);
|
|
150
194
|
}
|
|
151
195
|
}
|
|
196
|
+
};
|
|
197
|
+
// 为了方便查找到action对象
|
|
198
|
+
const actionsMap = {};
|
|
199
|
+
const keys = Object.keys(stdCrudCfgObj);
|
|
200
|
+
for (let i = 0; i < keys.length; i++) {
|
|
201
|
+
const key = keys[i];
|
|
202
|
+
const arrayCfg = stdCrudCfgObj[key];
|
|
203
|
+
handleArrayCfg(arrayCfg);
|
|
152
204
|
}
|
|
153
205
|
return { ...others, stdCrudCfgObj, actionsMap };
|
|
154
206
|
}
|
|
@@ -159,6 +211,70 @@ let CrudStdService = class CrudStdService extends ApiBaseService_1.ApiBaseServic
|
|
|
159
211
|
}
|
|
160
212
|
return true; // 无需鉴权
|
|
161
213
|
}
|
|
214
|
+
async fixCfgModelByFilterValue(params, cfgModel, appInfo, arg3) {
|
|
215
|
+
const { filterValue } = params || {};
|
|
216
|
+
if (!filterValue && filterValue !== 0) {
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
const filterList = _.get(appInfo, 'stdCrudCfgObj.filterList');
|
|
220
|
+
if (!Array.isArray(filterList) || filterList.length === 0) {
|
|
221
|
+
this.logWarn('filterValue存在,但是filterList没有设置');
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
const filterItem = filterList.find(item => item.value === filterValue);
|
|
225
|
+
if (!filterItem) {
|
|
226
|
+
this.logWarn('filterValue存在,但是filterList中没有找到此配置项');
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
const partialCondition = _.get(filterItem, 'partialCondition');
|
|
230
|
+
if (!partialCondition) {
|
|
231
|
+
this.logWarn('filterValue存在,但是filterList中的配置项没有设置partialCondition');
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
const partialConditionObj = (0, functions_1.parseJsonObject)(partialCondition);
|
|
235
|
+
if (Object.keys(partialConditionObj).length > 0) {
|
|
236
|
+
_.merge(cfgModel.updateCfg, { condition: partialConditionObj });
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
async fixSubmitDataByKeepSubmitData(params, cfgModel, appInfo, arg3) {
|
|
240
|
+
if (cfgModel.sqlSimpleName === keys_1.KeysOfSimpleSQL.SIMPLE_INSERT || cfgModel.sqlSimpleName === keys_1.KeysOfSimpleSQL.SIMPLE_UPDATE) {
|
|
241
|
+
const submitData = params.data || {};
|
|
242
|
+
//1. 按钮中配置的keepSubmitData
|
|
243
|
+
const buttonActionCfg = appInfo.buttonSettingKeyActionCfg || {};
|
|
244
|
+
const keepSubmitDataByButtonStr = _.get(buttonActionCfg, 'keepSubmitData');
|
|
245
|
+
const keepSubmitDataByButton = (0, functions_1.parseJsonObject)(keepSubmitDataByButtonStr);
|
|
246
|
+
//2. 全局配置的keepSubmitData
|
|
247
|
+
const keepSubmitDataByGlobalStr = _.get(appInfo, 'stdCrudCfgObj.othersSetting.values.keepSubmitData');
|
|
248
|
+
const keepSubmitDataByGlobal = (0, functions_1.parseJsonObject)(keepSubmitDataByGlobalStr);
|
|
249
|
+
//3. 合并
|
|
250
|
+
_.merge(submitData, keepSubmitDataByButton);
|
|
251
|
+
_.merge(submitData, keepSubmitDataByGlobal);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
async fixDataFieldTypeBySqlTableField(params, cfgModel, appInfo, arg3) {
|
|
255
|
+
const tableFields = _.get(appInfo, 'stdCrudCfgObj.tableFields');
|
|
256
|
+
const tableFieldMap = MixinUtils_1.MixinUtils.toMap(tableFields, (e) => {
|
|
257
|
+
return e.fieldIndex;
|
|
258
|
+
});
|
|
259
|
+
if (arg3.dbType === keys_1.SqlDbType.postgres) {
|
|
260
|
+
if (cfgModel.sqlSimpleName === keys_1.KeysOfSimpleSQL.SIMPLE_INSERT || cfgModel.sqlSimpleName === keys_1.KeysOfSimpleSQL.SIMPLE_UPDATE) {
|
|
261
|
+
const data = params.data || {};
|
|
262
|
+
const dataKeys = Object.keys(data);
|
|
263
|
+
for (let index = 0; index < dataKeys.length; index++) {
|
|
264
|
+
const dataKey = dataKeys[index];
|
|
265
|
+
const dataValue = data[dataKey];
|
|
266
|
+
const fieldInfo = tableFieldMap[dataKey];
|
|
267
|
+
const fieldType = ('' + _.get(fieldInfo, 'type')).toUpperCase();
|
|
268
|
+
if (fieldType === 'ARRAY') {
|
|
269
|
+
const dataValueArray = (0, functions_1.parseJsonObject)(dataValue);
|
|
270
|
+
if (Array.isArray(dataValueArray)) {
|
|
271
|
+
data[dataKey] = `{${dataValueArray.map(v => `"${v}"`).join(',')}}`;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
162
278
|
};
|
|
163
279
|
__decorate([
|
|
164
280
|
(0, core_1.Inject)(),
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { SqlDbType } from '../../libs/crud-pro/models/keys';
|
|
2
|
+
import { IRequestModel } from '../../libs/crud-pro/interfaces';
|
|
3
|
+
import { IRequestCfgModel2 } from '../../models/bizmodels';
|
|
4
|
+
import { CrudPro } from '../../libs/crud-pro/CrudPro';
|
|
5
|
+
import { ResModelAffected, ResModelStandard } from '../../libs/crud-pro/models/ResModel';
|
|
6
|
+
export declare class CrudProQuick {
|
|
7
|
+
private readonly curdPro;
|
|
8
|
+
private readonly sqlDbType;
|
|
9
|
+
private readonly sqlDatabase;
|
|
10
|
+
private readonly sqlTable?;
|
|
11
|
+
private baseCfgModel;
|
|
12
|
+
constructor(curdPro: CrudPro, sqlDatabase: string, sqlDbType: SqlDbType, sqlTable?: string);
|
|
13
|
+
setBaseCfgModel(baseCfgModel: IRequestCfgModel2): void;
|
|
14
|
+
private executeCrudByCfg;
|
|
15
|
+
/**
|
|
16
|
+
* 随便获取一个。不推荐使用。建议使用getUniqueOne。
|
|
17
|
+
* @deprecated
|
|
18
|
+
* @param reqJson
|
|
19
|
+
* @param sqlTable
|
|
20
|
+
* @returns
|
|
21
|
+
*/
|
|
22
|
+
getOne(reqJson: IRequestModel, sqlTable?: string): Promise<any>;
|
|
23
|
+
/**
|
|
24
|
+
* 期望获取唯一的一个对象,如果数据库中的数量不唯一,则报错。
|
|
25
|
+
* @param reqJson
|
|
26
|
+
* @param sqlTable
|
|
27
|
+
* @returns
|
|
28
|
+
*/
|
|
29
|
+
getUniqueOne(reqJson: IRequestModel, sqlTable?: string): Promise<any>;
|
|
30
|
+
/**
|
|
31
|
+
* 获取数据列表
|
|
32
|
+
* @param reqJson
|
|
33
|
+
* @param sqlTable 数据库表名称
|
|
34
|
+
* @returns
|
|
35
|
+
*/
|
|
36
|
+
getList(reqJson: IRequestModel, sqlTable?: string): Promise<any[]>;
|
|
37
|
+
getListPage(reqJson: IRequestModel, sqlTable?: string): Promise<ResModelStandard>;
|
|
38
|
+
getTotalCount(reqJson: IRequestModel, sqlTable?: string): Promise<number>;
|
|
39
|
+
insertObject(reqJson: IRequestModel, sqlTable?: string): Promise<ResModelAffected>;
|
|
40
|
+
updateObject(reqJson: IRequestModel, sqlTable?: string): Promise<ResModelAffected>;
|
|
41
|
+
insertOrUpdate(reqJson: IRequestModel, sqlTable?: string): Promise<ResModelStandard>;
|
|
42
|
+
deleteObject(reqJson: IRequestModel, sqlTable?: string): Promise<ResModelAffected>;
|
|
43
|
+
executeSQL(executeSql: string, args?: any[]): Promise<any>;
|
|
44
|
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CrudProQuick = void 0;
|
|
4
|
+
const keys_1 = require("../../libs/crud-pro/models/keys");
|
|
5
|
+
const DEFAULT_MAX_LIMIT = 10 * 10000;
|
|
6
|
+
class CrudProQuick {
|
|
7
|
+
constructor(curdPro, sqlDatabase, sqlDbType, sqlTable) {
|
|
8
|
+
this.baseCfgModel = {
|
|
9
|
+
maxLimit: DEFAULT_MAX_LIMIT,
|
|
10
|
+
};
|
|
11
|
+
this.sqlDatabase = sqlDatabase;
|
|
12
|
+
this.sqlDbType = sqlDbType;
|
|
13
|
+
this.curdPro = curdPro;
|
|
14
|
+
this.sqlTable = sqlTable; // 全局sqlTable为空时,单独调用时就必须传sqlTable参数。
|
|
15
|
+
}
|
|
16
|
+
setBaseCfgModel(baseCfgModel) {
|
|
17
|
+
Object.assign(this.baseCfgModel, baseCfgModel);
|
|
18
|
+
}
|
|
19
|
+
async executeCrudByCfg(reqJson, cfgModel2) {
|
|
20
|
+
const cfgModel = { ...this.baseCfgModel };
|
|
21
|
+
Object.assign(cfgModel, cfgModel2);
|
|
22
|
+
cfgModel.method = 'CrudProQuickAnonymous';
|
|
23
|
+
cfgModel.updateCfg = {};
|
|
24
|
+
cfgModel.sqlDatabase = this.sqlDatabase;
|
|
25
|
+
cfgModel.sqlDbType = this.sqlDbType;
|
|
26
|
+
if (!cfgModel.sqlTable) {
|
|
27
|
+
cfgModel.sqlTable = this.sqlTable;
|
|
28
|
+
}
|
|
29
|
+
if (!cfgModel.sqlTable) {
|
|
30
|
+
throw new Error('[CrudProQuick] sqlTable not found');
|
|
31
|
+
}
|
|
32
|
+
return await this.curdPro.executeCrudByCfg(reqJson, cfgModel);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* 随便获取一个。不推荐使用。建议使用getUniqueOne。
|
|
36
|
+
* @deprecated
|
|
37
|
+
* @param reqJson
|
|
38
|
+
* @param sqlTable
|
|
39
|
+
* @returns
|
|
40
|
+
*/
|
|
41
|
+
async getOne(reqJson, sqlTable) {
|
|
42
|
+
const cfgModel = {
|
|
43
|
+
sqlTable,
|
|
44
|
+
sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_QUERY_ONE,
|
|
45
|
+
};
|
|
46
|
+
const res = await this.executeCrudByCfg(reqJson, cfgModel);
|
|
47
|
+
return res.getOneObj();
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* 期望获取唯一的一个对象,如果数据库中的数量不唯一,则报错。
|
|
51
|
+
* @param reqJson
|
|
52
|
+
* @param sqlTable
|
|
53
|
+
* @returns
|
|
54
|
+
*/
|
|
55
|
+
async getUniqueOne(reqJson, sqlTable) {
|
|
56
|
+
const cfgModel = {
|
|
57
|
+
sqlTable,
|
|
58
|
+
sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_QUERY_PAGE,
|
|
59
|
+
};
|
|
60
|
+
reqJson.pageNo = 1;
|
|
61
|
+
reqJson.pageSize = 1;
|
|
62
|
+
const res = await this.executeCrudByCfg(reqJson, cfgModel);
|
|
63
|
+
const resModel = res.getResModel();
|
|
64
|
+
const total_count = resModel.total_count;
|
|
65
|
+
const rows = resModel.rows;
|
|
66
|
+
if (total_count === 0) {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
if (total_count > 1) {
|
|
70
|
+
throw new Error(`[CrudProQuick][getUniqueOne] only one object is required, but got ${total_count}`);
|
|
71
|
+
}
|
|
72
|
+
return rows[0];
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* 获取数据列表
|
|
76
|
+
* @param reqJson
|
|
77
|
+
* @param sqlTable 数据库表名称
|
|
78
|
+
* @returns
|
|
79
|
+
*/
|
|
80
|
+
async getList(reqJson, sqlTable) {
|
|
81
|
+
const cfgModel = {
|
|
82
|
+
sqlTable,
|
|
83
|
+
sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_QUERY,
|
|
84
|
+
};
|
|
85
|
+
const res = await this.executeCrudByCfg(reqJson, cfgModel);
|
|
86
|
+
return res.getResRows();
|
|
87
|
+
}
|
|
88
|
+
async getListPage(reqJson, sqlTable) {
|
|
89
|
+
const cfgModel = {
|
|
90
|
+
sqlTable,
|
|
91
|
+
sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_QUERY_PAGE,
|
|
92
|
+
};
|
|
93
|
+
const res = await this.executeCrudByCfg(reqJson, cfgModel);
|
|
94
|
+
return res.getResModel(); // 因为它有2个返回值
|
|
95
|
+
}
|
|
96
|
+
async getTotalCount(reqJson, sqlTable) {
|
|
97
|
+
const cfgModel = {
|
|
98
|
+
sqlTable,
|
|
99
|
+
sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_QUERY_COUNT,
|
|
100
|
+
};
|
|
101
|
+
const res = await this.executeCrudByCfg(reqJson, cfgModel);
|
|
102
|
+
return res.getResModel().total_count;
|
|
103
|
+
}
|
|
104
|
+
async insertObject(reqJson, sqlTable) {
|
|
105
|
+
const cfgModel = {
|
|
106
|
+
sqlTable,
|
|
107
|
+
sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_INSERT,
|
|
108
|
+
};
|
|
109
|
+
const res = await this.executeCrudByCfg(reqJson, cfgModel);
|
|
110
|
+
return res.getResModel().affected;
|
|
111
|
+
}
|
|
112
|
+
async updateObject(reqJson, sqlTable) {
|
|
113
|
+
const cfgModel = {
|
|
114
|
+
sqlTable,
|
|
115
|
+
sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_UPDATE,
|
|
116
|
+
};
|
|
117
|
+
const res = await this.executeCrudByCfg(reqJson, cfgModel);
|
|
118
|
+
return res.getResModel().affected;
|
|
119
|
+
}
|
|
120
|
+
async insertOrUpdate(reqJson, sqlTable) {
|
|
121
|
+
const cfgModel = {
|
|
122
|
+
sqlTable,
|
|
123
|
+
sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_INSERT_OR_UPDATE,
|
|
124
|
+
};
|
|
125
|
+
const res = await this.executeCrudByCfg(reqJson, cfgModel);
|
|
126
|
+
return res.getResModel(); // 因为它有三个返回值
|
|
127
|
+
}
|
|
128
|
+
async deleteObject(reqJson, sqlTable) {
|
|
129
|
+
const cfgModel = {
|
|
130
|
+
sqlTable,
|
|
131
|
+
sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_DELETE,
|
|
132
|
+
};
|
|
133
|
+
const res = await this.executeCrudByCfg(reqJson, cfgModel);
|
|
134
|
+
return res.getResModel().affected;
|
|
135
|
+
}
|
|
136
|
+
async executeSQL(executeSql, args) {
|
|
137
|
+
const sqlCfgModel = {
|
|
138
|
+
executeSql: executeSql,
|
|
139
|
+
executeSqlArgs: args,
|
|
140
|
+
sqlDatabase: this.sqlDatabase,
|
|
141
|
+
sqlDbType: this.sqlDbType,
|
|
142
|
+
maxLimit: this.baseCfgModel.maxLimit || DEFAULT_MAX_LIMIT,
|
|
143
|
+
};
|
|
144
|
+
return await this.curdPro.executeSQL(sqlCfgModel);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
exports.CrudProQuick = CrudProQuick;
|
|
@@ -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 CurdMixByAccountService implements IExecuteContextHandler {
|
|
5
|
-
ctx: Context;
|
|
5
|
+
protected 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
|
}
|
|
@@ -17,10 +17,12 @@ const CurdMixUtils_1 = require("./CurdMixUtils");
|
|
|
17
17
|
const SystemTables_1 = require("../../models/SystemTables");
|
|
18
18
|
const keys_1 = require("../../libs/crud-pro/models/keys");
|
|
19
19
|
const MixinUtils_1 = require("../../libs/crud-pro/utils/MixinUtils");
|
|
20
|
+
const global_config_1 = require("../../libs/global-config/global-config");
|
|
20
21
|
const dictMixUtils = new CurdMixUtils_1.CrudMixUtils(CurdMixUtils_1.RelatedType.accountBasic);
|
|
21
22
|
const TMP_CTX_KEY = _.uniqueId('CurdMixByAccountService');
|
|
22
23
|
let CurdMixByAccountService = class CurdMixByAccountService {
|
|
23
24
|
async handleExecuteContextPrepare(executeContext) {
|
|
25
|
+
const { SystemDbName, SystemDbType, toFatcmsUserAccountId } = global_config_1.GLOBAL_STATIC_CONFIG.getConfig();
|
|
24
26
|
const relations = dictMixUtils.pickColumnRelations(executeContext);
|
|
25
27
|
if (!relations || relations.length === 0) {
|
|
26
28
|
return;
|
|
@@ -28,9 +30,12 @@ let CurdMixByAccountService = class CurdMixByAccountService {
|
|
|
28
30
|
const accountIds = new Set();
|
|
29
31
|
dictMixUtils.forEachRowAndColumnsRelation(executeContext, (row, columnRelation) => {
|
|
30
32
|
const { sourceColumn } = columnRelation;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
if (sourceColumn) {
|
|
34
|
+
const accountId = _.get(row, sourceColumn);
|
|
35
|
+
if (accountId) {
|
|
36
|
+
const fatcmsUserAccountId = toFatcmsUserAccountId(accountId);
|
|
37
|
+
accountIds.add(fatcmsUserAccountId);
|
|
38
|
+
}
|
|
34
39
|
}
|
|
35
40
|
});
|
|
36
41
|
if (accountIds.size === 0) {
|
|
@@ -40,8 +45,8 @@ let CurdMixByAccountService = class CurdMixByAccountService {
|
|
|
40
45
|
method: 'UserAccountService.queryAccountBasicInfoByIds',
|
|
41
46
|
sqlTable: SystemTables_1.SystemTables.sys_user_account,
|
|
42
47
|
sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_QUERY,
|
|
43
|
-
sqlDatabase:
|
|
44
|
-
|
|
48
|
+
sqlDatabase: SystemDbName,
|
|
49
|
+
sqlDbType: SystemDbType,
|
|
45
50
|
};
|
|
46
51
|
const reqJson = {
|
|
47
52
|
columns: ['nick_name', 'avatar', 'account_id'],
|
|
@@ -69,7 +74,7 @@ let CurdMixByAccountService = class CurdMixByAccountService {
|
|
|
69
74
|
{ from: 'avatar', to: `${sourceColumn}_user.avatar` },
|
|
70
75
|
];
|
|
71
76
|
}
|
|
72
|
-
dictMixUtils.
|
|
77
|
+
dictMixUtils.copyUserInfoToRowNoRelatedCode(row, userInfoMap, columnRelation);
|
|
73
78
|
});
|
|
74
79
|
}
|
|
75
80
|
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Context } from '@midwayjs/koa';
|
|
2
|
-
import {
|
|
3
|
-
import { RedisCacheService } from
|
|
2
|
+
import { HandleExecuteContextType, IExecuteContextHandler } from '../../libs/crud-pro/models/ExecuteContext';
|
|
3
|
+
import { RedisCacheService } from '../base/RedisCacheService';
|
|
4
4
|
export declare class CurdMixByDictService implements IExecuteContextHandler {
|
|
5
5
|
ctx: Context;
|
|
6
6
|
private curdProService;
|
|
7
7
|
protected redisCacheService: RedisCacheService;
|
|
8
8
|
private getFromCache;
|
|
9
9
|
private setToCache;
|
|
10
|
-
handleExecuteContextPrepare(executeContext:
|
|
10
|
+
handleExecuteContextPrepare(executeContext: HandleExecuteContextType): Promise<void>;
|
|
11
11
|
private getDictItemRows;
|
|
12
|
-
handleExecuteContext(executeContext:
|
|
12
|
+
handleExecuteContext(executeContext: HandleExecuteContextType): Promise<void>;
|
|
13
13
|
}
|
|
@@ -10,23 +10,25 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.CurdMixByDictService = void 0;
|
|
13
|
+
const _ = require("lodash");
|
|
13
14
|
const core_1 = require("@midwayjs/core");
|
|
14
15
|
const CurdProService_1 = require("./CurdProService");
|
|
15
16
|
const CurdMixUtils_1 = require("./CurdMixUtils");
|
|
16
17
|
const SystemTables_1 = require("../../models/SystemTables");
|
|
17
18
|
const keys_1 = require("../../libs/crud-pro/models/keys");
|
|
18
19
|
const MultiKeyMap_1 = require("../../libs/crud-pro/utils/MultiKeyMap");
|
|
19
|
-
const _ = require("lodash");
|
|
20
20
|
const RedisCacheService_1 = require("../base/RedisCacheService");
|
|
21
|
+
const global_config_1 = require("../../libs/global-config/global-config");
|
|
22
|
+
const RedisKeys_1 = require("../../models/RedisKeys");
|
|
21
23
|
const TMP_CTX_KEY = _.uniqueId('CurdMixByDictService');
|
|
22
24
|
const dictMixUtils = new CurdMixUtils_1.CrudMixUtils(CurdMixUtils_1.RelatedType.dict);
|
|
23
25
|
let CurdMixByDictService = class CurdMixByDictService {
|
|
24
26
|
async getFromCache(code) {
|
|
25
|
-
const cacheKey =
|
|
27
|
+
const cacheKey = `${RedisKeys_1.RedisKeys.CURD_MIX_BY_DICT_PREFIX}${code}`;
|
|
26
28
|
return this.redisCacheService.getJsonObject(cacheKey);
|
|
27
29
|
}
|
|
28
30
|
async setToCache(code, value) {
|
|
29
|
-
const cacheKey =
|
|
31
|
+
const cacheKey = `${RedisKeys_1.RedisKeys.CURD_MIX_BY_DICT_PREFIX}${code}`;
|
|
30
32
|
return this.redisCacheService.setJsonObject(cacheKey, value, 60 * 60);
|
|
31
33
|
}
|
|
32
34
|
async handleExecuteContextPrepare(executeContext) {
|
|
@@ -38,6 +40,7 @@ let CurdMixByDictService = class CurdMixByDictService {
|
|
|
38
40
|
executeContext[TMP_CTX_KEY] = new MultiKeyMap_1.MultiKeyMap(rows, 'dict_code', 'value');
|
|
39
41
|
}
|
|
40
42
|
async getDictItemRows(codes) {
|
|
43
|
+
const { SystemDbName, SystemDbType } = global_config_1.GLOBAL_STATIC_CONFIG.getConfig();
|
|
41
44
|
const noCacheCodes = [];
|
|
42
45
|
// 从缓存里面取
|
|
43
46
|
let cachedRows = [];
|
|
@@ -60,8 +63,8 @@ let CurdMixByDictService = class CurdMixByDictService {
|
|
|
60
63
|
}, {
|
|
61
64
|
sqlTable: SystemTables_1.SystemTables.sys_data_dict_item,
|
|
62
65
|
sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_QUERY,
|
|
63
|
-
sqlDatabase:
|
|
64
|
-
|
|
66
|
+
sqlDatabase: SystemDbName,
|
|
67
|
+
sqlDbType: SystemDbType,
|
|
65
68
|
});
|
|
66
69
|
selectedRows = res1.getResRows();
|
|
67
70
|
//放到缓存里
|
|
@@ -84,8 +87,8 @@ let CurdMixByDictService = class CurdMixByDictService {
|
|
|
84
87
|
if (!Array.isArray(targetColumns) || targetColumns.length === 0) {
|
|
85
88
|
columnRelation.targetColumns = [
|
|
86
89
|
{
|
|
87
|
-
|
|
88
|
-
|
|
90
|
+
from: '*',
|
|
91
|
+
to: `${sourceColumn}_info[$ARRAY_INDEX]`,
|
|
89
92
|
},
|
|
90
93
|
];
|
|
91
94
|
}
|
|
@@ -1,22 +1,31 @@
|
|
|
1
1
|
import { Context } from '@midwayjs/koa';
|
|
2
2
|
import { CurdProService } from './CurdProService';
|
|
3
|
-
import {
|
|
4
|
-
import { RedisCacheService } from
|
|
3
|
+
import { HandleExecuteContextType, IExecuteContextHandler } from '../../libs/crud-pro/models/ExecuteContext';
|
|
4
|
+
import { RedisCacheService } from '../base/RedisCacheService';
|
|
5
5
|
export declare class CurdMixByLinkToCustomService implements IExecuteContextHandler {
|
|
6
6
|
protected ctx: Context;
|
|
7
7
|
protected curdProService: CurdProService;
|
|
8
8
|
protected redisCacheService: RedisCacheService;
|
|
9
|
-
handleExecuteContextPrepare(executeContext:
|
|
10
|
-
handleExecuteContext(executeContext:
|
|
9
|
+
handleExecuteContextPrepare(executeContext: HandleExecuteContextType): Promise<void>;
|
|
10
|
+
handleExecuteContext(executeContext: HandleExecuteContextType): Promise<void>;
|
|
11
11
|
queryInfoByLinkToCustom(code: string): Promise<Map<string, any>>;
|
|
12
12
|
/**
|
|
13
13
|
* code形如:mysql_________fatcms~~~sys_perm_role~~~role_code,role_name,xxx_name
|
|
14
14
|
* code形如:fatcms~~~sys_perm_role~~~role_code,role_name,xxx_name
|
|
15
15
|
* code形如:fatcms~~~sys_perm_role~~~id,*
|
|
16
|
+
* code形如:GET_BY_CRUD_METHOD~~~GetActiveLineEnum~~~id,*
|
|
17
|
+
* code形如:GET_BY_CRUD_METHOD~~~GetActiveLineEnum~~~id,name
|
|
16
18
|
* 【数据库】~~~【表名】~~~【value】,【label】,【style】
|
|
17
19
|
* @param code
|
|
18
20
|
* @private
|
|
19
21
|
*/
|
|
20
22
|
private queryInfoByLinkToCustomImpl;
|
|
23
|
+
/**
|
|
24
|
+
*
|
|
25
|
+
* @param code
|
|
26
|
+
* code形如:GET_BY_CRUD_METHOD~~~GetActiveLineEnum~~~id,*
|
|
27
|
+
* code形如:GET_BY_CRUD_METHOD~~~GetActiveLineEnum~~~id,name
|
|
28
|
+
*/
|
|
29
|
+
private queryInfoByLinkToCustomByCrudMethod;
|
|
21
30
|
private loadInfoByLinkToCustomMap;
|
|
22
31
|
}
|