midway-fatcms 0.0.1-beta.3 → 0.0.1-beta.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +14 -0
- package/.prettierrc.js +4 -0
- package/README.md +7 -0
- package/dist/config/config.default.js +60 -19
- package/dist/config/seed/aeskey.txt +1 -1
- package/dist/configuration.d.ts +1 -0
- package/dist/configuration.js +33 -9
- package/dist/controller/base/BaseApiController.d.ts +7 -1
- package/dist/controller/base/BaseApiController.js +32 -6
- package/dist/controller/gateway/AsyncTaskController.d.ts +20 -0
- package/dist/controller/gateway/AsyncTaskController.js +181 -0
- package/dist/controller/gateway/CrudMtdGatewayController.d.ts +3 -3
- package/dist/controller/gateway/CrudMtdGatewayController.js +9 -6
- package/dist/controller/gateway/DocGatewayController.js +14 -9
- package/dist/controller/gateway/FileController.d.ts +3 -2
- package/dist/controller/gateway/PublicApiController.js +4 -6
- package/dist/controller/gateway/StaticController.d.ts +3 -0
- package/dist/controller/gateway/StaticController.js +74 -51
- package/dist/controller/helpers.controller.d.ts +1 -1
- package/dist/controller/home.controller.js +4 -3
- package/dist/controller/manage/AnyApiMangeApi.js +2 -2
- package/dist/controller/manage/AppLogMangeApi.js +2 -2
- package/dist/controller/manage/AppMangeApi.js +2 -2
- package/dist/controller/manage/AppPageMangeApi.js +2 -2
- package/dist/controller/manage/AppSchemaHistoryApi.js +2 -2
- package/dist/controller/manage/CrudMethodsMangeApi.js +2 -2
- package/dist/controller/manage/CrudStandardDesignApi.d.ts +1 -1
- package/dist/controller/manage/CrudStandardDesignApi.js +86 -83
- package/dist/controller/manage/DataDictManageApi.d.ts +1 -1
- package/dist/controller/manage/DataDictManageApi.js +1 -1
- package/dist/controller/manage/DeployManageApi.d.ts +1 -1
- package/dist/controller/manage/DeployManageApi.js +38 -34
- package/dist/controller/manage/DocLibManageApi.js +2 -2
- package/dist/controller/manage/DocManageApi.js +2 -2
- package/dist/controller/manage/FileManageApi.js +1 -1
- package/dist/controller/manage/LowCodeTplManageApi.js +2 -2
- package/dist/controller/manage/MenuManageApi.js +2 -2
- package/dist/controller/manage/ProxyApiMangeApi.js +2 -2
- package/dist/controller/manage/SuperAdminManageApi.d.ts +2 -2
- package/dist/controller/manage/SuperAdminManageApi.js +12 -8
- package/dist/controller/manage/SysConfigMangeApi.d.ts +1 -1
- package/dist/controller/manage/SysConfigMangeApi.js +8 -6
- package/dist/controller/manage/SystemInfoManageApi.d.ts +1 -1
- package/dist/controller/manage/SystemInfoManageApi.js +7 -1
- package/dist/controller/manage/UserAccountManageApi.d.ts +2 -2
- package/dist/controller/manage/UserAccountManageApi.js +7 -2
- package/dist/controller/manage/WorkbenchMangeApi.js +3 -3
- package/dist/controller/myinfo/AuthController.d.ts +0 -4
- package/dist/controller/myinfo/AuthController.js +1 -54
- package/dist/controller/render/AppRenderController.js +12 -5
- package/dist/controller/test.controller.d.ts +1 -1
- package/dist/controller/test.controller.js +5 -5
- package/dist/index.d.ts +35 -4
- package/dist/index.js +35 -4
- package/dist/libs/crud-pro/CrudPro.d.ts +1 -0
- package/dist/libs/crud-pro/CrudPro.js +5 -0
- package/dist/libs/crud-pro/defaultConfigs.js +2 -0
- package/dist/libs/crud-pro/interfaces.d.ts +7 -1
- package/dist/libs/crud-pro/models/ExecuteContext.d.ts +12 -5
- package/dist/libs/crud-pro/models/ExecuteContextFunc.d.ts +8 -1
- package/dist/libs/crud-pro/models/ExecuteContextFunc.js +8 -0
- package/dist/libs/crud-pro/models/RequestCfgModel.d.ts +1 -1
- package/dist/libs/crud-pro/models/ResModel.d.ts +16 -0
- package/dist/libs/crud-pro/models/ResModel.js +2 -0
- package/dist/libs/crud-pro/models/SqlCfgModel.d.ts +1 -1
- package/dist/libs/crud-pro/models/TransactionSqlServer.js +1 -1
- package/dist/libs/crud-pro/services/CrudProCachedCfgService.d.ts +1 -0
- package/dist/libs/crud-pro/services/CrudProCachedCfgService.js +27 -15
- package/dist/libs/crud-pro/services/CrudProExecuteSqlService.js +17 -19
- package/dist/libs/crud-pro/services/CrudProGenSqlCondition.d.ts +1 -1
- package/dist/libs/crud-pro/services/CrudProGenSqlCondition.js +10 -12
- package/dist/libs/crud-pro/services/CrudProGenSqlService.js +14 -23
- package/dist/libs/crud-pro/services/CrudProOriginToExecuteSql.js +7 -6
- package/dist/libs/crud-pro/services/CrudProServiceBase.d.ts +2 -6
- package/dist/libs/crud-pro/services/CrudProServiceBase.js +14 -2
- package/dist/libs/crud-pro/services/CrudProTableMetaService.d.ts +1 -0
- package/dist/libs/crud-pro/services/CrudProTableMetaService.js +32 -7
- package/dist/libs/crud-pro/sql.txt +120 -120
- package/dist/libs/crud-pro/utils/DatabaseName.js +24 -3
- package/dist/libs/crud-pro/utils/MixinUtils.js +1 -1
- package/dist/libs/crud-pro/utils/ValidateUtils.js +1 -1
- package/dist/libs/crud-pro/utils/sqlConvert/convertColumnName.js +2 -2
- package/dist/libs/crud-pro/utils/sqlConvert/convertMix.d.ts +3 -0
- package/dist/libs/crud-pro/utils/sqlConvert/convertMix.js +22 -0
- package/dist/libs/global-config/global-config.d.ts +45 -0
- package/dist/libs/global-config/global-config.js +33 -0
- package/dist/libs/utils/errorToString.d.ts +2 -0
- package/dist/libs/utils/errorToString.js +57 -0
- package/dist/libs/utils/fatcms-request.js +2 -2
- package/dist/libs/utils/functions.d.ts +2 -1
- package/dist/libs/utils/functions.js +6 -1
- package/dist/middleware/forbidden.middleware.js +4 -20
- package/dist/middleware/global.middleware.js +30 -10
- package/dist/middleware/permission.middleware.js +1 -1
- package/dist/models/AsyncTaskModel.d.ts +74 -0
- package/dist/models/AsyncTaskModel.js +31 -0
- package/dist/models/RedisKeys.d.ts +14 -0
- package/dist/models/RedisKeys.js +17 -0
- package/dist/models/SystemTables.d.ts +1 -3
- package/dist/models/SystemTables.js +2 -4
- package/dist/models/bizmodels.d.ts +28 -0
- package/dist/models/bizmodels.js +6 -1
- package/dist/schedule/anonymousContext.d.ts +14 -0
- package/dist/schedule/anonymousContext.js +59 -0
- package/dist/schedule/index.d.ts +4 -3
- package/dist/schedule/index.js +8 -67
- package/dist/schedule/runSchedule.d.ts +12 -0
- package/dist/schedule/runSchedule.js +68 -0
- package/dist/schedule/scheduleNames.d.ts +13 -0
- package/dist/schedule/scheduleNames.js +17 -0
- package/dist/service/AuthService.js +8 -5
- package/dist/service/EnumInfoService.js +9 -5
- package/dist/service/FileCenterService.js +13 -9
- package/dist/service/SysConfigService.d.ts +1 -1
- package/dist/service/SysConfigService.js +4 -2
- package/dist/service/UserAccountService.js +10 -6
- package/dist/service/UserSessionService.d.ts +21 -0
- package/dist/service/UserSessionService.js +73 -2
- package/dist/service/VisitStatService.d.ts +1 -1
- package/dist/service/VisitStatService.js +20 -27
- package/dist/service/WorkbenchService.d.ts +32 -0
- package/dist/service/WorkbenchService.js +61 -12
- package/dist/service/anyapi/AnyApiSandboxService.js +12 -12
- package/dist/service/anyapi/AnyApiService.js +4 -2
- package/dist/service/asyncTask/AsyncTaskRunnerService.d.ts +50 -0
- package/dist/service/asyncTask/AsyncTaskRunnerService.js +287 -0
- package/dist/service/asyncTask/AsyncTaskService.d.ts +7 -0
- package/dist/service/asyncTask/AsyncTaskService.js +34 -0
- package/dist/service/asyncTask/handler/ExcelInfoModel.d.ts +10 -0
- package/dist/service/asyncTask/handler/ExcelInfoModel.js +2 -0
- package/dist/service/asyncTask/handler/ExportExcelAsyncTaskHandler.d.ts +7 -0
- package/dist/service/asyncTask/handler/ExportExcelAsyncTaskHandler.js +216 -0
- package/dist/service/asyncTask/handler/ExportExcelByInnerHttpHandler.d.ts +36 -0
- package/dist/service/asyncTask/handler/ExportExcelByInnerHttpHandler.js +139 -0
- package/dist/service/asyncTask/handler/ExportExcelByStdCrudHandler.d.ts +46 -0
- package/dist/service/asyncTask/handler/ExportExcelByStdCrudHandler.js +121 -0
- package/dist/service/base/BaseService.d.ts +12 -0
- package/dist/service/base/BaseService.js +22 -0
- package/dist/service/base/RedisCacheService.d.ts +7 -0
- package/dist/service/base/RedisCacheService.js +7 -0
- package/dist/service/crudstd/CrudStdService.d.ts +8 -1
- package/dist/service/crudstd/CrudStdService.js +63 -6
- package/dist/service/curd/CrudProQuick.d.ts +44 -0
- package/dist/service/curd/CrudProQuick.js +147 -0
- package/dist/service/curd/CurdMixByAccountService.d.ts +4 -4
- package/dist/service/curd/CurdMixByAccountService.js +12 -6
- package/dist/service/curd/CurdMixByDictService.d.ts +4 -4
- package/dist/service/curd/CurdMixByDictService.js +10 -7
- package/dist/service/curd/CurdMixByLinkToCustomService.d.ts +13 -4
- package/dist/service/curd/CurdMixByLinkToCustomService.js +73 -24
- package/dist/service/curd/CurdMixBySysConfigService.d.ts +3 -3
- package/dist/service/curd/CurdMixBySysConfigService.js +4 -2
- package/dist/service/curd/CurdMixByWorkbenchService.d.ts +3 -3
- package/dist/service/curd/CurdMixByWorkbenchService.js +4 -2
- package/dist/service/curd/CurdMixService.d.ts +13 -3
- package/dist/service/curd/CurdMixService.js +26 -2
- package/dist/service/curd/CurdMixUtils.d.ts +27 -4
- package/dist/service/curd/CurdMixUtils.js +115 -41
- package/dist/service/curd/CurdProService.d.ts +3 -10
- package/dist/service/curd/CurdProService.js +36 -148
- package/dist/service/curd/fixCfgModel.d.ts +3 -0
- package/dist/service/curd/fixCfgModel.js +107 -0
- package/dist/service/proxyapi/ProxyApiLoadService.js +7 -4
- package/dist/views/404_app.html +31 -31
- package/dist/views/404_workbench.html +34 -34
- package/package.json +25 -24
- package/tsconfig.json +32 -0
- package/dist/controller/medstatistic/MedAdminController.d.ts +0 -35
- package/dist/controller/medstatistic/MedAdminController.js +0 -205
- package/dist/controller/medstatistic/MedClientController.d.ts +0 -28
- package/dist/controller/medstatistic/MedClientController.js +0 -188
- package/dist/controller/medstatistic/MedMessageService.d.ts +0 -19
- package/dist/controller/medstatistic/MedMessageService.js +0 -95
- package/dist/controller/medstatistic/MedScoreService.d.ts +0 -21
- package/dist/controller/medstatistic/MedScoreService.js +0 -107
- package/dist/controller/medstatistic/constants.d.ts +0 -32
- package/dist/controller/medstatistic/constants.js +0 -43
- package/src/config/config.default.ts +0 -172
- package/src/config/seed/aeskey.txt +0 -1
- package/src/config/utils.ts +0 -23
- package/src/configuration.ts +0 -83
- package/src/controller/base/BaseApiController.ts +0 -145
- package/src/controller/gateway/AnyApiGatewayController.ts +0 -33
- package/src/controller/gateway/CrudMtdGatewayController.ts +0 -107
- package/src/controller/gateway/CrudStdGatewayController.ts +0 -101
- package/src/controller/gateway/DocGatewayController.ts +0 -165
- package/src/controller/gateway/FileController.ts +0 -110
- package/src/controller/gateway/ProxyApiGatewayController.ts +0 -47
- package/src/controller/gateway/PublicApiController.ts +0 -145
- package/src/controller/gateway/StaticController.ts +0 -303
- package/src/controller/helpers.controller.ts +0 -161
- package/src/controller/home.controller.ts +0 -71
- package/src/controller/manage/AnyApiMangeApi.ts +0 -66
- package/src/controller/manage/AppLogMangeApi.ts +0 -53
- package/src/controller/manage/AppMangeApi.ts +0 -53
- package/src/controller/manage/AppPageMangeApi.ts +0 -52
- package/src/controller/manage/AppSchemaHistoryApi.ts +0 -49
- package/src/controller/manage/CrudMethodsMangeApi.ts +0 -49
- package/src/controller/manage/CrudStandardDesignApi.ts +0 -353
- package/src/controller/manage/DataDictManageApi.ts +0 -78
- package/src/controller/manage/DeployManageApi.ts +0 -179
- package/src/controller/manage/DocLibManageApi.ts +0 -69
- package/src/controller/manage/DocManageApi.ts +0 -99
- package/src/controller/manage/FileManageApi.ts +0 -45
- package/src/controller/manage/LowCodeTplManageApi.ts +0 -52
- package/src/controller/manage/MenuManageApi.ts +0 -63
- package/src/controller/manage/ProxyApiMangeApi.ts +0 -52
- package/src/controller/manage/SuperAdminManageApi.ts +0 -138
- package/src/controller/manage/SysConfigMangeApi.ts +0 -95
- package/src/controller/manage/SystemInfoManageApi.ts +0 -48
- package/src/controller/manage/UserAccountManageApi.ts +0 -88
- package/src/controller/manage/WorkbenchMangeApi.ts +0 -72
- package/src/controller/medstatistic/MedAdminController.ts +0 -221
- package/src/controller/medstatistic/MedClientController.ts +0 -188
- package/src/controller/medstatistic/MedMessageService.ts +0 -89
- package/src/controller/medstatistic/MedScoreService.ts +0 -108
- package/src/controller/medstatistic/constants.ts +0 -63
- package/src/controller/myinfo/AuthController.ts +0 -174
- package/src/controller/myinfo/MyInfoController.ts +0 -32
- package/src/controller/render/AppRenderController.ts +0 -76
- package/src/controller/test.controller.ts +0 -37
- package/src/filter/default.filter.ts +0 -13
- package/src/filter/notfound.filter.ts +0 -10
- package/src/index.ts +0 -71
- package/src/interface.ts +0 -31
- package/src/libs/crud-pro/CrudPro.ts +0 -158
- package/src/libs/crud-pro/defaultConfigs.ts +0 -13
- package/src/libs/crud-pro/exceptions.ts +0 -124
- package/src/libs/crud-pro/interfaces.ts +0 -183
- package/src/libs/crud-pro/models/ExecuteContext.ts +0 -111
- package/src/libs/crud-pro/models/ExecuteContextFunc.ts +0 -86
- package/src/libs/crud-pro/models/FuncContext.ts +0 -21
- package/src/libs/crud-pro/models/RequestCfgModel.ts +0 -141
- package/src/libs/crud-pro/models/RequestModel.ts +0 -141
- package/src/libs/crud-pro/models/ServiceHub.ts +0 -32
- package/src/libs/crud-pro/models/SqlCfgModel.ts +0 -52
- package/src/libs/crud-pro/models/SqlSegArg.ts +0 -13
- package/src/libs/crud-pro/models/Transaction.ts +0 -74
- package/src/libs/crud-pro/models/TransactionMySQL.ts +0 -79
- package/src/libs/crud-pro/models/TransactionPostgres.ts +0 -91
- package/src/libs/crud-pro/models/TransactionSqlServer.ts +0 -107
- package/src/libs/crud-pro/models/keys.ts +0 -159
- package/src/libs/crud-pro/services/CrudProCachedCfgService.ts +0 -75
- package/src/libs/crud-pro/services/CrudProExecuteFuncService.ts +0 -128
- package/src/libs/crud-pro/services/CrudProExecuteSqlService.ts +0 -279
- package/src/libs/crud-pro/services/CrudProFieldUpdateService.ts +0 -60
- package/src/libs/crud-pro/services/CrudProFieldValidateService.ts +0 -180
- package/src/libs/crud-pro/services/CrudProGenSqlCondition.ts +0 -373
- package/src/libs/crud-pro/services/CrudProGenSqlService.ts +0 -202
- package/src/libs/crud-pro/services/CrudProOriginToExecuteSql.ts +0 -397
- package/src/libs/crud-pro/services/CrudProServiceBase.ts +0 -98
- package/src/libs/crud-pro/services/CrudProTableMetaService.ts +0 -59
- package/src/libs/crud-pro/services/CurdProServiceHub.ts +0 -92
- package/src/libs/crud-pro/sql.txt +0 -120
- package/src/libs/crud-pro/utils/CompareUtils.ts +0 -23
- package/src/libs/crud-pro/utils/DatabaseName.ts +0 -40
- package/src/libs/crud-pro/utils/DateTimeUtils.ts +0 -20
- package/src/libs/crud-pro/utils/MemoryRefreshCache.ts +0 -64
- package/src/libs/crud-pro/utils/MessageParseUtils.ts +0 -33
- package/src/libs/crud-pro/utils/MixinUtils.ts +0 -285
- package/src/libs/crud-pro/utils/ModelUtils.ts +0 -55
- package/src/libs/crud-pro/utils/MultiKeyMap.ts +0 -72
- package/src/libs/crud-pro/utils/SqlFuncUtils.ts +0 -29
- package/src/libs/crud-pro/utils/TypeUtils.ts +0 -188
- package/src/libs/crud-pro/utils/ValidateUtils.ts +0 -167
- package/src/libs/crud-pro/utils/pool/MySQLUtils.ts +0 -20
- package/src/libs/crud-pro/utils/pool/PostgresUtils.ts +0 -22
- package/src/libs/crud-pro/utils/pool/SqlServerUtils.ts +0 -22
- package/src/libs/crud-pro/utils/sqlConvert/convertColumnName.ts +0 -26
- package/src/libs/crud-pro/utils/sqlConvert/convertMsSql.ts +0 -11
- package/src/libs/crud-pro/utils/sqlConvert/convertPgSql.ts +0 -11
- package/src/libs/crud-pro/utils/sqlConvert/convertPgType.ts +0 -129
- package/src/libs/utils/common-dto.ts +0 -52
- package/src/libs/utils/crypto-utils.ts +0 -52
- package/src/libs/utils/fatcms-request.ts +0 -115
- package/src/libs/utils/functions.ts +0 -67
- package/src/libs/utils/ordernum-utils.ts +0 -18
- package/src/libs/utils/parseConfig.ts +0 -62
- package/src/libs/utils/parseCreateSql.ts +0 -91
- package/src/libs/utils/render-utils.ts +0 -184
- package/src/middleware/forbidden.middleware.ts +0 -71
- package/src/middleware/global.middleware.ts +0 -278
- package/src/middleware/permission.middleware.ts +0 -81
- package/src/middleware/tx.middleware.ts +0 -30
- package/src/models/SystemEntities.ts +0 -115
- package/src/models/SystemPerm.ts +0 -105
- package/src/models/SystemTables.ts +0 -30
- package/src/models/bizmodels.ts +0 -89
- package/src/models/contextLogger.ts +0 -132
- package/src/models/devops.ts +0 -17
- package/src/models/userSession.ts +0 -216
- package/src/schedule/index.ts +0 -73
- package/src/service/AuthService.ts +0 -270
- package/src/service/EnumInfoService.ts +0 -129
- package/src/service/FileCenterService.ts +0 -394
- package/src/service/SysConfigService.ts +0 -34
- package/src/service/UserAccountService.ts +0 -100
- package/src/service/UserSessionService.ts +0 -81
- package/src/service/VisitStatService.ts +0 -179
- package/src/service/WorkbenchService.ts +0 -160
- package/src/service/anyapi/AnyApiSandboxService.ts +0 -121
- package/src/service/anyapi/AnyApiService.ts +0 -184
- package/src/service/base/ApiBaseService.ts +0 -42
- package/src/service/base/ApiRateLimiter.ts +0 -59
- package/src/service/base/BaseService.ts +0 -74
- package/src/service/base/RedisCacheService.ts +0 -38
- package/src/service/crudstd/CrudStdActionService.ts +0 -27
- package/src/service/crudstd/CrudStdConstant.ts +0 -62
- package/src/service/crudstd/CrudStdRelationService.ts +0 -78
- package/src/service/crudstd/CrudStdService.ts +0 -188
- package/src/service/curd/CurdMixByAccountService.ts +0 -83
- package/src/service/curd/CurdMixByDictService.ts +0 -113
- package/src/service/curd/CurdMixByLinkToCustomService.ts +0 -167
- package/src/service/curd/CurdMixBySysConfigService.ts +0 -78
- package/src/service/curd/CurdMixByWorkbenchService.ts +0 -68
- package/src/service/curd/CurdMixService.ts +0 -65
- package/src/service/curd/CurdMixUtils.ts +0 -248
- package/src/service/curd/CurdProService.ts +0 -379
- package/src/service/proxyapi/ProxyApiLoadService.ts +0 -165
- package/src/service/proxyapi/ProxyApiService.ts +0 -262
- package/src/service/proxyapi/ProxyApiUtils.ts +0 -32
- package/src/service/proxyapi/RouteHandler.ts +0 -8
- package/src/service/proxyapi/RouteTrie.ts +0 -74
- package/src/service/proxyapi/WeightedRandom.ts +0 -37
- package/src/service/proxyapi/WeightedRoundRobin.ts +0 -44
- package/src/views/404_app.html +0 -31
- package/src/views/404_workbench.html +0 -34
- package/src/views/static/favicon.ico +0 -0
|
@@ -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,13 @@ 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
|
+
row['__fatcmsUserAccountId__'] = fatcmsUserAccountId;
|
|
39
|
+
}
|
|
34
40
|
}
|
|
35
41
|
});
|
|
36
42
|
if (accountIds.size === 0) {
|
|
@@ -40,8 +46,8 @@ let CurdMixByAccountService = class CurdMixByAccountService {
|
|
|
40
46
|
method: 'UserAccountService.queryAccountBasicInfoByIds',
|
|
41
47
|
sqlTable: SystemTables_1.SystemTables.sys_user_account,
|
|
42
48
|
sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_QUERY,
|
|
43
|
-
sqlDatabase:
|
|
44
|
-
|
|
49
|
+
sqlDatabase: SystemDbName,
|
|
50
|
+
sqlDbType: SystemDbType,
|
|
45
51
|
};
|
|
46
52
|
const reqJson = {
|
|
47
53
|
columns: ['nick_name', 'avatar', 'account_id'],
|
|
@@ -69,7 +75,7 @@ let CurdMixByAccountService = class CurdMixByAccountService {
|
|
|
69
75
|
{ from: 'avatar', to: `${sourceColumn}_user.avatar` },
|
|
70
76
|
];
|
|
71
77
|
}
|
|
72
|
-
dictMixUtils.
|
|
78
|
+
dictMixUtils.copyUserInfoToRowNoRelatedCode(row, userInfoMap, columnRelation);
|
|
73
79
|
});
|
|
74
80
|
}
|
|
75
81
|
};
|
|
@@ -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
|
}
|
|
@@ -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,9 @@
|
|
|
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
|
+
export interface ILinkColumnRelationParam {
|
|
5
|
+
columnsRelations: ColumnRelation[];
|
|
6
|
+
}
|
|
4
7
|
export declare class CurdMixService {
|
|
5
8
|
private curdProService;
|
|
6
9
|
private curdMixByDictService;
|
|
@@ -10,8 +13,15 @@ export declare class CurdMixService {
|
|
|
10
13
|
private curdMixByLinkToCustomService;
|
|
11
14
|
private prepare;
|
|
12
15
|
executeCrudByCfg(reqJson: IRequestModel, cfgModel: IRequestCfgModel2): Promise<import("../../libs/crud-pro/models/ExecuteContext").ExecuteContext>;
|
|
13
|
-
getBbUtil(
|
|
16
|
+
getBbUtil(sqlDatabase: string, sqlDbType: SqlDbType, sqlTable?: string): import("./CrudProQuick").CrudProQuick;
|
|
14
17
|
executeSQL(sqlCfgModel: ISqlCfgModel): Promise<any>;
|
|
15
18
|
executeCrud(reqJson: IRequestModel): Promise<import("../../libs/crud-pro/models/ExecuteContext").ExecuteContext>;
|
|
16
19
|
getCachedCfgByMethod(method: string): Promise<IRequestCfgModel>;
|
|
20
|
+
/**
|
|
21
|
+
* 根据配置的关联关系,直接关联数据
|
|
22
|
+
* @param rows
|
|
23
|
+
* @param param
|
|
24
|
+
* @returns
|
|
25
|
+
*/
|
|
26
|
+
linkColumnRelationDatas(rows: any[], param: ILinkColumnRelationParam): Promise<void>;
|
|
17
27
|
}
|
|
@@ -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)(),
|