From 7ced8c7b82791ba4b71e9afccabccb1dda2f445d Mon Sep 17 00:00:00 2001 From: cKey <35512826+colinin@users.noreply.github.com> Date: Fri, 5 Nov 2021 10:04:02 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=BD=91=E5=85=B3=E8=81=9A?= =?UTF-8?q?=E5=90=88api=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- aspnet-core/database/ApiGateway-Init.sql | 133 ++++++----- ...ueVbenAdminNavigationDefinitionProvider.cs | 11 + .../BackendAdminHostModule.Configure.cs | 1 + .../TenantHeaderParamter.cs | 33 +++ .../LINGYUN.ApiGateway.Host/.gitignore | 3 +- .../ApiGatewayHostModule.Builder.cs | 24 ++ .../ApiGatewayHostModule.Configure.cs | 224 ++++++++++++++++++ .../ApiGatewayHostModule.cs | 153 ++---------- .../ApiGatewayOptions.cs | 21 +- .../LINGYUN.ApiGateway.Host.csproj | 1 + .../Models/DownstreamOpenApi.cs | 8 + .../Properties/launchSettings.json | 40 ++-- .../TenantHeaderParamter.cs | 33 +++ .../appsettings.Development.json | 28 ++- .../LINGYUN.ApiGateway.Host/appsettings.json | 7 + .../LINGYUN.ApiGateway.Host/event-bus-cap.db | Bin 40960 -> 0 bytes .../ApiGatewayHttpApiHostModule.Configure.cs | 1 + .../TenantHeaderParamter.cs | 33 +++ ...yServerAdminHttpApiHostModule.Configure.cs | 1 + .../TenantHeaderParamter.cs | 33 +++ ...onManagementHttpApiHostModule.Configure.cs | 1 + .../LocalizationCacheInitialize.cs | 47 ---- .../TenantHeaderParamter.cs | 33 +++ ...ssageServiceHttpApiHostModule.Configure.cs | 1 + .../TenantHeaderParamter.cs | 33 +++ .../AppPlatformHttpApiHostModule.Configure.cs | 1 + .../LINGYUN.Platform.HttpApi.Host.csproj.user | 4 +- .../TenantHeaderParamter.cs | 33 +++ 28 files changed, 668 insertions(+), 273 deletions(-) create mode 100644 aspnet-core/services/admin/LINGYUN.Abp.BackendAdmin.HttpApi.Host/TenantHeaderParamter.cs create mode 100644 aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/ApiGatewayHostModule.Builder.cs create mode 100644 aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/ApiGatewayHostModule.Configure.cs create mode 100644 aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/Models/DownstreamOpenApi.cs create mode 100644 aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/TenantHeaderParamter.cs delete mode 100644 aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/event-bus-cap.db create mode 100644 aspnet-core/services/apigateway/LINGYUN.ApiGateway.HttpApi.Host/TenantHeaderParamter.cs create mode 100644 aspnet-core/services/identity-server/LINGYUN.Abp.IdentityServer4.HttpApi.Host/TenantHeaderParamter.cs delete mode 100644 aspnet-core/services/localization/LINGYUN.Abp.LocalizationManagement.HttpApi.Host/LocalizationCacheInitialize.cs create mode 100644 aspnet-core/services/localization/LINGYUN.Abp.LocalizationManagement.HttpApi.Host/TenantHeaderParamter.cs create mode 100644 aspnet-core/services/messages/LINGYUN.Abp.MessageService.HttpApi.Host/TenantHeaderParamter.cs create mode 100644 aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/TenantHeaderParamter.cs diff --git a/aspnet-core/database/ApiGateway-Init.sql b/aspnet-core/database/ApiGateway-Init.sql index cd7645184..e0b8d0c39 100644 --- a/aspnet-core/database/ApiGateway-Init.sql +++ b/aspnet-core/database/ApiGateway-Init.sql @@ -11,7 +11,7 @@ Target Server Version : 50736 File Encoding : 65001 - Date: 30/10/2021 13:52:29 + Date: 05/11/2021 09:45:37 */ SET NAMES utf8mb4; @@ -36,10 +36,10 @@ INSERT INTO `__efmigrationshistory` VALUES ('20200618090102_Modify-ReRoute-Index INSERT INTO `__efmigrationshistory` VALUES ('20200908020925_Upgrade-abp-3.1.0', '3.1.7'); -- ---------------------------- --- Table structure for api.gateway.published +-- Table structure for apa.published -- ---------------------------- -DROP TABLE IF EXISTS `api.gateway.published`; -CREATE TABLE `api.gateway.published` ( +DROP TABLE IF EXISTS `apa.published`; +CREATE TABLE `apa.published` ( `Id` bigint(20) NOT NULL, `Version` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, `Name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, @@ -53,14 +53,14 @@ CREATE TABLE `api.gateway.published` ( ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; -- ---------------------------- --- Records of api.gateway.published +-- Records of apa.published -- ---------------------------- -- ---------------------------- --- Table structure for api.gateway.received +-- Table structure for apa.received -- ---------------------------- -DROP TABLE IF EXISTS `api.gateway.received`; -CREATE TABLE `api.gateway.received` ( +DROP TABLE IF EXISTS `apa.received`; +CREATE TABLE `apa.received` ( `Id` bigint(20) NOT NULL, `Version` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, `Name` varchar(400) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, @@ -123,6 +123,10 @@ CREATE TABLE `appapigatewayaggregateconfig` ( -- ---------------------------- -- Records of appapigatewayaggregateconfig -- ---------------------------- +INSERT INTO `appapigatewayaggregateconfig` VALUES (1, 1418025237863149568, 'fff', NULL, NULL, 11); +INSERT INTO `appapigatewayaggregateconfig` VALUES (2, 1418025237863149568, 'sss', NULL, NULL, 11); +INSERT INTO `appapigatewayaggregateconfig` VALUES (3, 1418025237863149568, '242424', '', '', 11); +INSERT INTO `appapigatewayaggregateconfig` VALUES (4, 1420228420337348608, 'sss', 'ds', 'f', 12); -- ---------------------------- -- Table structure for appapigatewayauthoptions @@ -136,7 +140,7 @@ CREATE TABLE `appapigatewayauthoptions` ( PRIMARY KEY (`Id`) USING BTREE, UNIQUE INDEX `IX_AppApiGatewayAuthOptions_ReRouteId`(`ReRouteId`) USING BTREE, CONSTRAINT `FK_AppApiGatewayAuthOptions_AppApiGatewayReRoute_ReRouteId` FOREIGN KEY (`ReRouteId`) REFERENCES `appapigatewayreroute` (`ReRouteId`) ON DELETE CASCADE ON UPDATE RESTRICT -) ENGINE = InnoDB AUTO_INCREMENT = 240 CHARACTER SET = latin1 COLLATE = latin1_swedish_ci ROW_FORMAT = Dynamic; +) ENGINE = InnoDB AUTO_INCREMENT = 248 CHARACTER SET = latin1 COLLATE = latin1_swedish_ci ROW_FORMAT = Dynamic; -- ---------------------------- -- Records of appapigatewayauthoptions @@ -337,6 +341,12 @@ INSERT INTO `appapigatewayauthoptions` VALUES (236, 1442413171470688256, NULL, ' INSERT INTO `appapigatewayauthoptions` VALUES (237, 1449257280751026176, NULL, ''); INSERT INTO `appapigatewayauthoptions` VALUES (238, 1454289352609521664, NULL, ''); INSERT INTO `appapigatewayauthoptions` VALUES (239, 1454289896489115648, NULL, ''); +INSERT INTO `appapigatewayauthoptions` VALUES (240, 1456263181821501440, NULL, ''); +INSERT INTO `appapigatewayauthoptions` VALUES (241, 1456263413661655040, NULL, ''); +INSERT INTO `appapigatewayauthoptions` VALUES (242, 1456263574232195072, NULL, ''); +INSERT INTO `appapigatewayauthoptions` VALUES (243, 1456263679999959040, NULL, ''); +INSERT INTO `appapigatewayauthoptions` VALUES (244, 1456263785251823616, NULL, ''); +INSERT INTO `appapigatewayauthoptions` VALUES (245, 1456263957046321152, NULL, ''); -- ---------------------------- -- Table structure for appapigatewaybalanceroptions @@ -354,7 +364,7 @@ CREATE TABLE `appapigatewaybalanceroptions` ( UNIQUE INDEX `IX_AppApiGatewayBalancerOptions_ReRouteId`(`ReRouteId`) USING BTREE, CONSTRAINT `FK_AppApiGatewayBalancerOptions_AppApiGatewayGlobalConfiguratio~` FOREIGN KEY (`ItemId`) REFERENCES `appapigatewayglobalconfiguration` (`ItemId`) ON DELETE CASCADE ON UPDATE RESTRICT, CONSTRAINT `FK_AppApiGatewayBalancerOptions_AppApiGatewayReRoute_ReRouteId` FOREIGN KEY (`ReRouteId`) REFERENCES `appapigatewayreroute` (`ReRouteId`) ON DELETE CASCADE ON UPDATE RESTRICT -) ENGINE = InnoDB AUTO_INCREMENT = 250 CHARACTER SET = latin1 COLLATE = latin1_swedish_ci ROW_FORMAT = Dynamic; +) ENGINE = InnoDB AUTO_INCREMENT = 258 CHARACTER SET = latin1 COLLATE = latin1_swedish_ci ROW_FORMAT = Dynamic; -- ---------------------------- -- Records of appapigatewaybalanceroptions @@ -562,6 +572,12 @@ INSERT INTO `appapigatewaybalanceroptions` VALUES (246, NULL, 144241317147068825 INSERT INTO `appapigatewaybalanceroptions` VALUES (247, NULL, 1449257280751026176, NULL, NULL, NULL); INSERT INTO `appapigatewaybalanceroptions` VALUES (248, NULL, 1454289352609521664, NULL, NULL, NULL); INSERT INTO `appapigatewaybalanceroptions` VALUES (249, NULL, 1454289896489115648, NULL, NULL, NULL); +INSERT INTO `appapigatewaybalanceroptions` VALUES (250, NULL, 1456263181821501440, NULL, NULL, NULL); +INSERT INTO `appapigatewaybalanceroptions` VALUES (251, NULL, 1456263413661655040, NULL, NULL, NULL); +INSERT INTO `appapigatewaybalanceroptions` VALUES (252, NULL, 1456263574232195072, NULL, NULL, NULL); +INSERT INTO `appapigatewaybalanceroptions` VALUES (253, NULL, 1456263679999959040, NULL, NULL, NULL); +INSERT INTO `appapigatewaybalanceroptions` VALUES (254, NULL, 1456263785251823616, NULL, NULL, NULL); +INSERT INTO `appapigatewaybalanceroptions` VALUES (255, NULL, 1456263957046321152, NULL, NULL, NULL); -- ---------------------------- -- Table structure for appapigatewaycacheoptions @@ -575,7 +591,7 @@ CREATE TABLE `appapigatewaycacheoptions` ( PRIMARY KEY (`Id`) USING BTREE, UNIQUE INDEX `IX_AppApiGatewayCacheOptions_ReRouteId`(`ReRouteId`) USING BTREE, CONSTRAINT `FK_AppApiGatewayCacheOptions_AppApiGatewayReRoute_ReRouteId` FOREIGN KEY (`ReRouteId`) REFERENCES `appapigatewayreroute` (`ReRouteId`) ON DELETE CASCADE ON UPDATE RESTRICT -) ENGINE = InnoDB AUTO_INCREMENT = 240 CHARACTER SET = latin1 COLLATE = latin1_swedish_ci ROW_FORMAT = Dynamic; +) ENGINE = InnoDB AUTO_INCREMENT = 248 CHARACTER SET = latin1 COLLATE = latin1_swedish_ci ROW_FORMAT = Dynamic; -- ---------------------------- -- Records of appapigatewaycacheoptions @@ -776,6 +792,12 @@ INSERT INTO `appapigatewaycacheoptions` VALUES (236, 1442413171470688256, NULL, INSERT INTO `appapigatewaycacheoptions` VALUES (237, 1449257280751026176, NULL, NULL); INSERT INTO `appapigatewaycacheoptions` VALUES (238, 1454289352609521664, NULL, NULL); INSERT INTO `appapigatewaycacheoptions` VALUES (239, 1454289896489115648, NULL, NULL); +INSERT INTO `appapigatewaycacheoptions` VALUES (240, 1456263181821501440, NULL, NULL); +INSERT INTO `appapigatewaycacheoptions` VALUES (241, 1456263413661655040, NULL, NULL); +INSERT INTO `appapigatewaycacheoptions` VALUES (242, 1456263574232195072, NULL, NULL); +INSERT INTO `appapigatewaycacheoptions` VALUES (243, 1456263679999959040, NULL, NULL); +INSERT INTO `appapigatewaycacheoptions` VALUES (244, 1456263785251823616, NULL, NULL); +INSERT INTO `appapigatewaycacheoptions` VALUES (245, 1456263957046321152, NULL, NULL); -- ---------------------------- -- Table structure for appapigatewaydiscovery @@ -848,7 +870,7 @@ CREATE TABLE `appapigatewayglobalconfiguration` ( -- Records of appapigatewayglobalconfiguration -- ---------------------------- INSERT INTO `appapigatewayglobalconfiguration` VALUES (1, '{}', 'f7973118f2c2425c8cc96b59883b99aa', 1260841964962947072, NULL, 'http://localhost:30000', 'HTTP', NULL, 0, 1, 'TEST-APP'); - +I -- ---------------------------- -- Table structure for appapigatewayheaders -- ---------------------------- @@ -891,7 +913,7 @@ CREATE TABLE `appapigatewayhttpoptions` ( UNIQUE INDEX `IX_AppApiGatewayHttpOptions_ReRouteId`(`ReRouteId`) USING BTREE, CONSTRAINT `FK_AppApiGatewayHttpOptions_AppApiGatewayGlobalConfiguration_It~` FOREIGN KEY (`ItemId`) REFERENCES `appapigatewayglobalconfiguration` (`ItemId`) ON DELETE CASCADE ON UPDATE RESTRICT, CONSTRAINT `FK_AppApiGatewayHttpOptions_AppApiGatewayReRoute_ReRouteId` FOREIGN KEY (`ReRouteId`) REFERENCES `appapigatewayreroute` (`ReRouteId`) ON DELETE CASCADE ON UPDATE RESTRICT -) ENGINE = InnoDB AUTO_INCREMENT = 250 CHARACTER SET = latin1 COLLATE = latin1_swedish_ci ROW_FORMAT = Dynamic; +) ENGINE = InnoDB AUTO_INCREMENT = 258 CHARACTER SET = latin1 COLLATE = latin1_swedish_ci ROW_FORMAT = Dynamic; -- ---------------------------- -- Records of appapigatewayhttpoptions @@ -1099,6 +1121,12 @@ INSERT INTO `appapigatewayhttpoptions` VALUES (246, NULL, 1442413171470688256, N INSERT INTO `appapigatewayhttpoptions` VALUES (247, NULL, 1449257280751026176, NULL, 0, 0, 0, 0); INSERT INTO `appapigatewayhttpoptions` VALUES (248, NULL, 1454289352609521664, NULL, 0, 0, 0, 0); INSERT INTO `appapigatewayhttpoptions` VALUES (249, NULL, 1454289896489115648, NULL, 0, 0, 0, 0); +INSERT INTO `appapigatewayhttpoptions` VALUES (250, NULL, 1456263181821501440, NULL, 0, 0, 0, 0); +INSERT INTO `appapigatewayhttpoptions` VALUES (251, NULL, 1456263413661655040, NULL, 0, 0, 0, 0); +INSERT INTO `appapigatewayhttpoptions` VALUES (252, NULL, 1456263574232195072, NULL, 0, 0, 0, 0); +INSERT INTO `appapigatewayhttpoptions` VALUES (253, NULL, 1456263679999959040, NULL, 0, 0, 0, 0); +INSERT INTO `appapigatewayhttpoptions` VALUES (254, NULL, 1456263785251823616, NULL, 0, 0, 0, 0); +INSERT INTO `appapigatewayhttpoptions` VALUES (255, NULL, 1456263957046321152, NULL, 0, 0, 0, 0); -- ---------------------------- -- Table structure for appapigatewayqosoptions @@ -1116,7 +1144,7 @@ CREATE TABLE `appapigatewayqosoptions` ( UNIQUE INDEX `IX_AppApiGatewayQoSOptions_ReRouteId`(`ReRouteId`) USING BTREE, CONSTRAINT `FK_AppApiGatewayQoSOptions_AppApiGatewayGlobalConfiguration_Ite~` FOREIGN KEY (`ItemId`) REFERENCES `appapigatewayglobalconfiguration` (`ItemId`) ON DELETE CASCADE ON UPDATE RESTRICT, CONSTRAINT `FK_AppApiGatewayQoSOptions_AppApiGatewayReRoute_ReRouteId` FOREIGN KEY (`ReRouteId`) REFERENCES `appapigatewayreroute` (`ReRouteId`) ON DELETE CASCADE ON UPDATE RESTRICT -) ENGINE = InnoDB AUTO_INCREMENT = 250 CHARACTER SET = latin1 COLLATE = latin1_swedish_ci ROW_FORMAT = Dynamic; +) ENGINE = InnoDB AUTO_INCREMENT = 258 CHARACTER SET = latin1 COLLATE = latin1_swedish_ci ROW_FORMAT = Dynamic; -- ---------------------------- -- Records of appapigatewayqosoptions @@ -1324,6 +1352,12 @@ INSERT INTO `appapigatewayqosoptions` VALUES (246, NULL, 1442413171470688256, 50 INSERT INTO `appapigatewayqosoptions` VALUES (247, NULL, 1449257280751026176, 50, 60000, 10000); INSERT INTO `appapigatewayqosoptions` VALUES (248, NULL, 1454289352609521664, 50, 60000, 10000); INSERT INTO `appapigatewayqosoptions` VALUES (249, NULL, 1454289896489115648, 50, 60000, 10000); +INSERT INTO `appapigatewayqosoptions` VALUES (250, NULL, 1456263181821501440, 50, 60000, 10000); +INSERT INTO `appapigatewayqosoptions` VALUES (251, NULL, 1456263413661655040, 50, 60000, 10000); +INSERT INTO `appapigatewayqosoptions` VALUES (252, NULL, 1456263574232195072, 50, 60000, 10000); +INSERT INTO `appapigatewayqosoptions` VALUES (253, NULL, 1456263679999959040, 50, 60000, 10000); +INSERT INTO `appapigatewayqosoptions` VALUES (254, NULL, 1456263785251823616, 50, 60000, 10000); +INSERT INTO `appapigatewayqosoptions` VALUES (255, NULL, 1456263957046321152, 50, 60000, 10000); -- ---------------------------- -- Table structure for appapigatewayratelimitoptions @@ -1347,6 +1381,7 @@ CREATE TABLE `appapigatewayratelimitoptions` ( -- ---------------------------- INSERT INTO `appapigatewayratelimitoptions` VALUES (1, 1260841964962947072, 'ClientId', '{\n \"error\": {\n \"code\": \"429\",\n \"message\": \"您的操作过快,请稍后再试!\",\n \"details\": \"您的操作过快,请稍后再试!\",\n \"data\": {},\n \"validationErrors\": []\n }\n}', 'ocelot', 1, 429); + -- ---------------------------- -- Table structure for appapigatewayratelimitrule -- ---------------------------- @@ -1365,7 +1400,7 @@ CREATE TABLE `appapigatewayratelimitrule` ( UNIQUE INDEX `IX_AppApiGatewayRateLimitRule_ReRouteId`(`ReRouteId`) USING BTREE, CONSTRAINT `FK_AppApiGatewayRateLimitRule_AppApiGatewayDynamicReRoute_Dynam~` FOREIGN KEY (`DynamicReRouteId`) REFERENCES `appapigatewaydynamicreroute` (`DynamicReRouteId`) ON DELETE CASCADE ON UPDATE RESTRICT, CONSTRAINT `FK_AppApiGatewayRateLimitRule_AppApiGatewayReRoute_ReRouteId` FOREIGN KEY (`ReRouteId`) REFERENCES `appapigatewayreroute` (`ReRouteId`) ON DELETE CASCADE ON UPDATE RESTRICT -) ENGINE = InnoDB AUTO_INCREMENT = 240 CHARACTER SET = latin1 COLLATE = latin1_swedish_ci ROW_FORMAT = Dynamic; +) ENGINE = InnoDB AUTO_INCREMENT = 248 CHARACTER SET = latin1 COLLATE = latin1_swedish_ci ROW_FORMAT = Dynamic; -- ---------------------------- -- Records of appapigatewayratelimitrule @@ -1566,6 +1601,12 @@ INSERT INTO `appapigatewayratelimitrule` VALUES (236, 1442413171470688256, NULL, INSERT INTO `appapigatewayratelimitrule` VALUES (237, 1449257280751026176, NULL, '', 0, NULL, NULL, NULL); INSERT INTO `appapigatewayratelimitrule` VALUES (238, 1454289352609521664, NULL, '', 0, NULL, NULL, NULL); INSERT INTO `appapigatewayratelimitrule` VALUES (239, 1454289896489115648, NULL, '', 0, NULL, NULL, NULL); +INSERT INTO `appapigatewayratelimitrule` VALUES (240, 1456263181821501440, NULL, '', 0, NULL, NULL, NULL); +INSERT INTO `appapigatewayratelimitrule` VALUES (241, 1456263413661655040, NULL, '', 0, NULL, NULL, NULL); +INSERT INTO `appapigatewayratelimitrule` VALUES (242, 1456263574232195072, NULL, '', 0, NULL, NULL, NULL); +INSERT INTO `appapigatewayratelimitrule` VALUES (243, 1456263679999959040, NULL, '', 0, NULL, NULL, NULL); +INSERT INTO `appapigatewayratelimitrule` VALUES (244, 1456263785251823616, NULL, '', 0, NULL, NULL, NULL); +INSERT INTO `appapigatewayratelimitrule` VALUES (245, 1456263957046321152, NULL, '', 0, NULL, NULL, NULL); -- ---------------------------- -- Table structure for appapigatewayreroute @@ -1605,7 +1646,7 @@ CREATE TABLE `appapigatewayreroute` ( PRIMARY KEY (`Id`) USING BTREE, UNIQUE INDEX `AK_AppApiGatewayReRoute_ReRouteId`(`ReRouteId`) USING BTREE, UNIQUE INDEX `IX_AppApiGatewayReRoute_AppId_DownstreamPathTemplate_UpstreamPa~`(`AppId`, `DownstreamPathTemplate`, `UpstreamPathTemplate`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 503 CHARACTER SET = latin1 COLLATE = latin1_swedish_ci ROW_FORMAT = Dynamic; +) ENGINE = InnoDB AUTO_INCREMENT = 511 CHARACTER SET = latin1 COLLATE = latin1_swedish_ci ROW_FORMAT = Dynamic; -- ---------------------------- -- Records of appapigatewayreroute @@ -1660,8 +1701,8 @@ INSERT INTO `appapigatewayreroute` VALUES (60, '{}', '8409117162504f71aa66982f05 INSERT INTO `appapigatewayreroute` VALUES (61, '{}', '9f520820071b4e14bc94ab57989cea1f', 1263304204797648896, '【平台服务】- 框架配置', '/api/abp/application-configuration', '', '', '/api/abp/platform/application-configuration', 'GET,', '', '', '', '', '', '', '', 1, '', '', 'HTTP', '127.0.0.1:30025,', '', '', 'platform-configuration', 0, 120000, 1, '', 'TEST-APP'); INSERT INTO `appapigatewayreroute` VALUES (62, '{}', '530ab314560f41678b40f48da9383d51', 1263304872891555840, '【后台管理】- 租户管理', '/api/tenant-management/tenants', '', '', '/api/tenant-management/tenants', 'GET,POST,', '', '', '', '', '', '', '', 1, '', '', 'HTTP', '127.0.0.1:30010,', '', '', '', 0, 30000, 1, '', 'TEST-APP'); INSERT INTO `appapigatewayreroute` VALUES (63, '{}', '21334c6da4c349cc883c38c13de0e754', 1263305106250047488, '【后台管理】- 特定租户管理', '/api/tenant-management/tenants/{id}', '', '', '/api/tenant-management/tenants/{id}', 'GET,PUT,DELETE,', '', '', '', '', '', '', '', 1, '', '', 'HTTP', '127.0.0.1:30010,', '', '', '', 0, 30000, 1, '', 'TEST-APP'); -INSERT INTO `appapigatewayreroute` VALUES (64, '{}', 'cc8fdf1b2d0b414ebf2dc51a6dc78305', 1263305244594970624, '【后台管理】- 租户连接字符串', '/api/tenant-management/tenants/{id}/connection-string', '', '', '/api/tenant-management/tenants/{id}/connection-string', 'GET,PUT,', '', '', '', '', '', '', '', 1, '', '', 'HTTP', '127.0.0.1:30010,', '', '', '', 2, 30000, 1, '', 'TEST-APP'); -INSERT INTO `appapigatewayreroute` VALUES (65, '{}', 'aaf285ed10da4024ba561d5cf8c6322b', 1263305430536855552, '【后台管理】- 特定租户连接字符串', '/api/tenant-management/tenants/{id}/connection-string/{name}', '', '', '/api/tenant-management/tenants/{id}/connection-string/{name}', 'GET,DELETE,', '', '', '', '', '', '', '', 1, '', '', 'HTTP', '127.0.0.1:30010,', '', '', '', 1, 30000, 1, '', 'TEST-APP'); +INSERT INTO `appapigatewayreroute` VALUES (64, '{}', 'cc8fdf1b2d0b414ebf2dc51a6dc78305', 1263305244594970624, '【后台管理】- 租户连接字符串', '/api/tenant-management/tenants/{id}/connection-string', '', '', '/api/tenant-management/tenants/{id}/concatenation', 'GET,PUT,', '', '', '', '', '', '', '', 1, '', '', 'HTTP', '127.0.0.1:30010,', '', '', '', 2, 30000, 1, '', 'TEST-APP'); +INSERT INTO `appapigatewayreroute` VALUES (65, '{}', 'aaf285ed10da4024ba561d5cf8c6322b', 1263305430536855552, '【后台管理】- 特定租户连接字符串', '/api/tenant-management/tenants/{id}/connection-string/{name}', '', '', '/api/tenant-management/tenants/{id}/concatenation/{name}', 'GET,DELETE,', '', '', '', '', '', '', '', 1, '', '', 'HTTP', '127.0.0.1:30010,', '', '', '', 1, 30000, 1, '', 'TEST-APP'); INSERT INTO `appapigatewayreroute` VALUES (66, '{}', '6a7da198f4c84d94969a437adc47642b', 1263639172959174656, '【后台管理】- 全局设置', '/api/setting-management/settings/by-global', '', '', '/api/setting-management/settings/by-global/app', 'GET,', '', '', '', '', '', '', '', 1, '', '', 'HTTP', '127.0.0.1:30010,', '', '', 'setting-global', 0, 30000, 1, '', 'TEST-APP'); INSERT INTO `appapigatewayreroute` VALUES (67, '{}', '755b4dce5c34444785fa3b647fef4131', 1264799968944640000, '【身份认证服务】- 验证手机号', '/api/account/phone/verify', '', '', '/api/account/phone/verify', 'POST,', '', '', '', '', '', '', '', 1, '', '', 'HTTP', '127.0.0.1:30015,', '', '', '', 0, 30000, 1, '', 'TEST-APP'); INSERT INTO `appapigatewayreroute` VALUES (68, '{}', '535191c570ae453ab320012304d7a62c', 1264800070161584128, '【身份认证服务】- 手机号注册', '/api/account/phone/register', '', '', '/api/account/phone/register', 'POST,', '', '', '', '', '', '', '', 1, '', '', 'HTTP', '127.0.0.1:30015,', '', '', '', 0, 30000, 1, '', 'TEST-APP'); @@ -1782,13 +1823,18 @@ INSERT INTO `appapigatewayreroute` VALUES (219, '{}', '701ddf9f15844e968f0a98001 INSERT INTO `appapigatewayreroute` VALUES (225, '{}', '13249916a52a4568b55b6c3fa813b374', 1393020696332705792, '【后台管理】- 路由代理测试', '/api/connect', '', '', '/api/connect', 'GET,', '', '', '', '', '', '', '', 1, '', '', 'HTTP', '127.0.0.1:30010,', '', '', '', 0, 30000, 1, '', 'TEST-APP'); INSERT INTO `appapigatewayreroute` VALUES (482, '{}', '295034c498744783ba0ecf3b80546ca5', 1395924337284407296, '【后台管理】- 通过名称查询租户', '/api/tenant-management/tenants/name/{name}', '', '', '/api/tenant-management/tenants/name/{name}', 'GET,', '', '', '', '', '', '', '', 1, '', '', 'HTTP', '127.0.0.1:30010,', '', '', '', 0, 30000, 1, '', 'TEST-APP'); INSERT INTO `appapigatewayreroute` VALUES (483, '{}', 'be25633a37d14ab4b94803698c528e4c', 1406817452004757504, '【平台服务】- 参照名称查询字典', '/api/platform/datas/by-name/{name}', '', '', '/api/platform/datas/by-name/{name}', 'GET,', '', '', '', '', '', '', '', 1, '', '', 'HTTP', '127.0.0.1:30025,', '', '', '', 0, 30000, 1, '', 'TEST-APP'); -INSERT INTO `appapigatewayreroute` VALUES (484, '{}', 'a95d0fe8a6eb4b5484ebd47878f7092f', 1421397683162664960, '【身份认证服务】- 管理角色声明', '/api​/identity​/roles​/{id}​/claims', '', NULL, '/api​/identity​/roles​/{id}​/claims', 'GET,POST,PUT,DELETE,', '', '', '', '', '', '', NULL, 1, NULL, NULL, 'HTTP', '127.0.0.1:30015,', '', NULL, NULL, 0, 10000, 1, NULL, 'TEST-APP'); INSERT INTO `appapigatewayreroute` VALUES (493, '{}', '7f1af94bf83343fd91bf9e8eaa0e2fc5', 1431803251955654656, '【身份认证服务】- 换取token', '/connect/token', '', '', '/connect/token', 'POST,', '', '', '', '', '', '', '', 1, '', '', 'HTTP', '127.0.0.1:44385,', '', '', '', 0, 30000, 1, '', 'TEST-APP'); INSERT INTO `appapigatewayreroute` VALUES (494, '{}', 'dd09d208eca64c91b804377f45c85974', 1431806909455851520, '【身份认证服务】- 用户信息', '/connect/userinfo', '', '', '/connect/userinfo', 'GET,POST,', '', '', '', '', '', '', '', 1, '', '', 'HTTP', '127.0.0.1:44385,', '', '', '', 0, 30000, 1, '', 'TEST-APP'); INSERT INTO `appapigatewayreroute` VALUES (495, '{}', 'f0660047374f43b3bcdf3555799488c6', 1432189824874373120, '【身份认证服务】- 发送变更手机号短信', '/api/identity/my-profile/send-phone-number-change-code', '', '', '/api/identity/my-profile/send-phone-number-change-code', 'PUT,', '', '', '', '', '', '', '', 1, '', '', 'HTTP', '127.0.0.1:30015,', '', '', '', 0, 30000, 1, '', 'TEST-APP'); INSERT INTO `appapigatewayreroute` VALUES (496, '{}', 'da9dbe339b3e453abf79df15fe774bda', 1432190028071624704, '【身份认证服务】- 变更手机号', '/api/identity/my-profile/change-phone-number', '', '', '/api/identity/my-profile/change-phone-number', 'PUT,', '', '', '', '', '', '', '', 1, '', '', 'HTTP', '127.0.0.1:30015,', '', '', '', 0, 30000, 1, '', 'TEST-APP'); -IINSERT INTO `appapigatewayreroute` VALUES (501, '{}', '4019724446ad4a609916b6fb4eb2b489', 1454289352609521664, '【后台管理】- 系统日志列表', '/api/auditing/logging', '', NULL, '/api/auditing/logging', 'GET,', '', '', '', '', '', '', NULL, 1, NULL, NULL, 'HTTP', '127.0.0.1:30010,', '', NULL, NULL, 0, 10000, 1, NULL, 'TEST-APP'); +INSERT INTO `appapigatewayreroute` VALUES (501, '{}', '4019724446ad4a609916b6fb4eb2b489', 1454289352609521664, '【后台管理】- 系统日志列表', '/api/auditing/logging', '', NULL, '/api/auditing/logging', 'GET,', '', '', '', '', '', '', NULL, 1, NULL, NULL, 'HTTP', '127.0.0.1:30010,', '', NULL, NULL, 0, 10000, 1, NULL, 'TEST-APP'); INSERT INTO `appapigatewayreroute` VALUES (502, '{}', '03fd15647a4b41f3bd650fdbaa069cc0', 1454289896489115648, '【后台管理】- 系统日志', '/api/auditing/logging/{everything}', '', NULL, '/api/auditing/logging/{everything}', 'GET,DELETE,', '', '', '', '', '', '', NULL, 1, NULL, NULL, 'HTTP', '127.0.0.1:30010,', '', NULL, NULL, 0, 10000, 1, NULL, 'TEST-APP'); +INSERT INTO `appapigatewayreroute` VALUES (503, '{}', '31dfee95c57b4558b9d96c92ed07334d', 1456263181821501440, '【后台管理服务】- Api文档', '/swagger/v1/swagger.json', '', NULL, '/admin/v1/swagger.json', 'GET,', '', '', '', '', '', '', NULL, 1, NULL, NULL, 'HTTP', '127.0.0.1:30010,', '', NULL, NULL, 0, 10000, 1, NULL, 'TEST-APP'); +INSERT INTO `appapigatewayreroute` VALUES (504, '{}', '6dd0dce5366d40e0930c09940253653d', 1456263413661655040, '【身份认证服务】- Api文档', '/swagger/v1/swagger.json', '', NULL, '/ids-admin/v1/swagger.json', 'GET,', '', '', '', '', '', '', NULL, 1, NULL, NULL, 'HTTP', '127.0.0.1:30015,', '', NULL, NULL, 0, 10000, 1, NULL, 'TEST-APP'); +INSERT INTO `appapigatewayreroute` VALUES (505, '{}', '611409b212844d9c9d90445e09c59cd0', 1456263574232195072, '【消息服务】- Api文档', '/swagger/v1/swagger.json', '', NULL, '/messages/v1/swagger.json', 'GET,', '', '', '', '', '', '', NULL, 1, NULL, NULL, 'HTTP', '127.0.0.1:30020,', '', NULL, NULL, 0, 10000, 1, NULL, 'TEST-APP'); +INSERT INTO `appapigatewayreroute` VALUES (506, '{}', 'c2fd89c2cc9a4823be4d691eaad75c45', 1456263679999959040, '【平台服务】- Api文档', '/swagger/v1/swagger.json', '', NULL, '/platform/v1/swagger.json', 'GET,', '', '', '', '', '', '', NULL, 1, NULL, NULL, 'HTTP', '127.0.0.1:30025,', '', NULL, NULL, 0, 10000, 1, NULL, 'TEST-APP'); +INSERT INTO `appapigatewayreroute` VALUES (507, '{}', '814d4b9e3c7b4179950047fb43c1ab82', 1456263785251823616, '【本地化管理】- Api文档', '/swagger/v1/swagger.json', '', NULL, '/localization/v1/swagger.json', 'GET,', '', '', '', '', '', '', NULL, 1, NULL, NULL, 'HTTP', '127.0.0.1:30030,', '', NULL, NULL, 0, 10000, 1, NULL, 'TEST-APP'); +INSERT INTO `appapigatewayreroute` VALUES (508, '{}', '34fd7f3411fe487bbf6d1cb487349b86', 1456263957046321152, '【服务网关管理】- Api文档', '/swagger/v1/swagger.json', '', NULL, '/apigateway-admin/v1/swagger.json', 'GET,', '', '', '', '', '', '', NULL, 1, NULL, NULL, 'HTTP', '127.0.0.1:30001,', '', NULL, NULL, 0, 10000, 1, NULL, 'TEST-APP'); -- ---------------------------- -- Table structure for appapigatewayroutegroup @@ -1832,7 +1878,7 @@ CREATE TABLE `appapigatewaysecurityoptions` ( PRIMARY KEY (`Id`) USING BTREE, UNIQUE INDEX `IX_AppApiGatewaySecurityOptions_ReRouteId`(`ReRouteId`) USING BTREE, CONSTRAINT `FK_AppApiGatewaySecurityOptions_AppApiGatewayReRoute_ReRouteId` FOREIGN KEY (`ReRouteId`) REFERENCES `appapigatewayreroute` (`ReRouteId`) ON DELETE CASCADE ON UPDATE RESTRICT -) ENGINE = InnoDB AUTO_INCREMENT = 240 CHARACTER SET = latin1 COLLATE = latin1_swedish_ci ROW_FORMAT = Dynamic; +) ENGINE = InnoDB AUTO_INCREMENT = 248 CHARACTER SET = latin1 COLLATE = latin1_swedish_ci ROW_FORMAT = Dynamic; -- ---------------------------- -- Records of appapigatewaysecurityoptions @@ -2033,44 +2079,11 @@ INSERT INTO `appapigatewaysecurityoptions` VALUES (236, 1442413171470688256, '', INSERT INTO `appapigatewaysecurityoptions` VALUES (237, 1449257280751026176, '', ''); INSERT INTO `appapigatewaysecurityoptions` VALUES (238, 1454289352609521664, '', ''); INSERT INTO `appapigatewaysecurityoptions` VALUES (239, 1454289896489115648, '', ''); - --- ---------------------------- --- Table structure for cap.published --- ---------------------------- -DROP TABLE IF EXISTS `cap.published`; -CREATE TABLE `cap.published` ( - `Id` bigint(20) NOT NULL, - `Version` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, - `Name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, - `Content` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL, - `Retries` int(11) NULL DEFAULT NULL, - `Added` datetime(0) NOT NULL, - `ExpiresAt` datetime(0) NULL DEFAULT NULL, - `StatusName` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, - PRIMARY KEY (`Id`) USING BTREE, - INDEX `IX_ExpiresAt`(`ExpiresAt`) USING BTREE -) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; - --- ---------------------------- --- Records of cap.published --- ---------------------------- - --- ---------------------------- --- Table structure for cap.received --- ---------------------------- -DROP TABLE IF EXISTS `cap.received`; -CREATE TABLE `cap.received` ( - `Id` bigint(20) NOT NULL, - `Version` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, - `Name` varchar(400) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, - `Group` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, - `Content` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL, - `Retries` int(11) NULL DEFAULT NULL, - `Added` datetime(0) NOT NULL, - `ExpiresAt` datetime(0) NULL DEFAULT NULL, - `StatusName` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, - PRIMARY KEY (`Id`) USING BTREE, - INDEX `IX_ExpiresAt`(`ExpiresAt`) USING BTREE -) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; +INSERT INTO `appapigatewaysecurityoptions` VALUES (240, 1456263181821501440, '', ''); +INSERT INTO `appapigatewaysecurityoptions` VALUES (241, 1456263413661655040, '', ''); +INSERT INTO `appapigatewaysecurityoptions` VALUES (242, 1456263574232195072, '', ''); +INSERT INTO `appapigatewaysecurityoptions` VALUES (243, 1456263679999959040, '', ''); +INSERT INTO `appapigatewaysecurityoptions` VALUES (244, 1456263785251823616, '', ''); +INSERT INTO `appapigatewaysecurityoptions` VALUES (245, 1456263957046321152, '', ''); SET FOREIGN_KEY_CHECKS = 1; diff --git a/aspnet-core/modules/platform/LINGYUN.Abp.UI.Navigation.VueVbenAdmin/LINGYUN/Abp/UI/Navigation/VueVbenAdmin/AbpUINavigationVueVbenAdminNavigationDefinitionProvider.cs b/aspnet-core/modules/platform/LINGYUN.Abp.UI.Navigation.VueVbenAdmin/LINGYUN/Abp/UI/Navigation/VueVbenAdmin/AbpUINavigationVueVbenAdminNavigationDefinitionProvider.cs index 5f668da12..ca9cade57 100644 --- a/aspnet-core/modules/platform/LINGYUN.Abp.UI.Navigation.VueVbenAdmin/LINGYUN/Abp/UI/Navigation/VueVbenAdmin/AbpUINavigationVueVbenAdminNavigationDefinitionProvider.cs +++ b/aspnet-core/modules/platform/LINGYUN.Abp.UI.Navigation.VueVbenAdmin/LINGYUN/Abp/UI/Navigation/VueVbenAdmin/AbpUINavigationVueVbenAdminNavigationDefinitionProvider.cs @@ -178,6 +178,17 @@ namespace LINGYUN.Abp.UI.Navigation.VueVbenAdmin component: "/sys/logging/index", description: "系统日志")); + manage.AddItem( + new ApplicationMenu( + name: "ApiDocument", + displayName: "Api 文档", + url: "/openapi", + component: "IFrame", + description: "Api 文档", + multiTenancySides: MultiTenancySides.Host) + // TODO: 注意在部署完毕之后手动修改此菜单iframe地址 + .SetProperty("frameSrc", "http://127.0.0.1:30000/swagger/index.html")); + return new NavigationDefinition(manage); } diff --git a/aspnet-core/services/admin/LINGYUN.Abp.BackendAdmin.HttpApi.Host/BackendAdminHostModule.Configure.cs b/aspnet-core/services/admin/LINGYUN.Abp.BackendAdmin.HttpApi.Host/BackendAdminHostModule.Configure.cs index cc61405e6..089f39072 100644 --- a/aspnet-core/services/admin/LINGYUN.Abp.BackendAdmin.HttpApi.Host/BackendAdminHostModule.Configure.cs +++ b/aspnet-core/services/admin/LINGYUN.Abp.BackendAdmin.HttpApi.Host/BackendAdminHostModule.Configure.cs @@ -206,6 +206,7 @@ namespace LINGYUN.Abp.BackendAdmin new string[] { } } }); + options.OperationFilter(); }); } diff --git a/aspnet-core/services/admin/LINGYUN.Abp.BackendAdmin.HttpApi.Host/TenantHeaderParamter.cs b/aspnet-core/services/admin/LINGYUN.Abp.BackendAdmin.HttpApi.Host/TenantHeaderParamter.cs new file mode 100644 index 000000000..7d1fa87ca --- /dev/null +++ b/aspnet-core/services/admin/LINGYUN.Abp.BackendAdmin.HttpApi.Host/TenantHeaderParamter.cs @@ -0,0 +1,33 @@ +using Microsoft.Extensions.Options; +using Microsoft.OpenApi.Models; +using Swashbuckle.AspNetCore.SwaggerGen; +using System.Collections.Generic; +using Volo.Abp.MultiTenancy; + +namespace LINGYUN.Abp.BackendAdmin +{ + public class TenantHeaderParamter : IOperationFilter + { + private readonly AbpMultiTenancyOptions _options; + public TenantHeaderParamter( + IOptions options) + { + _options = options.Value; + } + + public void Apply(OpenApiOperation operation, OperationFilterContext context) + { + if (_options.IsEnabled) + { + operation.Parameters = operation.Parameters ?? new List(); + operation.Parameters.Add(new OpenApiParameter + { + Name = TenantResolverConsts.DefaultTenantKey, + In = ParameterLocation.Header, + Description = "Tenant Id in http header", + Required = false + }); + } + } + } +} diff --git a/aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/.gitignore b/aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/.gitignore index 53f2c2fc2..67fc1cbca 100644 --- a/aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/.gitignore +++ b/aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/.gitignore @@ -1,4 +1,5 @@ bin obj Logs -appsettings.*.json \ No newline at end of file +appsettings.*.json +event-bus-cap.db \ No newline at end of file diff --git a/aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/ApiGatewayHostModule.Builder.cs b/aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/ApiGatewayHostModule.Builder.cs new file mode 100644 index 000000000..f00c67761 --- /dev/null +++ b/aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/ApiGatewayHostModule.Builder.cs @@ -0,0 +1,24 @@ +using Microsoft.AspNetCore.Builder; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Options; + +namespace LINGYUN.ApiGateway +{ + public partial class ApiGatewayHostModule + { + private void UseSwagger(IApplicationBuilder app) + { + app.UseSwagger(); + app.UseSwaggerUI(c => + { + c.SwaggerEndpoint("/swagger/v1/swagger.json", "Open API Document"); + var options = app.ApplicationServices.GetRequiredService>().Value; + foreach (var api in options.DownstreamOpenApis) + { + c.SwaggerEndpoint(api.EndPoint, api.Name); + } + }); + + } + } +} diff --git a/aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/ApiGatewayHostModule.Configure.cs b/aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/ApiGatewayHostModule.Configure.cs new file mode 100644 index 000000000..3e361ebb9 --- /dev/null +++ b/aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/ApiGatewayHostModule.Configure.cs @@ -0,0 +1,224 @@ +using DotNetCore.CAP; +using LINGYUN.Abp.Serilog.Enrichers.Application; +using LINGYUN.ApiGateway.Localization; +using Microsoft.AspNetCore.Authentication.JwtBearer; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.DataProtection; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Routing; +using Microsoft.AspNetCore.Server.Kestrel.Core; +using Microsoft.Extensions.Caching.StackExchangeRedis; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.OpenApi.Models; +using Ocelot.Configuration.Repository; +using Ocelot.DependencyInjection; +using Ocelot.Middleware.Multiplexer; +using Ocelot.Provider.Polly; +using StackExchange.Redis; +using System; +using System.Text.Encodings.Web; +using System.Text.Unicode; +using Volo.Abp.AutoMapper; +using Volo.Abp.Caching; +using Volo.Abp.Json.SystemTextJson; +using Volo.Abp.Localization; +using Volo.Abp.VirtualFileSystem; + +namespace LINGYUN.ApiGateway +{ + public partial class ApiGatewayHostModule + { + private void PreConfigureApp() + { + AbpSerilogEnrichersConsts.ApplicationName = "ApiGateWay"; + } + + private void PreConfigureCAP(IConfiguration configuration) + { + PreConfigure(options => + { + options + .UseSqlite("Data Source=./event-bus-cap.db") + .UseDashboard() + .UseRabbitMQ(rabbitMQOptions => + { + configuration.GetSection("CAP:RabbitMQ").Bind(rabbitMQOptions); + }); + }); + } + + private void PreConfigureApiGateway(IServiceCollection services, IConfiguration configuration) + { + // 不启用则使用本地配置文件的方式启动Ocelot + if (configuration.GetValue("EnabledDynamicOcelot")) + { + services.AddSingleton(); + } + } + + private void ConfigureKestrelServer(IConfiguration configuration, bool isDevelopment = true) + { + // fix: 不限制请求体大小,解决上传文件问题 + Configure(options => + { + options.Limits.MaxRequestBodySize = null; + options.Limits.MaxRequestBufferSize = null; + }); + + if (!isDevelopment) + { + // Ssl证书 + var sslOptions = configuration.GetSection("App:SslOptions"); + if (sslOptions.Exists()) + { + var fileName = sslOptions["FileName"]; + var password = sslOptions["Password"]; + Configure(options => + { + options.ConfigureEndpointDefaults(cfg => + { + cfg.UseHttps(fileName, password); + }); + }); + } + } + } + + private void ConfigureAbpAutoMapper() + { + Configure(options => + { + options.AddProfile(validate: true); + }); + } + + private void ConfigureJsonSerializer() + { + // 中文序列化的编码问题 + Configure(options => + { + options.JsonSerializerOptions.Encoder = JavaScriptEncoder.Create(UnicodeRanges.All); + }); + } + + private void ConfigureVirtualFileSystem() + { + Configure(options => + { + options.FileSets.AddEmbedded(); + }); + } + + private void ConfigureLocalization() + { + Configure(options => + { + options.Languages.Add(new LanguageInfo("en", "en", "English")); + options.Languages.Add(new LanguageInfo("zh-Hans", "zh-Hans", "简体中文")); + + options.Resources + .Get() + .AddVirtualJson("/Localization/Host"); + }); + } + + private void ConfigureMvc(IServiceCollection services) + { + var mvcBuilder = services.AddMvc(); + mvcBuilder.AddApplicationPart(typeof(ApiGatewayHostModule).Assembly); + + Configure(options => + { + options.EndpointConfigureActions.Add(endpointContext => + { + endpointContext.Endpoints.MapControllerRoute("defaultWithArea", "{area}/{controller=Home}/{action=Index}/{id?}"); + endpointContext.Endpoints.MapControllerRoute("default", "{controller=Home}/{action=Index}/{id?}"); + }); + }); + } + + private void ConfigureOcelot(IServiceCollection services) + { + services + .AddOcelot() + .AddPolly() + .AddSingletonDefinedAggregator(); + } + + private void ConfigureCaching(IConfiguration configuration) + { + Configure(options => + { + // 最好统一命名,不然某个缓存变动其他应用服务有例外发生 + options.KeyPrefix = "LINGYUN.Abp.Application"; + // 滑动过期30天 + options.GlobalCacheEntryOptions.SlidingExpiration = TimeSpan.FromDays(30); + // 绝对过期60天 + options.GlobalCacheEntryOptions.AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(60); + }); + + Configure(options => + { + var redisConfig = ConfigurationOptions.Parse(options.Configuration); + options.ConfigurationOptions = redisConfig; + options.InstanceName = configuration["Redis:InstanceName"]; + }); + } + + private void ConfigureApiGateway(IConfiguration configuration) + { + Configure(configuration.GetSection("ApiGateway")); + } + + private void ConfigureSwagger(IServiceCollection services) + { + services.AddSwaggerGen( + options => + { + options.SwaggerDoc("v1", new OpenApiInfo { Title = "Open API Document", Version = "v1" }); + options.DocInclusionPredicate((docName, description) => true); + options.CustomSchemaIds(type => type.FullName); + options.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme + { + Description = "JWT Authorization header using the Bearer scheme. Example: \"Authorization: Bearer {token}\"", + Name = "Authorization", + In = ParameterLocation.Header, + Scheme = "bearer", + Type = SecuritySchemeType.Http, + BearerFormat = "JWT" + }); + options.AddSecurityRequirement(new OpenApiSecurityRequirement + { + { + new OpenApiSecurityScheme + { + Reference = new OpenApiReference { Type = ReferenceType.SecurityScheme, Id = "Bearer" } + }, + new string[] { } + } + }); + options.OperationFilter(); + }); + } + + private void ConfigureSecurity(IServiceCollection services, IConfiguration configuration, bool isDevelopment = false) + { + services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) + .AddJwtBearer(options => + { + options.Authority = configuration["AuthServer:Authority"]; + options.RequireHttpsMetadata = false; + options.Audience = configuration["AuthServer:ApiName"]; + }); + + if (!isDevelopment) + { + var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); + services + .AddDataProtection() + .PersistKeysToStackExchangeRedis(redis, "ApiGatewayHost-Protection-Keys"); + } + } + } +} diff --git a/aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/ApiGatewayHostModule.cs b/aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/ApiGatewayHostModule.cs index 7ce19bde5..70aa87a1e 100644 --- a/aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/ApiGatewayHostModule.cs +++ b/aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/ApiGatewayHostModule.cs @@ -1,38 +1,18 @@ -using DotNetCore.CAP; -using LINGYUN.Abp.AspNetCore.HttpOverrides; +using LINGYUN.Abp.AspNetCore.HttpOverrides; using LINGYUN.Abp.EventBus.CAP; using LINGYUN.Abp.Serilog.Enrichers.Application; -using LINGYUN.ApiGateway.Localization; -using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Routing; -using Microsoft.AspNetCore.Server.Kestrel.Core; -using Microsoft.Extensions.Caching.StackExchangeRedis; -using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; -using Ocelot.Configuration.Repository; -using Ocelot.DependencyInjection; using Ocelot.Extenssions; -using Ocelot.Middleware.Multiplexer; -using Ocelot.Provider.Polly; -using StackExchange.Redis; -using System; -using System.Text.Encodings.Web; -using System.Text.Unicode; using Volo.Abp; using Volo.Abp.AspNetCore.Serilog; using Volo.Abp.Autofac; using Volo.Abp.AutoMapper; -using Volo.Abp.Caching; using Volo.Abp.Caching.StackExchangeRedis; using Volo.Abp.Http.Client.IdentityModel; -using Volo.Abp.Json.SystemTextJson; -using Volo.Abp.Localization; using Volo.Abp.Modularity; -using Volo.Abp.VirtualFileSystem; namespace LINGYUN.ApiGateway { @@ -47,29 +27,15 @@ namespace LINGYUN.ApiGateway typeof(AbpAspNetCoreSerilogModule), typeof(AbpAspNetCoreHttpOverridesModule) )] - public class ApiGatewayHostModule : AbpModule + public partial class ApiGatewayHostModule : AbpModule { public override void PreConfigureServices(ServiceConfigurationContext context) { - AbpSerilogEnrichersConsts.ApplicationName = "ApiGateWay"; var configuration = context.Services.GetConfiguration(); - // 不启用则使用本地配置文件的方式启动Ocelot - if (configuration.GetValue("EnabledDynamicOcelot")) - { - context.Services.AddSingleton(); - } - - PreConfigure(options => - { - options - .UseSqlite("Data Source=./event-bus-cap.db") - .UseDashboard() - .UseRabbitMQ(rabbitMQOptions => - { - configuration.GetSection("CAP:RabbitMQ").Bind(rabbitMQOptions); - }); - }); + PreConfigureApp(); + PreConfigureCAP(configuration); + PreConfigureApiGateway(context.Services, configuration); } public override void ConfigureServices(ServiceConfigurationContext context) @@ -77,105 +43,20 @@ namespace LINGYUN.ApiGateway var hostingEnvironment = context.Services.GetHostingEnvironment(); var configuration = context.Services.GetConfiguration(); - // fix: 不限制请求体大小,解决上传文件问题 - Configure(options => - { - options.Limits.MaxRequestBodySize = null; - options.Limits.MaxRequestBufferSize = null; - }); - - Configure(options => - { - options.AddProfile(validate: true); - }); - - Configure(configuration.GetSection("ApiGateway")); - - // 中文序列化的编码问题 - Configure(options => - { - options.JsonSerializerOptions.Encoder = JavaScriptEncoder.Create(UnicodeRanges.All); - }); - - context.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) - .AddJwtBearer(options => - { - options.Authority = configuration["AuthServer:Authority"]; - options.RequireHttpsMetadata = false; - options.Audience = configuration["AuthServer:ApiName"]; - }); - - Configure(options => - { - // 最好统一命名,不然某个缓存变动其他应用服务有例外发生 - options.KeyPrefix = "LINGYUN.Abp.Application"; - // 滑动过期30天 - options.GlobalCacheEntryOptions.SlidingExpiration = TimeSpan.FromDays(30); - // 绝对过期60天 - options.GlobalCacheEntryOptions.AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(60); - }); - - Configure(options => - { - var redisConfig = ConfigurationOptions.Parse(options.Configuration); - options.ConfigurationOptions = redisConfig; - options.InstanceName = configuration["Redis:InstanceName"]; - }); + ConfigureLocalization(); + ConfigureAbpAutoMapper(); + ConfigureJsonSerializer(); + ConfigureVirtualFileSystem(); - Configure(options => - { - options.FileSets.AddEmbedded(); - }); + ConfigureCaching(configuration); + ConfigureApiGateway(configuration); - Configure(options => - { - options.Languages.Add(new LanguageInfo("en", "en", "English")); - options.Languages.Add(new LanguageInfo("zh-Hans", "zh-Hans", "简体中文")); + ConfigureKestrelServer(configuration, hostingEnvironment.IsDevelopment()); + ConfigureSecurity(context.Services, configuration, hostingEnvironment.IsDevelopment()); - options.Resources - .Get() - .AddVirtualJson("/Localization/Host"); - }); - - var mvcBuilder = context.Services.AddMvc(); - mvcBuilder.AddApplicationPart(typeof(ApiGatewayHostModule).Assembly); - - Configure(options => - { - options.EndpointConfigureActions.Add(endpointContext => - { - endpointContext.Endpoints.MapControllerRoute("defaultWithArea", "{area}/{controller=Home}/{action=Index}/{id?}"); - endpointContext.Endpoints.MapControllerRoute("default", "{controller=Home}/{action=Index}/{id?}"); - }); - }); - - if (!hostingEnvironment.IsDevelopment()) - { - // Ssl证书 - var sslOptions = configuration.GetSection("App:SslOptions"); - if (sslOptions.Exists()) - { - var fileName = sslOptions["FileName"]; - var password = sslOptions["Password"]; - Configure(options => - { - options.ConfigureEndpointDefaults(cfg => - { - cfg.UseHttps(fileName, password); - }); - }); - } - - var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); - context.Services - .AddDataProtection() - .PersistKeysToStackExchangeRedis(redis, "ApiGatewayHost-Protection-Keys"); - } - - context.Services - .AddOcelot() - .AddPolly() - .AddSingletonDefinedAggregator(); + ConfigureMvc(context.Services); + ConfigureSwagger(context.Services); + ConfigureOcelot(context.Services); } public override void OnApplicationInitialization(ApplicationInitializationContext context) @@ -196,7 +77,7 @@ namespace LINGYUN.ApiGateway appNext.UseRouting(); appNext.UseConfiguredEndpoints(); }); - + UseSwagger(app); // 启用ws协议 app.UseWebSockets(); app.UseAbpSerilogEnrichers(); diff --git a/aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/ApiGatewayOptions.cs b/aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/ApiGatewayOptions.cs index aca351208..e8cce6cc9 100644 --- a/aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/ApiGatewayOptions.cs +++ b/aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/ApiGatewayOptions.cs @@ -1,7 +1,14 @@ -namespace LINGYUN.ApiGateway -{ - public class ApiGatewayOptions - { - public string AppId { get; set; } - } -} +using LINGYUN.ApiGateway.Models; + +namespace LINGYUN.ApiGateway +{ + public class ApiGatewayOptions + { + public string AppId { get; set; } + public DownstreamOpenApi[] DownstreamOpenApis { get; set; } + public ApiGatewayOptions() + { + DownstreamOpenApis = new DownstreamOpenApi[0]; + } + } +} diff --git a/aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/LINGYUN.ApiGateway.Host.csproj b/aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/LINGYUN.ApiGateway.Host.csproj index 15a41e670..34c9103bb 100644 --- a/aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/LINGYUN.ApiGateway.Host.csproj +++ b/aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/LINGYUN.ApiGateway.Host.csproj @@ -25,6 +25,7 @@ + diff --git a/aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/Models/DownstreamOpenApi.cs b/aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/Models/DownstreamOpenApi.cs new file mode 100644 index 000000000..a4e08e15c --- /dev/null +++ b/aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/Models/DownstreamOpenApi.cs @@ -0,0 +1,8 @@ +namespace LINGYUN.ApiGateway.Models +{ + public class DownstreamOpenApi + { + public string Name { get; set; } + public string EndPoint { get; set; } + } +} diff --git a/aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/Properties/launchSettings.json b/aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/Properties/launchSettings.json index 06d77d8df..f145a89fc 100644 --- a/aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/Properties/launchSettings.json +++ b/aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/Properties/launchSettings.json @@ -1,20 +1,20 @@ -{ - "iisSettings": { - "windowsAuthentication": false, - "anonymousAuthentication": true, - "iisExpress": { - "applicationUrl": "http://localhost:30000", - "sslPort": 0 - } - }, - "profiles": { - "LINGYUN.ApiGateway.Host": { - "commandName": "Project", - "launchBrowser": false, - "applicationUrl": "http://localhost:30000;https://localhost:30443", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Production" - } - } - } -} +{ + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:30000", + "sslPort": 0 + } + }, + "profiles": { + "LINGYUN.ApiGateway.Host": { + "commandName": "Project", + "launchBrowser": false, + "applicationUrl": "http://localhost:30000;https://localhost:30443", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/TenantHeaderParamter.cs b/aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/TenantHeaderParamter.cs new file mode 100644 index 000000000..728ef322c --- /dev/null +++ b/aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/TenantHeaderParamter.cs @@ -0,0 +1,33 @@ +using Microsoft.Extensions.Options; +using Microsoft.OpenApi.Models; +using Swashbuckle.AspNetCore.SwaggerGen; +using System.Collections.Generic; +using Volo.Abp.MultiTenancy; + +namespace LINGYUN.ApiGateway +{ + public class TenantHeaderParamter : IOperationFilter + { + private readonly AbpMultiTenancyOptions _options; + public TenantHeaderParamter( + IOptions options) + { + _options = options.Value; + } + + public void Apply(OpenApiOperation operation, OperationFilterContext context) + { + if (_options.IsEnabled) + { + operation.Parameters = operation.Parameters ?? new List(); + operation.Parameters.Add(new OpenApiParameter + { + Name = TenantResolverConsts.DefaultTenantKey, + In = ParameterLocation.Header, + Description = "Tenant Id in http header", + Required = false + }); + } + } + } +} diff --git a/aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/appsettings.Development.json b/aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/appsettings.Development.json index 8d11db68e..8b1e09cea 100644 --- a/aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/appsettings.Development.json +++ b/aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/appsettings.Development.json @@ -9,7 +9,33 @@ }, "EnabledDynamicOcelot": true, "ApiGateway": { - "AppId": "TEST-APP" //这里是用于Ocelot主机去API服务器获取参数的标识,指定需要获取什么类型的网关配置 + "AppId": "TEST-APP", + "DownstreamOpenApis": [ + { + "Name": "ApiGateway Admin API", + "EndPoint": "/apigateway-admin/v1/swagger.json" + }, + { + "Name": "Backend Admin API", + "EndPoint": "/admin/v1/swagger.json" + }, + { + "Name": "Platform API", + "EndPoint": "/platform/v1/swagger.json" + }, + { + "Name": "Localization API", + "EndPoint": "/localization/v1/swagger.json" + }, + { + "Name": "Messages API", + "EndPoint": "/messages/v1/swagger.json" + }, + { + "Name": "IdentityServer Admin API", + "EndPoint": "/ids-admin/v1/swagger.json" + } + ] }, "Redis": { "Configuration": "localhost,defaultDatabase=10", diff --git a/aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/appsettings.json b/aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/appsettings.json index 30cd8106f..d4ff36124 100644 --- a/aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/appsettings.json +++ b/aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/appsettings.json @@ -1,4 +1,11 @@ { + "AuthServer": { + "Authority": "http://10.21.15.28:44385/", + "ApiName": "lingyun-abp-application", + "SwaggerClientId": "ApigatewayHostClient", + "SwaggerClientSecret": "1q2w3e*", + "ApiSocpes": "lingyun-abp-application" + }, "StringEncryption": { "DefaultPassPhrase": "s46c5q55nxpeS8Ra", "InitVectorBytes": "s83ng0abvd02js84", diff --git a/aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/event-bus-cap.db b/aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/event-bus-cap.db deleted file mode 100644 index 216ee1ce7bb32e3e3e4774bd2e935e3e8ac4dddb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 40960 zcmeHQTWlOx86G>nB(9xFowlwVq)e@rrmA;xZgXa4C1|&fn}#@!<2Y3-q}J>8#98Xt zuDy0!Re?g|Dv0(4NL8LHRe<_{3KFV>c%X$BBqYQG;sxzLKYwnbSn`aE%d403C4*~+w2lt#e#6kTj@LC!>%(yX zM+c5h99=ldAOGAAAEaRlV?h76*43ZW4tDEr_2&kDwZla!SRtSgPzWdl6aoqXg@8gp zA)pXQD+15=?CTx6`|gg-)1~~}qF2bTm{aR>i^a7|-h7SGH8wq-n;AD|at}<58?!ZG zv&OML!GhC9hPx>{ad&1dczwQe5@ca!9rkA)fCb()m)pw7yoG zU9o*`r>0Mx$xT0MoF0GFIOfB4Pv1RmSI^LyyF0Yv(!BTd+LMbI);*qIFD(c5<27(U zPHW8W=k1Q(p}X$tc!5^RaM~+)#f`8C%ilY+_Z0$pJvfr;#x^e8&-}Arr>HpFHrN7r{_(t7l|A##{ ze{~;y;fwpn#*Pk7zxu;3pZJHiK_^a4o_zGeq?ubOp2P$2RQ?%rd;?F>1M6%4xrOi? z9<7VTg|SQdr3EhtK9MiwtCwURT3#!e8}!+chrIke9`%vzvm+pArjTD;oXZ!U$SmPe z9?34PFD{M-0hiYnGR66k>QNqhcK0zj9iItvNK^{iV&V9)% zl%n%%_^JLwkMqa}IZnxOW*OAZQkfODaW8SQghX)*%d4w9Wjctn<~@n@%9r^+b-`yg z&TWNkpNdZcITK=dN4HRBmPEl#k)e`1zSkZfXko zJmZxvE&J!rEYBA&K7%t?ub%1Y4~xFw7yaRmSFPW^^IZFjesi=tyzjL;g8L31kw0Ib zZTo%mb1RwkH7_cuxr@wk=jY}!4tKmv-f`zL1<6>3yB94wUnq!+f=9*cUszZyf)HUL zZ>-~j`OC$njJN1r#_3o*v@`i~yy$d{(Y6$VS(f7$7qe|4q9}0!Z5wARfj;F2fgb0_ znQQ#fsRqoY6y^9hvr~ zm)CLX$`w4nQQAf|ZCeoTvT_h7$q`)@8PWA<*cTZ7<=6KRU5Q_@I(UMCSW@Mh6eo3bWm)RBfv$eCs9ZrP+G@52 zNlV8D{&pQ(S(Xu#TSQtGjj^?(Qn}_(xgL0MiaNht4KF|6c#K{hapb$_9Cy)5cp^abUZOQb&VHkft-0>sl2i|kqVE?|Jj>E%`y?kMP zR=YVezGYwr@=#=4djp0Z8mx3XjDwN!$T?gy5E=A+82zE~na@sqFst1Z8b?0tgwYon zznidTwF8my)9E*7wf&Lt^4}5C8yOdt5YiJF!QyClWCTl3U7-=q?C*<=VBXY!kH5b> zEj0iGFa4{JLO>y)5Kssx1QY@a0fm4y)5Kssx1QY@a0fm4{ZPN2e3tN-+_Q%6#QLb#%S)_y0pE{f$5|3(8e$|9_z47Lz`+)&Bq8-TzOdB$icC ztMK3d@9unA8#veZTJQVaC-7B$6au@9z~;Srt>VvP!4{i#3r?n@#kZ)mY$(kL;R?>n zdX}~7f7`@KSBvjtg_C8pl^QBg|6?Rf)}(}UM>Hj&QjxUWUi`0`G__nQ;)*|&Ae<*Q zb1HS{=IFtS;*YP9IUMc*+Y@XR(xH?v{NoO_8?$wrIO$@mmE~3&#Q*FtSyMU?^<>Q{ zur{kzSxMV7U937~mYp_dkkI>ZyP_A@cDWS#KSWXRM!U=Iw zNLPqERq8*#v;E1XRRi8o+hl?f*KVy=WhHG(NSjp@s(h`=Fvu|pc}5U4wnJ zdxfqJlN5Zkq@BQb$*jVnqO6+w<^ zOGiL?Jk}Ywsg|zcPVc=zSHUd@t(+vT<0cAMC&oz^T_IfUWU15Y+7-gpezK+`90;Jc zwlh#kTRN^=OV=>Sg$lgGXiTj#9RFXhj{mRk^3YG+ULmkK+E-hLh5{LTr4EILH+t-x z*e*%Zr-mno#&J?thoW1@+E9o3$(q6@lG`oUrw-G08OF0to#Jm019fx_ zBwY3iT^Yx?lL;Z9Q{8w#1u5W!IH{wn%v$Xb|M!zM(I=8{SJBcQD%$lRZLpPNZKaN` z2$CjuQIm-HfNFmoT?3J!y+T*?x+sCqAZA+$iqrt=iEU@RNm0 z9>E;D<+W>=HdbU@iuth6Nl@fkB?yA{zkrN;tTPZf%&Iu93WVDB3SBYsv>gry05X}b zNpVs~SCJL%@U7w}Yr2xdl~{9YSItgWfskR^j*Yj6X&qe=1P4SII5@OQ*VtgwmjdvQ z-sp%0sjoLY0#~PQ51ZK+ih+;ENJ_Ka^;R=J9;wTuYf&(lN{Pm$07IW5QZ*c)5jzRnPa?8FPw90ymP? zA8bmrvT(VFx+M(a6)aGtQ9&KM(iC2u9I8<2KDZ5y1X)uol;~c zN;SxI`zS^HRX~6A*xa(p$Dx#e3(2V8Sk)2=0X7`8F1L8jY9C_gu*ln%#+kfw%}ADvLaEo}G%#sIU9QV4QPEK7lH zRo`-ccPI33`&8KMh0@R|p_IkpP75nG@T+N6d=>5{rAU@>w0yM_x^>N7!%Vk@Qc-S9 zpd*~-Mt*SD9<*+uPioZqmDjqoK_djqzwtgJ?vZWFVD+?W!twxLFEsQh1~;bKkO#p1t>wW&08r~o5g6s>bNSyx## z%yhdb<>$tP&w8wvG)Jke1OJ^U72X0f3zFCL(IYI-`ZCmDRd1F4`hRENx3z&U;Gg;^ z1QY@a0fm4)W$YnjQJB`v2q{{KInlTZo( diff --git a/aspnet-core/services/apigateway/LINGYUN.ApiGateway.HttpApi.Host/ApiGatewayHttpApiHostModule.Configure.cs b/aspnet-core/services/apigateway/LINGYUN.ApiGateway.HttpApi.Host/ApiGatewayHttpApiHostModule.Configure.cs index ebff0f297..c924bf09f 100644 --- a/aspnet-core/services/apigateway/LINGYUN.ApiGateway.HttpApi.Host/ApiGatewayHttpApiHostModule.Configure.cs +++ b/aspnet-core/services/apigateway/LINGYUN.ApiGateway.HttpApi.Host/ApiGatewayHttpApiHostModule.Configure.cs @@ -152,6 +152,7 @@ namespace LINGYUN.ApiGateway new string[] { } } }); + options.OperationFilter(); }); } diff --git a/aspnet-core/services/apigateway/LINGYUN.ApiGateway.HttpApi.Host/TenantHeaderParamter.cs b/aspnet-core/services/apigateway/LINGYUN.ApiGateway.HttpApi.Host/TenantHeaderParamter.cs new file mode 100644 index 000000000..728ef322c --- /dev/null +++ b/aspnet-core/services/apigateway/LINGYUN.ApiGateway.HttpApi.Host/TenantHeaderParamter.cs @@ -0,0 +1,33 @@ +using Microsoft.Extensions.Options; +using Microsoft.OpenApi.Models; +using Swashbuckle.AspNetCore.SwaggerGen; +using System.Collections.Generic; +using Volo.Abp.MultiTenancy; + +namespace LINGYUN.ApiGateway +{ + public class TenantHeaderParamter : IOperationFilter + { + private readonly AbpMultiTenancyOptions _options; + public TenantHeaderParamter( + IOptions options) + { + _options = options.Value; + } + + public void Apply(OpenApiOperation operation, OperationFilterContext context) + { + if (_options.IsEnabled) + { + operation.Parameters = operation.Parameters ?? new List(); + operation.Parameters.Add(new OpenApiParameter + { + Name = TenantResolverConsts.DefaultTenantKey, + In = ParameterLocation.Header, + Description = "Tenant Id in http header", + Required = false + }); + } + } + } +} diff --git a/aspnet-core/services/identity-server/LINGYUN.Abp.IdentityServer4.HttpApi.Host/AbpIdentityServerAdminHttpApiHostModule.Configure.cs b/aspnet-core/services/identity-server/LINGYUN.Abp.IdentityServer4.HttpApi.Host/AbpIdentityServerAdminHttpApiHostModule.Configure.cs index 5128989f0..d29fb3913 100644 --- a/aspnet-core/services/identity-server/LINGYUN.Abp.IdentityServer4.HttpApi.Host/AbpIdentityServerAdminHttpApiHostModule.Configure.cs +++ b/aspnet-core/services/identity-server/LINGYUN.Abp.IdentityServer4.HttpApi.Host/AbpIdentityServerAdminHttpApiHostModule.Configure.cs @@ -215,6 +215,7 @@ namespace LINGYUN.Abp.IdentityServer4 new string[] { } } }); + options.OperationFilter(); }); } diff --git a/aspnet-core/services/identity-server/LINGYUN.Abp.IdentityServer4.HttpApi.Host/TenantHeaderParamter.cs b/aspnet-core/services/identity-server/LINGYUN.Abp.IdentityServer4.HttpApi.Host/TenantHeaderParamter.cs new file mode 100644 index 000000000..b74bafe9d --- /dev/null +++ b/aspnet-core/services/identity-server/LINGYUN.Abp.IdentityServer4.HttpApi.Host/TenantHeaderParamter.cs @@ -0,0 +1,33 @@ +using Microsoft.Extensions.Options; +using Microsoft.OpenApi.Models; +using Swashbuckle.AspNetCore.SwaggerGen; +using System.Collections.Generic; +using Volo.Abp.MultiTenancy; + +namespace LINGYUN.Abp.IdentityServer4 +{ + public class TenantHeaderParamter : IOperationFilter + { + private readonly AbpMultiTenancyOptions _options; + public TenantHeaderParamter( + IOptions options) + { + _options = options.Value; + } + + public void Apply(OpenApiOperation operation, OperationFilterContext context) + { + if (_options.IsEnabled) + { + operation.Parameters = operation.Parameters ?? new List(); + operation.Parameters.Add(new OpenApiParameter + { + Name = TenantResolverConsts.DefaultTenantKey, + In = ParameterLocation.Header, + Description = "Tenant Id in http header", + Required = false + }); + } + } + } +} diff --git a/aspnet-core/services/localization/LINGYUN.Abp.LocalizationManagement.HttpApi.Host/AbpLocalizationManagementHttpApiHostModule.Configure.cs b/aspnet-core/services/localization/LINGYUN.Abp.LocalizationManagement.HttpApi.Host/AbpLocalizationManagementHttpApiHostModule.Configure.cs index ac34901dd..e0c0bba1b 100644 --- a/aspnet-core/services/localization/LINGYUN.Abp.LocalizationManagement.HttpApi.Host/AbpLocalizationManagementHttpApiHostModule.Configure.cs +++ b/aspnet-core/services/localization/LINGYUN.Abp.LocalizationManagement.HttpApi.Host/AbpLocalizationManagementHttpApiHostModule.Configure.cs @@ -170,6 +170,7 @@ namespace LINGYUN.Abp.LocalizationManagement new string[] { } } }); + options.OperationFilter(); }); } diff --git a/aspnet-core/services/localization/LINGYUN.Abp.LocalizationManagement.HttpApi.Host/LocalizationCacheInitialize.cs b/aspnet-core/services/localization/LINGYUN.Abp.LocalizationManagement.HttpApi.Host/LocalizationCacheInitialize.cs deleted file mode 100644 index d3630568c..000000000 --- a/aspnet-core/services/localization/LINGYUN.Abp.LocalizationManagement.HttpApi.Host/LocalizationCacheInitialize.cs +++ /dev/null @@ -1,47 +0,0 @@ -using LINGYUN.Abp.Localization.Dynamic; -using System.Linq; -using System.Threading.Tasks; -using Volo.Abp; -using Volo.Abp.Caching; -using Volo.Abp.DependencyInjection; - -namespace LINGYUN.Abp.LocalizationManagement -{ - public interface ILocalizationCacheInitialize : IAsyncInitialize - { - - } - public class LocalizationCacheInitialize : ILocalizationCacheInitialize, ITransientDependency - { - protected IDistributedCache Cache { get; } - protected ITextRepository TextRepository { get; } - - public LocalizationCacheInitialize( - IDistributedCache cache, - ITextRepository textRepository) - { - Cache = cache; - TextRepository = textRepository; - } - - public virtual async Task InitializeAsync() - { - var texts = await TextRepository.GetListAsync(); - - foreach (var textGroup in texts.GroupBy(x => x.ResourceName)) - { - foreach (var textCulture in textGroup.GroupBy(x => x.CultureName)) - { - var cacheKey = LocalizationCacheItem.NormalizeKey(textGroup.Key, textCulture.Key); - var cacheItem = new LocalizationCacheItem( - textGroup.Key, - textCulture.Key, - textCulture - .Select(x => new LocalizationText(x.Key, x.Value)) - .ToList()); - await Cache.SetAsync(cacheKey, cacheItem); - } - } - } - } -} diff --git a/aspnet-core/services/localization/LINGYUN.Abp.LocalizationManagement.HttpApi.Host/TenantHeaderParamter.cs b/aspnet-core/services/localization/LINGYUN.Abp.LocalizationManagement.HttpApi.Host/TenantHeaderParamter.cs new file mode 100644 index 000000000..b034b1bb4 --- /dev/null +++ b/aspnet-core/services/localization/LINGYUN.Abp.LocalizationManagement.HttpApi.Host/TenantHeaderParamter.cs @@ -0,0 +1,33 @@ +using Microsoft.Extensions.Options; +using Microsoft.OpenApi.Models; +using Swashbuckle.AspNetCore.SwaggerGen; +using System.Collections.Generic; +using Volo.Abp.MultiTenancy; + +namespace LINGYUN.Abp.LocalizationManagement +{ + public class TenantHeaderParamter : IOperationFilter + { + private readonly AbpMultiTenancyOptions _options; + public TenantHeaderParamter( + IOptions options) + { + _options = options.Value; + } + + public void Apply(OpenApiOperation operation, OperationFilterContext context) + { + if (_options.IsEnabled) + { + operation.Parameters = operation.Parameters ?? new List(); + operation.Parameters.Add(new OpenApiParameter + { + Name = TenantResolverConsts.DefaultTenantKey, + In = ParameterLocation.Header, + Description = "Tenant Id in http header", + Required = false + }); + } + } + } +} diff --git a/aspnet-core/services/messages/LINGYUN.Abp.MessageService.HttpApi.Host/AbpMessageServiceHttpApiHostModule.Configure.cs b/aspnet-core/services/messages/LINGYUN.Abp.MessageService.HttpApi.Host/AbpMessageServiceHttpApiHostModule.Configure.cs index 677e2bfba..90c09acc3 100644 --- a/aspnet-core/services/messages/LINGYUN.Abp.MessageService.HttpApi.Host/AbpMessageServiceHttpApiHostModule.Configure.cs +++ b/aspnet-core/services/messages/LINGYUN.Abp.MessageService.HttpApi.Host/AbpMessageServiceHttpApiHostModule.Configure.cs @@ -185,6 +185,7 @@ namespace LINGYUN.Abp.MessageService new string[] { } } }); + options.OperationFilter(); }); } diff --git a/aspnet-core/services/messages/LINGYUN.Abp.MessageService.HttpApi.Host/TenantHeaderParamter.cs b/aspnet-core/services/messages/LINGYUN.Abp.MessageService.HttpApi.Host/TenantHeaderParamter.cs new file mode 100644 index 000000000..2431837b1 --- /dev/null +++ b/aspnet-core/services/messages/LINGYUN.Abp.MessageService.HttpApi.Host/TenantHeaderParamter.cs @@ -0,0 +1,33 @@ +using Microsoft.Extensions.Options; +using Microsoft.OpenApi.Models; +using Swashbuckle.AspNetCore.SwaggerGen; +using System.Collections.Generic; +using Volo.Abp.MultiTenancy; + +namespace LINGYUN.Abp.MessageService +{ + public class TenantHeaderParamter : IOperationFilter + { + private readonly AbpMultiTenancyOptions _options; + public TenantHeaderParamter( + IOptions options) + { + _options = options.Value; + } + + public void Apply(OpenApiOperation operation, OperationFilterContext context) + { + if (_options.IsEnabled) + { + operation.Parameters = operation.Parameters ?? new List(); + operation.Parameters.Add(new OpenApiParameter + { + Name = TenantResolverConsts.DefaultTenantKey, + In = ParameterLocation.Header, + Description = "Tenant Id in http header", + Required = false + }); + } + } + } +} diff --git a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/AppPlatformHttpApiHostModule.Configure.cs b/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/AppPlatformHttpApiHostModule.Configure.cs index fafc94467..fb867820e 100644 --- a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/AppPlatformHttpApiHostModule.Configure.cs +++ b/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/AppPlatformHttpApiHostModule.Configure.cs @@ -215,6 +215,7 @@ namespace LINGYUN.Platform new string[] { } } }); + options.OperationFilter(); }); } diff --git a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/LINGYUN.Platform.HttpApi.Host.csproj.user b/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/LINGYUN.Platform.HttpApi.Host.csproj.user index 0f14913f3..429333de9 100644 --- a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/LINGYUN.Platform.HttpApi.Host.csproj.user +++ b/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/LINGYUN.Platform.HttpApi.Host.csproj.user @@ -1,4 +1,6 @@  - + + true + \ No newline at end of file diff --git a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/TenantHeaderParamter.cs b/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/TenantHeaderParamter.cs new file mode 100644 index 000000000..9251d083a --- /dev/null +++ b/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/TenantHeaderParamter.cs @@ -0,0 +1,33 @@ +using Microsoft.Extensions.Options; +using Microsoft.OpenApi.Models; +using Swashbuckle.AspNetCore.SwaggerGen; +using System.Collections.Generic; +using Volo.Abp.MultiTenancy; + +namespace LINGYUN.Platform +{ + public class TenantHeaderParamter : IOperationFilter + { + private readonly AbpMultiTenancyOptions _options; + public TenantHeaderParamter( + IOptions options) + { + _options = options.Value; + } + + public void Apply(OpenApiOperation operation, OperationFilterContext context) + { + if (_options.IsEnabled) + { + operation.Parameters = operation.Parameters ?? new List(); + operation.Parameters.Add(new OpenApiParameter + { + Name = TenantResolverConsts.DefaultTenantKey, + In = ParameterLocation.Header, + Description = "Tenant Id in http header", + Required = false + }); + } + } + } +}