midway-fatcms 0.0.1-beta.3 → 0.0.1-beta.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +14 -0
- package/.prettierrc.js +4 -0
- package/README.md +7 -0
- package/package.json +25 -24
- package/tsconfig.json +32 -0
- package/dist/config/config.default.d.ts +0 -3
- package/dist/config/config.default.js +0 -148
- package/dist/config/seed/aeskey.txt +0 -1
- package/dist/config/utils.d.ts +0 -1
- package/dist/config/utils.js +0 -23
- package/dist/configuration.d.ts +0 -6
- package/dist/configuration.js +0 -89
- package/dist/controller/base/BaseApiController.d.ts +0 -31
- package/dist/controller/base/BaseApiController.js +0 -138
- package/dist/controller/gateway/AnyApiGatewayController.d.ts +0 -13
- package/dist/controller/gateway/AnyApiGatewayController.js +0 -55
- package/dist/controller/gateway/CrudMtdGatewayController.d.ts +0 -21
- package/dist/controller/gateway/CrudMtdGatewayController.js +0 -116
- package/dist/controller/gateway/CrudStdGatewayController.d.ts +0 -38
- package/dist/controller/gateway/CrudStdGatewayController.js +0 -137
- package/dist/controller/gateway/DocGatewayController.d.ts +0 -27
- package/dist/controller/gateway/DocGatewayController.js +0 -174
- package/dist/controller/gateway/FileController.d.ts +0 -25
- package/dist/controller/gateway/FileController.js +0 -129
- package/dist/controller/gateway/ProxyApiGatewayController.d.ts +0 -18
- package/dist/controller/gateway/ProxyApiGatewayController.js +0 -78
- package/dist/controller/gateway/PublicApiController.d.ts +0 -27
- package/dist/controller/gateway/PublicApiController.js +0 -167
- package/dist/controller/gateway/StaticController.d.ts +0 -21
- package/dist/controller/gateway/StaticController.js +0 -265
- package/dist/controller/helpers.controller.d.ts +0 -39
- package/dist/controller/helpers.controller.js +0 -188
- package/dist/controller/home.controller.d.ts +0 -9
- package/dist/controller/home.controller.js +0 -71
- package/dist/controller/manage/AnyApiMangeApi.d.ts +0 -10
- package/dist/controller/manage/AnyApiMangeApi.js +0 -98
- package/dist/controller/manage/AppLogMangeApi.d.ts +0 -10
- package/dist/controller/manage/AppLogMangeApi.js +0 -88
- package/dist/controller/manage/AppMangeApi.d.ts +0 -10
- package/dist/controller/manage/AppMangeApi.js +0 -88
- package/dist/controller/manage/AppPageMangeApi.d.ts +0 -10
- package/dist/controller/manage/AppPageMangeApi.js +0 -87
- package/dist/controller/manage/AppSchemaHistoryApi.d.ts +0 -10
- package/dist/controller/manage/AppSchemaHistoryApi.js +0 -83
- package/dist/controller/manage/CrudMethodsMangeApi.d.ts +0 -10
- package/dist/controller/manage/CrudMethodsMangeApi.js +0 -84
- package/dist/controller/manage/CrudStandardDesignApi.d.ts +0 -38
- package/dist/controller/manage/CrudStandardDesignApi.js +0 -339
- package/dist/controller/manage/DataDictManageApi.d.ts +0 -15
- package/dist/controller/manage/DataDictManageApi.js +0 -133
- package/dist/controller/manage/DeployManageApi.d.ts +0 -19
- package/dist/controller/manage/DeployManageApi.js +0 -176
- package/dist/controller/manage/DocLibManageApi.d.ts +0 -10
- package/dist/controller/manage/DocLibManageApi.js +0 -104
- package/dist/controller/manage/DocManageApi.d.ts +0 -11
- package/dist/controller/manage/DocManageApi.js +0 -130
- package/dist/controller/manage/FileManageApi.d.ts +0 -13
- package/dist/controller/manage/FileManageApi.js +0 -77
- package/dist/controller/manage/LowCodeTplManageApi.d.ts +0 -13
- package/dist/controller/manage/LowCodeTplManageApi.js +0 -86
- package/dist/controller/manage/MenuManageApi.d.ts +0 -10
- package/dist/controller/manage/MenuManageApi.js +0 -93
- package/dist/controller/manage/ProxyApiMangeApi.d.ts +0 -10
- package/dist/controller/manage/ProxyApiMangeApi.js +0 -87
- package/dist/controller/manage/SuperAdminManageApi.d.ts +0 -24
- package/dist/controller/manage/SuperAdminManageApi.js +0 -149
- package/dist/controller/manage/SysConfigMangeApi.d.ts +0 -11
- package/dist/controller/manage/SysConfigMangeApi.js +0 -124
- package/dist/controller/manage/SystemInfoManageApi.d.ts +0 -12
- package/dist/controller/manage/SystemInfoManageApi.js +0 -66
- package/dist/controller/manage/UserAccountManageApi.d.ts +0 -14
- package/dist/controller/manage/UserAccountManageApi.js +0 -124
- package/dist/controller/manage/WorkbenchMangeApi.d.ts +0 -11
- package/dist/controller/manage/WorkbenchMangeApi.js +0 -103
- package/dist/controller/medstatistic/MedAdminController.d.ts +0 -35
- package/dist/controller/medstatistic/MedAdminController.js +0 -205
- package/dist/controller/medstatistic/MedClientController.d.ts +0 -28
- package/dist/controller/medstatistic/MedClientController.js +0 -188
- package/dist/controller/medstatistic/MedMessageService.d.ts +0 -19
- package/dist/controller/medstatistic/MedMessageService.js +0 -95
- package/dist/controller/medstatistic/MedScoreService.d.ts +0 -21
- package/dist/controller/medstatistic/MedScoreService.js +0 -107
- package/dist/controller/medstatistic/constants.d.ts +0 -32
- package/dist/controller/medstatistic/constants.js +0 -43
- package/dist/controller/myinfo/AuthController.d.ts +0 -37
- package/dist/controller/myinfo/AuthController.js +0 -189
- package/dist/controller/myinfo/MyInfoController.d.ts +0 -13
- package/dist/controller/myinfo/MyInfoController.js +0 -51
- package/dist/controller/render/AppRenderController.d.ts +0 -11
- package/dist/controller/render/AppRenderController.js +0 -85
- package/dist/controller/test.controller.d.ts +0 -8
- package/dist/controller/test.controller.js +0 -51
- package/dist/filter/default.filter.d.ts +0 -7
- package/dist/filter/default.filter.js +0 -23
- package/dist/filter/notfound.filter.d.ts +0 -5
- package/dist/filter/notfound.filter.js +0 -20
- package/dist/index.d.ts +0 -71
- package/dist/index.js +0 -89
- package/dist/interface.d.ts +0 -27
- package/dist/interface.js +0 -3
- package/dist/libs/crud-pro/CrudPro.d.ts +0 -36
- package/dist/libs/crud-pro/CrudPro.js +0 -131
- package/dist/libs/crud-pro/defaultConfigs.d.ts +0 -4
- package/dist/libs/crud-pro/defaultConfigs.js +0 -13
- package/dist/libs/crud-pro/exceptions.d.ts +0 -104
- package/dist/libs/crud-pro/exceptions.js +0 -117
- package/dist/libs/crud-pro/interfaces.d.ts +0 -157
- package/dist/libs/crud-pro/interfaces.js +0 -12
- package/dist/libs/crud-pro/models/ExecuteContext.d.ts +0 -42
- package/dist/libs/crud-pro/models/ExecuteContext.js +0 -79
- package/dist/libs/crud-pro/models/ExecuteContextFunc.d.ts +0 -31
- package/dist/libs/crud-pro/models/ExecuteContextFunc.js +0 -64
- package/dist/libs/crud-pro/models/FuncContext.d.ts +0 -18
- package/dist/libs/crud-pro/models/FuncContext.js +0 -6
- package/dist/libs/crud-pro/models/RequestCfgModel.d.ts +0 -65
- package/dist/libs/crud-pro/models/RequestCfgModel.js +0 -81
- package/dist/libs/crud-pro/models/RequestModel.d.ts +0 -25
- package/dist/libs/crud-pro/models/RequestModel.js +0 -113
- package/dist/libs/crud-pro/models/ServiceHub.d.ts +0 -20
- package/dist/libs/crud-pro/models/ServiceHub.js +0 -2
- package/dist/libs/crud-pro/models/SqlCfgModel.d.ts +0 -22
- package/dist/libs/crud-pro/models/SqlCfgModel.js +0 -40
- package/dist/libs/crud-pro/models/SqlSegArg.d.ts +0 -6
- package/dist/libs/crud-pro/models/SqlSegArg.js +0 -12
- package/dist/libs/crud-pro/models/Transaction.d.ts +0 -29
- package/dist/libs/crud-pro/models/Transaction.js +0 -67
- package/dist/libs/crud-pro/models/TransactionMySQL.d.ts +0 -28
- package/dist/libs/crud-pro/models/TransactionMySQL.js +0 -76
- package/dist/libs/crud-pro/models/TransactionPostgres.d.ts +0 -28
- package/dist/libs/crud-pro/models/TransactionPostgres.js +0 -85
- package/dist/libs/crud-pro/models/TransactionSqlServer.d.ts +0 -34
- package/dist/libs/crud-pro/models/TransactionSqlServer.js +0 -92
- package/dist/libs/crud-pro/models/keys.d.ts +0 -106
- package/dist/libs/crud-pro/models/keys.js +0 -149
- package/dist/libs/crud-pro/services/CrudProCachedCfgService.d.ts +0 -10
- package/dist/libs/crud-pro/services/CrudProCachedCfgService.js +0 -61
- package/dist/libs/crud-pro/services/CrudProExecuteFuncService.d.ts +0 -9
- package/dist/libs/crud-pro/services/CrudProExecuteFuncService.js +0 -112
- package/dist/libs/crud-pro/services/CrudProExecuteSqlService.d.ts +0 -17
- package/dist/libs/crud-pro/services/CrudProExecuteSqlService.js +0 -227
- package/dist/libs/crud-pro/services/CrudProFieldUpdateService.d.ts +0 -9
- package/dist/libs/crud-pro/services/CrudProFieldUpdateService.js +0 -51
- package/dist/libs/crud-pro/services/CrudProFieldValidateService.d.ts +0 -13
- package/dist/libs/crud-pro/services/CrudProFieldValidateService.js +0 -148
- package/dist/libs/crud-pro/services/CrudProGenSqlCondition.d.ts +0 -24
- package/dist/libs/crud-pro/services/CrudProGenSqlCondition.js +0 -342
- package/dist/libs/crud-pro/services/CrudProGenSqlService.d.ts +0 -25
- package/dist/libs/crud-pro/services/CrudProGenSqlService.js +0 -174
- package/dist/libs/crud-pro/services/CrudProOriginToExecuteSql.d.ts +0 -32
- package/dist/libs/crud-pro/services/CrudProOriginToExecuteSql.js +0 -333
- package/dist/libs/crud-pro/services/CrudProServiceBase.d.ts +0 -28
- package/dist/libs/crud-pro/services/CrudProServiceBase.js +0 -78
- package/dist/libs/crud-pro/services/CrudProTableMetaService.d.ts +0 -8
- package/dist/libs/crud-pro/services/CrudProTableMetaService.js +0 -53
- package/dist/libs/crud-pro/services/CurdProServiceHub.d.ts +0 -32
- package/dist/libs/crud-pro/services/CurdProServiceHub.js +0 -64
- package/dist/libs/crud-pro/sql.txt +0 -120
- package/dist/libs/crud-pro/utils/CompareUtils.d.ts +0 -9
- package/dist/libs/crud-pro/utils/CompareUtils.js +0 -25
- package/dist/libs/crud-pro/utils/DatabaseName.d.ts +0 -9
- package/dist/libs/crud-pro/utils/DatabaseName.js +0 -29
- package/dist/libs/crud-pro/utils/DateTimeUtils.d.ts +0 -7
- package/dist/libs/crud-pro/utils/DateTimeUtils.js +0 -21
- package/dist/libs/crud-pro/utils/MemoryRefreshCache.d.ts +0 -19
- package/dist/libs/crud-pro/utils/MemoryRefreshCache.js +0 -47
- package/dist/libs/crud-pro/utils/MessageParseUtils.d.ts +0 -5
- package/dist/libs/crud-pro/utils/MessageParseUtils.js +0 -33
- package/dist/libs/crud-pro/utils/MixinUtils.d.ts +0 -39
- package/dist/libs/crud-pro/utils/MixinUtils.js +0 -255
- package/dist/libs/crud-pro/utils/ModelUtils.d.ts +0 -11
- package/dist/libs/crud-pro/utils/ModelUtils.js +0 -49
- package/dist/libs/crud-pro/utils/MultiKeyMap.d.ts +0 -11
- package/dist/libs/crud-pro/utils/MultiKeyMap.js +0 -63
- package/dist/libs/crud-pro/utils/SqlFuncUtils.d.ts +0 -5
- package/dist/libs/crud-pro/utils/SqlFuncUtils.js +0 -29
- package/dist/libs/crud-pro/utils/TypeUtils.d.ts +0 -40
- package/dist/libs/crud-pro/utils/TypeUtils.js +0 -166
- package/dist/libs/crud-pro/utils/ValidateUtils.d.ts +0 -3
- package/dist/libs/crud-pro/utils/ValidateUtils.js +0 -165
- package/dist/libs/crud-pro/utils/pool/MySQLUtils.d.ts +0 -3
- package/dist/libs/crud-pro/utils/pool/MySQLUtils.js +0 -19
- package/dist/libs/crud-pro/utils/pool/PostgresUtils.d.ts +0 -3
- package/dist/libs/crud-pro/utils/pool/PostgresUtils.js +0 -20
- package/dist/libs/crud-pro/utils/pool/SqlServerUtils.d.ts +0 -3
- package/dist/libs/crud-pro/utils/pool/SqlServerUtils.js +0 -20
- package/dist/libs/crud-pro/utils/sqlConvert/convertColumnName.d.ts +0 -4
- package/dist/libs/crud-pro/utils/sqlConvert/convertColumnName.js +0 -21
- package/dist/libs/crud-pro/utils/sqlConvert/convertMsSql.d.ts +0 -2
- package/dist/libs/crud-pro/utils/sqlConvert/convertMsSql.js +0 -11
- package/dist/libs/crud-pro/utils/sqlConvert/convertPgSql.d.ts +0 -2
- package/dist/libs/crud-pro/utils/sqlConvert/convertPgSql.js +0 -11
- package/dist/libs/crud-pro/utils/sqlConvert/convertPgType.d.ts +0 -2
- package/dist/libs/crud-pro/utils/sqlConvert/convertPgType.js +0 -128
- package/dist/libs/utils/common-dto.d.ts +0 -18
- package/dist/libs/utils/common-dto.js +0 -40
- package/dist/libs/utils/crypto-utils.d.ts +0 -3
- package/dist/libs/utils/crypto-utils.js +0 -46
- package/dist/libs/utils/fatcms-request.d.ts +0 -30
- package/dist/libs/utils/fatcms-request.js +0 -104
- package/dist/libs/utils/functions.d.ts +0 -4
- package/dist/libs/utils/functions.js +0 -63
- package/dist/libs/utils/ordernum-utils.d.ts +0 -2
- package/dist/libs/utils/ordernum-utils.js +0 -13
- package/dist/libs/utils/parseConfig.d.ts +0 -7
- package/dist/libs/utils/parseConfig.js +0 -44
- package/dist/libs/utils/parseCreateSql.d.ts +0 -5
- package/dist/libs/utils/parseCreateSql.js +0 -86
- package/dist/libs/utils/render-utils.d.ts +0 -28
- package/dist/libs/utils/render-utils.js +0 -135
- package/dist/middleware/forbidden.middleware.d.ts +0 -10
- package/dist/middleware/forbidden.middleware.js +0 -70
- package/dist/middleware/global.middleware.d.ts +0 -10
- package/dist/middleware/global.middleware.js +0 -246
- package/dist/middleware/permission.middleware.d.ts +0 -18
- package/dist/middleware/permission.middleware.js +0 -74
- package/dist/middleware/tx.middleware.d.ts +0 -9
- package/dist/middleware/tx.middleware.js +0 -40
- package/dist/models/SystemEntities.d.ts +0 -98
- package/dist/models/SystemEntities.js +0 -2
- package/dist/models/SystemPerm.d.ts +0 -95
- package/dist/models/SystemPerm.js +0 -100
- package/dist/models/SystemTables.d.ts +0 -27
- package/dist/models/SystemTables.js +0 -30
- package/dist/models/bizmodels.d.ts +0 -69
- package/dist/models/bizmodels.js +0 -34
- package/dist/models/contextLogger.d.ts +0 -25
- package/dist/models/contextLogger.js +0 -112
- package/dist/models/devops.d.ts +0 -12
- package/dist/models/devops.js +0 -19
- package/dist/models/userSession.d.ts +0 -61
- package/dist/models/userSession.js +0 -165
- package/dist/schedule/index.d.ts +0 -3
- package/dist/schedule/index.js +0 -69
- package/dist/service/AuthService.d.ts +0 -70
- package/dist/service/AuthService.js +0 -248
- package/dist/service/EnumInfoService.d.ts +0 -30
- package/dist/service/EnumInfoService.js +0 -123
- package/dist/service/FileCenterService.d.ts +0 -43
- package/dist/service/FileCenterService.js +0 -347
- package/dist/service/SysConfigService.d.ts +0 -7
- package/dist/service/SysConfigService.js +0 -45
- package/dist/service/UserAccountService.d.ts +0 -23
- package/dist/service/UserAccountService.js +0 -103
- package/dist/service/UserSessionService.d.ts +0 -16
- package/dist/service/UserSessionService.js +0 -85
- package/dist/service/VisitStatService.d.ts +0 -14
- package/dist/service/VisitStatService.js +0 -165
- package/dist/service/WorkbenchService.d.ts +0 -20
- package/dist/service/WorkbenchService.js +0 -153
- package/dist/service/anyapi/AnyApiSandboxService.d.ts +0 -15
- package/dist/service/anyapi/AnyApiSandboxService.js +0 -122
- package/dist/service/anyapi/AnyApiService.d.ts +0 -27
- package/dist/service/anyapi/AnyApiService.js +0 -179
- package/dist/service/base/ApiBaseService.d.ts +0 -15
- package/dist/service/base/ApiBaseService.js +0 -50
- package/dist/service/base/ApiRateLimiter.d.ts +0 -10
- package/dist/service/base/ApiRateLimiter.js +0 -51
- package/dist/service/base/BaseService.d.ts +0 -29
- package/dist/service/base/BaseService.js +0 -79
- package/dist/service/base/RedisCacheService.d.ts +0 -13
- package/dist/service/base/RedisCacheService.js +0 -50
- package/dist/service/crudstd/CrudStdActionService.d.ts +0 -17
- package/dist/service/crudstd/CrudStdActionService.js +0 -32
- package/dist/service/crudstd/CrudStdConstant.d.ts +0 -58
- package/dist/service/crudstd/CrudStdConstant.js +0 -64
- package/dist/service/crudstd/CrudStdRelationService.d.ts +0 -10
- package/dist/service/crudstd/CrudStdRelationService.js +0 -85
- package/dist/service/crudstd/CrudStdService.d.ts +0 -50
- package/dist/service/crudstd/CrudStdService.js +0 -182
- package/dist/service/curd/CurdMixByAccountService.d.ts +0 -9
- package/dist/service/curd/CurdMixByAccountService.js +0 -87
- package/dist/service/curd/CurdMixByDictService.d.ts +0 -13
- package/dist/service/curd/CurdMixByDictService.js +0 -111
- package/dist/service/curd/CurdMixByLinkToCustomService.d.ts +0 -22
- package/dist/service/curd/CurdMixByLinkToCustomService.js +0 -154
- package/dist/service/curd/CurdMixBySysConfigService.d.ts +0 -9
- package/dist/service/curd/CurdMixBySysConfigService.js +0 -78
- package/dist/service/curd/CurdMixByWorkbenchService.d.ts +0 -10
- package/dist/service/curd/CurdMixByWorkbenchService.js +0 -76
- package/dist/service/curd/CurdMixService.d.ts +0 -17
- package/dist/service/curd/CurdMixService.js +0 -76
- package/dist/service/curd/CurdMixUtils.d.ts +0 -28
- package/dist/service/curd/CurdMixUtils.js +0 -201
- package/dist/service/curd/CurdProService.d.ts +0 -39
- package/dist/service/curd/CurdProService.js +0 -322
- package/dist/service/proxyapi/ProxyApiLoadService.d.ts +0 -21
- package/dist/service/proxyapi/ProxyApiLoadService.js +0 -164
- package/dist/service/proxyapi/ProxyApiService.d.ts +0 -60
- package/dist/service/proxyapi/ProxyApiService.js +0 -260
- package/dist/service/proxyapi/ProxyApiUtils.d.ts +0 -15
- package/dist/service/proxyapi/ProxyApiUtils.js +0 -34
- package/dist/service/proxyapi/RouteHandler.d.ts +0 -5
- package/dist/service/proxyapi/RouteHandler.js +0 -9
- package/dist/service/proxyapi/RouteTrie.d.ts +0 -12
- package/dist/service/proxyapi/RouteTrie.js +0 -63
- package/dist/service/proxyapi/WeightedRandom.d.ts +0 -9
- package/dist/service/proxyapi/WeightedRandom.js +0 -31
- package/dist/service/proxyapi/WeightedRoundRobin.d.ts +0 -8
- package/dist/service/proxyapi/WeightedRoundRobin.js +0 -32
- package/dist/views/404_app.html +0 -31
- package/dist/views/404_workbench.html +0 -34
- package/dist/views/static/favicon.ico +0 -0
- package/src/config/config.default.ts +0 -172
- package/src/config/seed/aeskey.txt +0 -1
- package/src/config/utils.ts +0 -23
- package/src/configuration.ts +0 -83
- package/src/controller/base/BaseApiController.ts +0 -145
- package/src/controller/gateway/AnyApiGatewayController.ts +0 -33
- package/src/controller/gateway/CrudMtdGatewayController.ts +0 -107
- package/src/controller/gateway/CrudStdGatewayController.ts +0 -101
- package/src/controller/gateway/DocGatewayController.ts +0 -165
- package/src/controller/gateway/FileController.ts +0 -110
- package/src/controller/gateway/ProxyApiGatewayController.ts +0 -47
- package/src/controller/gateway/PublicApiController.ts +0 -145
- package/src/controller/gateway/StaticController.ts +0 -303
- package/src/controller/helpers.controller.ts +0 -161
- package/src/controller/home.controller.ts +0 -71
- package/src/controller/manage/AnyApiMangeApi.ts +0 -66
- package/src/controller/manage/AppLogMangeApi.ts +0 -53
- package/src/controller/manage/AppMangeApi.ts +0 -53
- package/src/controller/manage/AppPageMangeApi.ts +0 -52
- package/src/controller/manage/AppSchemaHistoryApi.ts +0 -49
- package/src/controller/manage/CrudMethodsMangeApi.ts +0 -49
- package/src/controller/manage/CrudStandardDesignApi.ts +0 -353
- package/src/controller/manage/DataDictManageApi.ts +0 -78
- package/src/controller/manage/DeployManageApi.ts +0 -179
- package/src/controller/manage/DocLibManageApi.ts +0 -69
- package/src/controller/manage/DocManageApi.ts +0 -99
- package/src/controller/manage/FileManageApi.ts +0 -45
- package/src/controller/manage/LowCodeTplManageApi.ts +0 -52
- package/src/controller/manage/MenuManageApi.ts +0 -63
- package/src/controller/manage/ProxyApiMangeApi.ts +0 -52
- package/src/controller/manage/SuperAdminManageApi.ts +0 -138
- package/src/controller/manage/SysConfigMangeApi.ts +0 -95
- package/src/controller/manage/SystemInfoManageApi.ts +0 -48
- package/src/controller/manage/UserAccountManageApi.ts +0 -88
- package/src/controller/manage/WorkbenchMangeApi.ts +0 -72
- package/src/controller/medstatistic/MedAdminController.ts +0 -221
- package/src/controller/medstatistic/MedClientController.ts +0 -188
- package/src/controller/medstatistic/MedMessageService.ts +0 -89
- package/src/controller/medstatistic/MedScoreService.ts +0 -108
- package/src/controller/medstatistic/constants.ts +0 -63
- package/src/controller/myinfo/AuthController.ts +0 -174
- package/src/controller/myinfo/MyInfoController.ts +0 -32
- package/src/controller/render/AppRenderController.ts +0 -76
- package/src/controller/test.controller.ts +0 -37
- package/src/filter/default.filter.ts +0 -13
- package/src/filter/notfound.filter.ts +0 -10
- package/src/index.ts +0 -71
- package/src/interface.ts +0 -31
- package/src/libs/crud-pro/CrudPro.ts +0 -158
- package/src/libs/crud-pro/defaultConfigs.ts +0 -13
- package/src/libs/crud-pro/exceptions.ts +0 -124
- package/src/libs/crud-pro/interfaces.ts +0 -183
- package/src/libs/crud-pro/models/ExecuteContext.ts +0 -111
- package/src/libs/crud-pro/models/ExecuteContextFunc.ts +0 -86
- package/src/libs/crud-pro/models/FuncContext.ts +0 -21
- package/src/libs/crud-pro/models/RequestCfgModel.ts +0 -141
- package/src/libs/crud-pro/models/RequestModel.ts +0 -141
- package/src/libs/crud-pro/models/ServiceHub.ts +0 -32
- package/src/libs/crud-pro/models/SqlCfgModel.ts +0 -52
- package/src/libs/crud-pro/models/SqlSegArg.ts +0 -13
- package/src/libs/crud-pro/models/Transaction.ts +0 -74
- package/src/libs/crud-pro/models/TransactionMySQL.ts +0 -79
- package/src/libs/crud-pro/models/TransactionPostgres.ts +0 -91
- package/src/libs/crud-pro/models/TransactionSqlServer.ts +0 -107
- package/src/libs/crud-pro/models/keys.ts +0 -159
- package/src/libs/crud-pro/services/CrudProCachedCfgService.ts +0 -75
- package/src/libs/crud-pro/services/CrudProExecuteFuncService.ts +0 -128
- package/src/libs/crud-pro/services/CrudProExecuteSqlService.ts +0 -279
- package/src/libs/crud-pro/services/CrudProFieldUpdateService.ts +0 -60
- package/src/libs/crud-pro/services/CrudProFieldValidateService.ts +0 -180
- package/src/libs/crud-pro/services/CrudProGenSqlCondition.ts +0 -373
- package/src/libs/crud-pro/services/CrudProGenSqlService.ts +0 -202
- package/src/libs/crud-pro/services/CrudProOriginToExecuteSql.ts +0 -397
- package/src/libs/crud-pro/services/CrudProServiceBase.ts +0 -98
- package/src/libs/crud-pro/services/CrudProTableMetaService.ts +0 -59
- package/src/libs/crud-pro/services/CurdProServiceHub.ts +0 -92
- package/src/libs/crud-pro/sql.txt +0 -120
- package/src/libs/crud-pro/utils/CompareUtils.ts +0 -23
- package/src/libs/crud-pro/utils/DatabaseName.ts +0 -40
- package/src/libs/crud-pro/utils/DateTimeUtils.ts +0 -20
- package/src/libs/crud-pro/utils/MemoryRefreshCache.ts +0 -64
- package/src/libs/crud-pro/utils/MessageParseUtils.ts +0 -33
- package/src/libs/crud-pro/utils/MixinUtils.ts +0 -285
- package/src/libs/crud-pro/utils/ModelUtils.ts +0 -55
- package/src/libs/crud-pro/utils/MultiKeyMap.ts +0 -72
- package/src/libs/crud-pro/utils/SqlFuncUtils.ts +0 -29
- package/src/libs/crud-pro/utils/TypeUtils.ts +0 -188
- package/src/libs/crud-pro/utils/ValidateUtils.ts +0 -167
- package/src/libs/crud-pro/utils/pool/MySQLUtils.ts +0 -20
- package/src/libs/crud-pro/utils/pool/PostgresUtils.ts +0 -22
- package/src/libs/crud-pro/utils/pool/SqlServerUtils.ts +0 -22
- package/src/libs/crud-pro/utils/sqlConvert/convertColumnName.ts +0 -26
- package/src/libs/crud-pro/utils/sqlConvert/convertMsSql.ts +0 -11
- package/src/libs/crud-pro/utils/sqlConvert/convertPgSql.ts +0 -11
- package/src/libs/crud-pro/utils/sqlConvert/convertPgType.ts +0 -129
- package/src/libs/utils/common-dto.ts +0 -52
- package/src/libs/utils/crypto-utils.ts +0 -52
- package/src/libs/utils/fatcms-request.ts +0 -115
- package/src/libs/utils/functions.ts +0 -67
- package/src/libs/utils/ordernum-utils.ts +0 -18
- package/src/libs/utils/parseConfig.ts +0 -62
- package/src/libs/utils/parseCreateSql.ts +0 -91
- package/src/libs/utils/render-utils.ts +0 -184
- package/src/middleware/forbidden.middleware.ts +0 -71
- package/src/middleware/global.middleware.ts +0 -278
- package/src/middleware/permission.middleware.ts +0 -81
- package/src/middleware/tx.middleware.ts +0 -30
- package/src/models/SystemEntities.ts +0 -115
- package/src/models/SystemPerm.ts +0 -105
- package/src/models/SystemTables.ts +0 -30
- package/src/models/bizmodels.ts +0 -89
- package/src/models/contextLogger.ts +0 -132
- package/src/models/devops.ts +0 -17
- package/src/models/userSession.ts +0 -216
- package/src/schedule/index.ts +0 -73
- package/src/service/AuthService.ts +0 -270
- package/src/service/EnumInfoService.ts +0 -129
- package/src/service/FileCenterService.ts +0 -394
- package/src/service/SysConfigService.ts +0 -34
- package/src/service/UserAccountService.ts +0 -100
- package/src/service/UserSessionService.ts +0 -81
- package/src/service/VisitStatService.ts +0 -179
- package/src/service/WorkbenchService.ts +0 -160
- package/src/service/anyapi/AnyApiSandboxService.ts +0 -121
- package/src/service/anyapi/AnyApiService.ts +0 -184
- package/src/service/base/ApiBaseService.ts +0 -42
- package/src/service/base/ApiRateLimiter.ts +0 -59
- package/src/service/base/BaseService.ts +0 -74
- package/src/service/base/RedisCacheService.ts +0 -38
- package/src/service/crudstd/CrudStdActionService.ts +0 -27
- package/src/service/crudstd/CrudStdConstant.ts +0 -62
- package/src/service/crudstd/CrudStdRelationService.ts +0 -78
- package/src/service/crudstd/CrudStdService.ts +0 -188
- package/src/service/curd/CurdMixByAccountService.ts +0 -83
- package/src/service/curd/CurdMixByDictService.ts +0 -113
- package/src/service/curd/CurdMixByLinkToCustomService.ts +0 -167
- package/src/service/curd/CurdMixBySysConfigService.ts +0 -78
- package/src/service/curd/CurdMixByWorkbenchService.ts +0 -68
- package/src/service/curd/CurdMixService.ts +0 -65
- package/src/service/curd/CurdMixUtils.ts +0 -248
- package/src/service/curd/CurdProService.ts +0 -379
- package/src/service/proxyapi/ProxyApiLoadService.ts +0 -165
- package/src/service/proxyapi/ProxyApiService.ts +0 -262
- package/src/service/proxyapi/ProxyApiUtils.ts +0 -32
- package/src/service/proxyapi/RouteHandler.ts +0 -8
- package/src/service/proxyapi/RouteTrie.ts +0 -74
- package/src/service/proxyapi/WeightedRandom.ts +0 -37
- package/src/service/proxyapi/WeightedRoundRobin.ts +0 -44
- package/src/views/404_app.html +0 -31
- package/src/views/404_workbench.html +0 -34
- package/src/views/static/favicon.ico +0 -0
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
import {Inject, Provide} from '@midwayjs/core';
|
|
2
|
-
import {Context} from '@midwayjs/koa';
|
|
3
|
-
import {IScheduleService} from '../interface';
|
|
4
|
-
import {BaseService} from "./base/BaseService";
|
|
5
|
-
import {CurdProService} from "./curd/CurdProService";
|
|
6
|
-
import {SystemDbName, SystemDbType, SystemTables} from "../models/SystemTables";
|
|
7
|
-
import {KeysOfSimpleSQL} from "../libs/crud-pro/models/keys";
|
|
8
|
-
import {FILE_GET_TYPES} from "../models/bizmodels";
|
|
9
|
-
import {CommonResult} from "../libs/utils/common-dto";
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
// 3天 的秒数
|
|
13
|
-
const EXPIRE_TIME = 3 * 24 * 60 * 60;
|
|
14
|
-
|
|
15
|
-
const STAT_TYPES = {
|
|
16
|
-
pv: 'pv',
|
|
17
|
-
uv_ip: 'uv_ip',
|
|
18
|
-
uv_uid: 'uv_uid',
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
@Provide()
|
|
23
|
-
export class VisitStatService extends BaseService implements IScheduleService {
|
|
24
|
-
@Inject()
|
|
25
|
-
protected ctx: Context;
|
|
26
|
-
|
|
27
|
-
@Inject()
|
|
28
|
-
private curdProService: CurdProService;
|
|
29
|
-
|
|
30
|
-
async runBySchedule(): Promise<any> {
|
|
31
|
-
const hours = new Date().getHours();
|
|
32
|
-
this.logInfo("[VisitStatService] runBySchedule called, hours = " + hours);
|
|
33
|
-
return this.flushVisitStatToDB();
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
async flushVisitStatToDB(): Promise<any> {
|
|
38
|
-
// 统计昨天的数据。
|
|
39
|
-
const stat_date = new Date(Date.now() - 24 * 3600 * 1000).toISOString().split('T')[0];
|
|
40
|
-
|
|
41
|
-
const lockKey = `vs_lock_${stat_date}`;
|
|
42
|
-
// 每天只能执行一次
|
|
43
|
-
const client = this.redisService;
|
|
44
|
-
const nxRes = await client.set(lockKey, 1, 'EX', EXPIRE_TIME, 'NX')
|
|
45
|
-
if (nxRes !== 'OK') {
|
|
46
|
-
this.logInfo("[VisitStatService] flushVisitStatToDB 每天只能执行一次 ");
|
|
47
|
-
return CommonResult.errorRes("每天只能执行一次")
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
this.logInfo("[VisitStatService] flushVisitStatToDB start ");
|
|
51
|
-
|
|
52
|
-
let totalCount = 0 ;
|
|
53
|
-
let successCount = 0;
|
|
54
|
-
|
|
55
|
-
try {
|
|
56
|
-
|
|
57
|
-
const keys = await client.keys(`vs_${stat_date}::*`);
|
|
58
|
-
// `vs_${date}::${req_host}::${resource_type}::${stat_type}::${resource}`;
|
|
59
|
-
totalCount = keys.length;
|
|
60
|
-
|
|
61
|
-
for (const key of keys) {
|
|
62
|
-
try {
|
|
63
|
-
const parts = key.split('::');
|
|
64
|
-
if (parts.length === 5) {
|
|
65
|
-
const req_host = parts[1];
|
|
66
|
-
const resource_type = parts[2];
|
|
67
|
-
const stat_type = parts[3];
|
|
68
|
-
const stat_resource = parts[4];
|
|
69
|
-
|
|
70
|
-
let stat_count: number;
|
|
71
|
-
if (stat_type === STAT_TYPES.uv_ip || stat_type == STAT_TYPES.uv_uid) {
|
|
72
|
-
stat_count = await client.scard(key);
|
|
73
|
-
} else {
|
|
74
|
-
stat_count = parseInt(await client.get(key)) || 0;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
await this.curdProService.executeCrudByCfg({
|
|
78
|
-
data: {
|
|
79
|
-
stat_date,
|
|
80
|
-
stat_resource,
|
|
81
|
-
stat_type,
|
|
82
|
-
resource_type,
|
|
83
|
-
stat_count,
|
|
84
|
-
req_host
|
|
85
|
-
}
|
|
86
|
-
}, {
|
|
87
|
-
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_INSERT,
|
|
88
|
-
sqlDatabase: SystemDbName,
|
|
89
|
-
sqlDdType: SystemDbType,
|
|
90
|
-
sqlTable: SystemTables.sys_visit_stats,
|
|
91
|
-
})
|
|
92
|
-
|
|
93
|
-
await client.del(key);
|
|
94
|
-
successCount++;
|
|
95
|
-
}
|
|
96
|
-
} catch (e){
|
|
97
|
-
this.logError('[VisitStatService] flushVisitStatToDB: key = ' + key, e);
|
|
98
|
-
console.log('[VisitStatService] flushVisitStatToDB: key = ' + key, e);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
} catch (error) {
|
|
102
|
-
this.logError('[VisitStatService] flushVisitStatToDB' , error);
|
|
103
|
-
console.log('[VisitStatService] flushVisitStatToDB' , error);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
this.logInfo("[VisitStatService] flushVisitStatToDB end ");
|
|
107
|
-
|
|
108
|
-
return CommonResult.successRes({successCount, totalCount})
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* 统计请求数据
|
|
114
|
-
*/
|
|
115
|
-
async trackRequest(resource: string, resourceType: string) {
|
|
116
|
-
|
|
117
|
-
// 文件下载定制
|
|
118
|
-
if (resource.startsWith('/ns/gw/file/get/')) {
|
|
119
|
-
for (let i = 0; i < FILE_GET_TYPES.length; i++) {
|
|
120
|
-
const fileGetType = FILE_GET_TYPES[i];
|
|
121
|
-
const pathPrefix = `/ns/gw/file/get/${fileGetType}/`
|
|
122
|
-
if (resource.startsWith(pathPrefix)) {
|
|
123
|
-
const res2 = resource.substring(pathPrefix.length);
|
|
124
|
-
return this.trackRequestImpl(res2, fileGetType)
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
// 文档访问定制
|
|
130
|
-
if (resource.startsWith('/ns/app/doc-editor/libview')) {
|
|
131
|
-
const {docLibId,docId} = this.ctx.query || {};
|
|
132
|
-
return this.trackRequestImpl(`${docLibId},${docId}`, 'docLibView')
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
return this.trackRequestImpl(resource, resourceType)
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
private async trackRequestImpl(resource: string, resource_type: string) {
|
|
141
|
-
const client = this.redisService;
|
|
142
|
-
const ip = this.ctx.headers['x-real-ip'];
|
|
143
|
-
const userSession = this.ctx.userSession
|
|
144
|
-
const req_host = this.ctx?.request?.host || "null" // 域名
|
|
145
|
-
const date = new Date().toISOString().split('T')[0];
|
|
146
|
-
|
|
147
|
-
const toDateResourceKey = (stat_type: string): string => {
|
|
148
|
-
return `vs_${date}::${req_host}::${resource_type}::${stat_type}::${resource}`;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
const pv_key = toDateResourceKey(STAT_TYPES.pv);
|
|
152
|
-
const uv_ip_key = toDateResourceKey(STAT_TYPES.uv_ip);
|
|
153
|
-
const uv_uid_key = toDateResourceKey(STAT_TYPES.uv_uid);
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
// 统计 PV
|
|
157
|
-
await Promise.all([
|
|
158
|
-
client.incr(pv_key),
|
|
159
|
-
client.expire(pv_key, EXPIRE_TIME)
|
|
160
|
-
]);
|
|
161
|
-
|
|
162
|
-
// IP 访问 UV
|
|
163
|
-
await Promise.all([
|
|
164
|
-
client.sadd(uv_ip_key, `${ip}`),
|
|
165
|
-
client.expire(uv_ip_key, EXPIRE_TIME)
|
|
166
|
-
]);
|
|
167
|
-
|
|
168
|
-
if (userSession && userSession.isLogin()) {
|
|
169
|
-
const accountId = userSession.getSessionInfo().accountId;
|
|
170
|
-
// 统计 UV
|
|
171
|
-
await Promise.all([
|
|
172
|
-
client.sadd(uv_uid_key, accountId),
|
|
173
|
-
client.expire(uv_uid_key, EXPIRE_TIME)
|
|
174
|
-
]);
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
}
|
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
import { Inject, Provide } from '@midwayjs/core';
|
|
2
|
-
import { Context } from '@midwayjs/koa';
|
|
3
|
-
import { KeysOfSimpleSQL } from '../libs/crud-pro/models/keys';
|
|
4
|
-
import {SystemDbName, SystemDbType, SystemTables} from '../models/SystemTables';
|
|
5
|
-
import { BaseService } from './base/BaseService';
|
|
6
|
-
// import { LRUCache } from 'lru-cache';
|
|
7
|
-
import { CurdProService } from './curd/CurdProService';
|
|
8
|
-
import { CommonException } from '../libs/crud-pro/exceptions';
|
|
9
|
-
import { parseJsonObject } from '../libs/utils/functions';
|
|
10
|
-
import { IWorkbenchEntity } from '../models/SystemEntities';
|
|
11
|
-
import { IScheduleService } from '../interface';
|
|
12
|
-
import { getDebugWorkbenchCode } from '../libs/utils/fatcms-request';
|
|
13
|
-
import { MixinUtils } from '../libs/crud-pro/utils/MixinUtils';
|
|
14
|
-
//
|
|
15
|
-
// const lruCache = new LRUCache<string, any>({
|
|
16
|
-
// max: 500,
|
|
17
|
-
// ttl: 1000 * 60 * 60,
|
|
18
|
-
// ttlAutopurge: true,
|
|
19
|
-
// });
|
|
20
|
-
|
|
21
|
-
const lruCache = new Map<string, any>();
|
|
22
|
-
|
|
23
|
-
const CACHE_KEY_WORKBENCH_LIST = 'CACHE_KEY_WORKBENCH_LIST';
|
|
24
|
-
const CACHE_KEY_DOMAIN_MAP = 'CACHE_KEY_DOMAIN_MAP';
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
@Provide()
|
|
28
|
-
export class WorkbenchService extends BaseService implements IScheduleService {
|
|
29
|
-
@Inject()
|
|
30
|
-
ctx: Context;
|
|
31
|
-
|
|
32
|
-
@Inject()
|
|
33
|
-
private curdProService: CurdProService;
|
|
34
|
-
|
|
35
|
-
public clearCache() {
|
|
36
|
-
lruCache.set(CACHE_KEY_WORKBENCH_LIST, null);
|
|
37
|
-
lruCache.set(CACHE_KEY_DOMAIN_MAP, null);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
public async runBySchedule() {
|
|
41
|
-
await this.getAllWorkbenchInfoMap(true);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
public async getAllWorkbenchInfoList(isForceRefresh?: boolean): Promise<IWorkbenchEntity[]> {
|
|
45
|
-
let listData = lruCache.get(CACHE_KEY_WORKBENCH_LIST);
|
|
46
|
-
if (!listData || isForceRefresh === true) {
|
|
47
|
-
const reqJson = { condition: {}, pageSize: 1000, limit: 1000 };
|
|
48
|
-
const res = await this.curdProService.executeCrudByCfg(reqJson, {
|
|
49
|
-
sqlTable: SystemTables.sys_workbench,
|
|
50
|
-
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_QUERY,
|
|
51
|
-
sqlDatabase: SystemDbName,
|
|
52
|
-
sqlDdType: SystemDbType,
|
|
53
|
-
});
|
|
54
|
-
listData = res.getResRows();
|
|
55
|
-
lruCache.set(CACHE_KEY_WORKBENCH_LIST, listData);
|
|
56
|
-
}
|
|
57
|
-
return listData;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
public async getAllWorkbenchInfoMap(isForceRefresh?: boolean): Promise<Record<any, IWorkbenchEntity>> {
|
|
61
|
-
let listData: any[];
|
|
62
|
-
let domainMap = lruCache.get(CACHE_KEY_DOMAIN_MAP);
|
|
63
|
-
if (!domainMap || isForceRefresh === true) {
|
|
64
|
-
listData = await this.getAllWorkbenchInfoList(isForceRefresh);
|
|
65
|
-
const domainMap1 = MixinUtils.toMap(listData, (e: any) => e.workbench_domain); // 主域名。其他两个域名。
|
|
66
|
-
const domainMap2 = MixinUtils.toMap(listData, (e: any) => e.workbench_domain2);
|
|
67
|
-
const domainMap3 = MixinUtils.toMap(listData, (e: any) => e.workbench_domain3);
|
|
68
|
-
domainMap = {...domainMap1, ...domainMap2, ...domainMap3};
|
|
69
|
-
lruCache.set(CACHE_KEY_DOMAIN_MAP, domainMap);
|
|
70
|
-
}
|
|
71
|
-
return domainMap;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
public isMatchWorkbenchCode(workbench_code_array: string | string[], workbench_code: string): boolean {
|
|
75
|
-
if (workbench_code_array === '*') {
|
|
76
|
-
return true;
|
|
77
|
-
}
|
|
78
|
-
const supportWorkbenchArray = parseJsonObject(workbench_code_array)
|
|
79
|
-
.map(s => s.trim())
|
|
80
|
-
.filter(Boolean);
|
|
81
|
-
|
|
82
|
-
return supportWorkbenchArray.includes('*') || supportWorkbenchArray.includes(workbench_code);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* 获取当前请求的域名所对应的站点信息
|
|
87
|
-
*/
|
|
88
|
-
public async getCurrentHostWorkbenchInfo(): Promise<IWorkbenchEntity> {
|
|
89
|
-
// 本地调试模式
|
|
90
|
-
if (this.isEnableDebug() && this.isLocalEnv()) {
|
|
91
|
-
const debugWorkbenchCode = getDebugWorkbenchCode(this.ctx);
|
|
92
|
-
if (!debugWorkbenchCode) {
|
|
93
|
-
throw new CommonException('本地环境调试时需要使用ModHeader浏览器插件,指定站点编码');
|
|
94
|
-
}
|
|
95
|
-
const list = await this.getAllWorkbenchInfoList();
|
|
96
|
-
for (let i = 0; i < list.length; i++) {
|
|
97
|
-
const workbenchInfo = list[i];
|
|
98
|
-
if (workbenchInfo.workbench_code === debugWorkbenchCode) {
|
|
99
|
-
return workbenchInfo;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
return null;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
//正式环境: 根据域名获取站点配置
|
|
106
|
-
const host = this.getCurrentHost();
|
|
107
|
-
const domainMap = await this.getAllWorkbenchInfoMap();
|
|
108
|
-
return domainMap[host];
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
private getCurrentHost(): string {
|
|
112
|
-
const host = this.ctx.request.host;
|
|
113
|
-
if (!host) {
|
|
114
|
-
throw new CommonException('GET_CURRENT_HOST_ERROR','获取当前域名失败');
|
|
115
|
-
}
|
|
116
|
-
return host;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
public async isSupportCurrentWorkbench(workbench_code_array: string | string[]): Promise<boolean> {
|
|
121
|
-
// 本地调试模式
|
|
122
|
-
if (this.isEnableDebug() && this.isLocalEnv()) {
|
|
123
|
-
return true;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
if (!workbench_code_array) {
|
|
127
|
-
throw new CommonException('IS_SUPPORT_CURRENT_WORKBENCH', '未配置支持的站点字段');
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
const workbench = await this.getCurrentHostWorkbenchInfo();
|
|
131
|
-
if (!workbench) {
|
|
132
|
-
throw new CommonException('WORKBENCH_IS_NOT_FOUND', '站点未找到');
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
const curWorkbenchCode = workbench.workbench_code;
|
|
136
|
-
return this.isMatchWorkbenchCode(workbench_code_array, curWorkbenchCode);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
public async isSupportCurrentHostForForMiddleware(): Promise<string | boolean> {
|
|
140
|
-
// 本地调试模式
|
|
141
|
-
if (this.isEnableDebug() && this.isLocalEnv()) {
|
|
142
|
-
return true;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
const host = this.getCurrentHost();
|
|
146
|
-
|
|
147
|
-
const workbenchInfo = await this.getCurrentHostWorkbenchInfo();
|
|
148
|
-
|
|
149
|
-
if (!workbenchInfo || workbenchInfo.status !== 1) {
|
|
150
|
-
this.logInfo(`域名不存在 host=${host}`);
|
|
151
|
-
const infos = {
|
|
152
|
-
host,
|
|
153
|
-
errorInfo: `ERR_FATCMS_REFUSED <br/> 域名配置不存在 host=${host}`,
|
|
154
|
-
};
|
|
155
|
-
this.ctx.status = 404;
|
|
156
|
-
return this.ctx.render('404_workbench', infos);
|
|
157
|
-
}
|
|
158
|
-
return true;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import { Inject, Provide } from '@midwayjs/core';
|
|
2
|
-
import { Context } from '@midwayjs/koa';
|
|
3
|
-
import * as vm from 'node:vm';
|
|
4
|
-
import { LRUCache } from 'lru-cache';
|
|
5
|
-
import { BaseService } from '../base/BaseService';
|
|
6
|
-
import { CurdMixService } from '../curd/CurdMixService';
|
|
7
|
-
import { ISysAnyApiEntity } from '../../models/SystemEntities';
|
|
8
|
-
import axios from 'axios';
|
|
9
|
-
import * as _ from 'lodash';
|
|
10
|
-
import * as moment from 'moment';
|
|
11
|
-
import * as nodemailer from 'nodemailer';
|
|
12
|
-
|
|
13
|
-
const scriptCacheOptions = {
|
|
14
|
-
max: 500,
|
|
15
|
-
ttl: 1000 * 60 * 5,
|
|
16
|
-
allowStale: false,
|
|
17
|
-
updateAgeOnGet: true,
|
|
18
|
-
updateAgeOnHas: true,
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
const scriptCache = new LRUCache<string, vm.Script>(scriptCacheOptions);
|
|
22
|
-
|
|
23
|
-
function getCompiledScript(anyApi: ISysAnyApiEntity, code: string): vm.Script {
|
|
24
|
-
const { id, func_code_md5 } = anyApi;
|
|
25
|
-
const cacheKey = id + '_' + func_code_md5;
|
|
26
|
-
const oldScript = scriptCache.get(cacheKey);
|
|
27
|
-
if (oldScript) {
|
|
28
|
-
return oldScript;
|
|
29
|
-
}
|
|
30
|
-
const script = new vm.Script(code);
|
|
31
|
-
scriptCache.set(cacheKey, script);
|
|
32
|
-
return script;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export interface IRunInSandboxParams {
|
|
36
|
-
body: any;
|
|
37
|
-
query: any;
|
|
38
|
-
headers: any;
|
|
39
|
-
params?: any;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
@Provide()
|
|
43
|
-
export class AnyApiSandboxService extends BaseService {
|
|
44
|
-
@Inject()
|
|
45
|
-
protected ctx: Context;
|
|
46
|
-
|
|
47
|
-
@Inject()
|
|
48
|
-
private curdMixService: CurdMixService;
|
|
49
|
-
|
|
50
|
-
public async runInSandbox(anyApi: ISysAnyApiEntity, allParams: IRunInSandboxParams) {
|
|
51
|
-
const { func_code, method } = anyApi;
|
|
52
|
-
|
|
53
|
-
return new Promise((resolve, reject) => {
|
|
54
|
-
const logger = this.getPrefixContextLogger(`[AnyApiSandboxService][method=${method}]`);
|
|
55
|
-
// 创建一个沙盒上下文
|
|
56
|
-
const proc = process;
|
|
57
|
-
const newContext = {
|
|
58
|
-
sandbox: {
|
|
59
|
-
allParams,
|
|
60
|
-
logger,
|
|
61
|
-
moment,
|
|
62
|
-
axios,
|
|
63
|
-
nodemailer,
|
|
64
|
-
_,
|
|
65
|
-
userSession: this.ctx.userSession,
|
|
66
|
-
ctx: this.ctx,
|
|
67
|
-
curdMixService: this.curdMixService,
|
|
68
|
-
redisService: this.redisService,
|
|
69
|
-
publicOSSService: this.getPublicOSSService(),
|
|
70
|
-
privateOSSService: this.getPrivateOSSService(),
|
|
71
|
-
returnSuccess: resolve,
|
|
72
|
-
returnError: reject,
|
|
73
|
-
processInfo: {
|
|
74
|
-
version: proc.version,
|
|
75
|
-
versions: proc.versions,
|
|
76
|
-
env: process.env,
|
|
77
|
-
argv: process.argv,
|
|
78
|
-
cwd: process.cwd(),
|
|
79
|
-
},
|
|
80
|
-
},
|
|
81
|
-
console: logger,
|
|
82
|
-
JSON: JSON,
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
const nextLine100 = new Array(10).fill('\n').join('');
|
|
86
|
-
const bindCode = this.toBindCodeString('httpController', newContext, 'sandbox');
|
|
87
|
-
const code = `
|
|
88
|
-
(async () => {
|
|
89
|
-
${nextLine100}${func_code}; // 必须有一个 class HttpController { async handleRequest(params){} }
|
|
90
|
-
${nextLine100}
|
|
91
|
-
try {
|
|
92
|
-
const httpController = new HttpController();
|
|
93
|
-
${bindCode}
|
|
94
|
-
const res = await httpController.handleRequest(sandbox.allParams.params);
|
|
95
|
-
sandbox.returnSuccess(res);
|
|
96
|
-
} catch (e) {
|
|
97
|
-
sandbox.returnError(e)
|
|
98
|
-
}
|
|
99
|
-
})(); `;
|
|
100
|
-
|
|
101
|
-
try {
|
|
102
|
-
const script = getCompiledScript(anyApi, code);
|
|
103
|
-
script.runInNewContext(newContext, {
|
|
104
|
-
filename: 'method',
|
|
105
|
-
timeout: anyApi.timeout_ms || 1000 * 60 * 5,
|
|
106
|
-
});
|
|
107
|
-
} catch (e) {
|
|
108
|
-
reject(e);
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
private toBindCodeString(toName: string, newContext: any, fromName: any): string {
|
|
114
|
-
const keys = Object.keys(newContext[fromName]);
|
|
115
|
-
return keys
|
|
116
|
-
.map(key => {
|
|
117
|
-
return `${toName}.${key} = ${fromName}.${key};\n`;
|
|
118
|
-
})
|
|
119
|
-
.join('');
|
|
120
|
-
}
|
|
121
|
-
}
|
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
import { Inject, Provide } from '@midwayjs/core';
|
|
2
|
-
import { Context } from '@midwayjs/koa';
|
|
3
|
-
import { KeysOfSimpleSQL } from '../../libs/crud-pro/models/keys';
|
|
4
|
-
import {SystemDbName, SystemDbType, SystemTables} from '../../models/SystemTables';
|
|
5
|
-
import { LRUCache } from 'lru-cache';
|
|
6
|
-
import { BizException } from '../../models/devops';
|
|
7
|
-
import { CurdMixService } from '../curd/CurdMixService';
|
|
8
|
-
import { ISysAnyApiEntity } from '../../models/SystemEntities';
|
|
9
|
-
import { AnyApiSandboxService, IRunInSandboxParams } from './AnyApiSandboxService';
|
|
10
|
-
import { parseJsonObject } from '../../libs/utils/functions';
|
|
11
|
-
import * as _ from 'lodash';
|
|
12
|
-
import { MixinUtils } from '../../libs/crud-pro/utils/MixinUtils';
|
|
13
|
-
import { WorkbenchService } from '../WorkbenchService';
|
|
14
|
-
import { validateByCfgString } from '../../libs/crud-pro/utils/ValidateUtils';
|
|
15
|
-
import { API_BASE_TYPE, ApiBaseService } from '../base/ApiBaseService';
|
|
16
|
-
|
|
17
|
-
const lruCache = new LRUCache<string, any>({
|
|
18
|
-
max: 500,
|
|
19
|
-
ttl: 1000 * 60,
|
|
20
|
-
ttlAutopurge: true,
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
@Provide()
|
|
24
|
-
export class AnyApiService extends ApiBaseService {
|
|
25
|
-
@Inject()
|
|
26
|
-
protected ctx: Context;
|
|
27
|
-
|
|
28
|
-
@Inject()
|
|
29
|
-
private curdMixService: CurdMixService;
|
|
30
|
-
|
|
31
|
-
@Inject()
|
|
32
|
-
private anyApiSandboxService: AnyApiSandboxService;
|
|
33
|
-
|
|
34
|
-
@Inject()
|
|
35
|
-
protected workbenchService: WorkbenchService;
|
|
36
|
-
|
|
37
|
-
async executeAnyApiMethod(methodCode: string, headers: any, body: any, query: any) {
|
|
38
|
-
const anyApi = await this.getAnyApiMethod(methodCode);
|
|
39
|
-
if (!anyApi || anyApi.status !== 1) {
|
|
40
|
-
throw new BizException('接口不存在或已下线:' + methodCode);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const isSupport = await this.workbenchService.isSupportCurrentWorkbench(anyApi.workbench_code_array);
|
|
44
|
-
if (!isSupport) {
|
|
45
|
-
throw new BizException('此接口不支持在当前站点打开:' + methodCode);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
await super.beforeCheckApiAccessibility(API_BASE_TYPE.PROXY_API, anyApi);
|
|
49
|
-
|
|
50
|
-
if (!anyApi.func_code) {
|
|
51
|
-
throw new BizException('没有配置代码:' + methodCode);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
if (!this.checkFuncCode(anyApi.func_code)) {
|
|
55
|
-
throw new BizException('接口代码校验失败:不满足形式: class HttpController { async handleRequest(params){} }; ');
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const allParams: IRunInSandboxParams = { headers, body, query };
|
|
59
|
-
allParams.params = this.toAnyApiParams(anyApi, allParams); // 组合参数
|
|
60
|
-
|
|
61
|
-
// 执行代码
|
|
62
|
-
const funcRes = await this.executeFunctionCode(anyApi, allParams);
|
|
63
|
-
return funcRes;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
private async getAnyApiMethod(methodCode: string): Promise<ISysAnyApiEntity> {
|
|
67
|
-
|
|
68
|
-
// 开发环境,不使用缓存
|
|
69
|
-
if (this.isEnableDebug()) {
|
|
70
|
-
return this._getAnyApiMethod(methodCode);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// 线上环境可以使用缓存
|
|
74
|
-
let anyApi = lruCache.get(methodCode);
|
|
75
|
-
if (!anyApi) {
|
|
76
|
-
anyApi = await this._getAnyApiMethod(methodCode);
|
|
77
|
-
lruCache.set(methodCode, anyApi);
|
|
78
|
-
}
|
|
79
|
-
return anyApi;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
private async _getAnyApiMethod(methodCode: string): Promise<ISysAnyApiEntity> {
|
|
83
|
-
const res = await this.curdMixService.executeCrudByCfg(
|
|
84
|
-
{ condition: { method: methodCode } },
|
|
85
|
-
{
|
|
86
|
-
sqlTable: SystemTables.sys_anyapi,
|
|
87
|
-
method: `get_sys_anyapi_${methodCode}`,
|
|
88
|
-
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_QUERY_ONE,
|
|
89
|
-
sqlDatabase: SystemDbName,
|
|
90
|
-
sqlDdType: SystemDbType,
|
|
91
|
-
updateCfg: {},
|
|
92
|
-
}
|
|
93
|
-
);
|
|
94
|
-
const obj: ISysAnyApiEntity = res.getOneObj();
|
|
95
|
-
if (!obj) {
|
|
96
|
-
return null;
|
|
97
|
-
}
|
|
98
|
-
obj.parsedOthers = parseJsonObject(obj.others);
|
|
99
|
-
return obj;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* 构造参数
|
|
104
|
-
* @param anyApi
|
|
105
|
-
* @param allParams
|
|
106
|
-
* @private
|
|
107
|
-
*/
|
|
108
|
-
private toAnyApiParams(anyApi: ISysAnyApiEntity, allParams: IRunInSandboxParams): any {
|
|
109
|
-
if (!anyApi.req_params) {
|
|
110
|
-
return {};
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
const configs = anyApi.parsedOthers?.req_params || [];
|
|
114
|
-
const params = {};
|
|
115
|
-
for (let i = 0; i < configs.length; i++) {
|
|
116
|
-
const { name, fromType, fromKey, validate_required, validate_cfg_list, valueType, defaultValue } = configs[i];
|
|
117
|
-
const value = _.get(allParams, [fromType, fromKey], defaultValue);
|
|
118
|
-
if (validate_required && MixinUtils.isEmpty(value)) {
|
|
119
|
-
throw new BizException(`参数校验失败:${name} 不能为空`);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
// 参数校验
|
|
123
|
-
if (Array.isArray(validate_cfg_list)) {
|
|
124
|
-
for (let j = 0; j < validate_cfg_list.length; j++) {
|
|
125
|
-
const validateCfg = validate_cfg_list[j];
|
|
126
|
-
validateByCfgString(validateCfg, value, name);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
// 格式转换
|
|
131
|
-
params[name] = MixinUtils.parseValueByType(value, valueType);
|
|
132
|
-
}
|
|
133
|
-
return params;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* 运行代码
|
|
138
|
-
* @param anyApiEntity
|
|
139
|
-
* @param allParams
|
|
140
|
-
* @private
|
|
141
|
-
*/
|
|
142
|
-
private async executeFunctionCode(anyApiEntity: ISysAnyApiEntity, allParams: IRunInSandboxParams): Promise<any> {
|
|
143
|
-
return this.anyApiSandboxService.runInSandbox(anyApiEntity, allParams);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
private checkFuncCode(func_code: string): boolean {
|
|
147
|
-
if (!func_code) {
|
|
148
|
-
return false;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
const lineHasKey = (lineTrim: string, target: string): boolean => {
|
|
152
|
-
const words = lineTrim.split(/[\s{}();]/);
|
|
153
|
-
for (let i = 0; i < words.length; i++) {
|
|
154
|
-
const word = words[i];
|
|
155
|
-
if (word && word === target) {
|
|
156
|
-
return true;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
return false;
|
|
160
|
-
};
|
|
161
|
-
|
|
162
|
-
let hasClass = false;
|
|
163
|
-
let hasMethod = false;
|
|
164
|
-
const lines = func_code.split('\n');
|
|
165
|
-
for (let i = 0; i < lines.length; i++) {
|
|
166
|
-
const line = lines[i];
|
|
167
|
-
if (line) {
|
|
168
|
-
const lineTrim = line.trim();
|
|
169
|
-
if (lineTrim) {
|
|
170
|
-
if (lineHasKey(lineTrim, 'class') && lineHasKey(lineTrim, 'HttpController')) {
|
|
171
|
-
hasClass = true;
|
|
172
|
-
}
|
|
173
|
-
if (lineHasKey(lineTrim, 'async') && lineHasKey(lineTrim, 'handleRequest')) {
|
|
174
|
-
hasMethod = true;
|
|
175
|
-
}
|
|
176
|
-
if (lineTrim.startsWith('handleRequest')) {
|
|
177
|
-
hasMethod = true;
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
return hasMethod && hasClass;
|
|
183
|
-
}
|
|
184
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { Provide } from '@midwayjs/core';
|
|
2
|
-
import { BaseService } from './BaseService';
|
|
3
|
-
import { IApiBaseEntity } from '../../models/SystemEntities';
|
|
4
|
-
import { BizException } from '../../models/devops';
|
|
5
|
-
import { Exceptions } from '../../libs/crud-pro/exceptions';
|
|
6
|
-
import { tryAcquireToken } from './ApiRateLimiter';
|
|
7
|
-
|
|
8
|
-
export const API_BASE_TYPE = {
|
|
9
|
-
PROXY_API: 'PROXY_API',
|
|
10
|
-
ANY_API: 'ANY_API',
|
|
11
|
-
CRUD_METHOD: 'CRUD_METHOD',
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
@Provide()
|
|
15
|
-
export class ApiBaseService extends BaseService {
|
|
16
|
-
/**
|
|
17
|
-
* 前置校验
|
|
18
|
-
* @param apiBaseType
|
|
19
|
-
* @param entity
|
|
20
|
-
*/
|
|
21
|
-
public async beforeCheckApiAccessibility(apiBaseType: string, entity: IApiBaseEntity) {
|
|
22
|
-
// 权限校验
|
|
23
|
-
const isPermSuccess = this.ctx.userSession.isAuthPass(entity.auth_type as any, entity.auth_config);
|
|
24
|
-
if (!isPermSuccess) {
|
|
25
|
-
throw new BizException('权限校验失败', Exceptions.NO_AUTH);
|
|
26
|
-
}
|
|
27
|
-
//服务降级
|
|
28
|
-
if (entity.fallback_enable === 1) {
|
|
29
|
-
throw new BizException(entity.fallback_message || '此服务暂时不支持访问', 'FALLBACK_ENABLE');
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// 限流令牌桶
|
|
33
|
-
if (entity.limit_enabled === 1) {
|
|
34
|
-
const accountId = this.ctx.userSession.getSessionInfo().accountId;
|
|
35
|
-
const apiId = apiBaseType + '_' + entity.id;
|
|
36
|
-
const isAcquire = tryAcquireToken(apiId, accountId, entity.limit_max, entity.limit_rate);
|
|
37
|
-
if (!isAcquire) {
|
|
38
|
-
throw new BizException('频繁访问此接口,被限流', 'LIMIT_ENABLED');
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|