midway-fatcms 0.0.1-beta.1
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/README.md +1 -0
- package/dist/config/config.default.d.ts +3 -0
- package/dist/config/config.default.js +148 -0
- package/dist/config/seed/aeskey.txt +1 -0
- package/dist/config/utils.d.ts +1 -0
- package/dist/config/utils.js +23 -0
- package/dist/configuration.d.ts +6 -0
- package/dist/configuration.js +89 -0
- package/dist/controller/base/BaseApiController.d.ts +31 -0
- package/dist/controller/base/BaseApiController.js +138 -0
- package/dist/controller/gateway/AnyApiGatewayController.d.ts +13 -0
- package/dist/controller/gateway/AnyApiGatewayController.js +55 -0
- package/dist/controller/gateway/CrudMtdGatewayController.d.ts +21 -0
- package/dist/controller/gateway/CrudMtdGatewayController.js +116 -0
- package/dist/controller/gateway/CrudStdGatewayController.d.ts +38 -0
- package/dist/controller/gateway/CrudStdGatewayController.js +137 -0
- package/dist/controller/gateway/DocGatewayController.d.ts +27 -0
- package/dist/controller/gateway/DocGatewayController.js +174 -0
- package/dist/controller/gateway/FileController.d.ts +25 -0
- package/dist/controller/gateway/FileController.js +129 -0
- package/dist/controller/gateway/ProxyApiGatewayController.d.ts +18 -0
- package/dist/controller/gateway/ProxyApiGatewayController.js +78 -0
- package/dist/controller/gateway/PublicApiController.d.ts +27 -0
- package/dist/controller/gateway/PublicApiController.js +167 -0
- package/dist/controller/gateway/StaticController.d.ts +21 -0
- package/dist/controller/gateway/StaticController.js +265 -0
- package/dist/controller/helpers.controller.d.ts +39 -0
- package/dist/controller/helpers.controller.js +188 -0
- package/dist/controller/home.controller.d.ts +9 -0
- package/dist/controller/home.controller.js +71 -0
- package/dist/controller/manage/AnyApiMangeApi.d.ts +10 -0
- package/dist/controller/manage/AnyApiMangeApi.js +98 -0
- package/dist/controller/manage/AppLogMangeApi.d.ts +10 -0
- package/dist/controller/manage/AppLogMangeApi.js +88 -0
- package/dist/controller/manage/AppMangeApi.d.ts +10 -0
- package/dist/controller/manage/AppMangeApi.js +88 -0
- package/dist/controller/manage/AppPageMangeApi.d.ts +10 -0
- package/dist/controller/manage/AppPageMangeApi.js +87 -0
- package/dist/controller/manage/AppSchemaHistoryApi.d.ts +10 -0
- package/dist/controller/manage/AppSchemaHistoryApi.js +83 -0
- package/dist/controller/manage/CrudMethodsMangeApi.d.ts +10 -0
- package/dist/controller/manage/CrudMethodsMangeApi.js +84 -0
- package/dist/controller/manage/CrudStandardDesignApi.d.ts +38 -0
- package/dist/controller/manage/CrudStandardDesignApi.js +339 -0
- package/dist/controller/manage/DataDictManageApi.d.ts +15 -0
- package/dist/controller/manage/DataDictManageApi.js +133 -0
- package/dist/controller/manage/DeployManageApi.d.ts +19 -0
- package/dist/controller/manage/DeployManageApi.js +176 -0
- package/dist/controller/manage/DocLibManageApi.d.ts +10 -0
- package/dist/controller/manage/DocLibManageApi.js +104 -0
- package/dist/controller/manage/DocManageApi.d.ts +11 -0
- package/dist/controller/manage/DocManageApi.js +130 -0
- package/dist/controller/manage/FileManageApi.d.ts +13 -0
- package/dist/controller/manage/FileManageApi.js +77 -0
- package/dist/controller/manage/LowCodeTplManageApi.d.ts +13 -0
- package/dist/controller/manage/LowCodeTplManageApi.js +86 -0
- package/dist/controller/manage/MenuManageApi.d.ts +10 -0
- package/dist/controller/manage/MenuManageApi.js +93 -0
- package/dist/controller/manage/ProxyApiMangeApi.d.ts +10 -0
- package/dist/controller/manage/ProxyApiMangeApi.js +87 -0
- package/dist/controller/manage/SuperAdminManageApi.d.ts +24 -0
- package/dist/controller/manage/SuperAdminManageApi.js +149 -0
- package/dist/controller/manage/SysConfigMangeApi.d.ts +11 -0
- package/dist/controller/manage/SysConfigMangeApi.js +124 -0
- package/dist/controller/manage/SystemInfoManageApi.d.ts +12 -0
- package/dist/controller/manage/SystemInfoManageApi.js +66 -0
- package/dist/controller/manage/UserAccountManageApi.d.ts +14 -0
- package/dist/controller/manage/UserAccountManageApi.js +124 -0
- package/dist/controller/manage/WorkbenchMangeApi.d.ts +11 -0
- package/dist/controller/manage/WorkbenchMangeApi.js +103 -0
- package/dist/controller/medstatistic/MedAdminController.d.ts +35 -0
- package/dist/controller/medstatistic/MedAdminController.js +205 -0
- package/dist/controller/medstatistic/MedClientController.d.ts +28 -0
- package/dist/controller/medstatistic/MedClientController.js +188 -0
- package/dist/controller/medstatistic/MedMessageService.d.ts +19 -0
- package/dist/controller/medstatistic/MedMessageService.js +95 -0
- package/dist/controller/medstatistic/MedScoreService.d.ts +21 -0
- package/dist/controller/medstatistic/MedScoreService.js +107 -0
- package/dist/controller/medstatistic/constants.d.ts +32 -0
- package/dist/controller/medstatistic/constants.js +43 -0
- package/dist/controller/myinfo/AuthController.d.ts +37 -0
- package/dist/controller/myinfo/AuthController.js +189 -0
- package/dist/controller/myinfo/MyInfoController.d.ts +13 -0
- package/dist/controller/myinfo/MyInfoController.js +51 -0
- package/dist/controller/render/AppRenderController.d.ts +11 -0
- package/dist/controller/render/AppRenderController.js +85 -0
- package/dist/controller/test.controller.d.ts +8 -0
- package/dist/controller/test.controller.js +51 -0
- package/dist/filter/default.filter.d.ts +7 -0
- package/dist/filter/default.filter.js +23 -0
- package/dist/filter/notfound.filter.d.ts +5 -0
- package/dist/filter/notfound.filter.js +20 -0
- package/dist/index.d.ts +70 -0
- package/dist/index.js +88 -0
- package/dist/interface.d.ts +27 -0
- package/dist/interface.js +3 -0
- package/dist/libs/crud-pro/CrudPro.d.ts +36 -0
- package/dist/libs/crud-pro/CrudPro.js +131 -0
- package/dist/libs/crud-pro/defaultConfigs.d.ts +4 -0
- package/dist/libs/crud-pro/defaultConfigs.js +13 -0
- package/dist/libs/crud-pro/exceptions.d.ts +104 -0
- package/dist/libs/crud-pro/exceptions.js +117 -0
- package/dist/libs/crud-pro/interfaces.d.ts +157 -0
- package/dist/libs/crud-pro/interfaces.js +12 -0
- package/dist/libs/crud-pro/models/ExecuteContext.d.ts +42 -0
- package/dist/libs/crud-pro/models/ExecuteContext.js +79 -0
- package/dist/libs/crud-pro/models/ExecuteContextFunc.d.ts +31 -0
- package/dist/libs/crud-pro/models/ExecuteContextFunc.js +64 -0
- package/dist/libs/crud-pro/models/FuncContext.d.ts +18 -0
- package/dist/libs/crud-pro/models/FuncContext.js +6 -0
- package/dist/libs/crud-pro/models/RequestCfgModel.d.ts +65 -0
- package/dist/libs/crud-pro/models/RequestCfgModel.js +81 -0
- package/dist/libs/crud-pro/models/RequestModel.d.ts +25 -0
- package/dist/libs/crud-pro/models/RequestModel.js +113 -0
- package/dist/libs/crud-pro/models/ServiceHub.d.ts +20 -0
- package/dist/libs/crud-pro/models/ServiceHub.js +2 -0
- package/dist/libs/crud-pro/models/SqlCfgModel.d.ts +22 -0
- package/dist/libs/crud-pro/models/SqlCfgModel.js +40 -0
- package/dist/libs/crud-pro/models/SqlSegArg.d.ts +6 -0
- package/dist/libs/crud-pro/models/SqlSegArg.js +12 -0
- package/dist/libs/crud-pro/models/Transaction.d.ts +29 -0
- package/dist/libs/crud-pro/models/Transaction.js +67 -0
- package/dist/libs/crud-pro/models/TransactionMySQL.d.ts +28 -0
- package/dist/libs/crud-pro/models/TransactionMySQL.js +76 -0
- package/dist/libs/crud-pro/models/TransactionPostgres.d.ts +28 -0
- package/dist/libs/crud-pro/models/TransactionPostgres.js +85 -0
- package/dist/libs/crud-pro/models/TransactionSqlServer.d.ts +34 -0
- package/dist/libs/crud-pro/models/TransactionSqlServer.js +92 -0
- package/dist/libs/crud-pro/models/keys.d.ts +106 -0
- package/dist/libs/crud-pro/models/keys.js +149 -0
- package/dist/libs/crud-pro/services/CrudProCachedCfgService.d.ts +10 -0
- package/dist/libs/crud-pro/services/CrudProCachedCfgService.js +61 -0
- package/dist/libs/crud-pro/services/CrudProExecuteFuncService.d.ts +9 -0
- package/dist/libs/crud-pro/services/CrudProExecuteFuncService.js +112 -0
- package/dist/libs/crud-pro/services/CrudProExecuteSqlService.d.ts +17 -0
- package/dist/libs/crud-pro/services/CrudProExecuteSqlService.js +227 -0
- package/dist/libs/crud-pro/services/CrudProFieldUpdateService.d.ts +9 -0
- package/dist/libs/crud-pro/services/CrudProFieldUpdateService.js +51 -0
- package/dist/libs/crud-pro/services/CrudProFieldValidateService.d.ts +13 -0
- package/dist/libs/crud-pro/services/CrudProFieldValidateService.js +148 -0
- package/dist/libs/crud-pro/services/CrudProGenSqlCondition.d.ts +24 -0
- package/dist/libs/crud-pro/services/CrudProGenSqlCondition.js +342 -0
- package/dist/libs/crud-pro/services/CrudProGenSqlService.d.ts +25 -0
- package/dist/libs/crud-pro/services/CrudProGenSqlService.js +174 -0
- package/dist/libs/crud-pro/services/CrudProOriginToExecuteSql.d.ts +32 -0
- package/dist/libs/crud-pro/services/CrudProOriginToExecuteSql.js +333 -0
- package/dist/libs/crud-pro/services/CrudProServiceBase.d.ts +28 -0
- package/dist/libs/crud-pro/services/CrudProServiceBase.js +78 -0
- package/dist/libs/crud-pro/services/CrudProTableMetaService.d.ts +8 -0
- package/dist/libs/crud-pro/services/CrudProTableMetaService.js +53 -0
- package/dist/libs/crud-pro/services/CurdProServiceHub.d.ts +32 -0
- package/dist/libs/crud-pro/services/CurdProServiceHub.js +64 -0
- package/dist/libs/crud-pro/sql.txt +120 -0
- package/dist/libs/crud-pro/utils/CompareUtils.d.ts +9 -0
- package/dist/libs/crud-pro/utils/CompareUtils.js +25 -0
- package/dist/libs/crud-pro/utils/DatabaseName.d.ts +9 -0
- package/dist/libs/crud-pro/utils/DatabaseName.js +29 -0
- package/dist/libs/crud-pro/utils/DateTimeUtils.d.ts +7 -0
- package/dist/libs/crud-pro/utils/DateTimeUtils.js +21 -0
- package/dist/libs/crud-pro/utils/MemoryRefreshCache.d.ts +19 -0
- package/dist/libs/crud-pro/utils/MemoryRefreshCache.js +47 -0
- package/dist/libs/crud-pro/utils/MessageParseUtils.d.ts +5 -0
- package/dist/libs/crud-pro/utils/MessageParseUtils.js +33 -0
- package/dist/libs/crud-pro/utils/MixinUtils.d.ts +39 -0
- package/dist/libs/crud-pro/utils/MixinUtils.js +255 -0
- package/dist/libs/crud-pro/utils/ModelUtils.d.ts +11 -0
- package/dist/libs/crud-pro/utils/ModelUtils.js +49 -0
- package/dist/libs/crud-pro/utils/MultiKeyMap.d.ts +11 -0
- package/dist/libs/crud-pro/utils/MultiKeyMap.js +63 -0
- package/dist/libs/crud-pro/utils/SqlFuncUtils.d.ts +5 -0
- package/dist/libs/crud-pro/utils/SqlFuncUtils.js +29 -0
- package/dist/libs/crud-pro/utils/TypeUtils.d.ts +40 -0
- package/dist/libs/crud-pro/utils/TypeUtils.js +166 -0
- package/dist/libs/crud-pro/utils/ValidateUtils.d.ts +3 -0
- package/dist/libs/crud-pro/utils/ValidateUtils.js +165 -0
- package/dist/libs/crud-pro/utils/pool/MySQLUtils.d.ts +3 -0
- package/dist/libs/crud-pro/utils/pool/MySQLUtils.js +19 -0
- package/dist/libs/crud-pro/utils/pool/PostgresUtils.d.ts +3 -0
- package/dist/libs/crud-pro/utils/pool/PostgresUtils.js +20 -0
- package/dist/libs/crud-pro/utils/pool/SqlServerUtils.d.ts +3 -0
- package/dist/libs/crud-pro/utils/pool/SqlServerUtils.js +20 -0
- package/dist/libs/crud-pro/utils/sqlConvert/convertColumnName.d.ts +4 -0
- package/dist/libs/crud-pro/utils/sqlConvert/convertColumnName.js +21 -0
- package/dist/libs/crud-pro/utils/sqlConvert/convertMsSql.d.ts +2 -0
- package/dist/libs/crud-pro/utils/sqlConvert/convertMsSql.js +11 -0
- package/dist/libs/crud-pro/utils/sqlConvert/convertPgSql.d.ts +2 -0
- package/dist/libs/crud-pro/utils/sqlConvert/convertPgSql.js +11 -0
- package/dist/libs/crud-pro/utils/sqlConvert/convertPgType.d.ts +2 -0
- package/dist/libs/crud-pro/utils/sqlConvert/convertPgType.js +128 -0
- package/dist/libs/utils/common-dto.d.ts +18 -0
- package/dist/libs/utils/common-dto.js +40 -0
- package/dist/libs/utils/crypto-utils.d.ts +3 -0
- package/dist/libs/utils/crypto-utils.js +46 -0
- package/dist/libs/utils/fatcms-request.d.ts +30 -0
- package/dist/libs/utils/fatcms-request.js +104 -0
- package/dist/libs/utils/functions.d.ts +4 -0
- package/dist/libs/utils/functions.js +63 -0
- package/dist/libs/utils/ordernum-utils.d.ts +2 -0
- package/dist/libs/utils/ordernum-utils.js +13 -0
- package/dist/libs/utils/parseConfig.d.ts +7 -0
- package/dist/libs/utils/parseConfig.js +44 -0
- package/dist/libs/utils/parseCreateSql.d.ts +5 -0
- package/dist/libs/utils/parseCreateSql.js +86 -0
- package/dist/libs/utils/render-utils.d.ts +28 -0
- package/dist/libs/utils/render-utils.js +135 -0
- package/dist/middleware/forbidden.middleware.d.ts +10 -0
- package/dist/middleware/forbidden.middleware.js +70 -0
- package/dist/middleware/global.middleware.d.ts +10 -0
- package/dist/middleware/global.middleware.js +246 -0
- package/dist/middleware/permission.middleware.d.ts +18 -0
- package/dist/middleware/permission.middleware.js +74 -0
- package/dist/middleware/tx.middleware.d.ts +9 -0
- package/dist/middleware/tx.middleware.js +40 -0
- package/dist/models/SystemEntities.d.ts +98 -0
- package/dist/models/SystemEntities.js +2 -0
- package/dist/models/SystemPerm.d.ts +95 -0
- package/dist/models/SystemPerm.js +100 -0
- package/dist/models/SystemTables.d.ts +27 -0
- package/dist/models/SystemTables.js +30 -0
- package/dist/models/bizmodels.d.ts +69 -0
- package/dist/models/bizmodels.js +34 -0
- package/dist/models/contextLogger.d.ts +25 -0
- package/dist/models/contextLogger.js +112 -0
- package/dist/models/devops.d.ts +12 -0
- package/dist/models/devops.js +19 -0
- package/dist/models/userSession.d.ts +61 -0
- package/dist/models/userSession.js +165 -0
- package/dist/schedule/index.d.ts +3 -0
- package/dist/schedule/index.js +69 -0
- package/dist/service/AuthService.d.ts +70 -0
- package/dist/service/AuthService.js +248 -0
- package/dist/service/EnumInfoService.d.ts +30 -0
- package/dist/service/EnumInfoService.js +123 -0
- package/dist/service/FileCenterService.d.ts +43 -0
- package/dist/service/FileCenterService.js +347 -0
- package/dist/service/SysConfigService.d.ts +7 -0
- package/dist/service/SysConfigService.js +45 -0
- package/dist/service/UserAccountService.d.ts +23 -0
- package/dist/service/UserAccountService.js +103 -0
- package/dist/service/UserSessionService.d.ts +16 -0
- package/dist/service/UserSessionService.js +85 -0
- package/dist/service/VisitStatService.d.ts +14 -0
- package/dist/service/VisitStatService.js +165 -0
- package/dist/service/WorkbenchService.d.ts +20 -0
- package/dist/service/WorkbenchService.js +153 -0
- package/dist/service/anyapi/AnyApiSandboxService.d.ts +15 -0
- package/dist/service/anyapi/AnyApiSandboxService.js +122 -0
- package/dist/service/anyapi/AnyApiService.d.ts +27 -0
- package/dist/service/anyapi/AnyApiService.js +179 -0
- package/dist/service/base/ApiBaseService.d.ts +15 -0
- package/dist/service/base/ApiBaseService.js +50 -0
- package/dist/service/base/ApiRateLimiter.d.ts +10 -0
- package/dist/service/base/ApiRateLimiter.js +51 -0
- package/dist/service/base/BaseService.d.ts +29 -0
- package/dist/service/base/BaseService.js +79 -0
- package/dist/service/base/RedisCacheService.d.ts +13 -0
- package/dist/service/base/RedisCacheService.js +50 -0
- package/dist/service/crudstd/CrudStdActionService.d.ts +17 -0
- package/dist/service/crudstd/CrudStdActionService.js +32 -0
- package/dist/service/crudstd/CrudStdConstant.d.ts +58 -0
- package/dist/service/crudstd/CrudStdConstant.js +64 -0
- package/dist/service/crudstd/CrudStdRelationService.d.ts +10 -0
- package/dist/service/crudstd/CrudStdRelationService.js +85 -0
- package/dist/service/crudstd/CrudStdService.d.ts +50 -0
- package/dist/service/crudstd/CrudStdService.js +182 -0
- package/dist/service/curd/CurdMixByAccountService.d.ts +9 -0
- package/dist/service/curd/CurdMixByAccountService.js +87 -0
- package/dist/service/curd/CurdMixByDictService.d.ts +13 -0
- package/dist/service/curd/CurdMixByDictService.js +111 -0
- package/dist/service/curd/CurdMixByLinkToCustomService.d.ts +22 -0
- package/dist/service/curd/CurdMixByLinkToCustomService.js +154 -0
- package/dist/service/curd/CurdMixBySysConfigService.d.ts +9 -0
- package/dist/service/curd/CurdMixBySysConfigService.js +78 -0
- package/dist/service/curd/CurdMixByWorkbenchService.d.ts +10 -0
- package/dist/service/curd/CurdMixByWorkbenchService.js +76 -0
- package/dist/service/curd/CurdMixService.d.ts +17 -0
- package/dist/service/curd/CurdMixService.js +76 -0
- package/dist/service/curd/CurdMixUtils.d.ts +28 -0
- package/dist/service/curd/CurdMixUtils.js +201 -0
- package/dist/service/curd/CurdProService.d.ts +39 -0
- package/dist/service/curd/CurdProService.js +322 -0
- package/dist/service/proxyapi/ProxyApiLoadService.d.ts +21 -0
- package/dist/service/proxyapi/ProxyApiLoadService.js +164 -0
- package/dist/service/proxyapi/ProxyApiService.d.ts +60 -0
- package/dist/service/proxyapi/ProxyApiService.js +260 -0
- package/dist/service/proxyapi/ProxyApiUtils.d.ts +15 -0
- package/dist/service/proxyapi/ProxyApiUtils.js +34 -0
- package/dist/service/proxyapi/RouteHandler.d.ts +5 -0
- package/dist/service/proxyapi/RouteHandler.js +9 -0
- package/dist/service/proxyapi/RouteTrie.d.ts +12 -0
- package/dist/service/proxyapi/RouteTrie.js +63 -0
- package/dist/service/proxyapi/WeightedRandom.d.ts +9 -0
- package/dist/service/proxyapi/WeightedRandom.js +31 -0
- package/dist/service/proxyapi/WeightedRoundRobin.d.ts +8 -0
- package/dist/service/proxyapi/WeightedRoundRobin.js +32 -0
- package/index.d.ts +10 -0
- package/package.json +71 -0
- package/src/config/config.default.ts +172 -0
- package/src/config/seed/aeskey.txt +1 -0
- package/src/config/utils.ts +23 -0
- package/src/configuration.ts +83 -0
- package/src/controller/base/BaseApiController.ts +145 -0
- package/src/controller/gateway/AnyApiGatewayController.ts +33 -0
- package/src/controller/gateway/CrudMtdGatewayController.ts +107 -0
- package/src/controller/gateway/CrudStdGatewayController.ts +101 -0
- package/src/controller/gateway/DocGatewayController.ts +165 -0
- package/src/controller/gateway/FileController.ts +110 -0
- package/src/controller/gateway/ProxyApiGatewayController.ts +47 -0
- package/src/controller/gateway/PublicApiController.ts +145 -0
- package/src/controller/gateway/StaticController.ts +303 -0
- package/src/controller/helpers.controller.ts +161 -0
- package/src/controller/home.controller.ts +71 -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 +353 -0
- package/src/controller/manage/DataDictManageApi.ts +78 -0
- package/src/controller/manage/DeployManageApi.ts +179 -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 +63 -0
- package/src/controller/manage/ProxyApiMangeApi.ts +52 -0
- package/src/controller/manage/SuperAdminManageApi.ts +138 -0
- package/src/controller/manage/SysConfigMangeApi.ts +95 -0
- package/src/controller/manage/SystemInfoManageApi.ts +48 -0
- package/src/controller/manage/UserAccountManageApi.ts +88 -0
- package/src/controller/manage/WorkbenchMangeApi.ts +72 -0
- package/src/controller/medstatistic/MedAdminController.ts +221 -0
- package/src/controller/medstatistic/MedClientController.ts +188 -0
- package/src/controller/medstatistic/MedMessageService.ts +89 -0
- package/src/controller/medstatistic/MedScoreService.ts +108 -0
- package/src/controller/medstatistic/constants.ts +63 -0
- package/src/controller/myinfo/AuthController.ts +174 -0
- package/src/controller/myinfo/MyInfoController.ts +32 -0
- package/src/controller/render/AppRenderController.ts +76 -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 +70 -0
- package/src/interface.ts +31 -0
- package/src/libs/crud-pro/CrudPro.ts +158 -0
- package/src/libs/crud-pro/defaultConfigs.ts +13 -0
- package/src/libs/crud-pro/exceptions.ts +124 -0
- package/src/libs/crud-pro/interfaces.ts +183 -0
- package/src/libs/crud-pro/models/ExecuteContext.ts +111 -0
- package/src/libs/crud-pro/models/ExecuteContextFunc.ts +86 -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/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 +74 -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 +107 -0
- package/src/libs/crud-pro/models/keys.ts +159 -0
- package/src/libs/crud-pro/services/CrudProCachedCfgService.ts +75 -0
- package/src/libs/crud-pro/services/CrudProExecuteFuncService.ts +128 -0
- package/src/libs/crud-pro/services/CrudProExecuteSqlService.ts +279 -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 +373 -0
- package/src/libs/crud-pro/services/CrudProGenSqlService.ts +202 -0
- package/src/libs/crud-pro/services/CrudProOriginToExecuteSql.ts +397 -0
- package/src/libs/crud-pro/services/CrudProServiceBase.ts +98 -0
- package/src/libs/crud-pro/services/CrudProTableMetaService.ts +59 -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 +40 -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 +167 -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/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/utils/common-dto.ts +52 -0
- package/src/libs/utils/crypto-utils.ts +52 -0
- package/src/libs/utils/fatcms-request.ts +115 -0
- package/src/libs/utils/functions.ts +67 -0
- package/src/libs/utils/ordernum-utils.ts +18 -0
- package/src/libs/utils/parseConfig.ts +62 -0
- package/src/libs/utils/parseCreateSql.ts +91 -0
- package/src/libs/utils/render-utils.ts +184 -0
- package/src/middleware/forbidden.middleware.ts +71 -0
- package/src/middleware/global.middleware.ts +278 -0
- package/src/middleware/permission.middleware.ts +81 -0
- package/src/middleware/tx.middleware.ts +30 -0
- package/src/models/SystemEntities.ts +115 -0
- package/src/models/SystemPerm.ts +105 -0
- package/src/models/SystemTables.ts +30 -0
- package/src/models/bizmodels.ts +89 -0
- package/src/models/contextLogger.ts +132 -0
- package/src/models/devops.ts +17 -0
- package/src/models/userSession.ts +216 -0
- package/src/schedule/index.ts +73 -0
- package/src/service/AuthService.ts +270 -0
- package/src/service/EnumInfoService.ts +129 -0
- package/src/service/FileCenterService.ts +394 -0
- package/src/service/SysConfigService.ts +34 -0
- package/src/service/UserAccountService.ts +100 -0
- package/src/service/UserSessionService.ts +81 -0
- package/src/service/VisitStatService.ts +179 -0
- package/src/service/WorkbenchService.ts +160 -0
- package/src/service/anyapi/AnyApiSandboxService.ts +121 -0
- package/src/service/anyapi/AnyApiService.ts +184 -0
- package/src/service/base/ApiBaseService.ts +42 -0
- package/src/service/base/ApiRateLimiter.ts +59 -0
- package/src/service/base/BaseService.ts +74 -0
- package/src/service/base/RedisCacheService.ts +38 -0
- package/src/service/crudstd/CrudStdActionService.ts +27 -0
- package/src/service/crudstd/CrudStdConstant.ts +62 -0
- package/src/service/crudstd/CrudStdRelationService.ts +78 -0
- package/src/service/crudstd/CrudStdService.ts +188 -0
- package/src/service/curd/CurdMixByAccountService.ts +83 -0
- package/src/service/curd/CurdMixByDictService.ts +113 -0
- package/src/service/curd/CurdMixByLinkToCustomService.ts +167 -0
- package/src/service/curd/CurdMixBySysConfigService.ts +78 -0
- package/src/service/curd/CurdMixByWorkbenchService.ts +68 -0
- package/src/service/curd/CurdMixService.ts +65 -0
- package/src/service/curd/CurdMixUtils.ts +248 -0
- package/src/service/curd/CurdProService.ts +379 -0
- package/src/service/proxyapi/ProxyApiLoadService.ts +165 -0
- package/src/service/proxyapi/ProxyApiService.ts +262 -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
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { RequestCfgModel } from './RequestCfgModel';
|
|
2
|
+
import { RequestModel } from './RequestModel';
|
|
3
|
+
import { SqlCfgModel } from './SqlCfgModel';
|
|
4
|
+
import { ExecuteContext } from './ExecuteContext';
|
|
5
|
+
import { IFuncCfgModel, IRequestCfgModel, ITableMeta } from '../interfaces';
|
|
6
|
+
import { FuncContext } from './FuncContext';
|
|
7
|
+
|
|
8
|
+
export interface ICurdProServiceHub {
|
|
9
|
+
getExecuteContext(): ExecuteContext;
|
|
10
|
+
|
|
11
|
+
validateByAllow(cfgModel: RequestCfgModel, reqModel: RequestModel);
|
|
12
|
+
|
|
13
|
+
validateByReject(cfgModel: RequestCfgModel, reqModel: RequestModel);
|
|
14
|
+
|
|
15
|
+
validateByCfg(cfgModel: RequestCfgModel, reqModel: RequestModel);
|
|
16
|
+
|
|
17
|
+
validateByAuthCfg(cfgModel: RequestCfgModel, reqModel: RequestModel): void;
|
|
18
|
+
|
|
19
|
+
updateByCfg(cfgModel: RequestCfgModel, reqModel: RequestModel);
|
|
20
|
+
|
|
21
|
+
getCachedCfgByMethod(method: string, isEnableCache: boolean): Promise<IRequestCfgModel>;
|
|
22
|
+
|
|
23
|
+
generateSQLList(exeCtx: ExecuteContext): Promise<void>;
|
|
24
|
+
|
|
25
|
+
executeSqlCfgModels(exeCtx: ExecuteContext): Promise<void>;
|
|
26
|
+
|
|
27
|
+
convertOriginToExecuteSql(sqlCfgModel: SqlCfgModel): Promise<void>;
|
|
28
|
+
|
|
29
|
+
executeFuncCfg(tmpFunCfg: IFuncCfgModel, exeFunCtx: FuncContext): string;
|
|
30
|
+
|
|
31
|
+
getTableMeta(sqlCfgModel: SqlCfgModel): Promise<ITableMeta>;
|
|
32
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { ColumnRelation, IFuncCfgModel, ISqlCfgModel } from '../interfaces';
|
|
2
|
+
import { MixinUtils } from '../utils/MixinUtils';
|
|
3
|
+
import { KeyOfCrudTypes, KeysOfSqlResPicker, SqlDbType} from './keys';
|
|
4
|
+
import { parseJsonObject } from '../../utils/functions';
|
|
5
|
+
|
|
6
|
+
const { isEmpty } = MixinUtils;
|
|
7
|
+
|
|
8
|
+
class SqlCfgModel {
|
|
9
|
+
columns: string[]; // "columns": "id,name,age,sex,addr",
|
|
10
|
+
columnsRelation?: ColumnRelation[]; //只能关联基本信息:如枚举值
|
|
11
|
+
sqlTable: string; // 可以为空. originSql中不包含@@table时可以为空
|
|
12
|
+
sqlSchema?: string; // 可以为空
|
|
13
|
+
sqlDatabase?: string; // 可以为空,用此字段进行connection的选择和切换。配合getBizConnectionPool使用
|
|
14
|
+
sqlDdType?: SqlDbType; // 数据库类型,mysql(默认) 、postgres
|
|
15
|
+
maxLimit: number; // 最大一次性返回的数量
|
|
16
|
+
resName: string;
|
|
17
|
+
resPicker: KeysOfSqlResPicker;
|
|
18
|
+
originSql: string; // 有特殊占位符的SQL, 原始的SQL constructor(resName: string, originSql: string) {}
|
|
19
|
+
validate: IFuncCfgModel; //执行前,进行校验,校验不通过就抛出异常. 校验函数可以返回 boolean或直接抛出异常
|
|
20
|
+
executeWhen: IFuncCfgModel; //满足表达式的结果,才能执行。 默认:true 校验函数必须返回 booleansetResPicker(resPicker: string) {}
|
|
21
|
+
executeSql: string; // 可以运行的SQL
|
|
22
|
+
executeSqlArgs: any[]; //可以运行的SQL的参数setExecuteWhen(executeWhenFunCfg: IFuncCfgModel) {}
|
|
23
|
+
crudType: KeyOfCrudTypes = null;
|
|
24
|
+
|
|
25
|
+
constructor(json: Partial<ISqlCfgModel>) {
|
|
26
|
+
Object.assign(this, json);
|
|
27
|
+
this.columns = MixinUtils.parseColumns(json.columns);
|
|
28
|
+
this.executeWhen = parseJsonObject(json.executeWhen);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
public getCrudType(): KeyOfCrudTypes {
|
|
32
|
+
if (!this.crudType) {
|
|
33
|
+
const sql = this.executeSql.trim().toUpperCase();
|
|
34
|
+
if (isEmpty(sql)) {
|
|
35
|
+
this.crudType = KeyOfCrudTypes.EMPTY_SQL;
|
|
36
|
+
} else if (sql.startsWith(KeyOfCrudTypes.SELECT)) {
|
|
37
|
+
this.crudType = KeyOfCrudTypes.SELECT;
|
|
38
|
+
} else if (sql.startsWith(KeyOfCrudTypes.UPDATE)) {
|
|
39
|
+
this.crudType = KeyOfCrudTypes.UPDATE;
|
|
40
|
+
} else if (sql.startsWith(KeyOfCrudTypes.DELETE)) {
|
|
41
|
+
this.crudType = KeyOfCrudTypes.DELETE;
|
|
42
|
+
} else if (sql.startsWith(KeyOfCrudTypes.INSERT)) {
|
|
43
|
+
this.crudType = KeyOfCrudTypes.INSERT;
|
|
44
|
+
} else {
|
|
45
|
+
this.crudType = KeyOfCrudTypes.NOT_CRUD;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return this.crudType;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export { SqlCfgModel };
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import {IConnectionPool, IPoolConnectionClient} from '../interfaces';
|
|
2
|
+
import {SqlDbType} from "./keys";
|
|
3
|
+
import {TransactionMySQL} from "./TransactionMySQL";
|
|
4
|
+
import {TransactionPostgres} from "./TransactionPostgres";
|
|
5
|
+
import {TransactionSqlServer} from "./TransactionSqlServer";
|
|
6
|
+
|
|
7
|
+
class Transaction {
|
|
8
|
+
|
|
9
|
+
private transactionMySQL : TransactionMySQL = new TransactionMySQL();
|
|
10
|
+
private transactionPostgres : TransactionPostgres = new TransactionPostgres();
|
|
11
|
+
private transactionSqlServer : TransactionSqlServer = new TransactionSqlServer();
|
|
12
|
+
|
|
13
|
+
private getTxObj(pool: IConnectionPool): TransactionMySQL | TransactionPostgres | TransactionSqlServer {
|
|
14
|
+
if (pool.dbType === SqlDbType.postgres) {
|
|
15
|
+
return this.transactionPostgres;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (pool.dbType === SqlDbType.sqlserver) {
|
|
19
|
+
return this.transactionSqlServer;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (!pool.dbType || pool.dbType === SqlDbType.mysql) {
|
|
23
|
+
return this.transactionMySQL;
|
|
24
|
+
}
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* 获取链接对象
|
|
30
|
+
* @param pool
|
|
31
|
+
*/
|
|
32
|
+
public async getTxConnection(pool: IConnectionPool): Promise<IPoolConnectionClient> {
|
|
33
|
+
const txObj = this.getTxObj(pool);
|
|
34
|
+
return txObj.getTxConnection(pool);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* 开始事务
|
|
39
|
+
*/
|
|
40
|
+
public beginTx() {
|
|
41
|
+
this.transactionMySQL.beginTx();
|
|
42
|
+
this.transactionPostgres.beginTx();
|
|
43
|
+
this.transactionSqlServer.beginTx();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* 提交事务
|
|
48
|
+
*/
|
|
49
|
+
public async commitTx() {
|
|
50
|
+
await this.transactionMySQL.commitTx();
|
|
51
|
+
await this.transactionPostgres.commitTx();
|
|
52
|
+
await this.transactionSqlServer.commitTx();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* 事务回滚
|
|
57
|
+
*/
|
|
58
|
+
public async rollbackTx() {
|
|
59
|
+
await this.transactionMySQL.rollbackTx();
|
|
60
|
+
await this.transactionPostgres.rollbackTx();
|
|
61
|
+
await this.transactionSqlServer.rollbackTx();
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* 释放连接
|
|
66
|
+
*/
|
|
67
|
+
public async releaseTx() {
|
|
68
|
+
await this.transactionMySQL.releaseTx();
|
|
69
|
+
await this.transactionPostgres.releaseTx();
|
|
70
|
+
await this.transactionSqlServer.releaseTx();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export { Transaction };
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { PoolConnection, Pool } from 'mysql2/promise';
|
|
2
|
+
import { IConnectionPool } from '../interfaces';
|
|
3
|
+
|
|
4
|
+
class TransactionMySQL {
|
|
5
|
+
private isBeginTransaction = false;
|
|
6
|
+
private connectionMap: Record<string, PoolConnection> = {};
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* 获取链接对象
|
|
10
|
+
* @param pool
|
|
11
|
+
*/
|
|
12
|
+
public async getTxConnection(pool: IConnectionPool): Promise<PoolConnection> {
|
|
13
|
+
let connection = this.connectionMap[pool.poolName];
|
|
14
|
+
if (!connection) {
|
|
15
|
+
const poolInstance: Pool = pool.poolInstance as any;
|
|
16
|
+
connection = await poolInstance.getConnection();
|
|
17
|
+
this.connectionMap[pool.poolName] = connection;
|
|
18
|
+
// 开启了事务
|
|
19
|
+
if (this.isBeginTransaction) {
|
|
20
|
+
await connection.beginTransaction();
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return connection;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* 开始事务
|
|
28
|
+
*/
|
|
29
|
+
public beginTx() {
|
|
30
|
+
this.isBeginTransaction = true;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* 提交事务
|
|
35
|
+
*/
|
|
36
|
+
public async commitTx() {
|
|
37
|
+
if (!this.isBeginTransaction) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const connections = Object.values(this.connectionMap);
|
|
41
|
+
for (let i = 0; i < connections.length; i++) {
|
|
42
|
+
const connection = connections[i];
|
|
43
|
+
await connection.commit();
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* 事务回滚
|
|
49
|
+
*/
|
|
50
|
+
public async rollbackTx() {
|
|
51
|
+
if (!this.isBeginTransaction) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const connections = Object.values(this.connectionMap);
|
|
55
|
+
for (let i = 0; i < connections.length; i++) {
|
|
56
|
+
const connection = connections[i];
|
|
57
|
+
await connection.rollback();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* 释放连接
|
|
63
|
+
*/
|
|
64
|
+
public async releaseTx() {
|
|
65
|
+
// 不管有没有开启事务,都要释放连接。
|
|
66
|
+
const connections = Object.values(this.connectionMap);
|
|
67
|
+
for (let i = 0; i < connections.length; i++) {
|
|
68
|
+
const connection = connections[i];
|
|
69
|
+
try {
|
|
70
|
+
await connection.release();
|
|
71
|
+
} catch (e) {
|
|
72
|
+
console.error(e);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
this.connectionMap = {};
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export { TransactionMySQL };
|
|
@@ -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,107 @@
|
|
|
1
|
+
import { ConnectionPool, Request, Transaction } from 'mssql';
|
|
2
|
+
import { IConnectionPool, IPoolConnectionClient } from '../interfaces';
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
interface ISqlServerConnection extends IPoolConnectionClient {
|
|
6
|
+
originConnection: ConnectionPool
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class TransactionSqlServer {
|
|
12
|
+
private isBeginTransaction = false;
|
|
13
|
+
private connectionMap: Record<string, ISqlServerConnection> = {};
|
|
14
|
+
private transactionMap: Record<string, Transaction> = {};
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* 获取链接对象
|
|
18
|
+
* @param pool
|
|
19
|
+
*/
|
|
20
|
+
public async getTxConnection(pool: IConnectionPool): Promise<ISqlServerConnection> {
|
|
21
|
+
let connection = this.connectionMap[pool.poolName];
|
|
22
|
+
if (!connection) {
|
|
23
|
+
connection = await this.connectAndCreateConnection(pool);
|
|
24
|
+
this.connectionMap[pool.poolName] = connection;
|
|
25
|
+
|
|
26
|
+
// 开启了事务
|
|
27
|
+
if (this.isBeginTransaction) {
|
|
28
|
+
await this.beginTransaction(pool.poolName);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return connection;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
private async connectAndCreateConnection(pool: IConnectionPool) : Promise<ISqlServerConnection> {
|
|
35
|
+
const poolInstance: ConnectionPool = pool.poolInstance as any;
|
|
36
|
+
const originConnection = await poolInstance.connect();
|
|
37
|
+
return {
|
|
38
|
+
originConnection,
|
|
39
|
+
query: (sql:string, values: any) : Promise<any> =>{
|
|
40
|
+
const request = new Request(originConnection);
|
|
41
|
+
if (Array.isArray(values)) {
|
|
42
|
+
for (let i = 0; i < values.length; i++) {
|
|
43
|
+
const index = i+1;
|
|
44
|
+
const value = values[i];
|
|
45
|
+
request.input(`fatcms_ms${index}`, value);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return request.query(sql);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* 开始事务
|
|
55
|
+
*/
|
|
56
|
+
public beginTx() {
|
|
57
|
+
this.isBeginTransaction = true;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* 提交事务
|
|
62
|
+
*/
|
|
63
|
+
public async commitTx() {
|
|
64
|
+
if (!this.isBeginTransaction) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
const transactions = Object.values(this.transactionMap);
|
|
68
|
+
for (let i = 0; i < transactions.length; i++) {
|
|
69
|
+
const tmpTx = transactions[i];
|
|
70
|
+
await tmpTx.commit();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* 事务回滚
|
|
76
|
+
*/
|
|
77
|
+
public async rollbackTx() {
|
|
78
|
+
if (!this.isBeginTransaction) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const transactions = Object.values(this.transactionMap);
|
|
82
|
+
for (let i = 0; i < transactions.length; i++) {
|
|
83
|
+
const tmpTx = transactions[i];
|
|
84
|
+
await tmpTx.rollback();
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* 释放连接
|
|
90
|
+
*/
|
|
91
|
+
public async releaseTx() {
|
|
92
|
+
this.connectionMap = {};
|
|
93
|
+
this.transactionMap = {};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
private async beginTransaction(poolName: string) {
|
|
98
|
+
const connection = this.connectionMap[poolName];
|
|
99
|
+
const originConnection: ConnectionPool = connection.originConnection;
|
|
100
|
+
const tmpTx = new Transaction(originConnection);
|
|
101
|
+
this.transactionMap[poolName] = tmpTx;
|
|
102
|
+
return await tmpTx.begin()
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
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,75 @@
|
|
|
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 MemoryRefreshCache from '../utils/MemoryRefreshCache';
|
|
7
|
+
|
|
8
|
+
const methodCache = new MemoryRefreshCache();
|
|
9
|
+
|
|
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
|
+
|
|
19
|
+
|
|
20
|
+
class CrudProCachedCfgService extends CrudProServiceBase {
|
|
21
|
+
constructor(serviceHub: ICurdProServiceHub) {
|
|
22
|
+
super(serviceHub);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
public async getCachedCfgByMethod(method: string, isEnableCache: boolean): Promise<IRequestCfgModel | null> {
|
|
26
|
+
|
|
27
|
+
// 不使用缓存
|
|
28
|
+
if (!isEnableCache) {
|
|
29
|
+
return await this.loadMethodInfo(method)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
methodCache.setProps({
|
|
33
|
+
keepTime: 2000,
|
|
34
|
+
requestFn: () => this.loadMethodInfoList(),
|
|
35
|
+
getKeyFn: item => item.method,
|
|
36
|
+
});
|
|
37
|
+
return await methodCache.getItem(method);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
private async loadMethodInfo(method: string): Promise<any> {
|
|
42
|
+
const {methodsTableName, sysDatabaseName} = this.getContextCfg();
|
|
43
|
+
const sql = `select *
|
|
44
|
+
from ${methodsTableName}
|
|
45
|
+
where method = ? `; // 全部加载到内存
|
|
46
|
+
const baseInfo = {
|
|
47
|
+
tableName: methodsTableName, // // 方法配置的表名,默认 sys_crud_pro_methods
|
|
48
|
+
dbName: sysDatabaseName,
|
|
49
|
+
};
|
|
50
|
+
const [rows] = await this.executeUnsafeQuery(baseInfo, sql, [method]);
|
|
51
|
+
const rows2: any[] = rows as object[];
|
|
52
|
+
if (rows2.length > 0) {
|
|
53
|
+
return parseMethodInfo(rows2[0]);
|
|
54
|
+
}
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
private async loadMethodInfoList(): Promise<any[]> {
|
|
61
|
+
const { methodsTableName, sysDatabaseName } = this.getContextCfg();
|
|
62
|
+
const sql = `select * from ${methodsTableName}`; // 全部加载到内存
|
|
63
|
+
const baseInfo = {
|
|
64
|
+
tableName: methodsTableName, // // 方法配置的表名,默认 sys_crud_pro_methods
|
|
65
|
+
dbName: sysDatabaseName,
|
|
66
|
+
};
|
|
67
|
+
const [rows] = await this.executeUnsafeQuery(baseInfo, sql);
|
|
68
|
+
const rows2: any[] = rows as object[];
|
|
69
|
+
return rows2.map(row => {
|
|
70
|
+
return parseMethodInfo(row);
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export { CrudProCachedCfgService };
|