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,394 @@
|
|
|
1
|
+
import { Provide, Inject } from '@midwayjs/core';
|
|
2
|
+
import { Context } from '@midwayjs/koa';
|
|
3
|
+
import * as mime from 'mime-types';
|
|
4
|
+
import * as md5 from 'md5';
|
|
5
|
+
import * as fs from 'fs';
|
|
6
|
+
import * as util from 'util';
|
|
7
|
+
import { BizException } from '../models/devops';
|
|
8
|
+
import { CurdMixService } from './curd/CurdMixService';
|
|
9
|
+
import { KeysOfSimpleSQL, KeysOfValidators } from '../libs/crud-pro/models/keys';
|
|
10
|
+
import { AccessType, IEntityCommonInfo, UploadCategoryType } from '../models/bizmodels';
|
|
11
|
+
import { IRequestCfgModel } from '../libs/crud-pro/interfaces';
|
|
12
|
+
import { BaseService } from './base/BaseService';
|
|
13
|
+
import {SystemDbName, SystemDbType} from '../models/SystemTables';
|
|
14
|
+
|
|
15
|
+
function getSuffix(s: string): string {
|
|
16
|
+
if (s) {
|
|
17
|
+
const indexOf = s.lastIndexOf('.');
|
|
18
|
+
if (indexOf > 0) {
|
|
19
|
+
return s.substring(indexOf); //'.jpg'
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return '';
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function getDateTimeString() {
|
|
26
|
+
const now = new Date();
|
|
27
|
+
const year = now.getFullYear();
|
|
28
|
+
const month = now.getMonth() + 1;
|
|
29
|
+
const day = now.getDate();
|
|
30
|
+
return [year, month, day]
|
|
31
|
+
.map(num => {
|
|
32
|
+
if (num < 10) {
|
|
33
|
+
return '0' + num;
|
|
34
|
+
}
|
|
35
|
+
return num;
|
|
36
|
+
})
|
|
37
|
+
.join('');
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function generateFileKey(filename: string, sessionId: string, fileStat: any) {
|
|
41
|
+
const fileStatString = JSON.stringify(fileStat);
|
|
42
|
+
const date = getDateTimeString();
|
|
43
|
+
const fileSuffix = getSuffix(filename).toLowerCase();
|
|
44
|
+
const fileKey = md5(`${filename}${sessionId}${fileStatString}${Math.random()}`) + Date.now() + fileSuffix;
|
|
45
|
+
const storagePath = `upload/${date}/${fileKey}`;
|
|
46
|
+
|
|
47
|
+
return {
|
|
48
|
+
fileKey,
|
|
49
|
+
fileSuffix,
|
|
50
|
+
storagePath,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function getAssetsContentType(filename: string): string {
|
|
55
|
+
if (filename.endsWith('.css')) {
|
|
56
|
+
return 'text/css';
|
|
57
|
+
}
|
|
58
|
+
if (filename.endsWith('.txt')) {
|
|
59
|
+
return 'text/plain';
|
|
60
|
+
}
|
|
61
|
+
if (filename.endsWith('.js') || filename.endsWith('.cjs')) {
|
|
62
|
+
return 'application/javascript';
|
|
63
|
+
}
|
|
64
|
+
if (filename.endsWith('.html')) {
|
|
65
|
+
return 'text/html';
|
|
66
|
+
}
|
|
67
|
+
const contentType = mime.lookup(filename);
|
|
68
|
+
if (contentType && typeof contentType === 'string') {
|
|
69
|
+
return contentType;
|
|
70
|
+
}
|
|
71
|
+
return 'application/octet-stream';
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
// JPG、PNG、BMP、GIF、WebP、TIFF
|
|
76
|
+
export function isImageFile(fileKey: string) {
|
|
77
|
+
const fileKey1 = fileKey.toLowerCase();
|
|
78
|
+
const suffix = ['.jpg', '.jpeg', '.png', '.bmp', '.gif', '.webp', '.tiff'];
|
|
79
|
+
for (let i = 0; i < suffix.length; i++) {
|
|
80
|
+
const suffix1 = suffix[i];
|
|
81
|
+
if (fileKey1.endsWith(suffix1)) {
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
interface IFileInfo extends IEntityCommonInfo {
|
|
89
|
+
file_key: string;
|
|
90
|
+
file_name: string;
|
|
91
|
+
file_size: number;
|
|
92
|
+
file_type: string;
|
|
93
|
+
file_suffix: string;
|
|
94
|
+
file_desc: string;
|
|
95
|
+
storage_path: string;
|
|
96
|
+
storage_url: string;
|
|
97
|
+
storage_engine: string;
|
|
98
|
+
access_type: string;
|
|
99
|
+
referer: string;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
class FileDB {
|
|
103
|
+
private curdMixService: CurdMixService;
|
|
104
|
+
|
|
105
|
+
constructor(curdMixService: CurdMixService) {
|
|
106
|
+
this.curdMixService = curdMixService;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
async getFileInfo(fileKey: string): Promise<IFileInfo> {
|
|
110
|
+
const condition: any = { file_key: fileKey };
|
|
111
|
+
const cfgModel: IRequestCfgModel = {
|
|
112
|
+
sqlTable: 'sys_file',
|
|
113
|
+
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_QUERY_ONE,
|
|
114
|
+
sqlDatabase: SystemDbName,
|
|
115
|
+
sqlDdType: SystemDbType,
|
|
116
|
+
validateCfg: {
|
|
117
|
+
'condition.file_key': [KeysOfValidators.REQUIRED, KeysOfValidators.STRING],
|
|
118
|
+
},
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
const res = await this.curdMixService.executeCrudByCfg({ condition }, cfgModel);
|
|
122
|
+
return res.getOneObj();
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
async saveFileInfo(fileInfo: IFileInfo) {
|
|
126
|
+
const cfgModel = {
|
|
127
|
+
sqlTable: 'sys_file',
|
|
128
|
+
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_INSERT,
|
|
129
|
+
sqlDatabase: SystemDbName,
|
|
130
|
+
sqlDdType: SystemDbType,
|
|
131
|
+
};
|
|
132
|
+
return await this.curdMixService.executeCrudByCfg(
|
|
133
|
+
{
|
|
134
|
+
data: fileInfo,
|
|
135
|
+
condition: {
|
|
136
|
+
file_key: fileInfo.file_key,
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
cfgModel
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
async saveAssetsLog(fileInfo: IFileInfo) {
|
|
144
|
+
const cfgModel = {
|
|
145
|
+
sqlTable: 'sys_assets_log',
|
|
146
|
+
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_INSERT,
|
|
147
|
+
sqlDatabase: SystemDbName,
|
|
148
|
+
sqlDdType: SystemDbType,
|
|
149
|
+
};
|
|
150
|
+
return await this.curdMixService.executeCrudByCfg({ data: fileInfo }, cfgModel);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
async deleteFileInfo(id: number) {
|
|
154
|
+
const cfgModel: IRequestCfgModel = {
|
|
155
|
+
sqlTable: 'sys_file',
|
|
156
|
+
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_DELETE,
|
|
157
|
+
sqlDatabase: SystemDbName,
|
|
158
|
+
sqlDdType: SystemDbType,
|
|
159
|
+
validateCfg: {
|
|
160
|
+
'condition.id': [KeysOfValidators.REQUIRED, KeysOfValidators.NUMBER],
|
|
161
|
+
},
|
|
162
|
+
};
|
|
163
|
+
return await this.curdMixService.executeCrudByCfg({ condition: { id } }, cfgModel);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
interface IUploadFileToOSSOptions {
|
|
168
|
+
uploadCategoryType: UploadCategoryType;
|
|
169
|
+
uploadPath: string;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
export const PATH_PREFIX = '/ns/gw/file';
|
|
175
|
+
|
|
176
|
+
export function toDownloadPaths(origin: string, fileKey: string) {
|
|
177
|
+
const downloadPath = `${PATH_PREFIX}/get/download/${fileKey}`;
|
|
178
|
+
const previewPath = `${PATH_PREFIX}/get/preview/${fileKey}`;
|
|
179
|
+
const thumbnailPath = `${PATH_PREFIX}/get/thumbnail/${fileKey}`;
|
|
180
|
+
|
|
181
|
+
return {
|
|
182
|
+
downloadPath,
|
|
183
|
+
previewPath,
|
|
184
|
+
thumbnailPath,
|
|
185
|
+
downloadURL: `${origin}${downloadPath}`,
|
|
186
|
+
previewURL: `${origin}${previewPath}`,
|
|
187
|
+
thumbnailURL: `${origin}${thumbnailPath}`,
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
function toUploadOriginByReferer(referer: string): string {
|
|
193
|
+
try {
|
|
194
|
+
if (!referer || !referer.startsWith('http')) {
|
|
195
|
+
return '';
|
|
196
|
+
}
|
|
197
|
+
const urlObj = new URL(referer);
|
|
198
|
+
const pathname = urlObj.pathname;
|
|
199
|
+
if (pathname.startsWith('/ns/app/doc-editor/')) {
|
|
200
|
+
return 'doc-editor';
|
|
201
|
+
}
|
|
202
|
+
if (pathname.startsWith('/pages/devops/file-manage')) {
|
|
203
|
+
return 'file-manage';
|
|
204
|
+
}
|
|
205
|
+
} catch (error) {
|
|
206
|
+
console.error('toUploadOriginByReferer', error);
|
|
207
|
+
}
|
|
208
|
+
return '';
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
@Provide()
|
|
213
|
+
export class FileCenterService extends BaseService {
|
|
214
|
+
@Inject()
|
|
215
|
+
protected ctx: Context;
|
|
216
|
+
|
|
217
|
+
@Inject()
|
|
218
|
+
private curdMixService: CurdMixService;
|
|
219
|
+
|
|
220
|
+
private get fileBD(): FileDB {
|
|
221
|
+
return new FileDB(this.curdMixService);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
public async uploadFileToOSS(files: any, accessType: AccessType, referer: string, options?: IUploadFileToOSSOptions) {
|
|
225
|
+
if (!files || files.length === 0) {
|
|
226
|
+
throw new BizException('没有选中任何文件');
|
|
227
|
+
}
|
|
228
|
+
if (files.length > 1) {
|
|
229
|
+
throw new BizException('每次只能上传一个文件');
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
const file = files[0]; // 每次只能上传一个文件
|
|
233
|
+
const { mimeType, filename, data: fileData } = file;
|
|
234
|
+
this.logInfo('[FileCenterService]uploadFileToOSS', file);
|
|
235
|
+
|
|
236
|
+
const statAsync = util.promisify(fs.stat);
|
|
237
|
+
|
|
238
|
+
const fileStat = await statAsync(fileData);
|
|
239
|
+
|
|
240
|
+
this.logInfo('[FileCenterService]uploadFileToOSS fileStat', fileStat);
|
|
241
|
+
|
|
242
|
+
const sessionId = this.ctx.userSession.getSessionInfo().sessionId;
|
|
243
|
+
|
|
244
|
+
let fileSuffix = getSuffix(filename).toLowerCase();
|
|
245
|
+
let fileKey: string, storagePath: string, result: any;
|
|
246
|
+
const isAssets = options && options.uploadCategoryType === UploadCategoryType.assets;
|
|
247
|
+
if (isAssets) {
|
|
248
|
+
const uploadPath = options.uploadPath;
|
|
249
|
+
storagePath = `assets/${uploadPath}`;
|
|
250
|
+
fileKey = storagePath;
|
|
251
|
+
result = await this.getPublicOSSService().put(storagePath, fileData, {
|
|
252
|
+
mime: mimeType,
|
|
253
|
+
headers: {
|
|
254
|
+
'Content-Type': getAssetsContentType(filename),
|
|
255
|
+
},
|
|
256
|
+
});
|
|
257
|
+
} else {
|
|
258
|
+
const generated = generateFileKey(filename, sessionId, fileStat);
|
|
259
|
+
fileKey = generated.fileKey;
|
|
260
|
+
fileSuffix = generated.fileSuffix;
|
|
261
|
+
storagePath = generated.storagePath;
|
|
262
|
+
result = await this.getPrivateOSSService().put(storagePath, fileData, {
|
|
263
|
+
mime: mimeType,
|
|
264
|
+
headers: {
|
|
265
|
+
'Content-Type': getAssetsContentType(filename),
|
|
266
|
+
'Content-Disposition': `attachment; filename="${encodeURI(filename)}"`,
|
|
267
|
+
},
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
const uploadOrigin = toUploadOriginByReferer(referer);
|
|
272
|
+
|
|
273
|
+
const saveInfo = {
|
|
274
|
+
file_key: fileKey,
|
|
275
|
+
file_name: filename,
|
|
276
|
+
file_size: fileStat.size,
|
|
277
|
+
file_type: file.mimeType,
|
|
278
|
+
file_suffix: fileSuffix,
|
|
279
|
+
file_desc: '',
|
|
280
|
+
storage_path: storagePath,
|
|
281
|
+
storage_url: result.url,
|
|
282
|
+
storage_engine: 'AliYunOSS',
|
|
283
|
+
access_type: accessType,
|
|
284
|
+
referer: referer,
|
|
285
|
+
upload_origin: uploadOrigin,
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
if (isAssets) {
|
|
289
|
+
await this.fileBD.saveAssetsLog(saveInfo);
|
|
290
|
+
} else {
|
|
291
|
+
await this.fileBD.saveFileInfo(saveInfo);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
return {
|
|
295
|
+
fileKey,
|
|
296
|
+
fileSuffix,
|
|
297
|
+
storagePath,
|
|
298
|
+
storageUrl: result.url,
|
|
299
|
+
fileSize: result.res.size,
|
|
300
|
+
filename: file.filename,
|
|
301
|
+
mimeType: file.mimeType,
|
|
302
|
+
name: result.name,
|
|
303
|
+
url: result.url,
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
public async deleteFile(fileKey: string) {
|
|
308
|
+
const fileInfo = await this.fileBD.getFileInfo(fileKey);
|
|
309
|
+
if (!fileInfo || fileInfo.status !== 1) {
|
|
310
|
+
throw new BizException('文件不存在');
|
|
311
|
+
}
|
|
312
|
+
const storagePath = fileInfo.storage_path;
|
|
313
|
+
const res = await this.getPrivateOSSService().delete(storagePath);
|
|
314
|
+
this.logInfo('deleteFile', res);
|
|
315
|
+
|
|
316
|
+
return await this.fileBD.deleteFileInfo(fileInfo.id);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
private async headFile(path: string) {
|
|
320
|
+
try {
|
|
321
|
+
return await this.getPrivateOSSService().head(path);
|
|
322
|
+
} catch (error) {
|
|
323
|
+
if (error.code !== 'NoSuchKey') {
|
|
324
|
+
this.logError('[FILE_CHECK_ERROR]', error);
|
|
325
|
+
}
|
|
326
|
+
return false;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
public async downloadFile(fileKey: string, streaming: boolean, process: string): Promise<any> {
|
|
331
|
+
const fileInfo = await this.fileBD.getFileInfo(fileKey);
|
|
332
|
+
if (!fileInfo || fileInfo.status !== 1) {
|
|
333
|
+
throw new BizException('文件不存在');
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
await this.checkAuthUserDownloadFile(fileInfo);
|
|
337
|
+
|
|
338
|
+
const storagePath = fileInfo.storage_path;
|
|
339
|
+
|
|
340
|
+
const header = await this.headFile(storagePath);
|
|
341
|
+
if (!header) {
|
|
342
|
+
throw new BizException('文件不存在或者已过期');
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
const urlParam: any = {};
|
|
346
|
+
urlParam.expires = 60;
|
|
347
|
+
if (process) {
|
|
348
|
+
urlParam.process = process;
|
|
349
|
+
}
|
|
350
|
+
try {
|
|
351
|
+
if (streaming) {
|
|
352
|
+
const { res, stream } = await this.getPrivateOSSService().getStream(storagePath, urlParam);
|
|
353
|
+
return { res, stream, downloadURL: null };
|
|
354
|
+
} else {
|
|
355
|
+
const downloadURL = this.getPrivateOSSService().signatureUrl(storagePath, urlParam);
|
|
356
|
+
return { res: null, stream: null, downloadURL };
|
|
357
|
+
}
|
|
358
|
+
} catch (e) {
|
|
359
|
+
this.logError('ossService ==> ', storagePath);
|
|
360
|
+
throw e;
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
/**
|
|
365
|
+
* 检查用户下载权限
|
|
366
|
+
* @param fileInfo
|
|
367
|
+
* @private
|
|
368
|
+
*/
|
|
369
|
+
private async checkAuthUserDownloadFile(fileInfo: IFileInfo) {
|
|
370
|
+
const userSession = this.ctx.userSession;
|
|
371
|
+
if (userSession.isSuperAdmin()) {
|
|
372
|
+
return 'OK';
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
const access_type = fileInfo.access_type;
|
|
376
|
+
if (access_type === AccessType.open) {
|
|
377
|
+
return 'OK';
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
if (access_type === AccessType.owner) {
|
|
381
|
+
if (!userSession.isMySelf(fileInfo.created_by)) {
|
|
382
|
+
throw new BizException('您没有访问此文件的权限');
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
if (access_type === AccessType.login) {
|
|
387
|
+
if (!userSession.isLogin()) {
|
|
388
|
+
throw new BizException('您当前未登录,您没有访问此文件的权限');
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
return 'OK';
|
|
393
|
+
}
|
|
394
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
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 {CurdProService} from "./curd/CurdProService";
|
|
7
|
+
|
|
8
|
+
@Provide()
|
|
9
|
+
export class SysConfigService extends BaseService {
|
|
10
|
+
@Inject()
|
|
11
|
+
ctx: Context;
|
|
12
|
+
|
|
13
|
+
@Inject()
|
|
14
|
+
private curdProService: CurdProService;
|
|
15
|
+
|
|
16
|
+
async getSysConfigOne(config_code: string): Promise<any> {
|
|
17
|
+
if (!config_code){
|
|
18
|
+
throw new Error('[getSysConfigOne] config_code required');
|
|
19
|
+
}
|
|
20
|
+
const res1 = await this.curdProService.executeCrudByCfg(
|
|
21
|
+
{
|
|
22
|
+
condition: { config_code },
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
sqlTable: SystemTables.sys_configs,
|
|
26
|
+
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_QUERY_ONE,
|
|
27
|
+
sqlDatabase: SystemDbName,
|
|
28
|
+
sqlDdType: SystemDbType,
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
return res1.getOneObj();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import * as md5 from 'md5';
|
|
2
|
+
import { Inject, Provide } from '@midwayjs/core';
|
|
3
|
+
import { Context } from '@midwayjs/koa';
|
|
4
|
+
import { KeysOfSimpleSQL } from '../libs/crud-pro/models/keys';
|
|
5
|
+
import { CurdMixService } from './curd/CurdMixService';
|
|
6
|
+
import { createUniqueId } from '../libs/utils/functions';
|
|
7
|
+
import { CommonException, Exceptions } from '../libs/crud-pro/exceptions';
|
|
8
|
+
import { IRequestCfgModel, IRequestModel } from '../libs/crud-pro/interfaces';
|
|
9
|
+
import {SystemDbName, SystemDbType, SystemTables} from '../models/SystemTables';
|
|
10
|
+
import { CommonResult } from '../libs/utils/common-dto';
|
|
11
|
+
|
|
12
|
+
@Provide()
|
|
13
|
+
export class UserAccountService {
|
|
14
|
+
@Inject()
|
|
15
|
+
ctx: Context;
|
|
16
|
+
@Inject()
|
|
17
|
+
private curdMixService: CurdMixService;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* 查询用户: 根据loginName查询
|
|
21
|
+
* @param loginName
|
|
22
|
+
*/
|
|
23
|
+
public async queryUserAccountByLoginName(loginName: string) {
|
|
24
|
+
const query = await this.curdMixService.executeCrudByCfg(
|
|
25
|
+
{
|
|
26
|
+
condition: { login_name: loginName },
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
method: 'UserAccountService.queryUserAccountByLoginName',
|
|
30
|
+
sqlTable: SystemTables.sys_user_account,
|
|
31
|
+
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_QUERY_ONE,
|
|
32
|
+
sqlDatabase: SystemDbName,
|
|
33
|
+
sqlDdType: SystemDbType,
|
|
34
|
+
}
|
|
35
|
+
);
|
|
36
|
+
const { row } = query.getResModel();
|
|
37
|
+
return row;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* 查询基本信息:根据accountId数组
|
|
42
|
+
* @param accountIdList
|
|
43
|
+
* @param columns
|
|
44
|
+
*/
|
|
45
|
+
public async queryAccountBasicInfoByIds(accountIdList: any[], columns: string[]): Promise<any[]> {
|
|
46
|
+
if (!accountIdList || accountIdList.length === 0) {
|
|
47
|
+
return [];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const accountIds = accountIdList.map(userId => {
|
|
51
|
+
return `${userId}`;
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
const cfgModel: IRequestCfgModel = {
|
|
55
|
+
method: 'UserAccountService.queryAccountBasicInfoByIds',
|
|
56
|
+
sqlTable: SystemTables.sys_user_account,
|
|
57
|
+
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_QUERY,
|
|
58
|
+
sqlDatabase: SystemDbName,
|
|
59
|
+
sqlDdType: SystemDbType,
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const reqJson: IRequestModel = {
|
|
63
|
+
columns: columns,
|
|
64
|
+
condition: {
|
|
65
|
+
account_id: {
|
|
66
|
+
$in: accountIds,
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const res = await this.curdMixService.executeCrudByCfg(reqJson, cfgModel);
|
|
72
|
+
return res.getResRows();
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* 修改密码
|
|
77
|
+
* @param loginName
|
|
78
|
+
* @param unsaltedPwd
|
|
79
|
+
*/
|
|
80
|
+
public async chgUserPassword(loginName: any, unsaltedPwd: any) {
|
|
81
|
+
if (!loginName) {
|
|
82
|
+
throw new CommonException(Exceptions.OTHER_EXCEPTION, 'loginName不存在');
|
|
83
|
+
}
|
|
84
|
+
const pwd_salt = createUniqueId();
|
|
85
|
+
const pwd_md5 = md5(unsaltedPwd + pwd_salt);
|
|
86
|
+
const res1 = await this.curdMixService.executeCrudByCfg(
|
|
87
|
+
{
|
|
88
|
+
data: { pwd_md5: pwd_md5, pwd_salt: pwd_salt },
|
|
89
|
+
condition: { login_name: loginName },
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
sqlTable: SystemTables.sys_user_account,
|
|
93
|
+
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_UPDATE,
|
|
94
|
+
sqlDatabase: SystemDbName,
|
|
95
|
+
sqlDdType: SystemDbType,
|
|
96
|
+
}
|
|
97
|
+
);
|
|
98
|
+
return CommonResult.successRes(res1.getResModel());
|
|
99
|
+
}
|
|
100
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import {Inject, Provide} from '@midwayjs/core';
|
|
2
|
+
import {Context} from '@midwayjs/koa';
|
|
3
|
+
import {parseJsonObject} from '../libs/utils/functions';
|
|
4
|
+
import {ISessionInfo, SESSION_ID_KEY, sessionCookieCfg} from '../models/userSession';
|
|
5
|
+
import {RedisCacheService} from "./base/RedisCacheService";
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
function pickUserAvatar(avatar: any): string {
|
|
9
|
+
if (!avatar) {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
if (typeof avatar === 'string') {
|
|
13
|
+
if (avatar.startsWith('http') || avatar.startsWith('/')) {
|
|
14
|
+
return avatar;
|
|
15
|
+
}
|
|
16
|
+
const obj = parseJsonObject(avatar);
|
|
17
|
+
if (!obj) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
if (Array.isArray(obj)) {
|
|
21
|
+
return pickUserAvatar(obj[0]);
|
|
22
|
+
}
|
|
23
|
+
return pickUserAvatar(obj);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (avatar && avatar.imgURL) {
|
|
27
|
+
return avatar.imgURL;
|
|
28
|
+
}
|
|
29
|
+
if (avatar && avatar.downloadURL) {
|
|
30
|
+
return avatar.downloadURL;
|
|
31
|
+
}
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
const SESSION_KEEP_TIME_SECOND: number = 3600 * 24 * 30;
|
|
37
|
+
|
|
38
|
+
const toCacheKey = (sessionId: string)=>{
|
|
39
|
+
return `UserSession@@${sessionId}`;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
@Provide()
|
|
43
|
+
export class UserSessionService {
|
|
44
|
+
@Inject()
|
|
45
|
+
private ctx: Context;
|
|
46
|
+
|
|
47
|
+
@Inject()
|
|
48
|
+
private redisCacheService: RedisCacheService
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
public async saveUserSession(sessionInfo: ISessionInfo) {
|
|
52
|
+
sessionInfo.avatar = pickUserAvatar(sessionInfo.avatar);
|
|
53
|
+
const sessionId = sessionInfo.sessionId;
|
|
54
|
+
await this.redisCacheService.setJsonObject(toCacheKey(sessionId), sessionInfo, SESSION_KEEP_TIME_SECOND)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* 移除Session
|
|
59
|
+
* @param sessionId
|
|
60
|
+
*/
|
|
61
|
+
public async removeUserSession(sessionId: string) {
|
|
62
|
+
return await this.redisCacheService.removeItem(toCacheKey(sessionId))
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
private async getCurrentUserSessionForMiddleware1(sessionId: string): Promise<ISessionInfo> {
|
|
66
|
+
if (!sessionId) {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
return await this.redisCacheService.getJsonObject(toCacheKey(sessionId))
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* 专门给中间件点调用的
|
|
74
|
+
*/
|
|
75
|
+
public async getCurrentUserSessionForMiddleware(): Promise<ISessionInfo> {
|
|
76
|
+
const cookies = this.ctx.cookies;
|
|
77
|
+
const sessionId = cookies.get(SESSION_ID_KEY, sessionCookieCfg);
|
|
78
|
+
return this.getCurrentUserSessionForMiddleware1(sessionId);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
}
|