midway-fatcms 0.0.1-beta.55 → 0.0.1-beta.56
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 +160 -160
- 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 +37 -37
- package/dist/controller/base/BaseApiController.js +164 -164
- 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 -119
- package/dist/controller/gateway/CrudStdGatewayController.d.ts +38 -38
- package/dist/controller/gateway/CrudStdGatewayController.js +129 -129
- package/dist/controller/gateway/DocGatewayController.d.ts +27 -27
- package/dist/controller/gateway/DocGatewayController.js +179 -179
- package/dist/controller/gateway/FileController.d.ts +26 -26
- package/dist/controller/gateway/FileController.js +129 -129
- package/dist/controller/gateway/ProxyApiGatewayController.d.ts +18 -18
- package/dist/controller/gateway/ProxyApiGatewayController.js +78 -78
- package/dist/controller/gateway/PublicApiController.d.ts +27 -27
- package/dist/controller/gateway/PublicApiController.js +162 -162
- 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 +10 -10
- package/dist/controller/manage/AppMangeApi.js +88 -88
- 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 +395 -395
- package/dist/controller/manage/DataDictManageApi.d.ts +15 -15
- package/dist/controller/manage/DataDictManageApi.js +133 -133
- 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 +11 -11
- package/dist/controller/manage/SysConfigMangeApi.js +126 -126
- package/dist/controller/manage/SystemInfoManageApi.d.ts +12 -12
- package/dist/controller/manage/SystemInfoManageApi.js +72 -72
- package/dist/controller/manage/UserAccountManageApi.d.ts +14 -14
- package/dist/controller/manage/UserAccountManageApi.js +129 -129
- package/dist/controller/manage/WorkbenchMangeApi.d.ts +11 -11
- package/dist/controller/manage/WorkbenchMangeApi.js +103 -103
- package/dist/controller/myinfo/AuthController.d.ts +33 -33
- package/dist/controller/myinfo/AuthController.js +136 -136
- package/dist/controller/myinfo/MyInfoController.d.ts +13 -13
- package/dist/controller/myinfo/MyInfoController.js +51 -51
- package/dist/controller/render/AppRenderController.d.ts +11 -11
- package/dist/controller/render/AppRenderController.js +92 -92
- 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 +103 -103
- package/dist/index.js +121 -121
- package/dist/interface.d.ts +27 -27
- package/dist/interface.js +3 -3
- package/dist/libs/crud-pro/CrudPro.d.ts +37 -37
- package/dist/libs/crud-pro/CrudPro.js +136 -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 +104 -104
- package/dist/libs/crud-pro/exceptions.js +117 -117
- package/dist/libs/crud-pro/interfaces.d.ts +163 -163
- package/dist/libs/crud-pro/interfaces.js +12 -12
- package/dist/libs/crud-pro/models/ExecuteContext.d.ts +49 -49
- package/dist/libs/crud-pro/models/ExecuteContext.js +79 -79
- 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 +16 -16
- 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 +22 -22
- 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 +30 -30
- package/dist/libs/crud-pro/models/Transaction.js +74 -74
- package/dist/libs/crud-pro/models/TransactionMySQL.d.ts +28 -28
- package/dist/libs/crud-pro/models/TransactionMySQL.js +76 -76
- package/dist/libs/crud-pro/models/TransactionPostgres.d.ts +28 -28
- package/dist/libs/crud-pro/models/TransactionPostgres.js +85 -85
- package/dist/libs/crud-pro/models/TransactionSqlServer.d.ts +34 -34
- package/dist/libs/crud-pro/models/TransactionSqlServer.js +92 -92
- package/dist/libs/crud-pro/models/keys.d.ts +106 -106
- package/dist/libs/crud-pro/models/keys.js +149 -149
- 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 +112 -112
- package/dist/libs/crud-pro/services/CrudProExecuteSqlService.d.ts +17 -17
- package/dist/libs/crud-pro/services/CrudProExecuteSqlService.js +225 -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 +340 -340
- 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 +334 -334
- package/dist/libs/crud-pro/services/CrudProServiceBase.d.ts +24 -24
- package/dist/libs/crud-pro/services/CrudProServiceBase.js +90 -90
- 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/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 +39 -39
- package/dist/libs/crud-pro/utils/MixinUtils.js +255 -255
- package/dist/libs/crud-pro/utils/ModelUtils.d.ts +11 -11
- package/dist/libs/crud-pro/utils/ModelUtils.js +49 -49
- 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 +21 -21
- package/dist/libs/crud-pro/utils/sqlConvert/convertMix.d.ts +3 -3
- package/dist/libs/crud-pro/utils/sqlConvert/convertMix.js +22 -22
- package/dist/libs/crud-pro/utils/sqlConvert/convertMsSql.d.ts +2 -2
- package/dist/libs/crud-pro/utils/sqlConvert/convertMsSql.js +11 -11
- package/dist/libs/crud-pro/utils/sqlConvert/convertPgSql.d.ts +2 -2
- package/dist/libs/crud-pro/utils/sqlConvert/convertPgSql.js +11 -11
- package/dist/libs/crud-pro/utils/sqlConvert/convertPgType.d.ts +2 -2
- package/dist/libs/crud-pro/utils/sqlConvert/convertPgType.js +128 -128
- package/dist/libs/global-config/global-config.d.ts +69 -60
- package/dist/libs/global-config/global-config.js +36 -35
- 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/functions.d.ts +5 -5
- package/dist/libs/utils/functions.js +72 -72
- 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 +7 -7
- package/dist/libs/utils/parseConfig.js +44 -44
- 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 +28 -28
- package/dist/libs/utils/render-utils.js +135 -135
- 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 +266 -266
- 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 +105 -105
- package/dist/models/SystemEntities.js +9 -9
- 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/bizmodels.d.ts +99 -99
- package/dist/models/bizmodels.js +39 -39
- package/dist/models/contextLogger.d.ts +25 -25
- package/dist/models/contextLogger.js +112 -112
- package/dist/models/devops.d.ts +12 -12
- package/dist/models/devops.js +19 -19
- package/dist/models/userSession.d.ts +62 -62
- package/dist/models/userSession.js +165 -165
- package/dist/schedule/anonymousContext.d.ts +14 -14
- package/dist/schedule/anonymousContext.js +59 -59
- 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 +13 -13
- package/dist/schedule/scheduleNames.js +17 -17
- package/dist/service/AuthService.d.ts +71 -71
- package/dist/service/AuthService.js +259 -259
- package/dist/service/EnumInfoService.d.ts +30 -30
- package/dist/service/EnumInfoService.js +127 -127
- package/dist/service/FileCenterService.d.ts +43 -43
- package/dist/service/FileCenterService.js +351 -351
- package/dist/service/SysConfigService.d.ts +7 -7
- package/dist/service/SysConfigService.js +47 -47
- package/dist/service/UserAccountService.d.ts +23 -23
- package/dist/service/UserAccountService.js +107 -107
- package/dist/service/UserSessionService.d.ts +38 -38
- package/dist/service/UserSessionService.js +157 -157
- package/dist/service/VisitStatService.d.ts +14 -14
- package/dist/service/VisitStatService.js +158 -158
- package/dist/service/WorkbenchService.d.ts +53 -53
- package/dist/service/WorkbenchService.js +211 -211
- 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/RedisCacheService.d.ts +20 -20
- package/dist/service/base/RedisCacheService.js +57 -57
- 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 +112 -112
- package/dist/service/crudstd/CrudStdService.d.ts +68 -68
- package/dist/service/crudstd/CrudStdService.js +347 -347
- package/dist/service/curd/CrudProQuick.d.ts +44 -44
- package/dist/service/curd/CrudProQuick.js +147 -147
- package/dist/service/curd/CurdMixByAccountService.d.ts +9 -9
- package/dist/service/curd/CurdMixByAccountService.js +92 -92
- package/dist/service/curd/CurdMixByDictService.d.ts +13 -13
- package/dist/service/curd/CurdMixByDictService.js +114 -114
- package/dist/service/curd/CurdMixByLinkToCustomService.d.ts +31 -31
- package/dist/service/curd/CurdMixByLinkToCustomService.js +203 -203
- package/dist/service/curd/CurdMixBySysConfigService.d.ts +9 -9
- package/dist/service/curd/CurdMixBySysConfigService.js +80 -80
- package/dist/service/curd/CurdMixByWorkbenchService.d.ts +10 -10
- package/dist/service/curd/CurdMixByWorkbenchService.js +78 -78
- package/dist/service/curd/CurdMixService.d.ts +28 -28
- package/dist/service/curd/CurdMixService.js +100 -100
- package/dist/service/curd/CurdMixUtils.d.ts +51 -51
- package/dist/service/curd/CurdMixUtils.js +277 -277
- 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 -81
- package/src/config/config.default.ts +179 -0
- package/src/config/seed/aeskey.txt +1 -0
- package/src/config/utils.ts +22 -0
- package/src/configuration.ts +109 -0
- package/src/controller/base/BaseApiController.ts +170 -0
- package/src/controller/gateway/AnyApiGatewayController.ts +1 -0
- package/src/controller/gateway/AsyncTaskController.ts +157 -0
- package/src/controller/gateway/CrudMtdGatewayController.ts +116 -0
- package/src/controller/gateway/CrudStdGatewayController.ts +87 -0
- package/src/controller/gateway/DocGatewayController.ts +173 -0
- package/src/controller/gateway/FileController.ts +109 -0
- package/src/controller/gateway/ProxyApiGatewayController.ts +47 -0
- package/src/controller/gateway/PublicApiController.ts +140 -0
- package/src/controller/gateway/StaticController.ts +296 -0
- package/src/controller/helpers.controller.ts +161 -0
- package/src/controller/home.controller.ts +66 -0
- package/src/controller/manage/AnyApiMangeApi.ts +66 -0
- package/src/controller/manage/AppLogMangeApi.ts +53 -0
- package/src/controller/manage/AppMangeApi.ts +53 -0
- package/src/controller/manage/AppPageMangeApi.ts +52 -0
- package/src/controller/manage/AppSchemaHistoryApi.ts +49 -0
- package/src/controller/manage/CrudMethodsMangeApi.ts +49 -0
- package/src/controller/manage/CrudStandardDesignApi.ts +406 -0
- package/src/controller/manage/DataDictManageApi.ts +78 -0
- package/src/controller/manage/DeployManageApi.ts +175 -0
- package/src/controller/manage/DocLibManageApi.ts +69 -0
- package/src/controller/manage/DocManageApi.ts +99 -0
- package/src/controller/manage/FileManageApi.ts +45 -0
- package/src/controller/manage/LowCodeTplManageApi.ts +52 -0
- package/src/controller/manage/MenuManageApi.ts +58 -0
- package/src/controller/manage/ProxyApiMangeApi.ts +52 -0
- package/src/controller/manage/SuperAdminManageApi.ts +139 -0
- package/src/controller/manage/SysConfigMangeApi.ts +95 -0
- package/src/controller/manage/SystemInfoManageApi.ts +53 -0
- package/src/controller/manage/UserAccountManageApi.ts +94 -0
- package/src/controller/manage/WorkbenchMangeApi.ts +72 -0
- package/src/controller/myinfo/AuthController.ts +108 -0
- package/src/controller/myinfo/MyInfoController.ts +32 -0
- package/src/controller/render/AppRenderController.ts +81 -0
- package/src/controller/test.controller.ts +37 -0
- package/src/filter/default.filter.ts +13 -0
- package/src/filter/notfound.filter.ts +10 -0
- package/src/index.ts +107 -0
- package/src/interface.ts +31 -0
- package/src/libs/crud-pro/CrudPro.ts +165 -0
- package/src/libs/crud-pro/defaultConfigs.ts +15 -0
- package/src/libs/crud-pro/exceptions.ts +124 -0
- package/src/libs/crud-pro/interfaces.ts +190 -0
- package/src/libs/crud-pro/models/ExecuteContext.ts +120 -0
- package/src/libs/crud-pro/models/ExecuteContextFunc.ts +96 -0
- package/src/libs/crud-pro/models/FuncContext.ts +21 -0
- package/src/libs/crud-pro/models/RequestCfgModel.ts +141 -0
- package/src/libs/crud-pro/models/RequestModel.ts +141 -0
- package/src/libs/crud-pro/models/ResModel.ts +19 -0
- package/src/libs/crud-pro/models/ServiceHub.ts +32 -0
- package/src/libs/crud-pro/models/SqlCfgModel.ts +52 -0
- package/src/libs/crud-pro/models/SqlSegArg.ts +13 -0
- package/src/libs/crud-pro/models/Transaction.ts +83 -0
- package/src/libs/crud-pro/models/TransactionMySQL.ts +79 -0
- package/src/libs/crud-pro/models/TransactionPostgres.ts +91 -0
- package/src/libs/crud-pro/models/TransactionSqlServer.ts +102 -0
- package/src/libs/crud-pro/models/keys.ts +159 -0
- package/src/libs/crud-pro/services/CrudProCachedCfgService.ts +83 -0
- package/src/libs/crud-pro/services/CrudProExecuteFuncService.ts +128 -0
- package/src/libs/crud-pro/services/CrudProExecuteSqlService.ts +262 -0
- package/src/libs/crud-pro/services/CrudProFieldUpdateService.ts +60 -0
- package/src/libs/crud-pro/services/CrudProFieldValidateService.ts +180 -0
- package/src/libs/crud-pro/services/CrudProGenSqlCondition.ts +354 -0
- package/src/libs/crud-pro/services/CrudProGenSqlService.ts +185 -0
- package/src/libs/crud-pro/services/CrudProOriginToExecuteSql.ts +393 -0
- package/src/libs/crud-pro/services/CrudProServiceBase.ts +107 -0
- package/src/libs/crud-pro/services/CrudProTableMetaService.ts +86 -0
- package/src/libs/crud-pro/services/CurdProServiceHub.ts +92 -0
- package/src/libs/crud-pro/sql.txt +120 -0
- package/src/libs/crud-pro/utils/CompareUtils.ts +23 -0
- package/src/libs/crud-pro/utils/DatabaseName.ts +60 -0
- package/src/libs/crud-pro/utils/DateTimeUtils.ts +20 -0
- package/src/libs/crud-pro/utils/MemoryRefreshCache.ts +64 -0
- package/src/libs/crud-pro/utils/MessageParseUtils.ts +33 -0
- package/src/libs/crud-pro/utils/MixinUtils.ts +285 -0
- package/src/libs/crud-pro/utils/ModelUtils.ts +55 -0
- package/src/libs/crud-pro/utils/MultiKeyMap.ts +72 -0
- package/src/libs/crud-pro/utils/SqlFuncUtils.ts +29 -0
- package/src/libs/crud-pro/utils/TypeUtils.ts +188 -0
- package/src/libs/crud-pro/utils/ValidateUtils.ts +165 -0
- package/src/libs/crud-pro/utils/pool/MySQLUtils.ts +20 -0
- package/src/libs/crud-pro/utils/pool/PostgresUtils.ts +22 -0
- package/src/libs/crud-pro/utils/pool/SqlServerUtils.ts +22 -0
- package/src/libs/crud-pro/utils/sqlConvert/convertColumnName.ts +26 -0
- package/src/libs/crud-pro/utils/sqlConvert/convertMix.ts +26 -0
- package/src/libs/crud-pro/utils/sqlConvert/convertMsSql.ts +11 -0
- package/src/libs/crud-pro/utils/sqlConvert/convertPgSql.ts +11 -0
- package/src/libs/crud-pro/utils/sqlConvert/convertPgType.ts +129 -0
- package/src/libs/global-config/global-config.ts +109 -0
- package/src/libs/utils/base64.ts +47 -0
- package/src/libs/utils/common-dto.ts +52 -0
- package/src/libs/utils/crypto-utils.ts +50 -0
- package/src/libs/utils/errorToString.ts +61 -0
- package/src/libs/utils/fatcms-request.ts +103 -0
- package/src/libs/utils/functions.ts +78 -0
- package/src/libs/utils/ordernum-utils.ts +14 -0
- package/src/libs/utils/parseConfig.ts +54 -0
- package/src/libs/utils/parseCreateSql.ts +91 -0
- package/src/libs/utils/render-utils.ts +184 -0
- package/src/middleware/forbidden.middleware.ts +52 -0
- package/src/middleware/global.middleware.ts +293 -0
- package/src/middleware/permission.middleware.ts +80 -0
- package/src/middleware/rediscache.middleware.ts +91 -0
- package/src/middleware/redislock.middleware.ts +83 -0
- package/src/middleware/tx.middleware.ts +30 -0
- package/src/models/AsyncTaskModel.ts +85 -0
- package/src/models/RedisKeys.ts +16 -0
- package/src/models/SystemEntities.ts +125 -0
- package/src/models/SystemPerm.ts +105 -0
- package/src/models/SystemTables.ts +27 -0
- package/src/models/bizmodels.ts +123 -0
- package/src/models/contextLogger.ts +132 -0
- package/src/models/devops.ts +17 -0
- package/src/models/userSession.ts +217 -0
- package/src/schedule/anonymousContext.ts +73 -0
- package/src/schedule/index.ts +12 -0
- package/src/schedule/runSchedule.ts +82 -0
- package/src/schedule/scheduleNames.ts +21 -0
- package/src/service/AuthService.ts +284 -0
- package/src/service/EnumInfoService.ts +130 -0
- package/src/service/FileCenterService.ts +395 -0
- package/src/service/SysConfigService.ts +37 -0
- package/src/service/UserAccountService.ts +107 -0
- package/src/service/UserSessionService.ts +161 -0
- package/src/service/VisitStatService.ts +166 -0
- package/src/service/WorkbenchService.ts +220 -0
- package/src/service/anyapi/AnyApiSandboxService.ts +121 -0
- package/src/service/anyapi/AnyApiService.ts +186 -0
- package/src/service/asyncTask/AsyncTaskRunnerService.ts +325 -0
- package/src/service/asyncTask/AsyncTaskService.ts +21 -0
- package/src/service/asyncTask/handler/ExcelInfoModel.ts +11 -0
- package/src/service/asyncTask/handler/ExportExcelAsyncTaskHandler.ts +245 -0
- package/src/service/asyncTask/handler/ExportExcelByInnerHttpHandler.ts +159 -0
- package/src/service/asyncTask/handler/ExportExcelByStdCrudHandler.ts +159 -0
- package/src/service/base/ApiBaseService.ts +42 -0
- package/src/service/base/ApiRateLimiter.ts +59 -0
- package/src/service/base/BaseService.ts +100 -0
- package/src/service/base/RedisCacheService.ts +45 -0
- package/src/service/crudstd/CrudStdActionService.ts +27 -0
- package/src/service/crudstd/CrudStdConstant.ts +62 -0
- package/src/service/crudstd/CrudStdRelationService.ts +118 -0
- package/src/service/crudstd/CrudStdService.ts +420 -0
- package/src/service/curd/CrudProQuick.ts +172 -0
- package/src/service/curd/CurdMixByAccountService.ts +89 -0
- package/src/service/curd/CurdMixByDictService.ts +114 -0
- package/src/service/curd/CurdMixByLinkToCustomService.ts +219 -0
- package/src/service/curd/CurdMixBySysConfigService.ts +78 -0
- package/src/service/curd/CurdMixByWorkbenchService.ts +71 -0
- package/src/service/curd/CurdMixService.ts +97 -0
- package/src/service/curd/CurdMixUtils.ts +316 -0
- package/src/service/curd/CurdProService.ts +231 -0
- package/src/service/curd/fixCfgModel.ts +120 -0
- package/src/service/proxyapi/ProxyApiLoadService.ts +174 -0
- package/src/service/proxyapi/ProxyApiService.ts +298 -0
- package/src/service/proxyapi/ProxyApiUtils.ts +32 -0
- package/src/service/proxyapi/RouteHandler.ts +8 -0
- package/src/service/proxyapi/RouteTrie.ts +74 -0
- package/src/service/proxyapi/WeightedRandom.ts +37 -0
- package/src/service/proxyapi/WeightedRoundRobin.ts +44 -0
- package/src/views/404_app.html +31 -0
- package/src/views/404_workbench.html +34 -0
- package/src/views/static/favicon.ico +0 -0
- package/tsconfig.json +32 -32
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { PoolClient, Pool } from 'pg';
|
|
2
|
+
import { IConnectionPool } from '../interfaces';
|
|
3
|
+
|
|
4
|
+
async function beginTransaction(connection: PoolClient) {
|
|
5
|
+
return await connection.query('BEGIN');
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
async function commit(connection: PoolClient) {
|
|
9
|
+
return await connection.query('COMMIT');
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async function rollback(connection: PoolClient) {
|
|
13
|
+
return await connection.query('ROLLBACK');
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
class TransactionPostgres {
|
|
17
|
+
private isBeginTransaction = false;
|
|
18
|
+
private connectionMap: Record<string, PoolClient> = {};
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* 获取链接对象
|
|
22
|
+
* @param pool
|
|
23
|
+
*/
|
|
24
|
+
public async getTxConnection(pool: IConnectionPool): Promise<PoolClient> {
|
|
25
|
+
let connection = this.connectionMap[pool.poolName];
|
|
26
|
+
if (!connection) {
|
|
27
|
+
const poolInstance: Pool = pool.poolInstance as any;
|
|
28
|
+
connection = await poolInstance.connect();
|
|
29
|
+
this.connectionMap[pool.poolName] = connection;
|
|
30
|
+
// 开启了事务
|
|
31
|
+
if (this.isBeginTransaction) {
|
|
32
|
+
await beginTransaction(connection);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return connection;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* 开始事务
|
|
40
|
+
*/
|
|
41
|
+
public beginTx() {
|
|
42
|
+
this.isBeginTransaction = true;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* 提交事务
|
|
47
|
+
*/
|
|
48
|
+
public async commitTx() {
|
|
49
|
+
if (!this.isBeginTransaction) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
const connections = Object.values(this.connectionMap);
|
|
53
|
+
for (let i = 0; i < connections.length; i++) {
|
|
54
|
+
const connection = connections[i];
|
|
55
|
+
await commit(connection);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* 事务回滚
|
|
61
|
+
*/
|
|
62
|
+
public async rollbackTx() {
|
|
63
|
+
if (!this.isBeginTransaction) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const connections = Object.values(this.connectionMap);
|
|
67
|
+
for (let i = 0; i < connections.length; i++) {
|
|
68
|
+
const connection = connections[i];
|
|
69
|
+
await rollback(connection);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* 释放连接
|
|
75
|
+
*/
|
|
76
|
+
public async releaseTx() {
|
|
77
|
+
// 不管有没有开启事务,都要释放连接。
|
|
78
|
+
const connections = Object.values(this.connectionMap);
|
|
79
|
+
for (let i = 0; i < connections.length; i++) {
|
|
80
|
+
const connection = connections[i];
|
|
81
|
+
try {
|
|
82
|
+
await connection.release();
|
|
83
|
+
} catch (e) {
|
|
84
|
+
console.error(e);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
this.connectionMap = {};
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export { TransactionPostgres };
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { ConnectionPool, Request, Transaction } from 'mssql';
|
|
2
|
+
import { IConnectionPool, IPoolConnectionClient } from '../interfaces';
|
|
3
|
+
|
|
4
|
+
interface ISqlServerConnection extends IPoolConnectionClient {
|
|
5
|
+
originConnection: ConnectionPool;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
class TransactionSqlServer {
|
|
9
|
+
private isBeginTransaction = false;
|
|
10
|
+
private connectionMap: Record<string, ISqlServerConnection> = {};
|
|
11
|
+
private transactionMap: Record<string, Transaction> = {};
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* 获取链接对象
|
|
15
|
+
* @param pool
|
|
16
|
+
*/
|
|
17
|
+
public async getTxConnection(pool: IConnectionPool): Promise<ISqlServerConnection> {
|
|
18
|
+
let connection = this.connectionMap[pool.poolName];
|
|
19
|
+
if (!connection) {
|
|
20
|
+
connection = await this.connectAndCreateConnection(pool);
|
|
21
|
+
this.connectionMap[pool.poolName] = connection;
|
|
22
|
+
|
|
23
|
+
// 开启了事务
|
|
24
|
+
if (this.isBeginTransaction) {
|
|
25
|
+
await this.beginTransaction(pool.poolName);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return connection;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
private async connectAndCreateConnection(pool: IConnectionPool): Promise<ISqlServerConnection> {
|
|
32
|
+
const poolInstance: ConnectionPool = pool.poolInstance as any;
|
|
33
|
+
const originConnection = await poolInstance.connect();
|
|
34
|
+
return {
|
|
35
|
+
originConnection,
|
|
36
|
+
query: (sql: string, values: any): Promise<any> => {
|
|
37
|
+
const request = new Request(originConnection);
|
|
38
|
+
if (Array.isArray(values)) {
|
|
39
|
+
for (let i = 0; i < values.length; i++) {
|
|
40
|
+
const index = i + 1;
|
|
41
|
+
const value = values[i];
|
|
42
|
+
request.input(`fatcms_ms${index}`, value);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return request.query(sql);
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* 开始事务
|
|
52
|
+
*/
|
|
53
|
+
public beginTx() {
|
|
54
|
+
this.isBeginTransaction = true;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* 提交事务
|
|
59
|
+
*/
|
|
60
|
+
public async commitTx() {
|
|
61
|
+
if (!this.isBeginTransaction) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const transactions = Object.values(this.transactionMap);
|
|
65
|
+
for (let i = 0; i < transactions.length; i++) {
|
|
66
|
+
const tmpTx = transactions[i];
|
|
67
|
+
await tmpTx.commit();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* 事务回滚
|
|
73
|
+
*/
|
|
74
|
+
public async rollbackTx() {
|
|
75
|
+
if (!this.isBeginTransaction) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const transactions = Object.values(this.transactionMap);
|
|
79
|
+
for (let i = 0; i < transactions.length; i++) {
|
|
80
|
+
const tmpTx = transactions[i];
|
|
81
|
+
await tmpTx.rollback();
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* 释放连接
|
|
87
|
+
*/
|
|
88
|
+
public async releaseTx() {
|
|
89
|
+
this.connectionMap = {};
|
|
90
|
+
this.transactionMap = {};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
private async beginTransaction(poolName: string) {
|
|
94
|
+
const connection = this.connectionMap[poolName];
|
|
95
|
+
const originConnection: ConnectionPool = connection.originConnection;
|
|
96
|
+
const tmpTx = new Transaction(originConnection);
|
|
97
|
+
this.transactionMap[poolName] = tmpTx;
|
|
98
|
+
return await tmpTx.begin();
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export { TransactionSqlServer };
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
export enum SqlDbType {
|
|
2
|
+
mysql = 'mysql',
|
|
3
|
+
postgres = 'postgres',
|
|
4
|
+
sqlserver = 'sqlserver', //微软 SQL Server
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export enum KeysOfFunCtx {
|
|
8
|
+
FUNC_CTX = '$',
|
|
9
|
+
CURRENT_VALUE = '$current',
|
|
10
|
+
VISITOR = 'visitor',
|
|
11
|
+
VISITOR_ATTR = 'visitor.',
|
|
12
|
+
REQUEST = 'req.',
|
|
13
|
+
RESULT = 'res.',
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
//鉴权类型;free无需鉴权,login仅登录即可,byRoleCode校验角色,byFuncCode校验功能点
|
|
17
|
+
export enum KeysOfAuthType {
|
|
18
|
+
free = 'free', // 无需任何校验
|
|
19
|
+
login = 'login', // 仅仅登录即可
|
|
20
|
+
byRoleCode = 'byRoleCode', // 根据角色校验
|
|
21
|
+
byFuncCode = 'byFuncCode', // 根据功能点校验
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export enum KeysOfValidators {
|
|
25
|
+
REQUIRED = 'required',
|
|
26
|
+
BOOLEAN = 'boolean', // 布尔值类型
|
|
27
|
+
OBJECT = 'object', // 普通对象类型类型
|
|
28
|
+
ARRAY = 'array', // 数组
|
|
29
|
+
ARRAY_STRING = 'array:string', // 数组
|
|
30
|
+
ARRAY_NUMBER = 'array:number', // 数组
|
|
31
|
+
STRING = 'string', // 字符串类型
|
|
32
|
+
EMAIL = 'email',
|
|
33
|
+
NAME = 'name', //必须以字母开头,只能包含:字母/数字/下划线
|
|
34
|
+
PHONE_CN = 'phone:cn', // 中国手机号:11位
|
|
35
|
+
INTEGER = 'integer', // long,int,short,bigInteger
|
|
36
|
+
NUMBER = 'number', // long,int,short,float,double
|
|
37
|
+
NUMERIC = 'numeric', //long,int,short,float,double或只包含数字的字符串
|
|
38
|
+
MOMENT = 'moment:', // moment:YYYY-MM-DD HH:mm:ss 时间日期格式校验
|
|
39
|
+
SCALE = 'scale:', // 判断参数是否位于这个区间:scale:[1,3] ; scale:(1,3) ; scale:(1,3] ;
|
|
40
|
+
LENGTH = 'length:', // length:1,5 ; length >=1 and length <=5
|
|
41
|
+
REG_EXP = 'regexp:', // regexp:[a-zA-Z-_.]
|
|
42
|
+
ENUM = 'enum:', // enum : 1,2,3,4,5,6,aa,bb,cc :比较时用字符串比较
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export enum KeyOfCrudTypes {
|
|
46
|
+
SELECT = 'SELECT',
|
|
47
|
+
UPDATE = 'UPDATE',
|
|
48
|
+
INSERT = 'INSERT',
|
|
49
|
+
DELETE = 'DELETE',
|
|
50
|
+
NOT_CRUD = 'NOT_CRUD',
|
|
51
|
+
EMPTY_SQL = 'EMPTY_SQL',
|
|
52
|
+
SYS_QUERY = 'SYS_QUERY',
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export enum KeysOfSimpleSQL {
|
|
56
|
+
SIMPLE_QUERY = 'SIMPLE_QUERY', // select * from xx where @condition limit 100,
|
|
57
|
+
SIMPLE_QUERY_ONE = 'SIMPLE_QUERY_ONE', //只查询一条 select * from xx where @condition limit 1,
|
|
58
|
+
SIMPLE_QUERY_PAGE = 'SIMPLE_QUERY_PAGE', //分页查询 select * from xx where @condition limit 100 offset 100,
|
|
59
|
+
SIMPLE_QUERY_COUNT = 'SIMPLE_QUERY_COUNT', //查询数量 select count(0) as totalCount from xx where @condition,
|
|
60
|
+
SIMPLE_UPDATE = 'SIMPLE_UPDATE', // update xx set @data where @condition limit 1
|
|
61
|
+
SIMPLE_INSERT = 'SIMPLE_INSERT', // insert into xx values @datas
|
|
62
|
+
SIMPLE_DELETE = 'SIMPLE_DELETE', // delete from xx values where @condition limit 1
|
|
63
|
+
SIMPLE_INSERT_ON_DUPLICATE_UPDATE = 'SIMPLE_INSERT_ON_DUPLICATE_UPDATE',
|
|
64
|
+
SIMPLE_INSERT_OR_UPDATE = 'SIMPLE_INSERT_OR_UPDATE',
|
|
65
|
+
CUSTOM = 'CUSTOM',
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export enum KeysOfSqlResPicker {
|
|
69
|
+
UPDATE_RESULT = 'UPDATE_RESULT', // update/insert/delete 产生影响的结果
|
|
70
|
+
RESULT_FIRST_ROW = 'RESULT_FIRST_ROW', // $ResultSet[0], 只取第一行的数据返回。返回JSONObject
|
|
71
|
+
RESULT_TOTAL_COUNT = 'RESULT_TOTAL_COUNT', // $ResultSet[0].total_count , 只取第一行的的total_count。返回long
|
|
72
|
+
RESULT_ONE_VALUE = 'RESULT_ONE_VALUE', // $ResultSet[0].total_count , 只取第一行的的total_count。返回long
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export const KeysOfCustomSQL = {
|
|
76
|
+
SQL_COLUMNS: '@@columns',
|
|
77
|
+
SQL_TABLE: '@@table', // 只有简单查询才能用得到
|
|
78
|
+
SQL_OFFSET_LIMIT: '@@offsetLimit',
|
|
79
|
+
SQL_ORDER_BYS: '@@orderBys',
|
|
80
|
+
|
|
81
|
+
SQL_AS_WHERE: '@@asWhere:', // @@asWhere:condition , @@asWhere:condition_zhangsan
|
|
82
|
+
SQL_AS_UPDATE: '@@asUpdate:', // @@asUpdate:data, @@asWhere:data_zhangsan
|
|
83
|
+
SQL_AS_INSERT_KEYS: '@@asInsertKeys:', // @@asInsertKeys:data, @@asInsertKeys:data_zhangsan
|
|
84
|
+
SQL_AS_INSERT_VALUES: '@@asInsertValues:', // @@asInsertValues:data, @@asInsertValues:data_zhangsan
|
|
85
|
+
|
|
86
|
+
// 从Req中取值:单独取Data中的某个字段:获取单个值。
|
|
87
|
+
SQL_GET_DATA_ATTR_START: '@@data', // // select * from fa_lang_faq where id = @@data.id
|
|
88
|
+
SQL_GET_CONDITION_ATTR_START: '@@condition', // select * from fa_lang_faq where id = @@condition.id
|
|
89
|
+
|
|
90
|
+
// 从Res中取值
|
|
91
|
+
SQL_PICK_RES_AS_NUMBER: '@@pickResAsNumber:', // select * from fa_lang_faq where id = @@pickResAsNumber:rows[0].id
|
|
92
|
+
SQL_PICK_RES_AS_STRING: '@@pickResAsString:', // select * from fa_lang_faq where lang_code = @@pickResAsString:row.lang_code
|
|
93
|
+
|
|
94
|
+
// 使用java函数:获取单个值
|
|
95
|
+
SQL_FUNCTION: '@@function:', // @@function:aaa
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* 查询条件中允许出现的关键词
|
|
100
|
+
* 与MongoDB的语法完全一致
|
|
101
|
+
*/
|
|
102
|
+
export const KeysOfConditions = {
|
|
103
|
+
$OR: '$or', //或
|
|
104
|
+
|
|
105
|
+
$NE: '$ne', //不等于
|
|
106
|
+
$LT: '$lt', //小于
|
|
107
|
+
$LTE: '$lte', //小于或等于
|
|
108
|
+
$GT: '$gt', //大于
|
|
109
|
+
$GTE: '$gte', //大于或等于
|
|
110
|
+
$IN: '$in', //in
|
|
111
|
+
$NIN: '$nin', // not in
|
|
112
|
+
$NOT_NULL: '$notNull', // is not null
|
|
113
|
+
$NULL: '$null', // is null
|
|
114
|
+
$RANGE: '$range', // between 1 and 2
|
|
115
|
+
$LIKE: '$like', // A% 以A开头 {age:1, name:{"$like":"张"} }
|
|
116
|
+
$NOT_LIKE: '$notLike', // A% 以A开头 {age:1, name:{"$notLike":"张"} }
|
|
117
|
+
|
|
118
|
+
$LIKE_INCLUDE: '$likeInclude', // %A% 包含A {age:1, name:{"$like":"张"} }
|
|
119
|
+
$NOT_LIKE_INCLUDE: '$notLikeInclude', // %A% 包含A {age:1, name:{"$notLike":"张"} }
|
|
120
|
+
|
|
121
|
+
$MATCH: '$match', // 全文索引 {age:1, name:{"$match":"张"} }
|
|
122
|
+
$MATCH_BOOL: '$matchBool', // 全文索引 {age:1, name:{"$matchBool":"张"} }
|
|
123
|
+
|
|
124
|
+
COMPARE_KEYS: new Set<string>([]),
|
|
125
|
+
ALL_KEYS: new Set<string>([]),
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
function initKeysOfConditions() {
|
|
129
|
+
const addIgnoreCase = (keys: Set<string>, key: string) => {
|
|
130
|
+
keys.add(key);
|
|
131
|
+
keys.add(key.toUpperCase());
|
|
132
|
+
keys.add(key.toLowerCase());
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
// 比较操作符, 支持忽略大小写
|
|
136
|
+
KeysOfConditions.COMPARE_KEYS = new Set([]);
|
|
137
|
+
addIgnoreCase(KeysOfConditions.COMPARE_KEYS, KeysOfConditions.$NE);
|
|
138
|
+
addIgnoreCase(KeysOfConditions.COMPARE_KEYS, KeysOfConditions.$LT);
|
|
139
|
+
addIgnoreCase(KeysOfConditions.COMPARE_KEYS, KeysOfConditions.$LTE);
|
|
140
|
+
addIgnoreCase(KeysOfConditions.COMPARE_KEYS, KeysOfConditions.$GT);
|
|
141
|
+
addIgnoreCase(KeysOfConditions.COMPARE_KEYS, KeysOfConditions.$GTE);
|
|
142
|
+
addIgnoreCase(KeysOfConditions.COMPARE_KEYS, KeysOfConditions.$IN);
|
|
143
|
+
addIgnoreCase(KeysOfConditions.COMPARE_KEYS, KeysOfConditions.$NIN);
|
|
144
|
+
addIgnoreCase(KeysOfConditions.COMPARE_KEYS, KeysOfConditions.$LIKE);
|
|
145
|
+
addIgnoreCase(KeysOfConditions.COMPARE_KEYS, KeysOfConditions.$LIKE_INCLUDE);
|
|
146
|
+
addIgnoreCase(KeysOfConditions.COMPARE_KEYS, KeysOfConditions.$NOT_LIKE);
|
|
147
|
+
addIgnoreCase(KeysOfConditions.COMPARE_KEYS, KeysOfConditions.$NOT_LIKE_INCLUDE);
|
|
148
|
+
addIgnoreCase(KeysOfConditions.COMPARE_KEYS, KeysOfConditions.$MATCH);
|
|
149
|
+
addIgnoreCase(KeysOfConditions.COMPARE_KEYS, KeysOfConditions.$MATCH_BOOL);
|
|
150
|
+
addIgnoreCase(KeysOfConditions.COMPARE_KEYS, KeysOfConditions.$RANGE);
|
|
151
|
+
addIgnoreCase(KeysOfConditions.COMPARE_KEYS, KeysOfConditions.$NULL);
|
|
152
|
+
addIgnoreCase(KeysOfConditions.COMPARE_KEYS, KeysOfConditions.$NOT_NULL);
|
|
153
|
+
|
|
154
|
+
// 所有操作符
|
|
155
|
+
KeysOfConditions.ALL_KEYS = new Set([...KeysOfConditions.COMPARE_KEYS]);
|
|
156
|
+
addIgnoreCase(KeysOfConditions.ALL_KEYS, KeysOfConditions.$OR);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
initKeysOfConditions();
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { camelizeKeys } from 'humps';
|
|
2
|
+
import { CrudProServiceBase } from './CrudProServiceBase';
|
|
3
|
+
import { IRequestCfgModel } from '../interfaces';
|
|
4
|
+
import { MixinUtils } from '../utils/MixinUtils';
|
|
5
|
+
import { ICurdProServiceHub } from '../models/ServiceHub';
|
|
6
|
+
import { pickAndConvertRowsByMix } from '../utils/sqlConvert/convertMix';
|
|
7
|
+
import MemoryRefreshCache from '../utils/MemoryRefreshCache';
|
|
8
|
+
|
|
9
|
+
const methodCache = new MemoryRefreshCache();
|
|
10
|
+
|
|
11
|
+
function parseMethodInfo(methodInfo: any): any {
|
|
12
|
+
const row: any = camelizeKeys(methodInfo as object); //转换成驼峰
|
|
13
|
+
const configObject = MixinUtils.parseJsonObject(row.moreConfig) || {};
|
|
14
|
+
const sqlCfgList = MixinUtils.parseJsonObject(row.sqlCfgList) || [];
|
|
15
|
+
return { ...configObject, ...row, sqlCfgList };
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
class CrudProCachedCfgService extends CrudProServiceBase {
|
|
19
|
+
constructor(serviceHub: ICurdProServiceHub) {
|
|
20
|
+
super(serviceHub);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
public async getCachedCfgByMethod(method: string, isEnableCache: boolean): Promise<IRequestCfgModel | null> {
|
|
24
|
+
const methodInfo = await this.getCachedCfgByMethodInner(method, isEnableCache);
|
|
25
|
+
if (!methodInfo) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
return { ...methodInfo };
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
private async getCachedCfgByMethodInner(method: string, isEnableCache: boolean): Promise<IRequestCfgModel | null> {
|
|
32
|
+
// 不使用缓存
|
|
33
|
+
if (!isEnableCache) {
|
|
34
|
+
return await this.loadMethodInfo(method);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
methodCache.setProps({
|
|
38
|
+
keepTime: 1000 * 60 * 2, // 2分钟
|
|
39
|
+
requestFn: () => this.loadMethodInfoList(),
|
|
40
|
+
getKeyFn: item => item.method,
|
|
41
|
+
});
|
|
42
|
+
const methodInfo = await methodCache.getItem(method);
|
|
43
|
+
if (methodInfo) {
|
|
44
|
+
return methodInfo;
|
|
45
|
+
}
|
|
46
|
+
return await this.loadMethodInfo(method);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
private async loadMethodInfo(method: string): Promise<any> {
|
|
50
|
+
const { methodsTableName, sysDatabaseName, sysDatabaseDbType } = this.getContextCfg();
|
|
51
|
+
const sql = `select * from ${methodsTableName} where method = ? `; // 全部加载到内存
|
|
52
|
+
|
|
53
|
+
const baseInfo = {
|
|
54
|
+
sqlTable: methodsTableName,
|
|
55
|
+
sqlDatabase: sysDatabaseName,
|
|
56
|
+
sqlDbType: sysDatabaseDbType,
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const queryRes = await this.executeUnsafeQuery(baseInfo, sql, [method]);
|
|
60
|
+
const rows2: any[] = pickAndConvertRowsByMix(queryRes, sysDatabaseDbType);
|
|
61
|
+
if (rows2.length > 0) {
|
|
62
|
+
return parseMethodInfo(rows2[0]);
|
|
63
|
+
}
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
private async loadMethodInfoList(): Promise<any[]> {
|
|
68
|
+
const { methodsTableName, sysDatabaseName, sysDatabaseDbType } = this.getContextCfg();
|
|
69
|
+
const sql = `select * from ${methodsTableName}`; // 全部加载到内存
|
|
70
|
+
const baseInfo = {
|
|
71
|
+
sqlTable: methodsTableName,
|
|
72
|
+
sqlDatabase: sysDatabaseName,
|
|
73
|
+
sqlDbType: sysDatabaseDbType,
|
|
74
|
+
};
|
|
75
|
+
const queryRes = await this.executeUnsafeQuery(baseInfo, sql);
|
|
76
|
+
const rows2: any[] = pickAndConvertRowsByMix(queryRes, sysDatabaseDbType);
|
|
77
|
+
return rows2.map(row => {
|
|
78
|
+
return parseMethodInfo(row);
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export { CrudProCachedCfgService };
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { CrudProServiceBase } from './CrudProServiceBase';
|
|
2
|
+
import { IFuncCfgModel, IFunctionParam } from '../interfaces';
|
|
3
|
+
import { FuncContext } from '../models/FuncContext';
|
|
4
|
+
import { TypeUtils } from '../utils/TypeUtils';
|
|
5
|
+
import { MixinUtils } from '../utils/MixinUtils';
|
|
6
|
+
import * as _ from 'lodash';
|
|
7
|
+
import { CommonException, Exceptions } from '../exceptions';
|
|
8
|
+
import { KeysOfFunCtx } from '../models/keys';
|
|
9
|
+
|
|
10
|
+
const { isNil, isNumeric } = TypeUtils;
|
|
11
|
+
const { isEmpty } = MixinUtils;
|
|
12
|
+
|
|
13
|
+
function isNotNil(obj: any): boolean {
|
|
14
|
+
return !isNil(obj);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
class CrudProExecuteFuncService extends CrudProServiceBase {
|
|
18
|
+
executeFuncCfg(funCfg: IFuncCfgModel, funcContext: FuncContext) {
|
|
19
|
+
if (isNil(funCfg)) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (funCfg.___PLAIN_OBJECT___ === true) {
|
|
24
|
+
return funCfg;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (isNotNil(funCfg.const)) {
|
|
28
|
+
return funCfg.const;
|
|
29
|
+
}
|
|
30
|
+
if (isNotNil(funCfg.constString)) {
|
|
31
|
+
return '' + funCfg.constString;
|
|
32
|
+
}
|
|
33
|
+
if (isNotNil(funCfg.constNumber) && isNumeric(funCfg.constNumber)) {
|
|
34
|
+
return Number(funCfg.constNumber);
|
|
35
|
+
}
|
|
36
|
+
if (isNotNil(funCfg.constBool)) {
|
|
37
|
+
return Boolean(funCfg.constBool);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (isNotNil(funCfg.context)) {
|
|
41
|
+
return this.pickContextValue(funCfg.context, funcContext);
|
|
42
|
+
}
|
|
43
|
+
if (isNotNil(funCfg.contextAsString)) {
|
|
44
|
+
return '' + this.pickContextValue(funCfg.contextAsString, funcContext);
|
|
45
|
+
}
|
|
46
|
+
if (isNotNil(funCfg.contextAsNumber)) {
|
|
47
|
+
return Number(this.pickContextValue(funCfg.contextAsNumber, funcContext));
|
|
48
|
+
}
|
|
49
|
+
if (isNotNil(funCfg.contextAsBool)) {
|
|
50
|
+
return Boolean(this.pickContextValue(funCfg.contextAsBool, funcContext));
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (isNotNil(funCfg.functionName)) {
|
|
54
|
+
const func = this.getExecuteFunction(funCfg.functionName);
|
|
55
|
+
if (!func) {
|
|
56
|
+
throw new CommonException(Exceptions.RUN_FUNCTION_NOT_FOUND, funCfg.functionName);
|
|
57
|
+
}
|
|
58
|
+
const functionParamValues = this.getFunctionParamValues(funCfg.functionParams, funcContext);
|
|
59
|
+
return func.apply(funcContext, functionParamValues);
|
|
60
|
+
}
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
private pickContextValue(pickString: string, funcCtx: FuncContext) {
|
|
65
|
+
if (!pickString) {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (pickString === KeysOfFunCtx.FUNC_CTX) {
|
|
70
|
+
return funcCtx;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (pickString === KeysOfFunCtx.CURRENT_VALUE) {
|
|
74
|
+
return funcCtx.currentValue;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// 例如:accountId, 访问此变量,用户必须登录。
|
|
78
|
+
if (pickString.startsWith(KeysOfFunCtx.VISITOR_ATTR)) {
|
|
79
|
+
const reqModel = funcCtx?.reqModel;
|
|
80
|
+
const attrValue = _.get(reqModel, pickString); // visitor.nickName
|
|
81
|
+
if (isNil(attrValue)) {
|
|
82
|
+
throw new CommonException(Exceptions.RUN_PICK_ERR_VISITOR_NULL, '获取用户ID失败, 可能用户没有登陆');
|
|
83
|
+
}
|
|
84
|
+
return attrValue;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// 例如:accountId, 访问此变量,用户必须登录。
|
|
88
|
+
if (pickString === KeysOfFunCtx.VISITOR) {
|
|
89
|
+
const visitor = funcCtx?.reqModel?.visitor;
|
|
90
|
+
if (isNil(visitor)) {
|
|
91
|
+
throw new CommonException(Exceptions.RUN_PICK_ERR_VISITOR_NULL, '获取用户对象失败, 可能用户没有登陆');
|
|
92
|
+
}
|
|
93
|
+
return visitor;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// 例如: req.data.name
|
|
97
|
+
if (pickString.startsWith(KeysOfFunCtx.REQUEST)) {
|
|
98
|
+
const reqExpress = pickString.substring(KeysOfFunCtx.REQUEST.length);
|
|
99
|
+
return _.get(funcCtx.reqModel, reqExpress);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// 例如: res.total_count
|
|
103
|
+
if (pickString.startsWith(KeysOfFunCtx.RESULT)) {
|
|
104
|
+
const reqExpress = pickString.substring(KeysOfFunCtx.RESULT.length);
|
|
105
|
+
return _.get(funcCtx.resModel, reqExpress);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
private getFunctionParamValues(functionParams: IFunctionParam[], funcContext: FuncContext): any[] {
|
|
112
|
+
if (isNil(functionParams) || isEmpty(functionParams)) {
|
|
113
|
+
return [];
|
|
114
|
+
}
|
|
115
|
+
return functionParams.map(p => {
|
|
116
|
+
if (typeof p === 'undefined' || p === null) {
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (typeof p === 'string' || typeof p === 'number' || typeof p === 'boolean') {
|
|
121
|
+
return p;
|
|
122
|
+
}
|
|
123
|
+
return this.executeFuncCfg(p, funcContext);
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export { CrudProExecuteFuncService };
|