midway-fatcms 0.0.1-beta.76 → 0.0.1-beta.77
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 -14
- package/.prettierrc.js +4 -4
- package/README.md +8 -8
- package/dist/config/config.default.d.ts +3 -3
- package/dist/config/config.default.js +177 -177
- package/dist/config/utils.d.ts +1 -1
- package/dist/config/utils.js +23 -23
- package/dist/configuration.d.ts +7 -7
- package/dist/configuration.js +113 -113
- package/dist/controller/base/BaseApiController.d.ts +48 -48
- package/dist/controller/base/BaseApiController.js +197 -197
- package/dist/controller/gateway/AnyApiGatewayController.d.ts +13 -13
- package/dist/controller/gateway/AnyApiGatewayController.js +55 -55
- package/dist/controller/gateway/AsyncTaskController.d.ts +20 -20
- package/dist/controller/gateway/AsyncTaskController.js +181 -181
- package/dist/controller/gateway/CrudMtdGatewayController.d.ts +21 -21
- package/dist/controller/gateway/CrudMtdGatewayController.js +122 -122
- package/dist/controller/gateway/CrudStdGatewayController.d.ts +39 -39
- package/dist/controller/gateway/CrudStdGatewayController.js +149 -149
- package/dist/controller/gateway/DocGatewayController.d.ts +27 -27
- package/dist/controller/gateway/DocGatewayController.js +179 -179
- package/dist/controller/gateway/FileController.d.ts +32 -32
- package/dist/controller/gateway/FileController.js +160 -160
- package/dist/controller/gateway/ProxyApiGatewayController.d.ts +18 -18
- package/dist/controller/gateway/ProxyApiGatewayController.js +78 -78
- package/dist/controller/gateway/PublicApiController.d.ts +33 -33
- package/dist/controller/gateway/PublicApiController.js +201 -201
- package/dist/controller/gateway/StaticController.d.ts +23 -23
- package/dist/controller/gateway/StaticController.js +286 -286
- package/dist/controller/helpers.controller.d.ts +39 -39
- package/dist/controller/helpers.controller.js +188 -188
- package/dist/controller/home.controller.d.ts +9 -9
- package/dist/controller/home.controller.js +72 -72
- package/dist/controller/manage/AnyApiMangeApi.d.ts +10 -10
- package/dist/controller/manage/AnyApiMangeApi.js +98 -98
- package/dist/controller/manage/AppLogMangeApi.d.ts +10 -10
- package/dist/controller/manage/AppLogMangeApi.js +88 -88
- package/dist/controller/manage/AppMangeApi.d.ts +12 -12
- package/dist/controller/manage/AppMangeApi.js +101 -101
- package/dist/controller/manage/AppPageMangeApi.d.ts +10 -10
- package/dist/controller/manage/AppPageMangeApi.js +87 -87
- package/dist/controller/manage/AppSchemaHistoryApi.d.ts +10 -10
- package/dist/controller/manage/AppSchemaHistoryApi.js +83 -83
- package/dist/controller/manage/CrudMethodsMangeApi.d.ts +10 -10
- package/dist/controller/manage/CrudMethodsMangeApi.js +84 -84
- package/dist/controller/manage/CrudStandardDesignApi.d.ts +46 -46
- package/dist/controller/manage/CrudStandardDesignApi.js +367 -367
- package/dist/controller/manage/DataDictManageApi.d.ts +17 -17
- package/dist/controller/manage/DataDictManageApi.js +165 -165
- package/dist/controller/manage/DeployManageApi.d.ts +19 -19
- package/dist/controller/manage/DeployManageApi.js +180 -180
- package/dist/controller/manage/DocLibManageApi.d.ts +10 -10
- package/dist/controller/manage/DocLibManageApi.js +104 -104
- package/dist/controller/manage/DocManageApi.d.ts +11 -11
- package/dist/controller/manage/DocManageApi.js +130 -130
- package/dist/controller/manage/FileManageApi.d.ts +13 -13
- package/dist/controller/manage/FileManageApi.js +77 -77
- package/dist/controller/manage/LowCodeTplManageApi.d.ts +13 -13
- package/dist/controller/manage/LowCodeTplManageApi.js +86 -86
- package/dist/controller/manage/MenuManageApi.d.ts +10 -10
- package/dist/controller/manage/MenuManageApi.js +93 -93
- package/dist/controller/manage/ProxyApiMangeApi.d.ts +10 -10
- package/dist/controller/manage/ProxyApiMangeApi.js +87 -87
- package/dist/controller/manage/SuperAdminManageApi.d.ts +24 -24
- package/dist/controller/manage/SuperAdminManageApi.js +153 -153
- package/dist/controller/manage/SysConfigMangeApi.d.ts +12 -12
- package/dist/controller/manage/SysConfigMangeApi.js +133 -133
- package/dist/controller/manage/SystemInfoManageApi.d.ts +12 -12
- package/dist/controller/manage/SystemInfoManageApi.js +74 -74
- package/dist/controller/manage/UserAccountManageApi.d.ts +16 -16
- package/dist/controller/manage/UserAccountManageApi.js +153 -153
- package/dist/controller/manage/WorkbenchMangeApi.d.ts +11 -11
- package/dist/controller/manage/WorkbenchMangeApi.js +103 -103
- package/dist/controller/myinfo/AuthController.d.ts +37 -37
- package/dist/controller/myinfo/AuthController.js +157 -157
- package/dist/controller/myinfo/MyInfoController.d.ts +13 -13
- package/dist/controller/myinfo/MyInfoController.js +51 -51
- package/dist/controller/render/AppRenderController.d.ts +12 -12
- package/dist/controller/render/AppRenderController.js +87 -87
- package/dist/controller/test.controller.d.ts +8 -8
- package/dist/controller/test.controller.js +51 -51
- package/dist/filter/default.filter.d.ts +7 -7
- package/dist/filter/default.filter.js +23 -23
- package/dist/filter/notfound.filter.d.ts +5 -5
- package/dist/filter/notfound.filter.js +20 -20
- package/dist/index.d.ts +106 -106
- package/dist/index.js +124 -124
- package/dist/interface.d.ts +29 -29
- package/dist/interface.js +3 -3
- package/dist/libs/crud-pro/CrudPro.d.ts +37 -37
- package/dist/libs/crud-pro/CrudPro.js +139 -136
- package/dist/libs/crud-pro/defaultConfigs.d.ts +4 -4
- package/dist/libs/crud-pro/defaultConfigs.js +15 -15
- package/dist/libs/crud-pro/exceptions.d.ts +106 -106
- package/dist/libs/crud-pro/exceptions.js +119 -119
- package/dist/libs/crud-pro/interfaces.d.ts +175 -166
- package/dist/libs/crud-pro/interfaces.js +12 -12
- package/dist/libs/crud-pro/models/ExecuteContext.d.ts +50 -50
- package/dist/libs/crud-pro/models/ExecuteContext.js +87 -87
- package/dist/libs/crud-pro/models/ExecuteContextFunc.d.ts +38 -38
- package/dist/libs/crud-pro/models/ExecuteContextFunc.js +72 -72
- package/dist/libs/crud-pro/models/FuncContext.d.ts +18 -18
- package/dist/libs/crud-pro/models/FuncContext.js +6 -6
- package/dist/libs/crud-pro/models/RequestCfgModel.d.ts +65 -65
- package/dist/libs/crud-pro/models/RequestCfgModel.js +81 -81
- package/dist/libs/crud-pro/models/RequestModel.d.ts +25 -25
- package/dist/libs/crud-pro/models/RequestModel.js +113 -113
- package/dist/libs/crud-pro/models/ResModel.d.ts +20 -20
- package/dist/libs/crud-pro/models/ResModel.js +2 -2
- package/dist/libs/crud-pro/models/ServiceHub.d.ts +20 -20
- package/dist/libs/crud-pro/models/ServiceHub.js +2 -2
- package/dist/libs/crud-pro/models/SqlCfgModel.d.ts +23 -23
- package/dist/libs/crud-pro/models/SqlCfgModel.js +40 -40
- package/dist/libs/crud-pro/models/SqlSegArg.d.ts +6 -6
- package/dist/libs/crud-pro/models/SqlSegArg.js +12 -12
- package/dist/libs/crud-pro/models/Transaction.d.ts +49 -30
- package/dist/libs/crud-pro/models/Transaction.js +177 -74
- package/dist/libs/crud-pro/models/TransactionMySQL.d.ts +19 -29
- package/dist/libs/crud-pro/models/TransactionMySQL.js +48 -83
- package/dist/libs/crud-pro/models/TransactionPostgres.d.ts +19 -29
- package/dist/libs/crud-pro/models/TransactionPostgres.js +64 -91
- package/dist/libs/crud-pro/models/TransactionSqlServer.d.ts +9 -35
- package/dist/libs/crud-pro/models/TransactionSqlServer.js +61 -100
- package/dist/libs/crud-pro/models/keys.d.ts +110 -110
- package/dist/libs/crud-pro/models/keys.js +154 -154
- package/dist/libs/crud-pro/services/CrudProCachedCfgService.d.ts +11 -11
- package/dist/libs/crud-pro/services/CrudProCachedCfgService.js +73 -73
- package/dist/libs/crud-pro/services/CrudProExecuteFuncService.d.ts +9 -9
- package/dist/libs/crud-pro/services/CrudProExecuteFuncService.js +125 -125
- package/dist/libs/crud-pro/services/CrudProExecuteSqlService.d.ts +17 -17
- package/dist/libs/crud-pro/services/CrudProExecuteSqlService.js +216 -225
- package/dist/libs/crud-pro/services/CrudProFieldUpdateService.d.ts +9 -9
- package/dist/libs/crud-pro/services/CrudProFieldUpdateService.js +51 -51
- package/dist/libs/crud-pro/services/CrudProFieldValidateService.d.ts +13 -13
- package/dist/libs/crud-pro/services/CrudProFieldValidateService.js +148 -148
- package/dist/libs/crud-pro/services/CrudProGenSqlCondition.d.ts +24 -24
- package/dist/libs/crud-pro/services/CrudProGenSqlCondition.js +355 -355
- package/dist/libs/crud-pro/services/CrudProGenSqlService.d.ts +25 -25
- package/dist/libs/crud-pro/services/CrudProGenSqlService.js +165 -165
- package/dist/libs/crud-pro/services/CrudProOriginToExecuteSql.d.ts +32 -32
- package/dist/libs/crud-pro/services/CrudProOriginToExecuteSql.js +339 -339
- package/dist/libs/crud-pro/services/CrudProServiceBase.d.ts +24 -24
- package/dist/libs/crud-pro/services/CrudProServiceBase.js +88 -88
- package/dist/libs/crud-pro/services/CrudProTableMetaService.d.ts +9 -9
- package/dist/libs/crud-pro/services/CrudProTableMetaService.js +72 -72
- package/dist/libs/crud-pro/services/CurdProServiceHub.d.ts +32 -32
- package/dist/libs/crud-pro/services/CurdProServiceHub.js +64 -64
- package/dist/libs/crud-pro/utils/CompareUtils.d.ts +9 -9
- package/dist/libs/crud-pro/utils/CompareUtils.js +25 -25
- package/dist/libs/crud-pro/utils/CrudMonitor.d.ts +9 -9
- package/dist/libs/crud-pro/utils/CrudMonitor.js +12 -12
- package/dist/libs/crud-pro/utils/DatabaseName.d.ts +9 -9
- package/dist/libs/crud-pro/utils/DatabaseName.js +50 -50
- package/dist/libs/crud-pro/utils/DateTimeUtils.d.ts +7 -7
- package/dist/libs/crud-pro/utils/DateTimeUtils.js +21 -21
- package/dist/libs/crud-pro/utils/MemoryRefreshCache.d.ts +19 -19
- package/dist/libs/crud-pro/utils/MemoryRefreshCache.js +47 -47
- package/dist/libs/crud-pro/utils/MessageParseUtils.d.ts +5 -5
- package/dist/libs/crud-pro/utils/MessageParseUtils.js +33 -33
- package/dist/libs/crud-pro/utils/MixinUtils.d.ts +40 -39
- package/dist/libs/crud-pro/utils/MixinUtils.js +258 -255
- package/dist/libs/crud-pro/utils/ModelUtils.d.ts +11 -11
- package/dist/libs/crud-pro/utils/ModelUtils.js +54 -54
- package/dist/libs/crud-pro/utils/MultiKeyMap.d.ts +11 -11
- package/dist/libs/crud-pro/utils/MultiKeyMap.js +63 -63
- package/dist/libs/crud-pro/utils/SqlFuncUtils.d.ts +5 -5
- package/dist/libs/crud-pro/utils/SqlFuncUtils.js +29 -29
- package/dist/libs/crud-pro/utils/TypeUtils.d.ts +40 -40
- package/dist/libs/crud-pro/utils/TypeUtils.js +166 -166
- package/dist/libs/crud-pro/utils/ValidateUtils.d.ts +3 -3
- package/dist/libs/crud-pro/utils/ValidateUtils.js +165 -165
- package/dist/libs/crud-pro/utils/pool/MySQLUtils.d.ts +3 -3
- package/dist/libs/crud-pro/utils/pool/MySQLUtils.js +19 -19
- package/dist/libs/crud-pro/utils/pool/PostgresUtils.d.ts +3 -3
- package/dist/libs/crud-pro/utils/pool/PostgresUtils.js +20 -20
- package/dist/libs/crud-pro/utils/pool/SqlServerUtils.d.ts +3 -3
- package/dist/libs/crud-pro/utils/pool/SqlServerUtils.js +20 -20
- package/dist/libs/crud-pro/utils/sqlConvert/convertColumnName.d.ts +4 -4
- package/dist/libs/crud-pro/utils/sqlConvert/convertColumnName.js +35 -35
- package/dist/libs/crud-pro/utils/sqlConvert/convertMix.d.ts +0 -3
- package/dist/libs/crud-pro/utils/sqlConvert/convertMix.js +24 -22
- package/dist/libs/crud-pro/utils/sqlConvert/convertMsSql.d.ts +2 -2
- package/dist/libs/crud-pro/utils/sqlConvert/convertMsSql.js +14 -14
- package/dist/libs/crud-pro/utils/sqlConvert/convertPgSql.d.ts +2 -2
- package/dist/libs/crud-pro/utils/sqlConvert/convertPgSql.js +14 -14
- package/dist/libs/global-config/global-config.d.ts +69 -69
- package/dist/libs/global-config/global-config.js +36 -36
- package/dist/libs/utils/AsymmetricCrypto.d.ts +76 -76
- package/dist/libs/utils/AsymmetricCrypto.js +261 -261
- package/dist/libs/utils/base64.d.ts +9 -9
- package/dist/libs/utils/base64.js +42 -42
- package/dist/libs/utils/common-dto.d.ts +18 -18
- package/dist/libs/utils/common-dto.js +40 -40
- package/dist/libs/utils/crypto-utils.d.ts +3 -3
- package/dist/libs/utils/crypto-utils.js +46 -46
- package/dist/libs/utils/errorToString.d.ts +2 -2
- package/dist/libs/utils/errorToString.js +57 -57
- package/dist/libs/utils/fatcms-request.d.ts +30 -30
- package/dist/libs/utils/fatcms-request.js +104 -104
- package/dist/libs/utils/format-url.d.ts +2 -2
- package/dist/libs/utils/format-url.js +13 -13
- package/dist/libs/utils/functions.d.ts +5 -5
- package/dist/libs/utils/functions.js +76 -76
- package/dist/libs/utils/ordernum-utils.d.ts +2 -2
- package/dist/libs/utils/ordernum-utils.js +13 -13
- package/dist/libs/utils/parseConfig.d.ts +8 -8
- package/dist/libs/utils/parseConfig.js +47 -47
- package/dist/libs/utils/parseCreateSql.d.ts +10 -10
- package/dist/libs/utils/parseCreateSql.js +87 -87
- package/dist/libs/utils/render-utils.d.ts +37 -37
- package/dist/libs/utils/render-utils.js +154 -154
- package/dist/middleware/forbidden.middleware.d.ts +10 -10
- package/dist/middleware/forbidden.middleware.js +54 -54
- package/dist/middleware/global.middleware.d.ts +10 -10
- package/dist/middleware/global.middleware.js +273 -273
- package/dist/middleware/permission.middleware.d.ts +18 -18
- package/dist/middleware/permission.middleware.js +74 -74
- package/dist/middleware/rediscache.middleware.d.ts +3 -3
- package/dist/middleware/rediscache.middleware.js +77 -77
- package/dist/middleware/redislock.middleware.d.ts +7 -7
- package/dist/middleware/redislock.middleware.js +72 -72
- package/dist/middleware/tx.middleware.d.ts +9 -9
- package/dist/middleware/tx.middleware.js +40 -40
- package/dist/models/AsyncTaskModel.d.ts +74 -74
- package/dist/models/AsyncTaskModel.js +31 -31
- package/dist/models/RedisKeys.d.ts +15 -15
- package/dist/models/RedisKeys.js +18 -18
- package/dist/models/SystemEntities.d.ts +117 -117
- package/dist/models/SystemEntities.js +17 -17
- package/dist/models/SystemPerm.d.ts +95 -95
- package/dist/models/SystemPerm.js +100 -100
- package/dist/models/SystemTables.d.ts +25 -25
- package/dist/models/SystemTables.js +28 -28
- package/dist/models/WorkbenchInfoTools.d.ts +7 -7
- package/dist/models/WorkbenchInfoTools.js +20 -20
- package/dist/models/bizmodels.d.ts +138 -138
- package/dist/models/bizmodels.js +61 -61
- package/dist/models/contextLogger.d.ts +27 -27
- package/dist/models/contextLogger.js +119 -119
- package/dist/models/devops.d.ts +12 -12
- package/dist/models/devops.js +19 -19
- package/dist/models/userSession.d.ts +66 -65
- package/dist/models/userSession.js +169 -168
- package/dist/schedule/anonymousContext.d.ts +15 -15
- package/dist/schedule/anonymousContext.js +74 -73
- package/dist/schedule/index.d.ts +4 -4
- package/dist/schedule/index.js +10 -10
- package/dist/schedule/runSchedule.d.ts +12 -12
- package/dist/schedule/runSchedule.js +68 -68
- package/dist/schedule/scheduleNames.d.ts +15 -15
- package/dist/schedule/scheduleNames.js +19 -19
- package/dist/service/AuthService.d.ts +57 -57
- package/dist/service/AuthService.js +270 -265
- package/dist/service/EnumInfoService.d.ts +30 -30
- package/dist/service/EnumInfoService.js +97 -97
- package/dist/service/FileCenterService.d.ts +64 -64
- package/dist/service/FileCenterService.js +422 -422
- package/dist/service/SysAppService.d.ts +14 -14
- package/dist/service/SysAppService.js +96 -96
- package/dist/service/SysConfigService.d.ts +10 -10
- package/dist/service/SysConfigService.js +64 -64
- package/dist/service/SysDictDataService.d.ts +9 -9
- package/dist/service/SysDictDataService.js +72 -72
- package/dist/service/UserAccountService.d.ts +23 -23
- package/dist/service/UserAccountService.js +107 -107
- package/dist/service/UserSessionService.d.ts +43 -43
- package/dist/service/UserSessionService.js +163 -163
- package/dist/service/VisitStatService.d.ts +14 -14
- package/dist/service/VisitStatService.js +158 -158
- package/dist/service/WorkbenchService.d.ts +59 -59
- package/dist/service/WorkbenchService.js +249 -249
- package/dist/service/anyapi/AnyApiSandboxService.d.ts +15 -15
- package/dist/service/anyapi/AnyApiSandboxService.js +110 -110
- package/dist/service/anyapi/AnyApiService.d.ts +27 -27
- package/dist/service/anyapi/AnyApiService.js +181 -181
- package/dist/service/asyncTask/AsyncTaskRunnerService.d.ts +50 -50
- package/dist/service/asyncTask/AsyncTaskRunnerService.js +287 -287
- package/dist/service/asyncTask/AsyncTaskService.d.ts +7 -7
- package/dist/service/asyncTask/AsyncTaskService.js +34 -34
- package/dist/service/asyncTask/handler/ExcelInfoModel.d.ts +10 -10
- package/dist/service/asyncTask/handler/ExcelInfoModel.js +2 -2
- package/dist/service/asyncTask/handler/ExportExcelAsyncTaskHandler.d.ts +7 -7
- package/dist/service/asyncTask/handler/ExportExcelAsyncTaskHandler.js +216 -216
- package/dist/service/asyncTask/handler/ExportExcelByInnerHttpHandler.d.ts +36 -36
- package/dist/service/asyncTask/handler/ExportExcelByInnerHttpHandler.js +141 -141
- package/dist/service/asyncTask/handler/ExportExcelByStdCrudHandler.d.ts +46 -46
- package/dist/service/asyncTask/handler/ExportExcelByStdCrudHandler.js +135 -135
- package/dist/service/base/ApiBaseService.d.ts +15 -15
- package/dist/service/base/ApiBaseService.js +50 -50
- package/dist/service/base/ApiRateLimiter.d.ts +10 -10
- package/dist/service/base/ApiRateLimiter.js +51 -51
- package/dist/service/base/BaseService.d.ts +41 -41
- package/dist/service/base/BaseService.js +101 -101
- package/dist/service/base/cache/CacheServiceFactory.d.ts +26 -26
- package/dist/service/base/cache/CacheServiceFactory.js +122 -122
- package/dist/service/base/cache/CtxCache.d.ts +18 -18
- package/dist/service/base/cache/CtxCache.js +37 -37
- package/dist/service/base/cache/DiskCache.d.ts +19 -19
- package/dist/service/base/cache/DiskCache.js +74 -74
- package/dist/service/base/cache/MemoryCache.d.ts +12 -12
- package/dist/service/base/cache/MemoryCache.js +58 -58
- package/dist/service/base/cache/NoneCache.d.ts +10 -10
- package/dist/service/base/cache/NoneCache.js +19 -19
- package/dist/service/base/cache/RedisCache.d.ts +14 -14
- package/dist/service/base/cache/RedisCache.js +31 -31
- package/dist/service/crudstd/CrudStdActionService.d.ts +17 -17
- package/dist/service/crudstd/CrudStdActionService.js +32 -32
- package/dist/service/crudstd/CrudStdConstant.d.ts +58 -58
- package/dist/service/crudstd/CrudStdConstant.js +64 -64
- package/dist/service/crudstd/CrudStdRelationService.d.ts +10 -10
- package/dist/service/crudstd/CrudStdRelationService.js +121 -121
- package/dist/service/crudstd/CrudStdService.d.ts +60 -60
- package/dist/service/crudstd/CrudStdService.js +376 -376
- package/dist/service/curd/CrudProQuick.d.ts +50 -50
- package/dist/service/curd/CrudProQuick.js +163 -163
- package/dist/service/curd/CurdMixByAccountService.d.ts +13 -13
- package/dist/service/curd/CurdMixByAccountService.js +151 -151
- package/dist/service/curd/CurdMixByDictService.d.ts +12 -12
- package/dist/service/curd/CurdMixByDictService.js +114 -114
- package/dist/service/curd/CurdMixByLinkToCustomService.d.ts +30 -30
- package/dist/service/curd/CurdMixByLinkToCustomService.js +209 -209
- package/dist/service/curd/CurdMixBySysConfigService.d.ts +13 -13
- package/dist/service/curd/CurdMixBySysConfigService.js +116 -116
- package/dist/service/curd/CurdMixByWorkbenchService.d.ts +11 -11
- package/dist/service/curd/CurdMixByWorkbenchService.js +80 -80
- package/dist/service/curd/CurdMixService.d.ts +28 -28
- package/dist/service/curd/CurdMixService.js +100 -100
- package/dist/service/curd/CurdMixUtils.d.ts +57 -57
- package/dist/service/curd/CurdMixUtils.js +331 -331
- package/dist/service/curd/CurdProService.d.ts +32 -32
- package/dist/service/curd/CurdProService.js +212 -212
- package/dist/service/curd/fixCfgModel.d.ts +3 -3
- package/dist/service/curd/fixCfgModel.js +104 -104
- package/dist/service/proxyapi/ProxyApiLoadService.d.ts +21 -21
- package/dist/service/proxyapi/ProxyApiLoadService.js +167 -167
- package/dist/service/proxyapi/ProxyApiService.d.ts +61 -61
- package/dist/service/proxyapi/ProxyApiService.js +294 -294
- package/dist/service/proxyapi/ProxyApiUtils.d.ts +15 -15
- package/dist/service/proxyapi/ProxyApiUtils.js +34 -34
- package/dist/service/proxyapi/RouteHandler.d.ts +5 -5
- package/dist/service/proxyapi/RouteHandler.js +9 -9
- package/dist/service/proxyapi/RouteTrie.d.ts +12 -12
- package/dist/service/proxyapi/RouteTrie.js +63 -63
- package/dist/service/proxyapi/WeightedRandom.d.ts +9 -9
- package/dist/service/proxyapi/WeightedRandom.js +31 -31
- package/dist/service/proxyapi/WeightedRoundRobin.d.ts +8 -8
- package/dist/service/proxyapi/WeightedRoundRobin.js +32 -32
- package/index.d.ts +10 -10
- package/package.json +87 -87
- package/src/libs/crud-pro/CrudPro.ts +5 -0
- package/src/libs/crud-pro/interfaces.ts +10 -1
- package/src/libs/crud-pro/models/Transaction.ts +141 -19
- package/src/libs/crud-pro/models/TransactionMySQL.ts +38 -69
- package/src/libs/crud-pro/models/TransactionPostgres.ts +49 -67
- package/src/libs/crud-pro/models/TransactionSqlServer.ts +51 -87
- package/src/libs/crud-pro/services/CrudProCachedCfgService.ts +3 -3
- package/src/libs/crud-pro/services/CrudProExecuteSqlService.ts +13 -22
- package/src/libs/crud-pro/services/CrudProTableMetaService.ts +3 -3
- package/src/libs/crud-pro/utils/CrudMonitor.ts +13 -13
- package/src/libs/crud-pro/utils/MixinUtils.ts +3 -0
- package/src/libs/crud-pro/utils/sqlConvert/convertMix.ts +24 -24
- package/src/libs/utils/AsymmetricCrypto.ts +307 -307
- package/src/libs/utils/format-url.ts +15 -15
- package/src/libs/utils/render-utils.ts +216 -216
- package/src/models/WorkbenchInfoTools.ts +19 -19
- package/src/models/userSession.ts +2 -0
- package/src/schedule/anonymousContext.ts +2 -1
- package/src/service/AuthService.ts +7 -1
- package/src/service/SysAppService.ts +88 -88
- package/src/service/SysDictDataService.ts +63 -63
- package/src/service/WorkbenchService.ts +277 -277
- package/src/service/base/cache/CacheServiceFactory.ts +135 -135
- package/src/service/base/cache/CtxCache.ts +45 -45
- package/src/service/base/cache/DiskCache.ts +82 -82
- package/src/service/base/cache/MemoryCache.ts +68 -68
- package/src/service/base/cache/NoneCache.ts +24 -24
- package/src/service/base/cache/RedisCache.ts +41 -41
- package/tsconfig.json +32 -32
- package/dist/libs/crud-pro/utils/sqlConvert/convertPgType.d.ts +0 -2
- package/dist/libs/crud-pro/utils/sqlConvert/convertPgType.js +0 -128
- package/src/libs/crud-pro/utils/sqlConvert/convertPgType.ts +0 -127
|
@@ -1,376 +1,376 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.CrudStdService = exports.SPECIAL_SETTING_KEY = void 0;
|
|
13
|
-
/* eslint-disable prettier/prettier */
|
|
14
|
-
const _ = require("lodash");
|
|
15
|
-
const ejs = require("ejs");
|
|
16
|
-
const core_1 = require("@midwayjs/core");
|
|
17
|
-
const CurdMixService_1 = require("../curd/CurdMixService");
|
|
18
|
-
const keys_1 = require("../../libs/crud-pro/models/keys");
|
|
19
|
-
const functions_1 = require("../../libs/utils/functions");
|
|
20
|
-
const devops_1 = require("../../models/devops");
|
|
21
|
-
const CrudStdActionService_1 = require("./CrudStdActionService");
|
|
22
|
-
const CrudStdRelationService_1 = require("./CrudStdRelationService");
|
|
23
|
-
const ApiBaseService_1 = require("../base/ApiBaseService");
|
|
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");
|
|
27
|
-
const SysAppService_1 = require("../../service/SysAppService");
|
|
28
|
-
exports.SPECIAL_SETTING_KEY = {
|
|
29
|
-
QUERY_LIST: 'QUERY_LIST',
|
|
30
|
-
QUERY_ONE: 'QUERY_ONE',
|
|
31
|
-
KANBAN_VIEW_STATUS_UPDATE: 'KANBAN_VIEW_STATUS_UPDATE', // 看板视图中更新状态
|
|
32
|
-
};
|
|
33
|
-
function isNotEmptyStr(str) {
|
|
34
|
-
return typeof str === 'string' && str.trim().length > 0;
|
|
35
|
-
}
|
|
36
|
-
function getExecuteTableNameBySettingKey(appInfo, stdAction, sqlSimpleName) {
|
|
37
|
-
const { settingKey } = stdAction || {};
|
|
38
|
-
const stdCrudCfgObj = appInfo.stdCrudCfgObj;
|
|
39
|
-
const actionsMap = appInfo.actionsMap || {};
|
|
40
|
-
// 操作按钮单独设置了mainTableName字段
|
|
41
|
-
const actionCfg = actionsMap[settingKey];
|
|
42
|
-
if (actionCfg) {
|
|
43
|
-
const mainTableName = _.get(actionCfg, 'component.props.mainTableName');
|
|
44
|
-
if (isNotEmptyStr(mainTableName)) {
|
|
45
|
-
return mainTableName.trim();
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
if (sqlSimpleName === keys_1.KeysOfSimpleSQL.SIMPLE_DELETE || sqlSimpleName === keys_1.KeysOfSimpleSQL.SIMPLE_INSERT || sqlSimpleName === keys_1.KeysOfSimpleSQL.SIMPLE_UPDATE) {
|
|
49
|
-
// 全局配置了mainTableName字段
|
|
50
|
-
const globalMainTableName = _.get(stdCrudCfgObj, 'othersSetting.values.globalMainTableName');
|
|
51
|
-
if (isNotEmptyStr(globalMainTableName)) {
|
|
52
|
-
return globalMainTableName.trim();
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
// 视图中配置的表。
|
|
56
|
-
return stdCrudCfgObj.tableBaseInfo.tableName;
|
|
57
|
-
}
|
|
58
|
-
let CrudStdService = class CrudStdService extends ApiBaseService_1.ApiBaseService {
|
|
59
|
-
/**
|
|
60
|
-
* 执行普通CRUD
|
|
61
|
-
*/
|
|
62
|
-
async executeStdQuery(stdAction, params, sqlSimpleName) {
|
|
63
|
-
var _a;
|
|
64
|
-
const appCode = stdAction.appCode;
|
|
65
|
-
const appInfo = await this.getParsedCrudStdAppForSettingKey(stdAction);
|
|
66
|
-
const stdCrudCfgObj = appInfo.stdCrudCfgObj;
|
|
67
|
-
if (!appInfo || appInfo.status !== 1) {
|
|
68
|
-
throw new devops_1.BizException('应用不存在或已下线:' + appCode);
|
|
69
|
-
}
|
|
70
|
-
const databaseName = stdCrudCfgObj.tableBaseInfo.databaseName;
|
|
71
|
-
const { dbType, dbName } = (0, DatabaseName_1.parseDatabaseName)(databaseName);
|
|
72
|
-
const cfgModel = {
|
|
73
|
-
sqlDatabase: dbName,
|
|
74
|
-
sqlDbType: dbType,
|
|
75
|
-
sqlTable: getExecuteTableNameBySettingKey(appInfo, stdAction, sqlSimpleName),
|
|
76
|
-
sqlSimpleName,
|
|
77
|
-
updateCfg: {}
|
|
78
|
-
};
|
|
79
|
-
// 接口返回最大值
|
|
80
|
-
const maxLimit = _.get(stdCrudCfgObj, 'othersSetting.values.maxLimit');
|
|
81
|
-
if (typeof maxLimit === 'number' && maxLimit > 0) {
|
|
82
|
-
cfgModel.maxLimit = maxLimit;
|
|
83
|
-
}
|
|
84
|
-
if (!((_a = appInfo.settingKeyActionCfg) === null || _a === void 0 ? void 0 : _a.hasOperationPerm)) {
|
|
85
|
-
throw new devops_1.BizException('没有权限');
|
|
86
|
-
}
|
|
87
|
-
// 软删除操作。
|
|
88
|
-
await this.fixCfgModelAndParamBySoftDelete(params, cfgModel, appInfo, sqlSimpleName);
|
|
89
|
-
// 根据用户配置,设置关联查询的数据信息。
|
|
90
|
-
await this.crudStdRelationService.addCfgModelColumnsRelation(cfgModel, appInfo);
|
|
91
|
-
// 根据FilterValue参数,设置updateCfg
|
|
92
|
-
await this.fixCfgModelByFilterValue(params, cfgModel, appInfo, { dbType, dbName });
|
|
93
|
-
// 根据用户配置的keepSubmitData字段修改提交的数据
|
|
94
|
-
await this.fixSubmitDataByKeepSubmitData(params, cfgModel, appInfo, { dbType, dbName });
|
|
95
|
-
// 根据表结构的数据类型,修正数据类型
|
|
96
|
-
await this.fixDataFieldTypeBySqlTableField(params, cfgModel, appInfo, { dbType, dbName });
|
|
97
|
-
// 业务系统自定义的修改:查询前的查询条件:cfgModel
|
|
98
|
-
await global_config_1.GLOBAL_STATIC_CONFIG.getConfig().bizUpdateCfgModelForCrudStd(params, cfgModel, appInfo, this.ctx);
|
|
99
|
-
const crudExeCtx = await this.curdMixService.executeCrudByCfg(params, cfgModel);
|
|
100
|
-
// 处理结果
|
|
101
|
-
await this.handleResult(stdAction, params, cfgModel, appInfo, crudExeCtx);
|
|
102
|
-
// 业务系统自定义的修改:查询后的返回值。
|
|
103
|
-
await global_config_1.GLOBAL_STATIC_CONFIG.getConfig().bizUpdateExecuteContextForCrudStd(params, cfgModel, appInfo, this.ctx, crudExeCtx);
|
|
104
|
-
return crudExeCtx;
|
|
105
|
-
}
|
|
106
|
-
async handleResult(stdAction, params, cfgModel, appInfo, crudExeCtx) {
|
|
107
|
-
await this.handleResultDataPermissionBySettingKey(stdAction, params, cfgModel, appInfo, crudExeCtx);
|
|
108
|
-
}
|
|
109
|
-
async handleResultDataPermissionBySettingKey(stdAction, params, cfgModel, appInfo, crudExeCtx) {
|
|
110
|
-
const { settingKey } = stdAction || {};
|
|
111
|
-
if (settingKey !== exports.SPECIAL_SETTING_KEY.QUERY_LIST && settingKey !== exports.SPECIAL_SETTING_KEY.QUERY_ONE) {
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
const rows = crudExeCtx.getResRows();
|
|
115
|
-
if (!Array.isArray(rows)) {
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
const actionColumns = _.get(appInfo, 'stdCrudCfgObj.actionColumns');
|
|
119
|
-
const checkDataPermissionObjBySettingKey = (record) => {
|
|
120
|
-
var _a, _b;
|
|
121
|
-
const permissionObj = {};
|
|
122
|
-
let count = 0;
|
|
123
|
-
const sessionInfo = ((_b = (_a = this.ctx) === null || _a === void 0 ? void 0 : _a.userSession) === null || _b === void 0 ? void 0 : _b.getSessionInfo()) || {};
|
|
124
|
-
for (let index = 0; index < actionColumns.length; index++) {
|
|
125
|
-
const column = actionColumns[index];
|
|
126
|
-
const rowAuthCfg = (0, functions_1.parseJsonObject)(column.rowAuthCfg);
|
|
127
|
-
if (rowAuthCfg && typeof rowAuthCfg.authByExpress === 'string') {
|
|
128
|
-
const authByExpress = rowAuthCfg.authByExpress.trim();
|
|
129
|
-
if (authByExpress) {
|
|
130
|
-
const authResult = ejs.render(authByExpress, { record, sessionInfo, params, _ });
|
|
131
|
-
permissionObj[column.settingKey] = authResult;
|
|
132
|
-
count++;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
if (count > 0) {
|
|
137
|
-
return permissionObj;
|
|
138
|
-
}
|
|
139
|
-
return null;
|
|
140
|
-
};
|
|
141
|
-
if (Array.isArray(actionColumns) && actionColumns.length > 0) {
|
|
142
|
-
for (let index = 0; index < rows.length; index++) {
|
|
143
|
-
const row = rows[index];
|
|
144
|
-
const dataPermissionObjBySettingKey = checkDataPermissionObjBySettingKey(row);
|
|
145
|
-
if (dataPermissionObjBySettingKey) {
|
|
146
|
-
row['__dataPermissionObjBySettingKey'] = dataPermissionObjBySettingKey;
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* 获取appInfo 并且拿到当前settingKey相关的信息
|
|
153
|
-
* @param appCode
|
|
154
|
-
* @param settingKey
|
|
155
|
-
* @private
|
|
156
|
-
*/
|
|
157
|
-
async getParsedCrudStdAppForSettingKey(stdAction) {
|
|
158
|
-
const { appCode, settingKey, buttonSettingKey } = stdAction || {};
|
|
159
|
-
if (!appCode) {
|
|
160
|
-
throw new devops_1.BizException('缺少参数:curdStdAppCode');
|
|
161
|
-
}
|
|
162
|
-
const appInfo = await this.getParsedCrudStdAppInfo(appCode);
|
|
163
|
-
if (!appInfo) {
|
|
164
|
-
return null;
|
|
165
|
-
}
|
|
166
|
-
const actionsMap = appInfo.actionsMap;
|
|
167
|
-
const appSchema = appInfo.stdCrudCfgObj;
|
|
168
|
-
// 看板视图中更新状态
|
|
169
|
-
if (settingKey === exports.SPECIAL_SETTING_KEY.KANBAN_VIEW_STATUS_UPDATE) {
|
|
170
|
-
const kanbanAuthSettingValues = _.get(appSchema, 'kanbanAuthSetting.values');
|
|
171
|
-
const { update_auth_type, update_auth_config_by_func_code, update_auth_config_by_role_code } = (kanbanAuthSettingValues || {});
|
|
172
|
-
const authConfig = update_auth_type === 'byFuncCode' ? update_auth_config_by_func_code : update_auth_config_by_role_code;
|
|
173
|
-
const hasOperationPerm = this.ctx.userSession.isAuthPass(update_auth_type, authConfig);
|
|
174
|
-
appInfo.settingKeyActionCfg = { settingKey, hasOperationPerm };
|
|
175
|
-
}
|
|
176
|
-
// 列表查询或详情查询
|
|
177
|
-
else if (settingKey === exports.SPECIAL_SETTING_KEY.QUERY_LIST || settingKey === exports.SPECIAL_SETTING_KEY.QUERY_ONE) {
|
|
178
|
-
const authSettingValues = _.get(appSchema, 'authSetting.values');
|
|
179
|
-
const { auth_type, auth_config_by_func_code, auth_config_by_role_code } = authSettingValues || {};
|
|
180
|
-
const authConfig = auth_type === 'byFuncCode' ? auth_config_by_func_code : auth_config_by_role_code;
|
|
181
|
-
const hasOperationPerm = this.ctx.userSession.isAuthPass(auth_type, authConfig);
|
|
182
|
-
appInfo.settingKeyActionCfg = { settingKey, hasOperationPerm };
|
|
183
|
-
}
|
|
184
|
-
else {
|
|
185
|
-
const actionCfg = actionsMap[settingKey];
|
|
186
|
-
if (!actionCfg) {
|
|
187
|
-
throw new devops_1.BizException('没有找到相关配置:' + JSON.stringify({ appCode, settingKey }));
|
|
188
|
-
}
|
|
189
|
-
const componentNameCfg = _.get(actionCfg, 'component.componentName');
|
|
190
|
-
if (!componentNameCfg) {
|
|
191
|
-
throw new devops_1.BizException('没有配置动作组件:' + JSON.stringify({ appCode, settingKey }));
|
|
192
|
-
}
|
|
193
|
-
appInfo.settingKeyActionCfg = actionCfg;
|
|
194
|
-
}
|
|
195
|
-
if (buttonSettingKey) {
|
|
196
|
-
appInfo.buttonSettingKeyActionCfg = actionsMap[buttonSettingKey];
|
|
197
|
-
}
|
|
198
|
-
return appInfo;
|
|
199
|
-
}
|
|
200
|
-
/**
|
|
201
|
-
* 执行动作
|
|
202
|
-
* @param stdAction
|
|
203
|
-
* @param params
|
|
204
|
-
*/
|
|
205
|
-
async executeStdActionByReq(stdAction, params) {
|
|
206
|
-
const appInfo = await this.getParsedCrudStdAppForSettingKey(stdAction);
|
|
207
|
-
if (!appInfo || appInfo.status !== 1) {
|
|
208
|
-
throw new devops_1.BizException('应用不存在或已下线:' + stdAction.appCode);
|
|
209
|
-
}
|
|
210
|
-
const actionsMap = appInfo.actionsMap;
|
|
211
|
-
const actionCfg = appInfo.settingKeyActionCfg;
|
|
212
|
-
return this.crudStdActionService.handleStdActionByReq({ appInfo, params, actionsMap, actionCfg });
|
|
213
|
-
}
|
|
214
|
-
/**
|
|
215
|
-
* 查询APP信息
|
|
216
|
-
* @param appCode
|
|
217
|
-
* @private
|
|
218
|
-
*/
|
|
219
|
-
async getParsedCrudStdAppInfo(appCode) {
|
|
220
|
-
const appInfo = await this.sysAppService.getSysAppOne(appCode);
|
|
221
|
-
if (!appInfo) {
|
|
222
|
-
return null;
|
|
223
|
-
}
|
|
224
|
-
const { app_schema, ...others } = appInfo;
|
|
225
|
-
const stdCrudCfgObj = (0, functions_1.parseJsonObject)(app_schema);
|
|
226
|
-
const handleArrayCfg = (arrayCfg) => {
|
|
227
|
-
if (Array.isArray(arrayCfg)) {
|
|
228
|
-
for (let j = 0; j < arrayCfg.length; j++) {
|
|
229
|
-
const actionCfg = arrayCfg[j];
|
|
230
|
-
actionCfg.hasOperationPerm = this.hasOperationPerm(actionCfg);
|
|
231
|
-
if (actionCfg.settingKey) {
|
|
232
|
-
actionsMap[actionCfg.settingKey] = actionCfg;
|
|
233
|
-
}
|
|
234
|
-
const submitButtonCfg = _.get(actionCfg, 'component.props.submitButtonCfg');
|
|
235
|
-
handleArrayCfg(submitButtonCfg);
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
};
|
|
239
|
-
// 为了方便查找到action对象
|
|
240
|
-
const actionsMap = {};
|
|
241
|
-
const keys = Object.keys(stdCrudCfgObj);
|
|
242
|
-
for (let i = 0; i < keys.length; i++) {
|
|
243
|
-
const key = keys[i];
|
|
244
|
-
const arrayCfg = stdCrudCfgObj[key];
|
|
245
|
-
handleArrayCfg(arrayCfg);
|
|
246
|
-
}
|
|
247
|
-
return { ...others, stdCrudCfgObj, actionsMap };
|
|
248
|
-
}
|
|
249
|
-
hasOperationPerm(actionCfg) {
|
|
250
|
-
const permissionCode = _.get(actionCfg, 'permissionCode');
|
|
251
|
-
if (permissionCode) {
|
|
252
|
-
return this.ctx.userSession.isAuthPass(keys_1.KeysOfAuthType.byFuncCode, permissionCode);
|
|
253
|
-
}
|
|
254
|
-
return true; // 无需鉴权
|
|
255
|
-
}
|
|
256
|
-
async fixCfgModelAndParamBySoftDelete(params, cfgModel, appInfo, sqlSimpleName) {
|
|
257
|
-
var _a, _b;
|
|
258
|
-
const stdCrudCfgObj = appInfo.stdCrudCfgObj;
|
|
259
|
-
//删除策略
|
|
260
|
-
const deleteStrategy = _.get(stdCrudCfgObj, 'othersSetting.values.deleteStrategy');
|
|
261
|
-
if (deleteStrategy !== 'soft') {
|
|
262
|
-
return;
|
|
263
|
-
}
|
|
264
|
-
// 删除操作,如果是软删除修改为update语句。
|
|
265
|
-
// 标准软删除:deleted_at 字段为0代表未删除,有任意时间字段代表已删除。
|
|
266
|
-
if (keys_1.KeysOfSimpleSQL.SIMPLE_DELETE === sqlSimpleName) {
|
|
267
|
-
const userSession = (_b = (_a = this.ctx) === null || _a === void 0 ? void 0 : _a.userSession) === null || _b === void 0 ? void 0 : _b.getSessionInfo();
|
|
268
|
-
if (!params.data) {
|
|
269
|
-
params.data = {};
|
|
270
|
-
}
|
|
271
|
-
params.data.deleted_at = Date.now(); // 默认值为 0; 0代表未删除
|
|
272
|
-
params.data.deleted_by = (userSession === null || userSession === void 0 ? void 0 : userSession.accountId) || "";
|
|
273
|
-
// 执行update操作
|
|
274
|
-
cfgModel.sqlSimpleName = keys_1.KeysOfSimpleSQL.SIMPLE_UPDATE;
|
|
275
|
-
if (!params.condition || Object.keys(params.condition).length === 0) {
|
|
276
|
-
throw new Error('执行删除操作,必须指定删除条件');
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
// 查询操作。强制查询未删除的。
|
|
280
|
-
if (keys_1.KeysOfSimpleSQL.SIMPLE_QUERY_ONE === sqlSimpleName || keys_1.KeysOfSimpleSQL.SIMPLE_QUERY_PAGE === sqlSimpleName) {
|
|
281
|
-
if (!params.condition) {
|
|
282
|
-
params.condition = {};
|
|
283
|
-
}
|
|
284
|
-
params.condition.deleted_at = 0; // 未删除
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
async fixCfgModelByFilterValue(params, cfgModel, appInfo, arg3) {
|
|
288
|
-
const { filterValue } = params || {};
|
|
289
|
-
if (!filterValue && filterValue !== 0) {
|
|
290
|
-
return;
|
|
291
|
-
}
|
|
292
|
-
const filterList = _.get(appInfo, 'stdCrudCfgObj.filterList');
|
|
293
|
-
if (!Array.isArray(filterList) || filterList.length === 0) {
|
|
294
|
-
this.logWarn('filterValue存在,但是filterList没有设置');
|
|
295
|
-
return;
|
|
296
|
-
}
|
|
297
|
-
const filterItem = filterList.find(item => item.value === filterValue);
|
|
298
|
-
if (!filterItem) {
|
|
299
|
-
this.logWarn('filterValue存在,但是filterList中没有找到此配置项');
|
|
300
|
-
return;
|
|
301
|
-
}
|
|
302
|
-
const partialCondition = _.get(filterItem, 'partialCondition');
|
|
303
|
-
if (!partialCondition) {
|
|
304
|
-
this.logWarn('filterValue存在,但是filterList中的配置项没有设置partialCondition');
|
|
305
|
-
return;
|
|
306
|
-
}
|
|
307
|
-
const partialConditionObj = (0, functions_1.parseJsonObject)(partialCondition);
|
|
308
|
-
if (Object.keys(partialConditionObj).length > 0) {
|
|
309
|
-
// partialConditionObj 配置的是 condition.xxxx = xx的形式
|
|
310
|
-
_.merge(cfgModel.updateCfg, partialConditionObj);
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
async fixSubmitDataByKeepSubmitData(params, cfgModel, appInfo, arg3) {
|
|
314
|
-
if (cfgModel.sqlSimpleName === keys_1.KeysOfSimpleSQL.SIMPLE_INSERT || cfgModel.sqlSimpleName === keys_1.KeysOfSimpleSQL.SIMPLE_UPDATE) {
|
|
315
|
-
const submitData = params.data || {};
|
|
316
|
-
//1. 按钮中配置的keepSubmitData
|
|
317
|
-
const buttonActionCfg = appInfo.buttonSettingKeyActionCfg || {};
|
|
318
|
-
const keepSubmitDataByButtonStr = _.get(buttonActionCfg, 'keepSubmitData');
|
|
319
|
-
const keepSubmitDataByButton = (0, functions_1.parseJsonObject)(keepSubmitDataByButtonStr);
|
|
320
|
-
//2. 全局配置的keepSubmitData
|
|
321
|
-
const keepSubmitDataByGlobalStr = _.get(appInfo, 'stdCrudCfgObj.othersSetting.values.keepSubmitData');
|
|
322
|
-
const keepSubmitDataByGlobal = (0, functions_1.parseJsonObject)(keepSubmitDataByGlobalStr);
|
|
323
|
-
//3. 合并
|
|
324
|
-
_.merge(submitData, keepSubmitDataByButton);
|
|
325
|
-
_.merge(submitData, keepSubmitDataByGlobal);
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
async fixDataFieldTypeBySqlTableField(params, cfgModel, appInfo, arg3) {
|
|
329
|
-
const tableFields = _.get(appInfo, 'stdCrudCfgObj.tableFields');
|
|
330
|
-
const tableFieldMap = MixinUtils_1.MixinUtils.toMap(tableFields, (e) => {
|
|
331
|
-
return e.fieldIndex;
|
|
332
|
-
});
|
|
333
|
-
if (arg3.dbType === keys_1.SqlDbType.postgres) {
|
|
334
|
-
if (cfgModel.sqlSimpleName === keys_1.KeysOfSimpleSQL.SIMPLE_INSERT || cfgModel.sqlSimpleName === keys_1.KeysOfSimpleSQL.SIMPLE_UPDATE) {
|
|
335
|
-
const data = params.data || {};
|
|
336
|
-
const dataKeys = Object.keys(data);
|
|
337
|
-
for (let index = 0; index < dataKeys.length; index++) {
|
|
338
|
-
const dataKey = dataKeys[index];
|
|
339
|
-
const dataValue = data[dataKey];
|
|
340
|
-
const fieldInfo = tableFieldMap[dataKey];
|
|
341
|
-
const fieldType = ('' + _.get(fieldInfo, 'type')).toUpperCase();
|
|
342
|
-
if (fieldType === 'ARRAY') {
|
|
343
|
-
const dataValueArray = (0, functions_1.parseJsonObject)(dataValue);
|
|
344
|
-
if (Array.isArray(dataValueArray)) {
|
|
345
|
-
data[dataKey] = `{${dataValueArray.map(v => `"${v}"`).join(',')}}`;
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
};
|
|
353
|
-
__decorate([
|
|
354
|
-
(0, core_1.Inject)(),
|
|
355
|
-
__metadata("design:type", Object)
|
|
356
|
-
], CrudStdService.prototype, "ctx", void 0);
|
|
357
|
-
__decorate([
|
|
358
|
-
(0, core_1.Inject)(),
|
|
359
|
-
__metadata("design:type", CurdMixService_1.CurdMixService)
|
|
360
|
-
], CrudStdService.prototype, "curdMixService", void 0);
|
|
361
|
-
__decorate([
|
|
362
|
-
(0, core_1.Inject)(),
|
|
363
|
-
__metadata("design:type", CrudStdActionService_1.CrudStdActionService)
|
|
364
|
-
], CrudStdService.prototype, "crudStdActionService", void 0);
|
|
365
|
-
__decorate([
|
|
366
|
-
(0, core_1.Inject)(),
|
|
367
|
-
__metadata("design:type", CrudStdRelationService_1.CrudStdRelationService)
|
|
368
|
-
], CrudStdService.prototype, "crudStdRelationService", void 0);
|
|
369
|
-
__decorate([
|
|
370
|
-
(0, core_1.Inject)(),
|
|
371
|
-
__metadata("design:type", SysAppService_1.SysAppService)
|
|
372
|
-
], CrudStdService.prototype, "sysAppService", void 0);
|
|
373
|
-
CrudStdService = __decorate([
|
|
374
|
-
(0, core_1.Provide)()
|
|
375
|
-
], CrudStdService);
|
|
376
|
-
exports.CrudStdService = CrudStdService;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.CrudStdService = exports.SPECIAL_SETTING_KEY = void 0;
|
|
13
|
+
/* eslint-disable prettier/prettier */
|
|
14
|
+
const _ = require("lodash");
|
|
15
|
+
const ejs = require("ejs");
|
|
16
|
+
const core_1 = require("@midwayjs/core");
|
|
17
|
+
const CurdMixService_1 = require("../curd/CurdMixService");
|
|
18
|
+
const keys_1 = require("../../libs/crud-pro/models/keys");
|
|
19
|
+
const functions_1 = require("../../libs/utils/functions");
|
|
20
|
+
const devops_1 = require("../../models/devops");
|
|
21
|
+
const CrudStdActionService_1 = require("./CrudStdActionService");
|
|
22
|
+
const CrudStdRelationService_1 = require("./CrudStdRelationService");
|
|
23
|
+
const ApiBaseService_1 = require("../base/ApiBaseService");
|
|
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");
|
|
27
|
+
const SysAppService_1 = require("../../service/SysAppService");
|
|
28
|
+
exports.SPECIAL_SETTING_KEY = {
|
|
29
|
+
QUERY_LIST: 'QUERY_LIST',
|
|
30
|
+
QUERY_ONE: 'QUERY_ONE',
|
|
31
|
+
KANBAN_VIEW_STATUS_UPDATE: 'KANBAN_VIEW_STATUS_UPDATE', // 看板视图中更新状态
|
|
32
|
+
};
|
|
33
|
+
function isNotEmptyStr(str) {
|
|
34
|
+
return typeof str === 'string' && str.trim().length > 0;
|
|
35
|
+
}
|
|
36
|
+
function getExecuteTableNameBySettingKey(appInfo, stdAction, sqlSimpleName) {
|
|
37
|
+
const { settingKey } = stdAction || {};
|
|
38
|
+
const stdCrudCfgObj = appInfo.stdCrudCfgObj;
|
|
39
|
+
const actionsMap = appInfo.actionsMap || {};
|
|
40
|
+
// 操作按钮单独设置了mainTableName字段
|
|
41
|
+
const actionCfg = actionsMap[settingKey];
|
|
42
|
+
if (actionCfg) {
|
|
43
|
+
const mainTableName = _.get(actionCfg, 'component.props.mainTableName');
|
|
44
|
+
if (isNotEmptyStr(mainTableName)) {
|
|
45
|
+
return mainTableName.trim();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
if (sqlSimpleName === keys_1.KeysOfSimpleSQL.SIMPLE_DELETE || sqlSimpleName === keys_1.KeysOfSimpleSQL.SIMPLE_INSERT || sqlSimpleName === keys_1.KeysOfSimpleSQL.SIMPLE_UPDATE) {
|
|
49
|
+
// 全局配置了mainTableName字段
|
|
50
|
+
const globalMainTableName = _.get(stdCrudCfgObj, 'othersSetting.values.globalMainTableName');
|
|
51
|
+
if (isNotEmptyStr(globalMainTableName)) {
|
|
52
|
+
return globalMainTableName.trim();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
// 视图中配置的表。
|
|
56
|
+
return stdCrudCfgObj.tableBaseInfo.tableName;
|
|
57
|
+
}
|
|
58
|
+
let CrudStdService = class CrudStdService extends ApiBaseService_1.ApiBaseService {
|
|
59
|
+
/**
|
|
60
|
+
* 执行普通CRUD
|
|
61
|
+
*/
|
|
62
|
+
async executeStdQuery(stdAction, params, sqlSimpleName) {
|
|
63
|
+
var _a;
|
|
64
|
+
const appCode = stdAction.appCode;
|
|
65
|
+
const appInfo = await this.getParsedCrudStdAppForSettingKey(stdAction);
|
|
66
|
+
const stdCrudCfgObj = appInfo.stdCrudCfgObj;
|
|
67
|
+
if (!appInfo || appInfo.status !== 1) {
|
|
68
|
+
throw new devops_1.BizException('应用不存在或已下线:' + appCode);
|
|
69
|
+
}
|
|
70
|
+
const databaseName = stdCrudCfgObj.tableBaseInfo.databaseName;
|
|
71
|
+
const { dbType, dbName } = (0, DatabaseName_1.parseDatabaseName)(databaseName);
|
|
72
|
+
const cfgModel = {
|
|
73
|
+
sqlDatabase: dbName,
|
|
74
|
+
sqlDbType: dbType,
|
|
75
|
+
sqlTable: getExecuteTableNameBySettingKey(appInfo, stdAction, sqlSimpleName),
|
|
76
|
+
sqlSimpleName,
|
|
77
|
+
updateCfg: {}
|
|
78
|
+
};
|
|
79
|
+
// 接口返回最大值
|
|
80
|
+
const maxLimit = _.get(stdCrudCfgObj, 'othersSetting.values.maxLimit');
|
|
81
|
+
if (typeof maxLimit === 'number' && maxLimit > 0) {
|
|
82
|
+
cfgModel.maxLimit = maxLimit;
|
|
83
|
+
}
|
|
84
|
+
if (!((_a = appInfo.settingKeyActionCfg) === null || _a === void 0 ? void 0 : _a.hasOperationPerm)) {
|
|
85
|
+
throw new devops_1.BizException('没有权限');
|
|
86
|
+
}
|
|
87
|
+
// 软删除操作。
|
|
88
|
+
await this.fixCfgModelAndParamBySoftDelete(params, cfgModel, appInfo, sqlSimpleName);
|
|
89
|
+
// 根据用户配置,设置关联查询的数据信息。
|
|
90
|
+
await this.crudStdRelationService.addCfgModelColumnsRelation(cfgModel, appInfo);
|
|
91
|
+
// 根据FilterValue参数,设置updateCfg
|
|
92
|
+
await this.fixCfgModelByFilterValue(params, cfgModel, appInfo, { dbType, dbName });
|
|
93
|
+
// 根据用户配置的keepSubmitData字段修改提交的数据
|
|
94
|
+
await this.fixSubmitDataByKeepSubmitData(params, cfgModel, appInfo, { dbType, dbName });
|
|
95
|
+
// 根据表结构的数据类型,修正数据类型
|
|
96
|
+
await this.fixDataFieldTypeBySqlTableField(params, cfgModel, appInfo, { dbType, dbName });
|
|
97
|
+
// 业务系统自定义的修改:查询前的查询条件:cfgModel
|
|
98
|
+
await global_config_1.GLOBAL_STATIC_CONFIG.getConfig().bizUpdateCfgModelForCrudStd(params, cfgModel, appInfo, this.ctx);
|
|
99
|
+
const crudExeCtx = await this.curdMixService.executeCrudByCfg(params, cfgModel);
|
|
100
|
+
// 处理结果
|
|
101
|
+
await this.handleResult(stdAction, params, cfgModel, appInfo, crudExeCtx);
|
|
102
|
+
// 业务系统自定义的修改:查询后的返回值。
|
|
103
|
+
await global_config_1.GLOBAL_STATIC_CONFIG.getConfig().bizUpdateExecuteContextForCrudStd(params, cfgModel, appInfo, this.ctx, crudExeCtx);
|
|
104
|
+
return crudExeCtx;
|
|
105
|
+
}
|
|
106
|
+
async handleResult(stdAction, params, cfgModel, appInfo, crudExeCtx) {
|
|
107
|
+
await this.handleResultDataPermissionBySettingKey(stdAction, params, cfgModel, appInfo, crudExeCtx);
|
|
108
|
+
}
|
|
109
|
+
async handleResultDataPermissionBySettingKey(stdAction, params, cfgModel, appInfo, crudExeCtx) {
|
|
110
|
+
const { settingKey } = stdAction || {};
|
|
111
|
+
if (settingKey !== exports.SPECIAL_SETTING_KEY.QUERY_LIST && settingKey !== exports.SPECIAL_SETTING_KEY.QUERY_ONE) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
const rows = crudExeCtx.getResRows();
|
|
115
|
+
if (!Array.isArray(rows)) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
const actionColumns = _.get(appInfo, 'stdCrudCfgObj.actionColumns');
|
|
119
|
+
const checkDataPermissionObjBySettingKey = (record) => {
|
|
120
|
+
var _a, _b;
|
|
121
|
+
const permissionObj = {};
|
|
122
|
+
let count = 0;
|
|
123
|
+
const sessionInfo = ((_b = (_a = this.ctx) === null || _a === void 0 ? void 0 : _a.userSession) === null || _b === void 0 ? void 0 : _b.getSessionInfo()) || {};
|
|
124
|
+
for (let index = 0; index < actionColumns.length; index++) {
|
|
125
|
+
const column = actionColumns[index];
|
|
126
|
+
const rowAuthCfg = (0, functions_1.parseJsonObject)(column.rowAuthCfg);
|
|
127
|
+
if (rowAuthCfg && typeof rowAuthCfg.authByExpress === 'string') {
|
|
128
|
+
const authByExpress = rowAuthCfg.authByExpress.trim();
|
|
129
|
+
if (authByExpress) {
|
|
130
|
+
const authResult = ejs.render(authByExpress, { record, sessionInfo, params, _ });
|
|
131
|
+
permissionObj[column.settingKey] = authResult;
|
|
132
|
+
count++;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
if (count > 0) {
|
|
137
|
+
return permissionObj;
|
|
138
|
+
}
|
|
139
|
+
return null;
|
|
140
|
+
};
|
|
141
|
+
if (Array.isArray(actionColumns) && actionColumns.length > 0) {
|
|
142
|
+
for (let index = 0; index < rows.length; index++) {
|
|
143
|
+
const row = rows[index];
|
|
144
|
+
const dataPermissionObjBySettingKey = checkDataPermissionObjBySettingKey(row);
|
|
145
|
+
if (dataPermissionObjBySettingKey) {
|
|
146
|
+
row['__dataPermissionObjBySettingKey'] = dataPermissionObjBySettingKey;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* 获取appInfo 并且拿到当前settingKey相关的信息
|
|
153
|
+
* @param appCode
|
|
154
|
+
* @param settingKey
|
|
155
|
+
* @private
|
|
156
|
+
*/
|
|
157
|
+
async getParsedCrudStdAppForSettingKey(stdAction) {
|
|
158
|
+
const { appCode, settingKey, buttonSettingKey } = stdAction || {};
|
|
159
|
+
if (!appCode) {
|
|
160
|
+
throw new devops_1.BizException('缺少参数:curdStdAppCode');
|
|
161
|
+
}
|
|
162
|
+
const appInfo = await this.getParsedCrudStdAppInfo(appCode);
|
|
163
|
+
if (!appInfo) {
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
166
|
+
const actionsMap = appInfo.actionsMap;
|
|
167
|
+
const appSchema = appInfo.stdCrudCfgObj;
|
|
168
|
+
// 看板视图中更新状态
|
|
169
|
+
if (settingKey === exports.SPECIAL_SETTING_KEY.KANBAN_VIEW_STATUS_UPDATE) {
|
|
170
|
+
const kanbanAuthSettingValues = _.get(appSchema, 'kanbanAuthSetting.values');
|
|
171
|
+
const { update_auth_type, update_auth_config_by_func_code, update_auth_config_by_role_code } = (kanbanAuthSettingValues || {});
|
|
172
|
+
const authConfig = update_auth_type === 'byFuncCode' ? update_auth_config_by_func_code : update_auth_config_by_role_code;
|
|
173
|
+
const hasOperationPerm = this.ctx.userSession.isAuthPass(update_auth_type, authConfig);
|
|
174
|
+
appInfo.settingKeyActionCfg = { settingKey, hasOperationPerm };
|
|
175
|
+
}
|
|
176
|
+
// 列表查询或详情查询
|
|
177
|
+
else if (settingKey === exports.SPECIAL_SETTING_KEY.QUERY_LIST || settingKey === exports.SPECIAL_SETTING_KEY.QUERY_ONE) {
|
|
178
|
+
const authSettingValues = _.get(appSchema, 'authSetting.values');
|
|
179
|
+
const { auth_type, auth_config_by_func_code, auth_config_by_role_code } = authSettingValues || {};
|
|
180
|
+
const authConfig = auth_type === 'byFuncCode' ? auth_config_by_func_code : auth_config_by_role_code;
|
|
181
|
+
const hasOperationPerm = this.ctx.userSession.isAuthPass(auth_type, authConfig);
|
|
182
|
+
appInfo.settingKeyActionCfg = { settingKey, hasOperationPerm };
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
const actionCfg = actionsMap[settingKey];
|
|
186
|
+
if (!actionCfg) {
|
|
187
|
+
throw new devops_1.BizException('没有找到相关配置:' + JSON.stringify({ appCode, settingKey }));
|
|
188
|
+
}
|
|
189
|
+
const componentNameCfg = _.get(actionCfg, 'component.componentName');
|
|
190
|
+
if (!componentNameCfg) {
|
|
191
|
+
throw new devops_1.BizException('没有配置动作组件:' + JSON.stringify({ appCode, settingKey }));
|
|
192
|
+
}
|
|
193
|
+
appInfo.settingKeyActionCfg = actionCfg;
|
|
194
|
+
}
|
|
195
|
+
if (buttonSettingKey) {
|
|
196
|
+
appInfo.buttonSettingKeyActionCfg = actionsMap[buttonSettingKey];
|
|
197
|
+
}
|
|
198
|
+
return appInfo;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* 执行动作
|
|
202
|
+
* @param stdAction
|
|
203
|
+
* @param params
|
|
204
|
+
*/
|
|
205
|
+
async executeStdActionByReq(stdAction, params) {
|
|
206
|
+
const appInfo = await this.getParsedCrudStdAppForSettingKey(stdAction);
|
|
207
|
+
if (!appInfo || appInfo.status !== 1) {
|
|
208
|
+
throw new devops_1.BizException('应用不存在或已下线:' + stdAction.appCode);
|
|
209
|
+
}
|
|
210
|
+
const actionsMap = appInfo.actionsMap;
|
|
211
|
+
const actionCfg = appInfo.settingKeyActionCfg;
|
|
212
|
+
return this.crudStdActionService.handleStdActionByReq({ appInfo, params, actionsMap, actionCfg });
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* 查询APP信息
|
|
216
|
+
* @param appCode
|
|
217
|
+
* @private
|
|
218
|
+
*/
|
|
219
|
+
async getParsedCrudStdAppInfo(appCode) {
|
|
220
|
+
const appInfo = await this.sysAppService.getSysAppOne(appCode);
|
|
221
|
+
if (!appInfo) {
|
|
222
|
+
return null;
|
|
223
|
+
}
|
|
224
|
+
const { app_schema, ...others } = appInfo;
|
|
225
|
+
const stdCrudCfgObj = (0, functions_1.parseJsonObject)(app_schema);
|
|
226
|
+
const handleArrayCfg = (arrayCfg) => {
|
|
227
|
+
if (Array.isArray(arrayCfg)) {
|
|
228
|
+
for (let j = 0; j < arrayCfg.length; j++) {
|
|
229
|
+
const actionCfg = arrayCfg[j];
|
|
230
|
+
actionCfg.hasOperationPerm = this.hasOperationPerm(actionCfg);
|
|
231
|
+
if (actionCfg.settingKey) {
|
|
232
|
+
actionsMap[actionCfg.settingKey] = actionCfg;
|
|
233
|
+
}
|
|
234
|
+
const submitButtonCfg = _.get(actionCfg, 'component.props.submitButtonCfg');
|
|
235
|
+
handleArrayCfg(submitButtonCfg);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
// 为了方便查找到action对象
|
|
240
|
+
const actionsMap = {};
|
|
241
|
+
const keys = Object.keys(stdCrudCfgObj);
|
|
242
|
+
for (let i = 0; i < keys.length; i++) {
|
|
243
|
+
const key = keys[i];
|
|
244
|
+
const arrayCfg = stdCrudCfgObj[key];
|
|
245
|
+
handleArrayCfg(arrayCfg);
|
|
246
|
+
}
|
|
247
|
+
return { ...others, stdCrudCfgObj, actionsMap };
|
|
248
|
+
}
|
|
249
|
+
hasOperationPerm(actionCfg) {
|
|
250
|
+
const permissionCode = _.get(actionCfg, 'permissionCode');
|
|
251
|
+
if (permissionCode) {
|
|
252
|
+
return this.ctx.userSession.isAuthPass(keys_1.KeysOfAuthType.byFuncCode, permissionCode);
|
|
253
|
+
}
|
|
254
|
+
return true; // 无需鉴权
|
|
255
|
+
}
|
|
256
|
+
async fixCfgModelAndParamBySoftDelete(params, cfgModel, appInfo, sqlSimpleName) {
|
|
257
|
+
var _a, _b;
|
|
258
|
+
const stdCrudCfgObj = appInfo.stdCrudCfgObj;
|
|
259
|
+
//删除策略
|
|
260
|
+
const deleteStrategy = _.get(stdCrudCfgObj, 'othersSetting.values.deleteStrategy');
|
|
261
|
+
if (deleteStrategy !== 'soft') {
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
// 删除操作,如果是软删除修改为update语句。
|
|
265
|
+
// 标准软删除:deleted_at 字段为0代表未删除,有任意时间字段代表已删除。
|
|
266
|
+
if (keys_1.KeysOfSimpleSQL.SIMPLE_DELETE === sqlSimpleName) {
|
|
267
|
+
const userSession = (_b = (_a = this.ctx) === null || _a === void 0 ? void 0 : _a.userSession) === null || _b === void 0 ? void 0 : _b.getSessionInfo();
|
|
268
|
+
if (!params.data) {
|
|
269
|
+
params.data = {};
|
|
270
|
+
}
|
|
271
|
+
params.data.deleted_at = Date.now(); // 默认值为 0; 0代表未删除
|
|
272
|
+
params.data.deleted_by = (userSession === null || userSession === void 0 ? void 0 : userSession.accountId) || "";
|
|
273
|
+
// 执行update操作
|
|
274
|
+
cfgModel.sqlSimpleName = keys_1.KeysOfSimpleSQL.SIMPLE_UPDATE;
|
|
275
|
+
if (!params.condition || Object.keys(params.condition).length === 0) {
|
|
276
|
+
throw new Error('执行删除操作,必须指定删除条件');
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
// 查询操作。强制查询未删除的。
|
|
280
|
+
if (keys_1.KeysOfSimpleSQL.SIMPLE_QUERY_ONE === sqlSimpleName || keys_1.KeysOfSimpleSQL.SIMPLE_QUERY_PAGE === sqlSimpleName) {
|
|
281
|
+
if (!params.condition) {
|
|
282
|
+
params.condition = {};
|
|
283
|
+
}
|
|
284
|
+
params.condition.deleted_at = 0; // 未删除
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
async fixCfgModelByFilterValue(params, cfgModel, appInfo, arg3) {
|
|
288
|
+
const { filterValue } = params || {};
|
|
289
|
+
if (!filterValue && filterValue !== 0) {
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
292
|
+
const filterList = _.get(appInfo, 'stdCrudCfgObj.filterList');
|
|
293
|
+
if (!Array.isArray(filterList) || filterList.length === 0) {
|
|
294
|
+
this.logWarn('filterValue存在,但是filterList没有设置');
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
const filterItem = filterList.find(item => item.value === filterValue);
|
|
298
|
+
if (!filterItem) {
|
|
299
|
+
this.logWarn('filterValue存在,但是filterList中没有找到此配置项');
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
const partialCondition = _.get(filterItem, 'partialCondition');
|
|
303
|
+
if (!partialCondition) {
|
|
304
|
+
this.logWarn('filterValue存在,但是filterList中的配置项没有设置partialCondition');
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
const partialConditionObj = (0, functions_1.parseJsonObject)(partialCondition);
|
|
308
|
+
if (Object.keys(partialConditionObj).length > 0) {
|
|
309
|
+
// partialConditionObj 配置的是 condition.xxxx = xx的形式
|
|
310
|
+
_.merge(cfgModel.updateCfg, partialConditionObj);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
async fixSubmitDataByKeepSubmitData(params, cfgModel, appInfo, arg3) {
|
|
314
|
+
if (cfgModel.sqlSimpleName === keys_1.KeysOfSimpleSQL.SIMPLE_INSERT || cfgModel.sqlSimpleName === keys_1.KeysOfSimpleSQL.SIMPLE_UPDATE) {
|
|
315
|
+
const submitData = params.data || {};
|
|
316
|
+
//1. 按钮中配置的keepSubmitData
|
|
317
|
+
const buttonActionCfg = appInfo.buttonSettingKeyActionCfg || {};
|
|
318
|
+
const keepSubmitDataByButtonStr = _.get(buttonActionCfg, 'keepSubmitData');
|
|
319
|
+
const keepSubmitDataByButton = (0, functions_1.parseJsonObject)(keepSubmitDataByButtonStr);
|
|
320
|
+
//2. 全局配置的keepSubmitData
|
|
321
|
+
const keepSubmitDataByGlobalStr = _.get(appInfo, 'stdCrudCfgObj.othersSetting.values.keepSubmitData');
|
|
322
|
+
const keepSubmitDataByGlobal = (0, functions_1.parseJsonObject)(keepSubmitDataByGlobalStr);
|
|
323
|
+
//3. 合并
|
|
324
|
+
_.merge(submitData, keepSubmitDataByButton);
|
|
325
|
+
_.merge(submitData, keepSubmitDataByGlobal);
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
async fixDataFieldTypeBySqlTableField(params, cfgModel, appInfo, arg3) {
|
|
329
|
+
const tableFields = _.get(appInfo, 'stdCrudCfgObj.tableFields');
|
|
330
|
+
const tableFieldMap = MixinUtils_1.MixinUtils.toMap(tableFields, (e) => {
|
|
331
|
+
return e.fieldIndex;
|
|
332
|
+
});
|
|
333
|
+
if (arg3.dbType === keys_1.SqlDbType.postgres) {
|
|
334
|
+
if (cfgModel.sqlSimpleName === keys_1.KeysOfSimpleSQL.SIMPLE_INSERT || cfgModel.sqlSimpleName === keys_1.KeysOfSimpleSQL.SIMPLE_UPDATE) {
|
|
335
|
+
const data = params.data || {};
|
|
336
|
+
const dataKeys = Object.keys(data);
|
|
337
|
+
for (let index = 0; index < dataKeys.length; index++) {
|
|
338
|
+
const dataKey = dataKeys[index];
|
|
339
|
+
const dataValue = data[dataKey];
|
|
340
|
+
const fieldInfo = tableFieldMap[dataKey];
|
|
341
|
+
const fieldType = ('' + _.get(fieldInfo, 'type')).toUpperCase();
|
|
342
|
+
if (fieldType === 'ARRAY') {
|
|
343
|
+
const dataValueArray = (0, functions_1.parseJsonObject)(dataValue);
|
|
344
|
+
if (Array.isArray(dataValueArray)) {
|
|
345
|
+
data[dataKey] = `{${dataValueArray.map(v => `"${v}"`).join(',')}}`;
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
};
|
|
353
|
+
__decorate([
|
|
354
|
+
(0, core_1.Inject)(),
|
|
355
|
+
__metadata("design:type", Object)
|
|
356
|
+
], CrudStdService.prototype, "ctx", void 0);
|
|
357
|
+
__decorate([
|
|
358
|
+
(0, core_1.Inject)(),
|
|
359
|
+
__metadata("design:type", CurdMixService_1.CurdMixService)
|
|
360
|
+
], CrudStdService.prototype, "curdMixService", void 0);
|
|
361
|
+
__decorate([
|
|
362
|
+
(0, core_1.Inject)(),
|
|
363
|
+
__metadata("design:type", CrudStdActionService_1.CrudStdActionService)
|
|
364
|
+
], CrudStdService.prototype, "crudStdActionService", void 0);
|
|
365
|
+
__decorate([
|
|
366
|
+
(0, core_1.Inject)(),
|
|
367
|
+
__metadata("design:type", CrudStdRelationService_1.CrudStdRelationService)
|
|
368
|
+
], CrudStdService.prototype, "crudStdRelationService", void 0);
|
|
369
|
+
__decorate([
|
|
370
|
+
(0, core_1.Inject)(),
|
|
371
|
+
__metadata("design:type", SysAppService_1.SysAppService)
|
|
372
|
+
], CrudStdService.prototype, "sysAppService", void 0);
|
|
373
|
+
CrudStdService = __decorate([
|
|
374
|
+
(0, core_1.Provide)()
|
|
375
|
+
], CrudStdService);
|
|
376
|
+
exports.CrudStdService = CrudStdService;
|