Compare commits
	
		
			1 Commits
		
	
	
		
			4e465563c4
			...
			dv_karl
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| fdfb005974 | 
							
								
								
									
										44
									
								
								KonSoft.sln
									
									
									
									
									
								
							
							
						
						
									
										44
									
								
								KonSoft.sln
									
									
									
									
									
								
							| @ -1,7 +1,7 @@ | |||||||
|  |  | ||||||
| Microsoft Visual Studio Solution File, Format Version 12.00 | Microsoft Visual Studio Solution File, Format Version 12.00 | ||||||
| # Visual Studio Version 17 | # Visual Studio Version 17 | ||||||
| VisualStudioVersion = 17.14.36414.22 | VisualStudioVersion = 17.14.36414.22 d17.14 | ||||||
| MinimumVisualStudioVersion = 10.0.40219.1 | MinimumVisualStudioVersion = 10.0.40219.1 | ||||||
| Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "applications", "applications", "{02EA681E-C7D8-13C7-8484-4AC65E1B71E8}" | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "applications", "applications", "{02EA681E-C7D8-13C7-8484-4AC65E1B71E8}" | ||||||
| EndProject | EndProject | ||||||
| @ -49,6 +49,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{E67FA5C3-132 | |||||||
| EndProject | EndProject | ||||||
| Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{1C06151A-45F0-4D48-8303-3D4CBE9517F7}" | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{1C06151A-45F0-4D48-8303-3D4CBE9517F7}" | ||||||
| EndProject | EndProject | ||||||
|  | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KonSoft.Shared", "shared\KonSoft.Shared\KonSoft.Shared.csproj", "{345B5CDA-DC77-4956-BF96-80707EC1B5B2}" | ||||||
|  | EndProject | ||||||
| Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KonSoft.Admin.Application", "modules\admin\src\KonSoft.Admin.Application\KonSoft.Admin.Application.csproj", "{9D9D979A-AFC7-F9D0-2D23-8809E83F9EF9}" | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KonSoft.Admin.Application", "modules\admin\src\KonSoft.Admin.Application\KonSoft.Admin.Application.csproj", "{9D9D979A-AFC7-F9D0-2D23-8809E83F9EF9}" | ||||||
| EndProject | EndProject | ||||||
| Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KonSoft.Admin.Application.Contracts", "modules\admin\src\KonSoft.Admin.Application.Contracts\KonSoft.Admin.Application.Contracts.csproj", "{9F68B0E2-0B1D-E0E8-1BE7-079F693A4643}" | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KonSoft.Admin.Application.Contracts", "modules\admin\src\KonSoft.Admin.Application.Contracts\KonSoft.Admin.Application.Contracts.csproj", "{9F68B0E2-0B1D-E0E8-1BE7-079F693A4643}" | ||||||
| @ -183,16 +185,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KonSoft.Report.HttpApi.Host | |||||||
| EndProject | EndProject | ||||||
| Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KonSoft.TenantManagement.HttpApi.Host", "microservices\KonSoft.TenantManagement.HttpApi.Host\KonSoft.TenantManagement.HttpApi.Host.csproj", "{3641CA05-99C5-2245-C663-6CE00730E87C}" | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KonSoft.TenantManagement.HttpApi.Host", "microservices\KonSoft.TenantManagement.HttpApi.Host\KonSoft.TenantManagement.HttpApi.Host.csproj", "{3641CA05-99C5-2245-C663-6CE00730E87C}" | ||||||
| EndProject | EndProject | ||||||
| Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KonSoft.Shared.Localization", "shared\KonSoft.Shared.Localization\KonSoft.Shared.Localization.csproj", "{A773C53C-F145-043A-7F55-79ABDB11893B}" |  | ||||||
| EndProject |  | ||||||
| Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KonSoft.Shared.Hosting", "shared\KonSoft.Shared.Hosting\KonSoft.Shared.Hosting.csproj", "{2DBCE12E-4A5F-4AB9-82BB-4BDDE48AABBF}" |  | ||||||
| EndProject |  | ||||||
| Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KonSoft.Shared.Hosting.AspNetCore", "shared\KonSoft.Shared.Hosting.AspNetCore\KonSoft.Shared.Hosting.AspNetCore.csproj", "{8CA6B487-3AAF-4E77-ACE0-01D878DE4836}" |  | ||||||
| EndProject |  | ||||||
| Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KonSoft.Shared.Hosting.Gateways", "shared\KonSoft.Shared.Hosting.Gateways\KonSoft.Shared.Hosting.Gateways.csproj", "{BBB1A129-9ED7-4F08-B710-B6C287197BFB}" |  | ||||||
| EndProject |  | ||||||
| Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KonSoft.Shared.Hosting.Microservices", "shared\KonSoft.Shared.Hosting.Microservices\KonSoft.Shared.Hosting.Microservices.csproj", "{ADF28580-F8A0-4495-96D6-736C6C7CF3FF}" |  | ||||||
| EndProject |  | ||||||
| Global | Global | ||||||
| 	GlobalSection(SolutionConfigurationPlatforms) = preSolution | 	GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||||||
| 		Debug|Any CPU = Debug|Any CPU | 		Debug|Any CPU = Debug|Any CPU | ||||||
| @ -211,6 +203,10 @@ Global | |||||||
| 		{AEBC7053-743F-4F80-BD10-8ED6A8A7B3EE}.Debug|Any CPU.Build.0 = Debug|Any CPU | 		{AEBC7053-743F-4F80-BD10-8ED6A8A7B3EE}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||||||
| 		{AEBC7053-743F-4F80-BD10-8ED6A8A7B3EE}.Release|Any CPU.ActiveCfg = Release|Any CPU | 		{AEBC7053-743F-4F80-BD10-8ED6A8A7B3EE}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||||||
| 		{AEBC7053-743F-4F80-BD10-8ED6A8A7B3EE}.Release|Any CPU.Build.0 = Release|Any CPU | 		{AEBC7053-743F-4F80-BD10-8ED6A8A7B3EE}.Release|Any CPU.Build.0 = Release|Any CPU | ||||||
|  | 		{345B5CDA-DC77-4956-BF96-80707EC1B5B2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||||||
|  | 		{345B5CDA-DC77-4956-BF96-80707EC1B5B2}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||||||
|  | 		{345B5CDA-DC77-4956-BF96-80707EC1B5B2}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||||||
|  | 		{345B5CDA-DC77-4956-BF96-80707EC1B5B2}.Release|Any CPU.Build.0 = Release|Any CPU | ||||||
| 		{9D9D979A-AFC7-F9D0-2D23-8809E83F9EF9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | 		{9D9D979A-AFC7-F9D0-2D23-8809E83F9EF9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||||||
| 		{9D9D979A-AFC7-F9D0-2D23-8809E83F9EF9}.Debug|Any CPU.Build.0 = Debug|Any CPU | 		{9D9D979A-AFC7-F9D0-2D23-8809E83F9EF9}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||||||
| 		{9D9D979A-AFC7-F9D0-2D23-8809E83F9EF9}.Release|Any CPU.ActiveCfg = Release|Any CPU | 		{9D9D979A-AFC7-F9D0-2D23-8809E83F9EF9}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||||||
| @ -479,26 +475,6 @@ Global | |||||||
| 		{3641CA05-99C5-2245-C663-6CE00730E87C}.Debug|Any CPU.Build.0 = Debug|Any CPU | 		{3641CA05-99C5-2245-C663-6CE00730E87C}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||||||
| 		{3641CA05-99C5-2245-C663-6CE00730E87C}.Release|Any CPU.ActiveCfg = Release|Any CPU | 		{3641CA05-99C5-2245-C663-6CE00730E87C}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||||||
| 		{3641CA05-99C5-2245-C663-6CE00730E87C}.Release|Any CPU.Build.0 = Release|Any CPU | 		{3641CA05-99C5-2245-C663-6CE00730E87C}.Release|Any CPU.Build.0 = Release|Any CPU | ||||||
| 		{A773C53C-F145-043A-7F55-79ABDB11893B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |  | ||||||
| 		{A773C53C-F145-043A-7F55-79ABDB11893B}.Debug|Any CPU.Build.0 = Debug|Any CPU |  | ||||||
| 		{A773C53C-F145-043A-7F55-79ABDB11893B}.Release|Any CPU.ActiveCfg = Release|Any CPU |  | ||||||
| 		{A773C53C-F145-043A-7F55-79ABDB11893B}.Release|Any CPU.Build.0 = Release|Any CPU |  | ||||||
| 		{2DBCE12E-4A5F-4AB9-82BB-4BDDE48AABBF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |  | ||||||
| 		{2DBCE12E-4A5F-4AB9-82BB-4BDDE48AABBF}.Debug|Any CPU.Build.0 = Debug|Any CPU |  | ||||||
| 		{2DBCE12E-4A5F-4AB9-82BB-4BDDE48AABBF}.Release|Any CPU.ActiveCfg = Release|Any CPU |  | ||||||
| 		{2DBCE12E-4A5F-4AB9-82BB-4BDDE48AABBF}.Release|Any CPU.Build.0 = Release|Any CPU |  | ||||||
| 		{8CA6B487-3AAF-4E77-ACE0-01D878DE4836}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |  | ||||||
| 		{8CA6B487-3AAF-4E77-ACE0-01D878DE4836}.Debug|Any CPU.Build.0 = Debug|Any CPU |  | ||||||
| 		{8CA6B487-3AAF-4E77-ACE0-01D878DE4836}.Release|Any CPU.ActiveCfg = Release|Any CPU |  | ||||||
| 		{8CA6B487-3AAF-4E77-ACE0-01D878DE4836}.Release|Any CPU.Build.0 = Release|Any CPU |  | ||||||
| 		{BBB1A129-9ED7-4F08-B710-B6C287197BFB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |  | ||||||
| 		{BBB1A129-9ED7-4F08-B710-B6C287197BFB}.Debug|Any CPU.Build.0 = Debug|Any CPU |  | ||||||
| 		{BBB1A129-9ED7-4F08-B710-B6C287197BFB}.Release|Any CPU.ActiveCfg = Release|Any CPU |  | ||||||
| 		{BBB1A129-9ED7-4F08-B710-B6C287197BFB}.Release|Any CPU.Build.0 = Release|Any CPU |  | ||||||
| 		{ADF28580-F8A0-4495-96D6-736C6C7CF3FF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |  | ||||||
| 		{ADF28580-F8A0-4495-96D6-736C6C7CF3FF}.Debug|Any CPU.Build.0 = Debug|Any CPU |  | ||||||
| 		{ADF28580-F8A0-4495-96D6-736C6C7CF3FF}.Release|Any CPU.ActiveCfg = Release|Any CPU |  | ||||||
| 		{ADF28580-F8A0-4495-96D6-736C6C7CF3FF}.Release|Any CPU.Build.0 = Release|Any CPU |  | ||||||
| 	EndGlobalSection | 	EndGlobalSection | ||||||
| 	GlobalSection(SolutionProperties) = preSolution | 	GlobalSection(SolutionProperties) = preSolution | ||||||
| 		HideSolutionNode = FALSE | 		HideSolutionNode = FALSE | ||||||
| @ -522,6 +498,7 @@ Global | |||||||
| 		{6C762F40-30BB-4CDA-951B-01D45F7C2B53} = {AAF02051-771B-4CC0-BD17-1A3643F83E09} | 		{6C762F40-30BB-4CDA-951B-01D45F7C2B53} = {AAF02051-771B-4CC0-BD17-1A3643F83E09} | ||||||
| 		{E67FA5C3-132C-4F47-B6A6-8FA4376C70BB} = {CF59695F-7948-4743-A467-42E4B4C9EECA} | 		{E67FA5C3-132C-4F47-B6A6-8FA4376C70BB} = {CF59695F-7948-4743-A467-42E4B4C9EECA} | ||||||
| 		{1C06151A-45F0-4D48-8303-3D4CBE9517F7} = {CF59695F-7948-4743-A467-42E4B4C9EECA} | 		{1C06151A-45F0-4D48-8303-3D4CBE9517F7} = {CF59695F-7948-4743-A467-42E4B4C9EECA} | ||||||
|  | 		{345B5CDA-DC77-4956-BF96-80707EC1B5B2} = {7EFFD2C6-2041-4967-A715-0F817D70C433} | ||||||
| 		{9D9D979A-AFC7-F9D0-2D23-8809E83F9EF9} = {EBCB740D-07E7-4CED-A422-90EB824B9021} | 		{9D9D979A-AFC7-F9D0-2D23-8809E83F9EF9} = {EBCB740D-07E7-4CED-A422-90EB824B9021} | ||||||
| 		{9F68B0E2-0B1D-E0E8-1BE7-079F693A4643} = {EBCB740D-07E7-4CED-A422-90EB824B9021} | 		{9F68B0E2-0B1D-E0E8-1BE7-079F693A4643} = {EBCB740D-07E7-4CED-A422-90EB824B9021} | ||||||
| 		{D1A86C77-533D-5B68-04F1-7F7BFBF56AC7} = {EBCB740D-07E7-4CED-A422-90EB824B9021} | 		{D1A86C77-533D-5B68-04F1-7F7BFBF56AC7} = {EBCB740D-07E7-4CED-A422-90EB824B9021} | ||||||
| @ -589,11 +566,6 @@ Global | |||||||
| 		{9A034977-0FBC-A3C8-8432-9FDD073F215A} = {4CBFE8AF-968B-453D-B763-3D0437C0883D} | 		{9A034977-0FBC-A3C8-8432-9FDD073F215A} = {4CBFE8AF-968B-453D-B763-3D0437C0883D} | ||||||
| 		{1C89424B-DA16-8840-4AB0-C446CFBD634C} = {4CBFE8AF-968B-453D-B763-3D0437C0883D} | 		{1C89424B-DA16-8840-4AB0-C446CFBD634C} = {4CBFE8AF-968B-453D-B763-3D0437C0883D} | ||||||
| 		{3641CA05-99C5-2245-C663-6CE00730E87C} = {4CBFE8AF-968B-453D-B763-3D0437C0883D} | 		{3641CA05-99C5-2245-C663-6CE00730E87C} = {4CBFE8AF-968B-453D-B763-3D0437C0883D} | ||||||
| 		{A773C53C-F145-043A-7F55-79ABDB11893B} = {7EFFD2C6-2041-4967-A715-0F817D70C433} |  | ||||||
| 		{2DBCE12E-4A5F-4AB9-82BB-4BDDE48AABBF} = {7EFFD2C6-2041-4967-A715-0F817D70C433} |  | ||||||
| 		{8CA6B487-3AAF-4E77-ACE0-01D878DE4836} = {7EFFD2C6-2041-4967-A715-0F817D70C433} |  | ||||||
| 		{BBB1A129-9ED7-4F08-B710-B6C287197BFB} = {7EFFD2C6-2041-4967-A715-0F817D70C433} |  | ||||||
| 		{ADF28580-F8A0-4495-96D6-736C6C7CF3FF} = {7EFFD2C6-2041-4967-A715-0F817D70C433} |  | ||||||
| 	EndGlobalSection | 	EndGlobalSection | ||||||
| 	GlobalSection(ExtensibilityGlobals) = postSolution | 	GlobalSection(ExtensibilityGlobals) = postSolution | ||||||
| 		SolutionGuid = {28315BFD-90E7-4E14-A2EA-F3D23AF4126F} | 		SolutionGuid = {28315BFD-90E7-4E14-A2EA-F3D23AF4126F} | ||||||
|  | |||||||
| @ -1,6 +1,7 @@ | |||||||
| FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base | FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base | ||||||
| USER $APP_UID | USER $APP_UID | ||||||
| WORKDIR /app | WORKDIR /app | ||||||
|  | EXPOSE 8080 | ||||||
| EXPOSE 8081 | EXPOSE 8081 | ||||||
|  |  | ||||||
| FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build | FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build | ||||||
| @ -8,21 +9,15 @@ ARG BUILD_CONFIGURATION=Release | |||||||
| WORKDIR /src | WORKDIR /src | ||||||
| COPY ["NuGet.Config", "."] | COPY ["NuGet.Config", "."] | ||||||
| COPY ["applications/KonSoft.AuthServer/KonSoft.AuthServer.csproj", "applications/KonSoft.AuthServer/"] | COPY ["applications/KonSoft.AuthServer/KonSoft.AuthServer.csproj", "applications/KonSoft.AuthServer/"] | ||||||
| COPY ["shared/KonSoft.Shared.Hosting.Microservices/KonSoft.Shared.Hosting.Microservices.csproj", "shared/KonSoft.Shared.Hosting.Microservices/"] |  | ||||||
| COPY ["shared/KonSoft.Shared.Hosting.AspNetCore/KonSoft.Shared.Hosting.AspNetCore.csproj", "shared/KonSoft.Shared.Hosting.AspNetCore/"] |  | ||||||
| COPY ["shared/KonSoft.Shared.Hosting/KonSoft.Shared.Hosting.csproj", "shared/KonSoft.Shared.Hosting/"] |  | ||||||
| COPY ["shared/KonSoft.Shared.Localization/KonSoft.Shared.Localization.csproj", "shared/KonSoft.Shared.Localization/"] |  | ||||||
| RUN dotnet restore "./applications/KonSoft.AuthServer/KonSoft.AuthServer.csproj" | RUN dotnet restore "./applications/KonSoft.AuthServer/KonSoft.AuthServer.csproj" | ||||||
| COPY . . | COPY . . | ||||||
| WORKDIR "/src/applications/KonSoft.AuthServer" | WORKDIR "/src/applications/KonSoft.AuthServer" | ||||||
| RUN dotnet build "./KonSoft.AuthServer.csproj" -c $BUILD_CONFIGURATION -o /app/build | RUN dotnet build "./KonSoft.AuthServer.csproj" -c $BUILD_CONFIGURATION -o /app/build | ||||||
|  |  | ||||||
| # 此阶段用于发布要复制到最终阶段的服务项目 |  | ||||||
| FROM build AS publish | FROM build AS publish | ||||||
| ARG BUILD_CONFIGURATION=Release | ARG BUILD_CONFIGURATION=Release | ||||||
| RUN dotnet publish "./KonSoft.AuthServer.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false | RUN dotnet publish "./KonSoft.AuthServer.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false | ||||||
|  |  | ||||||
| # 此阶段在生产中使用,或在常规模式下从 VS 运行时使用(在不使用调试配置时为默认值) |  | ||||||
| FROM base AS final | FROM base AS final | ||||||
| WORKDIR /app | WORKDIR /app | ||||||
| COPY --from=publish /app/publish . | COPY --from=publish /app/publish . | ||||||
|  | |||||||
| @ -39,11 +39,22 @@ | |||||||
|   </ItemGroup> |   </ItemGroup> | ||||||
|  |  | ||||||
|   <ItemGroup> |   <ItemGroup> | ||||||
| 		<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.22.1" /> |     <PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.22.1" /> | ||||||
|  |     <PackageReference Include="Serilog.AspNetCore" Version="8.0.0" /> | ||||||
|  |     <PackageReference Include="Serilog.Sinks.Async" Version="1.5.0" /> | ||||||
|  |     <PackageReference Include="Microsoft.AspNetCore.DataProtection.StackExchangeRedis" Version="8.0.4" /> | ||||||
|  |     <PackageReference Include="DistributedLock.Redis" Version="1.0.2" /> | ||||||
|  |   </ItemGroup> | ||||||
|  |  | ||||||
|  |   <ItemGroup> | ||||||
| 		<PackageReference Include="Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic" Version="8.3.4" /> | 		<PackageReference Include="Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic" Version="8.3.4" /> | ||||||
|   </ItemGroup> |   </ItemGroup> | ||||||
|  |  | ||||||
|   <ItemGroup> |   <ItemGroup> | ||||||
|  |     <PackageReference Include="Volo.Abp.Autofac" Version="8.3.4" /> | ||||||
|  |     <PackageReference Include="Volo.Abp.Caching.StackExchangeRedis" Version="8.3.4" /> | ||||||
|  |     <PackageReference Include="Volo.Abp.DistributedLocking" Version="8.3.4" /> | ||||||
|  |     <PackageReference Include="Volo.Abp.AspNetCore.Serilog" Version="8.3.4" /> | ||||||
|     <PackageReference Include="Volo.Abp.Account.Web.OpenIddict" Version="8.3.4" /> |     <PackageReference Include="Volo.Abp.Account.Web.OpenIddict" Version="8.3.4" /> | ||||||
|     <PackageReference Include="Volo.Abp.Account.Application" Version="8.3.4" /> |     <PackageReference Include="Volo.Abp.Account.Application" Version="8.3.4" /> | ||||||
|     <PackageReference Include="Volo.Abp.Account.HttpApi" Version="8.3.4" /> |     <PackageReference Include="Volo.Abp.Account.HttpApi" Version="8.3.4" /> | ||||||
| @ -58,8 +69,4 @@ | |||||||
|     <PackageReference Include="Volo.Abp.OpenIddict.EntityFrameworkCore" Version="8.3.4" /> |     <PackageReference Include="Volo.Abp.OpenIddict.EntityFrameworkCore" Version="8.3.4" /> | ||||||
|   </ItemGroup> |   </ItemGroup> | ||||||
|  |  | ||||||
|   <ItemGroup> |  | ||||||
|     <ProjectReference Include="..\..\shared\KonSoft.Shared.Hosting.Microservices\KonSoft.Shared.Hosting.Microservices.csproj" /> |  | ||||||
|   </ItemGroup> |  | ||||||
|  |  | ||||||
| </Project> | </Project> | ||||||
|  | |||||||
| @ -1,31 +1,48 @@ | |||||||
| using KonSoft.Shared.Hosting.AspNetCore; |  | ||||||
| using KonSoft.Shared.Hosting.Microservices; |  | ||||||
| using KonSoft.Shared.Localization.Localization; |  | ||||||
| using Localization.Resources.AbpUi; | using Localization.Resources.AbpUi; | ||||||
|  | using Medallion.Threading; | ||||||
|  | using Medallion.Threading.Redis; | ||||||
| using Microsoft.AspNetCore.Builder; | using Microsoft.AspNetCore.Builder; | ||||||
|  | using Microsoft.AspNetCore.Cors; | ||||||
|  | using Microsoft.AspNetCore.DataProtection; | ||||||
| using Microsoft.Extensions.DependencyInjection; | using Microsoft.Extensions.DependencyInjection; | ||||||
| using Microsoft.Extensions.Hosting; | using Microsoft.Extensions.Hosting; | ||||||
|  | using StackExchange.Redis; | ||||||
|  | using System; | ||||||
|  | using System.IO; | ||||||
|  | using System.Linq; | ||||||
| using Volo.Abp; | using Volo.Abp; | ||||||
| using Volo.Abp.Account; | using Volo.Abp.Account; | ||||||
| using Volo.Abp.Account.Localization; | using Volo.Abp.Account.Localization; | ||||||
| using Volo.Abp.Account.Web; | using Volo.Abp.Account.Web; | ||||||
| using Volo.Abp.AspNetCore.Mvc.UI.Bundling; | using Volo.Abp.AspNetCore.Mvc.UI.Bundling; | ||||||
|  | using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic; | ||||||
| using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.Bundling; | using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.Bundling; | ||||||
| using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared; | using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared; | ||||||
|  | using Volo.Abp.AspNetCore.Serilog; | ||||||
| using Volo.Abp.Auditing; | using Volo.Abp.Auditing; | ||||||
|  | using Volo.Abp.Autofac; | ||||||
| using Volo.Abp.BackgroundJobs; | using Volo.Abp.BackgroundJobs; | ||||||
|  | using Volo.Abp.Caching; | ||||||
|  | using Volo.Abp.Caching.StackExchangeRedis; | ||||||
|  | using Volo.Abp.DistributedLocking; | ||||||
| using Volo.Abp.Localization; | using Volo.Abp.Localization; | ||||||
| using Volo.Abp.Modularity; | using Volo.Abp.Modularity; | ||||||
| using Volo.Abp.OpenIddict; | using Volo.Abp.OpenIddict; | ||||||
| using Volo.Abp.Security.Claims; | using Volo.Abp.Security.Claims; | ||||||
|  | using Volo.Abp.UI.Navigation.Urls; | ||||||
|  | using Volo.Abp.VirtualFileSystem; | ||||||
|  |  | ||||||
| namespace KonSoft; | namespace KonSoft; | ||||||
|  |  | ||||||
| [DependsOn( | [DependsOn( | ||||||
|  |     typeof(AbpAutofacModule), | ||||||
|  |     typeof(AbpCachingStackExchangeRedisModule), | ||||||
|  |     typeof(AbpDistributedLockingModule), | ||||||
|     typeof(AbpAccountWebOpenIddictModule), |     typeof(AbpAccountWebOpenIddictModule), | ||||||
|     typeof(AbpAccountApplicationModule), |     typeof(AbpAccountApplicationModule), | ||||||
|     typeof(AbpAccountHttpApiModule), |     typeof(AbpAccountHttpApiModule), | ||||||
|     typeof(KonSoftSharedHostingMicroservicesModule) |     typeof(AbpAspNetCoreMvcUiBasicThemeModule), | ||||||
|  |     typeof(AbpAspNetCoreSerilogModule) | ||||||
|     )] |     )] | ||||||
| public class KonSoftAuthServerModule : AbpModule | public class KonSoftAuthServerModule : AbpModule | ||||||
| { | { | ||||||
| @ -90,11 +107,54 @@ public class KonSoftAuthServerModule : AbpModule | |||||||
|                 options.ApplicationName = "AuthServer"; |                 options.ApplicationName = "AuthServer"; | ||||||
|         }); |         }); | ||||||
|  |  | ||||||
|  |         Configure<AppUrlOptions>(options => | ||||||
|  |         { | ||||||
|  |             options.Applications["MVC"].RootUrl = configuration["App:SelfUrl"]; | ||||||
|  |             options.RedirectAllowedUrls.AddRange(configuration["App:RedirectAllowedUrls"]?.Split(',') ?? []); | ||||||
|  |         }); | ||||||
|  |  | ||||||
|         Configure<AbpBackgroundJobOptions>(options => |         Configure<AbpBackgroundJobOptions>(options => | ||||||
|         { |         { | ||||||
|             options.IsJobExecutionEnabled = false; |             options.IsJobExecutionEnabled = false; | ||||||
|         }); |         }); | ||||||
|  |  | ||||||
|  |         Configure<AbpDistributedCacheOptions>(options => | ||||||
|  |         { | ||||||
|  |             options.KeyPrefix = "KonSoft:"; | ||||||
|  |         }); | ||||||
|  |  | ||||||
|  |         var dataProtectionBuilder = context.Services.AddDataProtection().SetApplicationName("KonSoft"); | ||||||
|  |         if (!hostingEnvironment.IsDevelopment()) | ||||||
|  |         { | ||||||
|  |             var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]!); | ||||||
|  |             dataProtectionBuilder.PersistKeysToStackExchangeRedis(redis, "KonSoft-Protection-Keys"); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         context.Services.AddSingleton<IDistributedLockProvider>(sp => | ||||||
|  |         { | ||||||
|  |             var connection = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]!); | ||||||
|  |             return new RedisDistributedSynchronizationProvider(connection.GetDatabase()); | ||||||
|  |         }); | ||||||
|  |  | ||||||
|  |         context.Services.AddCors(options => | ||||||
|  |         { | ||||||
|  |             options.AddDefaultPolicy(builder => | ||||||
|  |             { | ||||||
|  |                 builder | ||||||
|  |                     .WithOrigins( | ||||||
|  |                         configuration["App:CorsOrigins"]? | ||||||
|  |                             .Split(",", StringSplitOptions.RemoveEmptyEntries) | ||||||
|  |                             .Select(o => o.RemovePostFix("/")) | ||||||
|  |                             .ToArray() ?? [] | ||||||
|  |                     ) | ||||||
|  |                     .WithAbpExposedHeaders() | ||||||
|  |                     .SetIsOriginAllowedToAllowWildcardSubdomains() | ||||||
|  |                     .AllowAnyHeader() | ||||||
|  |                     .AllowAnyMethod() | ||||||
|  |                     .AllowCredentials(); | ||||||
|  |             }); | ||||||
|  |         }); | ||||||
|  |  | ||||||
|         context.Services.Configure<AbpClaimsPrincipalFactoryOptions>(options => |         context.Services.Configure<AbpClaimsPrincipalFactoryOptions>(options => | ||||||
|         { |         { | ||||||
|             options.IsDynamicClaimsEnabled = true; |             options.IsDynamicClaimsEnabled = true; | ||||||
| @ -125,7 +185,7 @@ public class KonSoftAuthServerModule : AbpModule | |||||||
|         app.UseAuthentication(); |         app.UseAuthentication(); | ||||||
|         app.UseAbpOpenIddictValidation(); |         app.UseAbpOpenIddictValidation(); | ||||||
|  |  | ||||||
|         if (KonSoftConsts.MultiTenancyEnabled) |         if (MultiTenancyConsts.IsEnabled) | ||||||
|         { |         { | ||||||
|             app.UseMultiTenancy(); |             app.UseMultiTenancy(); | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -1,7 +1,7 @@ | |||||||
| using KonSoft.Shared.Localization.Localization; | using Microsoft.Extensions.Localization; | ||||||
| using Microsoft.Extensions.Localization; | using KonSoft.Localization; | ||||||
| using Volo.Abp.DependencyInjection; |  | ||||||
| using Volo.Abp.Ui.Branding; | using Volo.Abp.Ui.Branding; | ||||||
|  | using Volo.Abp.DependencyInjection; | ||||||
|  |  | ||||||
| namespace KonSoft; | namespace KonSoft; | ||||||
|  |  | ||||||
|  | |||||||
| @ -2,7 +2,7 @@ | |||||||
| @using Microsoft.AspNetCore.Http.Extensions | @using Microsoft.AspNetCore.Http.Extensions | ||||||
| @using Microsoft.AspNetCore.Mvc.Localization | @using Microsoft.AspNetCore.Mvc.Localization | ||||||
| @using KonSoft.Pages | @using KonSoft.Pages | ||||||
| @using KonSoft.Shared.Localization.Localization | @using KonSoft.Localization | ||||||
| @using Volo.Abp.Users | @using Volo.Abp.Users | ||||||
| @using Volo.Abp.AspNetCore.Mvc.UI.Theming | @using Volo.Abp.AspNetCore.Mvc.UI.Theming | ||||||
| @using Volo.Abp.Ui.Branding | @using Volo.Abp.Ui.Branding | ||||||
|  | |||||||
| @ -1,13 +1,38 @@ | |||||||
| { | { | ||||||
|   "$schema": "http://json.schemastore.org/launchsettings.json", |  | ||||||
|   "profiles": { |   "profiles": { | ||||||
|     "http": { |     "IIS Express": { | ||||||
|  |       "commandName": "IISExpress", | ||||||
|  |       "launchBrowser": true, | ||||||
|  |       "environmentVariables": { | ||||||
|  |         "ASPNETCORE_ENVIRONMENT": "Development" | ||||||
|  |       } | ||||||
|  |     }, | ||||||
|  |     "KonSoft.AuthServer": { | ||||||
|       "commandName": "Project", |       "commandName": "Project", | ||||||
|       "launchBrowser": true, |       "launchBrowser": true, | ||||||
|       "environmentVariables": { |       "environmentVariables": { | ||||||
|         "ASPNETCORE_ENVIRONMENT": "Development" |         "ASPNETCORE_ENVIRONMENT": "Development" | ||||||
|       }, |       }, | ||||||
|       "applicationUrl": "https://localhost:44322" |       "applicationUrl": "https://localhost:44322" | ||||||
|  |     }, | ||||||
|  |     "Container (Dockerfile)": { | ||||||
|  |       "commandName": "Docker", | ||||||
|  |       "launchBrowser": true, | ||||||
|  |       "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}", | ||||||
|  |       "environmentVariables": { | ||||||
|  |         "ASPNETCORE_HTTPS_PORTS": "8081", | ||||||
|  |         "ASPNETCORE_HTTP_PORTS": "8080" | ||||||
|  |       }, | ||||||
|  |       "publishAllPorts": true, | ||||||
|  |       "useSSL": true | ||||||
|  |     } | ||||||
|  |   }, | ||||||
|  |   "iisSettings": { | ||||||
|  |     "windowsAuthentication": false, | ||||||
|  |     "anonymousAuthentication": true, | ||||||
|  |     "iisExpress": { | ||||||
|  |       "applicationUrl": "https://localhost:44322", | ||||||
|  |       "sslPort": 44322 | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
| } | } | ||||||
| @ -1,5 +1,13 @@ | |||||||
| { | { | ||||||
|   "$schema": "http://json.schemastore.org/launchsettings.json", |   "$schema": "http://json.schemastore.org/launchsettings.json", | ||||||
|  |   "iisSettings": { | ||||||
|  |     "windowsAuthentication": false, | ||||||
|  |     "anonymousAuthentication": true, | ||||||
|  |     "iisExpress": { | ||||||
|  |       "applicationUrl": "http://localhost:4773", | ||||||
|  |       "sslPort": 44380 | ||||||
|  |     } | ||||||
|  |   }, | ||||||
|   "profiles": { |   "profiles": { | ||||||
|     "http": { |     "http": { | ||||||
|       "commandName": "Project", |       "commandName": "Project", | ||||||
| @ -10,6 +18,24 @@ | |||||||
|       "environmentVariables": { |       "environmentVariables": { | ||||||
|         "ASPNETCORE_ENVIRONMENT": "Development" |         "ASPNETCORE_ENVIRONMENT": "Development" | ||||||
|       } |       } | ||||||
|  |     }, | ||||||
|  |     "https": { | ||||||
|  |       "commandName": "Project", | ||||||
|  |       "dotnetRunMessages": true, | ||||||
|  |       "launchBrowser": true, | ||||||
|  |       "launchUrl": "swagger", | ||||||
|  |       "applicationUrl": "https://localhost:7094;http://localhost:5243", | ||||||
|  |       "environmentVariables": { | ||||||
|  |         "ASPNETCORE_ENVIRONMENT": "Development" | ||||||
|  |       } | ||||||
|  |     }, | ||||||
|  |     "IIS Express": { | ||||||
|  |       "commandName": "IISExpress", | ||||||
|  |       "launchBrowser": true, | ||||||
|  |       "launchUrl": "swagger", | ||||||
|  |       "environmentVariables": { | ||||||
|  |         "ASPNETCORE_ENVIRONMENT": "Development" | ||||||
|  |       } | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
| } | } | ||||||
|  | |||||||
| @ -1,5 +1,13 @@ | |||||||
| { | { | ||||||
|   "$schema": "http://json.schemastore.org/launchsettings.json", |   "$schema": "http://json.schemastore.org/launchsettings.json", | ||||||
|  |   "iisSettings": { | ||||||
|  |     "windowsAuthentication": false, | ||||||
|  |     "anonymousAuthentication": true, | ||||||
|  |     "iisExpress": { | ||||||
|  |       "applicationUrl": "http://localhost:22937", | ||||||
|  |       "sslPort": 44300 | ||||||
|  |     } | ||||||
|  |   }, | ||||||
|   "profiles": { |   "profiles": { | ||||||
|     "http": { |     "http": { | ||||||
|       "commandName": "Project", |       "commandName": "Project", | ||||||
| @ -10,6 +18,24 @@ | |||||||
|       "environmentVariables": { |       "environmentVariables": { | ||||||
|         "ASPNETCORE_ENVIRONMENT": "Development" |         "ASPNETCORE_ENVIRONMENT": "Development" | ||||||
|       } |       } | ||||||
|  |     }, | ||||||
|  |     "https": { | ||||||
|  |       "commandName": "Project", | ||||||
|  |       "dotnetRunMessages": true, | ||||||
|  |       "launchBrowser": true, | ||||||
|  |       "launchUrl": "swagger", | ||||||
|  |       "applicationUrl": "https://localhost:7183;http://localhost:5074", | ||||||
|  |       "environmentVariables": { | ||||||
|  |         "ASPNETCORE_ENVIRONMENT": "Development" | ||||||
|  |       } | ||||||
|  |     }, | ||||||
|  |     "IIS Express": { | ||||||
|  |       "commandName": "IISExpress", | ||||||
|  |       "launchBrowser": true, | ||||||
|  |       "launchUrl": "swagger", | ||||||
|  |       "environmentVariables": { | ||||||
|  |         "ASPNETCORE_ENVIRONMENT": "Development" | ||||||
|  |       } | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
| } | } | ||||||
|  | |||||||
| @ -1,37 +1,179 @@ | |||||||
| using KonSoft.Admin.EntityFrameworkCore; | using System; | ||||||
| using KonSoft.Shared.Hosting.AspNetCore; | using System.Collections.Generic; | ||||||
| using KonSoft.Shared.Hosting.Microservices; | using System.IO; | ||||||
|  | using System.Linq; | ||||||
|  | using Medallion.Threading; | ||||||
|  | using Medallion.Threading.Redis; | ||||||
|  | using Microsoft.AspNetCore.Authentication.JwtBearer; | ||||||
| using Microsoft.AspNetCore.Builder; | using Microsoft.AspNetCore.Builder; | ||||||
|  | using Microsoft.AspNetCore.Cors; | ||||||
|  | using Microsoft.AspNetCore.DataProtection; | ||||||
|  | using Microsoft.AspNetCore.Hosting; | ||||||
|  | using Microsoft.Extensions.Configuration; | ||||||
| using Microsoft.Extensions.DependencyInjection; | using Microsoft.Extensions.DependencyInjection; | ||||||
| using Microsoft.Extensions.Hosting; | using Microsoft.Extensions.Hosting; | ||||||
|  | using KonSoft.Admin.EntityFrameworkCore; | ||||||
|  | using KonSoft.Admin.MultiTenancy; | ||||||
|  | using StackExchange.Redis; | ||||||
|  | using Microsoft.OpenApi.Models; | ||||||
| using Volo.Abp; | using Volo.Abp; | ||||||
| using Volo.Abp.BackgroundJobs; | using Volo.Abp.AspNetCore.Authentication.JwtBearer; | ||||||
|  | using Volo.Abp.AspNetCore.Mvc; | ||||||
|  | using Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy; | ||||||
|  | using Volo.Abp.AspNetCore.Serilog; | ||||||
|  | using Volo.Abp.Autofac; | ||||||
|  | using Volo.Abp.Caching; | ||||||
|  | using Volo.Abp.Caching.StackExchangeRedis; | ||||||
|  | using Volo.Abp.DistributedLocking; | ||||||
|  | using Volo.Abp.Identity; | ||||||
|  | using Volo.Abp.Localization; | ||||||
| using Volo.Abp.Modularity; | using Volo.Abp.Modularity; | ||||||
|  | using Volo.Abp.Security.Claims; | ||||||
|  | using Volo.Abp.Swashbuckle; | ||||||
|  | using Volo.Abp.VirtualFileSystem; | ||||||
|  |  | ||||||
| namespace KonSoft.Admin; | namespace KonSoft.Admin; | ||||||
|  |  | ||||||
| [DependsOn( | [DependsOn( | ||||||
|     typeof(AdminHttpApiModule), |     typeof(AdminHttpApiModule), | ||||||
|  |     typeof(AbpAutofacModule), | ||||||
|  |     typeof(AbpCachingStackExchangeRedisModule), | ||||||
|  |     typeof(AbpDistributedLockingModule), | ||||||
|  |     typeof(AbpAspNetCoreMvcUiMultiTenancyModule), | ||||||
|  |     typeof(AbpAspNetCoreAuthenticationJwtBearerModule), | ||||||
|     typeof(AdminApplicationModule), |     typeof(AdminApplicationModule), | ||||||
|     typeof(AdminEntityFrameworkCoreModule), |     typeof(AdminEntityFrameworkCoreModule), | ||||||
|     typeof(KonSoftSharedHostingMicroservicesModule) |     typeof(AbpAspNetCoreSerilogModule), | ||||||
|  |     typeof(AbpSwashbuckleModule) | ||||||
| )] | )] | ||||||
| public class AdminHttpApiHostModule : AbpModule | public class AdminHttpApiHostModule : AbpModule | ||||||
| { | { | ||||||
|     public override void ConfigureServices(ServiceConfigurationContext context) |     public override void ConfigureServices(ServiceConfigurationContext context) | ||||||
|     { |     { | ||||||
|         var configuration = context.Services.GetConfiguration(); |         var configuration = context.Services.GetConfiguration(); | ||||||
|  |         var hostingEnvironment = context.Services.GetHostingEnvironment(); | ||||||
|  |  | ||||||
|         SwaggerConfigurationHelper.ConfigureWithOidc( |         ConfigureConventionalControllers(); | ||||||
|             context: context, |         ConfigureAuthentication(context, configuration); | ||||||
|             authority: configuration["AuthServer:Authority"]!, |         ConfigureCache(configuration); | ||||||
|             scopes: ["AdministrationService"], |         ConfigureVirtualFileSystem(context); | ||||||
|             discoveryEndpoint: configuration["AuthServer:MetadataAddress"], |         ConfigureDataProtection(context, configuration, hostingEnvironment); | ||||||
|             apiTitle: "Administration Service API" |         ConfigureDistributedLocking(context, configuration); | ||||||
|         ); |         ConfigureCors(context, configuration); | ||||||
|  |         ConfigureSwaggerServices(context, configuration); | ||||||
|  |     } | ||||||
|  |  | ||||||
|         // ֻ<><D6BB><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD> |     private void ConfigureCache(IConfiguration configuration) | ||||||
|         Configure<AbpBackgroundJobOptions>(options => options.IsJobExecutionEnabled = false); |     { | ||||||
|  |         Configure<AbpDistributedCacheOptions>(options => { options.KeyPrefix = "Admin:"; }); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     private void ConfigureVirtualFileSystem(ServiceConfigurationContext context) | ||||||
|  |     { | ||||||
|  |         var hostingEnvironment = context.Services.GetHostingEnvironment(); | ||||||
|  |  | ||||||
|  |         if (hostingEnvironment.IsDevelopment()) | ||||||
|  |         { | ||||||
|  |             Configure<AbpVirtualFileSystemOptions>(options => | ||||||
|  |             { | ||||||
|  |                 options.FileSets.ReplaceEmbeddedByPhysical<AdminDomainSharedModule>( | ||||||
|  |                     Path.Combine(hostingEnvironment.ContentRootPath, | ||||||
|  |                         $"..{Path.DirectorySeparatorChar}KonSoft.Admin.Domain.Shared")); | ||||||
|  |                 options.FileSets.ReplaceEmbeddedByPhysical<AdminDomainModule>( | ||||||
|  |                     Path.Combine(hostingEnvironment.ContentRootPath, | ||||||
|  |                         $"..{Path.DirectorySeparatorChar}KonSoft.Admin.Domain")); | ||||||
|  |                 options.FileSets.ReplaceEmbeddedByPhysical<AdminApplicationContractsModule>( | ||||||
|  |                     Path.Combine(hostingEnvironment.ContentRootPath, | ||||||
|  |                         $"..{Path.DirectorySeparatorChar}KonSoft.Admin.Application.Contracts")); | ||||||
|  |                 options.FileSets.ReplaceEmbeddedByPhysical<AdminApplicationModule>( | ||||||
|  |                     Path.Combine(hostingEnvironment.ContentRootPath, | ||||||
|  |                         $"..{Path.DirectorySeparatorChar}KonSoft.Admin.Application")); | ||||||
|  |             }); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     private void ConfigureConventionalControllers() | ||||||
|  |     { | ||||||
|  |         Configure<AbpAspNetCoreMvcOptions>(options => | ||||||
|  |         { | ||||||
|  |             options.ConventionalControllers.Create(typeof(AdminApplicationModule).Assembly); | ||||||
|  |         }); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     private void ConfigureAuthentication(ServiceConfigurationContext context, IConfiguration configuration) | ||||||
|  |     { | ||||||
|  |         context.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) | ||||||
|  |             .AddAbpJwtBearer(options => | ||||||
|  |             { | ||||||
|  |                 options.Authority = configuration["AuthServer:Authority"]; | ||||||
|  |                 options.RequireHttpsMetadata = configuration.GetValue<bool>("AuthServer:RequireHttpsMetadata"); | ||||||
|  |                 options.Audience = "Admin"; | ||||||
|  |             }); | ||||||
|  |  | ||||||
|  |         context.Services.Configure<AbpClaimsPrincipalFactoryOptions>(options => | ||||||
|  |         { | ||||||
|  |             options.IsDynamicClaimsEnabled = true; | ||||||
|  |         }); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     private static void ConfigureSwaggerServices(ServiceConfigurationContext context, IConfiguration configuration) | ||||||
|  |     { | ||||||
|  |         context.Services.AddAbpSwaggerGenWithOAuth( | ||||||
|  |             configuration["AuthServer:Authority"]!, | ||||||
|  |             new Dictionary<string, string> | ||||||
|  |             { | ||||||
|  |                     {"Admin", "Admin API"} | ||||||
|  |             }, | ||||||
|  |             options => | ||||||
|  |             { | ||||||
|  |                 options.SwaggerDoc("v1", new OpenApiInfo { Title = "Admin API", Version = "v1" }); | ||||||
|  |                 options.DocInclusionPredicate((docName, description) => true); | ||||||
|  |                 options.CustomSchemaIds(type => type.FullName); | ||||||
|  |             }); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     private void ConfigureDataProtection( | ||||||
|  |         ServiceConfigurationContext context, | ||||||
|  |         IConfiguration configuration, | ||||||
|  |         IWebHostEnvironment hostingEnvironment) | ||||||
|  |     { | ||||||
|  |         var dataProtectionBuilder = context.Services.AddDataProtection().SetApplicationName("Admin"); | ||||||
|  |         if (!hostingEnvironment.IsDevelopment()) | ||||||
|  |         { | ||||||
|  |             var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]!); | ||||||
|  |             dataProtectionBuilder.PersistKeysToStackExchangeRedis(redis, "Admin-Protection-Keys"); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     private void ConfigureDistributedLocking( | ||||||
|  |         ServiceConfigurationContext context, | ||||||
|  |         IConfiguration configuration) | ||||||
|  |     { | ||||||
|  |         context.Services.AddSingleton<IDistributedLockProvider>(sp => | ||||||
|  |         { | ||||||
|  |             var connection = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]!); | ||||||
|  |             return new RedisDistributedSynchronizationProvider(connection.GetDatabase()); | ||||||
|  |         }); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     private void ConfigureCors(ServiceConfigurationContext context, IConfiguration configuration) | ||||||
|  |     { | ||||||
|  |         context.Services.AddCors(options => | ||||||
|  |         { | ||||||
|  |             options.AddDefaultPolicy(builder => | ||||||
|  |             { | ||||||
|  |                 builder | ||||||
|  |                     .WithOrigins(configuration["App:CorsOrigins"]? | ||||||
|  |                         .Split(",", StringSplitOptions.RemoveEmptyEntries) | ||||||
|  |                         .Select(o => o.RemovePostFix("/")) | ||||||
|  |                         .ToArray() ?? []) | ||||||
|  |                     .WithAbpExposedHeaders() | ||||||
|  |                     .SetIsOriginAllowedToAllowWildcardSubdomains() | ||||||
|  |                     .AllowAnyHeader() | ||||||
|  |                     .AllowAnyMethod() | ||||||
|  |                     .AllowCredentials(); | ||||||
|  |             }); | ||||||
|  |         }); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public override void OnApplicationInitialization(ApplicationInitializationContext context) |     public override void OnApplicationInitialization(ApplicationInitializationContext context) | ||||||
| @ -51,7 +193,7 @@ public class AdminHttpApiHostModule : AbpModule | |||||||
|         app.UseCors(); |         app.UseCors(); | ||||||
|         app.UseAuthentication(); |         app.UseAuthentication(); | ||||||
|  |  | ||||||
|         if (KonSoftConsts.MultiTenancyEnabled) |         if (MultiTenancyConsts.IsEnabled) | ||||||
|         { |         { | ||||||
|             app.UseMultiTenancy(); |             app.UseMultiTenancy(); | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -1,14 +0,0 @@ | |||||||
| using System.Threading.Tasks; |  | ||||||
| using Volo.Abp.Data; |  | ||||||
| using Volo.Abp.DependencyInjection; |  | ||||||
|  |  | ||||||
| namespace KonSoft.Admin.DbMigrations |  | ||||||
| { |  | ||||||
|     public class AdminDataSeeder : IDataSeedContributor, ITransientDependency |  | ||||||
|     { |  | ||||||
|         public Task SeedAsync(DataSeedContext context) |  | ||||||
|         { |  | ||||||
|             return Task.CompletedTask; |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @ -1,26 +0,0 @@ | |||||||
| using System; |  | ||||||
| using KonSoft.Admin.EntityFrameworkCore; |  | ||||||
| using KonSoft.Shared.Hosting.Microservices.DbMigrations.EfCore; |  | ||||||
| using Volo.Abp.DistributedLocking; |  | ||||||
| using Volo.Abp.EventBus.Distributed; |  | ||||||
| using Volo.Abp.MultiTenancy; |  | ||||||
| using Volo.Abp.Uow; |  | ||||||
|  |  | ||||||
| namespace KonSoft.Admin.DbMigrations |  | ||||||
| { |  | ||||||
|     public class AdminPendingEfCoreMigrationsChecker : PendingEfCoreMigrationsChecker<AdminDbContext> |  | ||||||
|     { |  | ||||||
|         public AdminPendingEfCoreMigrationsChecker(IUnitOfWorkManager unitOfWorkManager, |  | ||||||
|             IServiceProvider serviceProvider, |  | ||||||
|             ICurrentTenant currentTenant, |  | ||||||
|             IDistributedEventBus distributedEventBus, |  | ||||||
|             IAbpDistributedLock abpDistributedLock) : base(unitOfWorkManager, |  | ||||||
|             serviceProvider, |  | ||||||
|             currentTenant, |  | ||||||
|             distributedEventBus, |  | ||||||
|             abpDistributedLock, |  | ||||||
|             "Clean") |  | ||||||
|         { |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @ -2,9 +2,8 @@ FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base | |||||||
| USER $APP_UID | USER $APP_UID | ||||||
| WORKDIR /app | WORKDIR /app | ||||||
| EXPOSE 8080 | EXPOSE 8080 | ||||||
|  | EXPOSE 8081 | ||||||
|  |  | ||||||
|  |  | ||||||
| # 此阶段用于生成服务项目 |  | ||||||
| FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build | FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build | ||||||
| ARG BUILD_CONFIGURATION=Release | ARG BUILD_CONFIGURATION=Release | ||||||
| WORKDIR /src | WORKDIR /src | ||||||
| @ -16,10 +15,6 @@ COPY ["modules/admin/src/KonSoft.Admin.Domain.Shared/KonSoft.Admin.Domain.Shared | |||||||
| COPY ["modules/admin/src/KonSoft.Admin.Application.Contracts/KonSoft.Admin.Application.Contracts.csproj", "modules/admin/src/KonSoft.Admin.Application.Contracts/"] | COPY ["modules/admin/src/KonSoft.Admin.Application.Contracts/KonSoft.Admin.Application.Contracts.csproj", "modules/admin/src/KonSoft.Admin.Application.Contracts/"] | ||||||
| COPY ["modules/admin/src/KonSoft.Admin.EntityFrameworkCore/KonSoft.Admin.EntityFrameworkCore.csproj", "modules/admin/src/KonSoft.Admin.EntityFrameworkCore/"] | COPY ["modules/admin/src/KonSoft.Admin.EntityFrameworkCore/KonSoft.Admin.EntityFrameworkCore.csproj", "modules/admin/src/KonSoft.Admin.EntityFrameworkCore/"] | ||||||
| COPY ["modules/admin/src/KonSoft.Admin.HttpApi/KonSoft.Admin.HttpApi.csproj", "modules/admin/src/KonSoft.Admin.HttpApi/"] | COPY ["modules/admin/src/KonSoft.Admin.HttpApi/KonSoft.Admin.HttpApi.csproj", "modules/admin/src/KonSoft.Admin.HttpApi/"] | ||||||
| COPY ["shared/KonSoft.Shared.Hosting.Microservices/KonSoft.Shared.Hosting.Microservices.csproj", "shared/KonSoft.Shared.Hosting.Microservices/"] |  | ||||||
| COPY ["shared/KonSoft.Shared.Hosting.AspNetCore/KonSoft.Shared.Hosting.AspNetCore.csproj", "shared/KonSoft.Shared.Hosting.AspNetCore/"] |  | ||||||
| COPY ["shared/KonSoft.Shared.Hosting/KonSoft.Shared.Hosting.csproj", "shared/KonSoft.Shared.Hosting/"] |  | ||||||
| COPY ["shared/KonSoft.Shared.Localization/KonSoft.Shared.Localization.csproj", "shared/KonSoft.Shared.Localization/"] |  | ||||||
| RUN dotnet restore "./microservices/KonSoft.Admin.HttpApi.Host/KonSoft.Admin.HttpApi.Host.csproj" | RUN dotnet restore "./microservices/KonSoft.Admin.HttpApi.Host/KonSoft.Admin.HttpApi.Host.csproj" | ||||||
| COPY . . | COPY . . | ||||||
| WORKDIR "/src/microservices/KonSoft.Admin.HttpApi.Host" | WORKDIR "/src/microservices/KonSoft.Admin.HttpApi.Host" | ||||||
|  | |||||||
| @ -1,4 +1,4 @@ | |||||||
| <Project Sdk="Microsoft.NET.Sdk.Web"> | <Project Sdk="Microsoft.NET.Sdk.Web"> | ||||||
|  |  | ||||||
|   <PropertyGroup> |   <PropertyGroup> | ||||||
|     <TargetFramework>net8.0</TargetFramework> |     <TargetFramework>net8.0</TargetFramework> | ||||||
| @ -10,6 +10,22 @@ | |||||||
|     <DockerfileContext>..\..</DockerfileContext> |     <DockerfileContext>..\..</DockerfileContext> | ||||||
|   </PropertyGroup> |   </PropertyGroup> | ||||||
|  |  | ||||||
|  |   <ItemGroup> | ||||||
|  |     <PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.22.1" /> | ||||||
|  |     <PackageReference Include="Serilog.AspNetCore" Version="8.0.0" /> | ||||||
|  |     <PackageReference Include="Serilog.Sinks.Async" Version="1.5.0" /> | ||||||
|  |     <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.4" /> | ||||||
|  |     <PackageReference Include="Microsoft.AspNetCore.DataProtection.StackExchangeRedis" Version="8.0.4" /> | ||||||
|  |     <PackageReference Include="DistributedLock.Redis" Version="1.0.2" /> | ||||||
|  |     <PackageReference Include="Volo.Abp.AspNetCore.Authentication.JwtBearer" Version="8.3.4" /> | ||||||
|  |     <PackageReference Include="Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy" Version="8.3.4" /> | ||||||
|  |     <PackageReference Include="Volo.Abp.Autofac" Version="8.3.4" /> | ||||||
|  |     <PackageReference Include="Volo.Abp.Caching.StackExchangeRedis" Version="8.3.4" /> | ||||||
|  |     <PackageReference Include="Volo.Abp.DistributedLocking" Version="8.3.4" /> | ||||||
|  |     <PackageReference Include="Volo.Abp.AspNetCore.Serilog" Version="8.3.4" /> | ||||||
|  |     <PackageReference Include="Volo.Abp.Swashbuckle" Version="8.3.4" /> | ||||||
|  |   </ItemGroup> | ||||||
|  |  | ||||||
|   <ItemGroup> |   <ItemGroup> | ||||||
|     <Compile Remove="Logs\**" /> |     <Compile Remove="Logs\**" /> | ||||||
|     <Content Remove="Logs\**" /> |     <Content Remove="Logs\**" /> | ||||||
| @ -21,7 +37,6 @@ | |||||||
|     <ProjectReference Include="..\..\modules\admin\src\KonSoft.Admin.Application\KonSoft.Admin.Application.csproj" /> |     <ProjectReference Include="..\..\modules\admin\src\KonSoft.Admin.Application\KonSoft.Admin.Application.csproj" /> | ||||||
|     <ProjectReference Include="..\..\modules\admin\src\KonSoft.Admin.EntityFrameworkCore\KonSoft.Admin.EntityFrameworkCore.csproj" /> |     <ProjectReference Include="..\..\modules\admin\src\KonSoft.Admin.EntityFrameworkCore\KonSoft.Admin.EntityFrameworkCore.csproj" /> | ||||||
|     <ProjectReference Include="..\..\modules\admin\src\KonSoft.Admin.HttpApi\KonSoft.Admin.HttpApi.csproj" /> |     <ProjectReference Include="..\..\modules\admin\src\KonSoft.Admin.HttpApi\KonSoft.Admin.HttpApi.csproj" /> | ||||||
|     <ProjectReference Include="..\..\shared\KonSoft.Shared.Hosting.Microservices\KonSoft.Shared.Hosting.Microservices.csproj" /> |  | ||||||
|   </ItemGroup> |   </ItemGroup> | ||||||
|  |  | ||||||
| </Project> | </Project> | ||||||
|  | |||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @ -1,28 +1,56 @@ | |||||||
| using KonSoft.Admin; | using System; | ||||||
| using KonSoft.Shared.Hosting.AspNetCore; | using System.Threading.Tasks; | ||||||
| using Microsoft.AspNetCore.Builder; | using Microsoft.AspNetCore.Builder; | ||||||
|  | using Microsoft.Extensions.DependencyInjection; | ||||||
|  | using Microsoft.Extensions.Hosting; | ||||||
| using Serilog; | using Serilog; | ||||||
| using System; | using Serilog.Events; | ||||||
|  |  | ||||||
| var assemblyName = typeof(Program).Assembly.GetName().Name!; | namespace KonSoft.Admin; | ||||||
|  |  | ||||||
| SerilogConfigurationHelper.Configure(assemblyName); | public class Program | ||||||
| try |  | ||||||
| { | { | ||||||
|     Log.Information($"Starting {assemblyName}."); |     public async static Task<int> Main(string[] args) | ||||||
|     var app = await ApplicationBuilderHelper |     { | ||||||
|         .BuildApplicationAsync<AdminHttpApiHostModule>(args); |         Log.Logger = new LoggerConfiguration() | ||||||
|     await app.InitializeApplicationAsync(); | #if DEBUG | ||||||
|     await app.RunAsync(); |             .MinimumLevel.Debug() | ||||||
|  | #else | ||||||
|  |             .MinimumLevel.Information() | ||||||
|  | #endif | ||||||
|  |             .MinimumLevel.Override("Microsoft", LogEventLevel.Information) | ||||||
|  |             .MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning) | ||||||
|  |             .Enrich.FromLogContext() | ||||||
|  |             .WriteTo.Async(c => c.File("Logs/logs.txt")) | ||||||
|  |             .WriteTo.Async(c => c.Console()) | ||||||
|  |             .CreateLogger(); | ||||||
|  |  | ||||||
|     return 0; |         try | ||||||
| } |         { | ||||||
| catch (Exception ex) |             Log.Information("Starting KonSoft.Admin.HttpApi.Host."); | ||||||
| { |             var builder = WebApplication.CreateBuilder(args); | ||||||
|     Log.Fatal(ex, $"{assemblyName} terminated unexpectedly!"); |             builder.Host.AddAppSettingsSecretsJson() | ||||||
|     return 1; |                 .UseAutofac() | ||||||
| } |                 .UseSerilog(); | ||||||
| finally |             await builder.AddApplicationAsync<AdminHttpApiHostModule>(); | ||||||
| { |             var app = builder.Build(); | ||||||
|     await Log.CloseAndFlushAsync(); |             await app.InitializeApplicationAsync(); | ||||||
|  |             await app.RunAsync(); | ||||||
|  |             return 0; | ||||||
|  |         } | ||||||
|  |         catch (Exception ex) | ||||||
|  |         { | ||||||
|  |             if (ex is HostAbortedException) | ||||||
|  |             { | ||||||
|  |                 throw; | ||||||
|  |             } | ||||||
|  |  | ||||||
|  |             Log.Fatal(ex, "Host terminated unexpectedly!"); | ||||||
|  |             return 1; | ||||||
|  |         } | ||||||
|  |         finally | ||||||
|  |         { | ||||||
|  |             Log.CloseAndFlush(); | ||||||
|  |         } | ||||||
|  |     } | ||||||
| } | } | ||||||
| @ -1,13 +1,38 @@ | |||||||
| { | { | ||||||
|   "$schema": "http://json.schemastore.org/launchsettings.json", |  | ||||||
|   "profiles": { |   "profiles": { | ||||||
|     "http": { |     "IIS Express": { | ||||||
|  |       "commandName": "IISExpress", | ||||||
|  |       "launchBrowser": true, | ||||||
|  |       "environmentVariables": { | ||||||
|  |         "ASPNETCORE_ENVIRONMENT": "Development" | ||||||
|  |       } | ||||||
|  |     }, | ||||||
|  |     "KonSoft.Admin.HttpApi.Host": { | ||||||
|       "commandName": "Project", |       "commandName": "Project", | ||||||
|       "launchBrowser": true, |       "launchBrowser": true, | ||||||
|       "environmentVariables": { |       "environmentVariables": { | ||||||
|         "ASPNETCORE_ENVIRONMENT": "Development" |         "ASPNETCORE_ENVIRONMENT": "Development" | ||||||
|       }, |       }, | ||||||
|       "applicationUrl": "https://localhost:44354" |       "applicationUrl": "https://localhost:44354" | ||||||
|  |     }, | ||||||
|  |     "Container (Dockerfile)": { | ||||||
|  |       "commandName": "Docker", | ||||||
|  |       "launchBrowser": true, | ||||||
|  |       "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}", | ||||||
|  |       "environmentVariables": { | ||||||
|  |         "ASPNETCORE_HTTPS_PORTS": "8081", | ||||||
|  |         "ASPNETCORE_HTTP_PORTS": "8080" | ||||||
|  |       }, | ||||||
|  |       "publishAllPorts": true, | ||||||
|  |       "useSSL": true | ||||||
|  |     } | ||||||
|  |   }, | ||||||
|  |   "iisSettings": { | ||||||
|  |     "windowsAuthentication": false, | ||||||
|  |     "anonymousAuthentication": true, | ||||||
|  |     "iisExpress": { | ||||||
|  |       "applicationUrl": "https://localhost:44354", | ||||||
|  |       "sslPort": 44354 | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
| } | } | ||||||
| @ -1,12 +1,12 @@ | |||||||
| { | { | ||||||
|   "App": { |   "App": { | ||||||
|     "CorsOrigins": "https://*.KonSoft.top" |     "CorsOrigins": "https://*.Admin.com,https://localhost:44357" | ||||||
|   }, |   }, | ||||||
|   "ConnectionStrings": { |   "ConnectionStrings": { | ||||||
|     "Default": "Host=1.94.99.47;Port=26666;Database=Clean;User ID=postgres;Password=zzx7845zzx;" |     "Default": "Host=localhost;Port=5432;Database=Admin;User ID=root;Password=myPassword;" | ||||||
|   }, |   }, | ||||||
|   "Redis": { |   "Redis": { | ||||||
|     "Configuration": "1.94.99.47:26668" |     "Configuration": "127.0.0.1" | ||||||
|   }, |   }, | ||||||
|   "AuthServer": { |   "AuthServer": { | ||||||
|     "Authority": "https://localhost:44397", |     "Authority": "https://localhost:44397", | ||||||
| @ -15,15 +15,5 @@ | |||||||
|   }, |   }, | ||||||
|   "StringEncryption": { |   "StringEncryption": { | ||||||
|     "DefaultPassPhrase": "g3NdNOyDR9oYj0gK" |     "DefaultPassPhrase": "g3NdNOyDR9oYj0gK" | ||||||
|   }, |  | ||||||
|   "RabbitMQ": { |  | ||||||
|     "Connections": { |  | ||||||
|       "Default": { |  | ||||||
|         "HostName": "1.94.99.47", |  | ||||||
|         "Port": 26667, |  | ||||||
|         "UserName": "admin", |  | ||||||
|         "Password": "zzx7845zzx" |  | ||||||
|       } |  | ||||||
|     } |  | ||||||
|   } |   } | ||||||
| } | } | ||||||
|  | |||||||
| @ -1,38 +1,179 @@ | |||||||
| using KonSoft.Dispatch.EntityFrameworkCore; | using System; | ||||||
| using KonSoft.Shared.Hosting.AspNetCore; | using System.Collections.Generic; | ||||||
| using KonSoft.Shared.Hosting.Microservices; | using System.IO; | ||||||
|  | using System.Linq; | ||||||
|  | using Medallion.Threading; | ||||||
|  | using Medallion.Threading.Redis; | ||||||
|  | using Microsoft.AspNetCore.Authentication.JwtBearer; | ||||||
| using Microsoft.AspNetCore.Builder; | using Microsoft.AspNetCore.Builder; | ||||||
|  | using Microsoft.AspNetCore.Cors; | ||||||
|  | using Microsoft.AspNetCore.DataProtection; | ||||||
| using Microsoft.AspNetCore.Hosting; | using Microsoft.AspNetCore.Hosting; | ||||||
|  | using Microsoft.Extensions.Configuration; | ||||||
| using Microsoft.Extensions.DependencyInjection; | using Microsoft.Extensions.DependencyInjection; | ||||||
| using Microsoft.Extensions.Hosting; | using Microsoft.Extensions.Hosting; | ||||||
|  | using KonSoft.Dispatch.EntityFrameworkCore; | ||||||
|  | using KonSoft.Dispatch.MultiTenancy; | ||||||
|  | using StackExchange.Redis; | ||||||
|  | using Microsoft.OpenApi.Models; | ||||||
| using Volo.Abp; | using Volo.Abp; | ||||||
| using Volo.Abp.BackgroundJobs; | using Volo.Abp.AspNetCore.Authentication.JwtBearer; | ||||||
|  | using Volo.Abp.AspNetCore.Mvc; | ||||||
|  | using Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy; | ||||||
|  | using Volo.Abp.AspNetCore.Serilog; | ||||||
|  | using Volo.Abp.Autofac; | ||||||
|  | using Volo.Abp.Caching; | ||||||
|  | using Volo.Abp.Caching.StackExchangeRedis; | ||||||
|  | using Volo.Abp.DistributedLocking; | ||||||
|  | using Volo.Abp.Identity; | ||||||
|  | using Volo.Abp.Localization; | ||||||
| using Volo.Abp.Modularity; | using Volo.Abp.Modularity; | ||||||
|  | using Volo.Abp.Security.Claims; | ||||||
|  | using Volo.Abp.Swashbuckle; | ||||||
|  | using Volo.Abp.VirtualFileSystem; | ||||||
|  |  | ||||||
| namespace KonSoft.Dispatch; | namespace KonSoft.Dispatch; | ||||||
|  |  | ||||||
| [DependsOn( | [DependsOn( | ||||||
|     typeof(DispatchHttpApiModule), |     typeof(DispatchHttpApiModule), | ||||||
|  |     typeof(AbpAutofacModule), | ||||||
|  |     typeof(AbpCachingStackExchangeRedisModule), | ||||||
|  |     typeof(AbpDistributedLockingModule), | ||||||
|  |     typeof(AbpAspNetCoreMvcUiMultiTenancyModule), | ||||||
|  |     typeof(AbpAspNetCoreAuthenticationJwtBearerModule), | ||||||
|     typeof(DispatchApplicationModule), |     typeof(DispatchApplicationModule), | ||||||
|     typeof(DispatchEntityFrameworkCoreModule), |     typeof(DispatchEntityFrameworkCoreModule), | ||||||
|     typeof(KonSoftSharedHostingMicroservicesModule) |     typeof(AbpAspNetCoreSerilogModule), | ||||||
|  |     typeof(AbpSwashbuckleModule) | ||||||
| )] | )] | ||||||
| public class DispatchHttpApiHostModule : AbpModule | public class DispatchHttpApiHostModule : AbpModule | ||||||
| { | { | ||||||
|     public override void ConfigureServices(ServiceConfigurationContext context) |     public override void ConfigureServices(ServiceConfigurationContext context) | ||||||
|     { |     { | ||||||
|         var configuration = context.Services.GetConfiguration(); |         var configuration = context.Services.GetConfiguration(); | ||||||
|  |         var hostingEnvironment = context.Services.GetHostingEnvironment(); | ||||||
|  |  | ||||||
|         SwaggerConfigurationHelper.ConfigureWithOidc( |         ConfigureConventionalControllers(); | ||||||
|             context: context, |         ConfigureAuthentication(context, configuration); | ||||||
|             authority: configuration["AuthServer:Authority"]!, |         ConfigureCache(configuration); | ||||||
|             scopes: ["DispatchService"], |         ConfigureVirtualFileSystem(context); | ||||||
|             discoveryEndpoint: configuration["AuthServer:MetadataAddress"], |         ConfigureDataProtection(context, configuration, hostingEnvironment); | ||||||
|             apiTitle: "Dispatch Service API" |         ConfigureDistributedLocking(context, configuration); | ||||||
|         ); |         ConfigureCors(context, configuration); | ||||||
|  |         ConfigureSwaggerServices(context, configuration); | ||||||
|  |     } | ||||||
|  |  | ||||||
|         // ֻ<><D6BB><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD> |     private void ConfigureCache(IConfiguration configuration) | ||||||
|         Configure<AbpBackgroundJobOptions>(options => options.IsJobExecutionEnabled = false); |     { | ||||||
|  |         Configure<AbpDistributedCacheOptions>(options => { options.KeyPrefix = "Dispatch:"; }); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     private void ConfigureVirtualFileSystem(ServiceConfigurationContext context) | ||||||
|  |     { | ||||||
|  |         var hostingEnvironment = context.Services.GetHostingEnvironment(); | ||||||
|  |  | ||||||
|  |         if (hostingEnvironment.IsDevelopment()) | ||||||
|  |         { | ||||||
|  |             Configure<AbpVirtualFileSystemOptions>(options => | ||||||
|  |             { | ||||||
|  |                 options.FileSets.ReplaceEmbeddedByPhysical<DispatchDomainSharedModule>( | ||||||
|  |                     Path.Combine(hostingEnvironment.ContentRootPath, | ||||||
|  |                         $"..{Path.DirectorySeparatorChar}KonSoft.Dispatch.Domain.Shared")); | ||||||
|  |                 options.FileSets.ReplaceEmbeddedByPhysical<DispatchDomainModule>( | ||||||
|  |                     Path.Combine(hostingEnvironment.ContentRootPath, | ||||||
|  |                         $"..{Path.DirectorySeparatorChar}KonSoft.Dispatch.Domain")); | ||||||
|  |                 options.FileSets.ReplaceEmbeddedByPhysical<DispatchApplicationContractsModule>( | ||||||
|  |                     Path.Combine(hostingEnvironment.ContentRootPath, | ||||||
|  |                         $"..{Path.DirectorySeparatorChar}KonSoft.Dispatch.Application.Contracts")); | ||||||
|  |                 options.FileSets.ReplaceEmbeddedByPhysical<DispatchApplicationModule>( | ||||||
|  |                     Path.Combine(hostingEnvironment.ContentRootPath, | ||||||
|  |                         $"..{Path.DirectorySeparatorChar}KonSoft.Dispatch.Application")); | ||||||
|  |             }); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     private void ConfigureConventionalControllers() | ||||||
|  |     { | ||||||
|  |         Configure<AbpAspNetCoreMvcOptions>(options => | ||||||
|  |         { | ||||||
|  |             options.ConventionalControllers.Create(typeof(DispatchApplicationModule).Assembly); | ||||||
|  |         }); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     private void ConfigureAuthentication(ServiceConfigurationContext context, IConfiguration configuration) | ||||||
|  |     { | ||||||
|  |         context.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) | ||||||
|  |             .AddAbpJwtBearer(options => | ||||||
|  |             { | ||||||
|  |                 options.Authority = configuration["AuthServer:Authority"]; | ||||||
|  |                 options.RequireHttpsMetadata = configuration.GetValue<bool>("AuthServer:RequireHttpsMetadata"); | ||||||
|  |                 options.Audience = "Dispatch"; | ||||||
|  |             }); | ||||||
|  |  | ||||||
|  |         context.Services.Configure<AbpClaimsPrincipalFactoryOptions>(options => | ||||||
|  |         { | ||||||
|  |             options.IsDynamicClaimsEnabled = true; | ||||||
|  |         }); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     private static void ConfigureSwaggerServices(ServiceConfigurationContext context, IConfiguration configuration) | ||||||
|  |     { | ||||||
|  |         context.Services.AddAbpSwaggerGenWithOAuth( | ||||||
|  |             configuration["AuthServer:Authority"]!, | ||||||
|  |             new Dictionary<string, string> | ||||||
|  |             { | ||||||
|  |                     {"Dispatch", "Dispatch API"} | ||||||
|  |             }, | ||||||
|  |             options => | ||||||
|  |             { | ||||||
|  |                 options.SwaggerDoc("v1", new OpenApiInfo { Title = "Dispatch API", Version = "v1" }); | ||||||
|  |                 options.DocInclusionPredicate((docName, description) => true); | ||||||
|  |                 options.CustomSchemaIds(type => type.FullName); | ||||||
|  |             }); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     private void ConfigureDataProtection( | ||||||
|  |         ServiceConfigurationContext context, | ||||||
|  |         IConfiguration configuration, | ||||||
|  |         IWebHostEnvironment hostingEnvironment) | ||||||
|  |     { | ||||||
|  |         var dataProtectionBuilder = context.Services.AddDataProtection().SetApplicationName("Dispatch"); | ||||||
|  |         if (!hostingEnvironment.IsDevelopment()) | ||||||
|  |         { | ||||||
|  |             var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]!); | ||||||
|  |             dataProtectionBuilder.PersistKeysToStackExchangeRedis(redis, "Dispatch-Protection-Keys"); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     private void ConfigureDistributedLocking( | ||||||
|  |         ServiceConfigurationContext context, | ||||||
|  |         IConfiguration configuration) | ||||||
|  |     { | ||||||
|  |         context.Services.AddSingleton<IDistributedLockProvider>(sp => | ||||||
|  |         { | ||||||
|  |             var connection = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]!); | ||||||
|  |             return new RedisDistributedSynchronizationProvider(connection.GetDatabase()); | ||||||
|  |         }); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     private void ConfigureCors(ServiceConfigurationContext context, IConfiguration configuration) | ||||||
|  |     { | ||||||
|  |         context.Services.AddCors(options => | ||||||
|  |         { | ||||||
|  |             options.AddDefaultPolicy(builder => | ||||||
|  |             { | ||||||
|  |                 builder | ||||||
|  |                     .WithOrigins(configuration["App:CorsOrigins"]? | ||||||
|  |                         .Split(",", StringSplitOptions.RemoveEmptyEntries) | ||||||
|  |                         .Select(o => o.RemovePostFix("/")) | ||||||
|  |                         .ToArray() ?? []) | ||||||
|  |                     .WithAbpExposedHeaders() | ||||||
|  |                     .SetIsOriginAllowedToAllowWildcardSubdomains() | ||||||
|  |                     .AllowAnyHeader() | ||||||
|  |                     .AllowAnyMethod() | ||||||
|  |                     .AllowCredentials(); | ||||||
|  |             }); | ||||||
|  |         }); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public override void OnApplicationInitialization(ApplicationInitializationContext context) |     public override void OnApplicationInitialization(ApplicationInitializationContext context) | ||||||
| @ -52,7 +193,7 @@ public class DispatchHttpApiHostModule : AbpModule | |||||||
|         app.UseCors(); |         app.UseCors(); | ||||||
|         app.UseAuthentication(); |         app.UseAuthentication(); | ||||||
|  |  | ||||||
|         if (KonSoftConsts.MultiTenancyEnabled) |         if (MultiTenancyConsts.IsEnabled) | ||||||
|         { |         { | ||||||
|             app.UseMultiTenancy(); |             app.UseMultiTenancy(); | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -1,4 +1,4 @@ | |||||||
| <Project Sdk="Microsoft.NET.Sdk.Web"> | <Project Sdk="Microsoft.NET.Sdk.Web"> | ||||||
|  |  | ||||||
|   <PropertyGroup> |   <PropertyGroup> | ||||||
|     <TargetFramework>net8.0</TargetFramework> |     <TargetFramework>net8.0</TargetFramework> | ||||||
| @ -8,6 +8,21 @@ | |||||||
|     <UserSecretsId>KonSoft.Dispatch-4681b4fd-151f-4221-84a4-929d86723e4c</UserSecretsId> |     <UserSecretsId>KonSoft.Dispatch-4681b4fd-151f-4221-84a4-929d86723e4c</UserSecretsId> | ||||||
|   </PropertyGroup> |   </PropertyGroup> | ||||||
|  |  | ||||||
|  |   <ItemGroup> | ||||||
|  |     <PackageReference Include="Serilog.AspNetCore" Version="8.0.0" /> | ||||||
|  |     <PackageReference Include="Serilog.Sinks.Async" Version="1.5.0" /> | ||||||
|  |     <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.4" /> | ||||||
|  |     <PackageReference Include="Microsoft.AspNetCore.DataProtection.StackExchangeRedis" Version="8.0.4" /> | ||||||
|  |     <PackageReference Include="DistributedLock.Redis" Version="1.0.2" /> | ||||||
|  |     <PackageReference Include="Volo.Abp.AspNetCore.Authentication.JwtBearer" Version="8.3.4" /> | ||||||
|  |     <PackageReference Include="Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy" Version="8.3.4" /> | ||||||
|  |     <PackageReference Include="Volo.Abp.Autofac" Version="8.3.4" /> | ||||||
|  |     <PackageReference Include="Volo.Abp.Caching.StackExchangeRedis" Version="8.3.4" /> | ||||||
|  |     <PackageReference Include="Volo.Abp.DistributedLocking" Version="8.3.4" /> | ||||||
|  |     <PackageReference Include="Volo.Abp.AspNetCore.Serilog" Version="8.3.4" /> | ||||||
|  |     <PackageReference Include="Volo.Abp.Swashbuckle" Version="8.3.4" /> | ||||||
|  |   </ItemGroup> | ||||||
|  |  | ||||||
|   <ItemGroup> |   <ItemGroup> | ||||||
|     <Compile Remove="Logs\**" /> |     <Compile Remove="Logs\**" /> | ||||||
|     <Content Remove="Logs\**" /> |     <Content Remove="Logs\**" /> | ||||||
| @ -19,7 +34,6 @@ | |||||||
|     <ProjectReference Include="..\..\modules\dispatch\src\KonSoft.Dispatch.Application\KonSoft.Dispatch.Application.csproj" /> |     <ProjectReference Include="..\..\modules\dispatch\src\KonSoft.Dispatch.Application\KonSoft.Dispatch.Application.csproj" /> | ||||||
|     <ProjectReference Include="..\..\modules\dispatch\src\KonSoft.Dispatch.EntityFrameworkCore\KonSoft.Dispatch.EntityFrameworkCore.csproj" /> |     <ProjectReference Include="..\..\modules\dispatch\src\KonSoft.Dispatch.EntityFrameworkCore\KonSoft.Dispatch.EntityFrameworkCore.csproj" /> | ||||||
|     <ProjectReference Include="..\..\modules\dispatch\src\KonSoft.Dispatch.HttpApi\KonSoft.Dispatch.HttpApi.csproj" /> |     <ProjectReference Include="..\..\modules\dispatch\src\KonSoft.Dispatch.HttpApi\KonSoft.Dispatch.HttpApi.csproj" /> | ||||||
|     <ProjectReference Include="..\..\shared\KonSoft.Shared.Hosting.Microservices\KonSoft.Shared.Hosting.Microservices.csproj" /> |  | ||||||
|   </ItemGroup> |   </ItemGroup> | ||||||
|  |  | ||||||
| </Project> | </Project> | ||||||
|  | |||||||
| @ -1,13 +1,27 @@ | |||||||
| { | { | ||||||
|   "$schema": "http://json.schemastore.org/launchsettings.json", |   "iisSettings": { | ||||||
|  |     "windowsAuthentication": false,  | ||||||
|  |     "anonymousAuthentication": true, | ||||||
|  |     "iisExpress": { | ||||||
|  |       "applicationUrl": "https://localhost:44331", | ||||||
|  |       "sslPort": 44331 | ||||||
|  |     } | ||||||
|  |   }, | ||||||
|   "profiles": { |   "profiles": { | ||||||
|     "http": { |     "IIS Express": { | ||||||
|       "commandName": "Project", |       "commandName": "IISExpress", | ||||||
|       "launchBrowser": true, |       "launchBrowser": true, | ||||||
|       "environmentVariables": { |       "environmentVariables": { | ||||||
|         "ASPNETCORE_ENVIRONMENT": "Development" |         "ASPNETCORE_ENVIRONMENT": "Development" | ||||||
|       }, |       } | ||||||
|       "applicationUrl": "https://localhost:44331" |     }, | ||||||
|  |     "KonSoft.Dispatch.HttpApi.Host": { | ||||||
|  |       "commandName": "Project", | ||||||
|  |       "launchBrowser": true, | ||||||
|  |       "applicationUrl": "https://localhost:44331", | ||||||
|  |       "environmentVariables": { | ||||||
|  |         "ASPNETCORE_ENVIRONMENT": "Development" | ||||||
|  |       } | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
| } | } | ||||||
| @ -8,6 +8,21 @@ | |||||||
|     <UserSecretsId>KonSoft.Payment-4681b4fd-151f-4221-84a4-929d86723e4c</UserSecretsId> |     <UserSecretsId>KonSoft.Payment-4681b4fd-151f-4221-84a4-929d86723e4c</UserSecretsId> | ||||||
|   </PropertyGroup> |   </PropertyGroup> | ||||||
|  |  | ||||||
|  |   <ItemGroup> | ||||||
|  |     <PackageReference Include="Serilog.AspNetCore" Version="8.0.0" /> | ||||||
|  |     <PackageReference Include="Serilog.Sinks.Async" Version="1.5.0" /> | ||||||
|  |     <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.4" /> | ||||||
|  |     <PackageReference Include="Microsoft.AspNetCore.DataProtection.StackExchangeRedis" Version="8.0.4" /> | ||||||
|  |     <PackageReference Include="DistributedLock.Redis" Version="1.0.2" /> | ||||||
|  |     <PackageReference Include="Volo.Abp.AspNetCore.Authentication.JwtBearer" Version="8.3.4" /> | ||||||
|  |     <PackageReference Include="Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy" Version="8.3.4" /> | ||||||
|  |     <PackageReference Include="Volo.Abp.Autofac" Version="8.3.4" /> | ||||||
|  |     <PackageReference Include="Volo.Abp.Caching.StackExchangeRedis" Version="8.3.4" /> | ||||||
|  |     <PackageReference Include="Volo.Abp.DistributedLocking" Version="8.3.4" /> | ||||||
|  |     <PackageReference Include="Volo.Abp.AspNetCore.Serilog" Version="8.3.4" /> | ||||||
|  |     <PackageReference Include="Volo.Abp.Swashbuckle" Version="8.3.4" /> | ||||||
|  |   </ItemGroup> | ||||||
|  |  | ||||||
|   <ItemGroup> |   <ItemGroup> | ||||||
|     <Compile Remove="Logs\**" /> |     <Compile Remove="Logs\**" /> | ||||||
|     <Content Remove="Logs\**" /> |     <Content Remove="Logs\**" /> | ||||||
| @ -19,7 +34,6 @@ | |||||||
|     <ProjectReference Include="..\..\modules\payment\src\KonSoft.Payment.Application\KonSoft.Payment.Application.csproj" /> |     <ProjectReference Include="..\..\modules\payment\src\KonSoft.Payment.Application\KonSoft.Payment.Application.csproj" /> | ||||||
|     <ProjectReference Include="..\..\modules\payment\src\KonSoft.Payment.EntityFrameworkCore\KonSoft.Payment.EntityFrameworkCore.csproj" /> |     <ProjectReference Include="..\..\modules\payment\src\KonSoft.Payment.EntityFrameworkCore\KonSoft.Payment.EntityFrameworkCore.csproj" /> | ||||||
|     <ProjectReference Include="..\..\modules\payment\src\KonSoft.Payment.HttpApi\KonSoft.Payment.HttpApi.csproj" /> |     <ProjectReference Include="..\..\modules\payment\src\KonSoft.Payment.HttpApi\KonSoft.Payment.HttpApi.csproj" /> | ||||||
|     <ProjectReference Include="..\..\shared\KonSoft.Shared.Hosting.Microservices\KonSoft.Shared.Hosting.Microservices.csproj" /> |  | ||||||
|   </ItemGroup> |   </ItemGroup> | ||||||
|  |  | ||||||
| </Project> | </Project> | ||||||
|  | |||||||
| @ -1,38 +1,179 @@ | |||||||
| using KonSoft.Payment.EntityFrameworkCore; | using System; | ||||||
| using KonSoft.Shared.Hosting.AspNetCore; | using System.Collections.Generic; | ||||||
| using KonSoft.Shared.Hosting.Microservices; | using System.IO; | ||||||
|  | using System.Linq; | ||||||
|  | using Medallion.Threading; | ||||||
|  | using Medallion.Threading.Redis; | ||||||
|  | using Microsoft.AspNetCore.Authentication.JwtBearer; | ||||||
| using Microsoft.AspNetCore.Builder; | using Microsoft.AspNetCore.Builder; | ||||||
|  | using Microsoft.AspNetCore.Cors; | ||||||
|  | using Microsoft.AspNetCore.DataProtection; | ||||||
| using Microsoft.AspNetCore.Hosting; | using Microsoft.AspNetCore.Hosting; | ||||||
|  | using Microsoft.Extensions.Configuration; | ||||||
| using Microsoft.Extensions.DependencyInjection; | using Microsoft.Extensions.DependencyInjection; | ||||||
| using Microsoft.Extensions.Hosting; | using Microsoft.Extensions.Hosting; | ||||||
|  | using KonSoft.Payment.EntityFrameworkCore; | ||||||
|  | using KonSoft.Payment.MultiTenancy; | ||||||
|  | using StackExchange.Redis; | ||||||
|  | using Microsoft.OpenApi.Models; | ||||||
| using Volo.Abp; | using Volo.Abp; | ||||||
| using Volo.Abp.BackgroundJobs; | using Volo.Abp.AspNetCore.Authentication.JwtBearer; | ||||||
|  | using Volo.Abp.AspNetCore.Mvc; | ||||||
|  | using Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy; | ||||||
|  | using Volo.Abp.AspNetCore.Serilog; | ||||||
|  | using Volo.Abp.Autofac; | ||||||
|  | using Volo.Abp.Caching; | ||||||
|  | using Volo.Abp.Caching.StackExchangeRedis; | ||||||
|  | using Volo.Abp.DistributedLocking; | ||||||
|  | using Volo.Abp.Identity; | ||||||
|  | using Volo.Abp.Localization; | ||||||
| using Volo.Abp.Modularity; | using Volo.Abp.Modularity; | ||||||
|  | using Volo.Abp.Security.Claims; | ||||||
|  | using Volo.Abp.Swashbuckle; | ||||||
|  | using Volo.Abp.VirtualFileSystem; | ||||||
|  |  | ||||||
| namespace KonSoft.Payment; | namespace KonSoft.Payment; | ||||||
|  |  | ||||||
| [DependsOn( | [DependsOn( | ||||||
|     typeof(PaymentHttpApiModule), |     typeof(PaymentHttpApiModule), | ||||||
|  |     typeof(AbpAutofacModule), | ||||||
|  |     typeof(AbpCachingStackExchangeRedisModule), | ||||||
|  |     typeof(AbpDistributedLockingModule), | ||||||
|  |     typeof(AbpAspNetCoreMvcUiMultiTenancyModule), | ||||||
|  |     typeof(AbpAspNetCoreAuthenticationJwtBearerModule), | ||||||
|     typeof(PaymentApplicationModule), |     typeof(PaymentApplicationModule), | ||||||
|     typeof(PaymentEntityFrameworkCoreModule), |     typeof(PaymentEntityFrameworkCoreModule), | ||||||
|     typeof(KonSoftSharedHostingMicroservicesModule) |     typeof(AbpAspNetCoreSerilogModule), | ||||||
|  |     typeof(AbpSwashbuckleModule) | ||||||
| )] | )] | ||||||
| public class PaymentHttpApiHostModule : AbpModule | public class PaymentHttpApiHostModule : AbpModule | ||||||
| { | { | ||||||
|     public override void ConfigureServices(ServiceConfigurationContext context) |     public override void ConfigureServices(ServiceConfigurationContext context) | ||||||
|     { |     { | ||||||
|         var configuration = context.Services.GetConfiguration(); |         var configuration = context.Services.GetConfiguration(); | ||||||
|  |         var hostingEnvironment = context.Services.GetHostingEnvironment(); | ||||||
|  |  | ||||||
|         SwaggerConfigurationHelper.ConfigureWithOidc( |         ConfigureConventionalControllers(); | ||||||
|             context: context, |         ConfigureAuthentication(context, configuration); | ||||||
|             authority: configuration["AuthServer:Authority"]!, |         ConfigureCache(configuration); | ||||||
|             scopes: ["PaymentService"], |         ConfigureVirtualFileSystem(context); | ||||||
|             discoveryEndpoint: configuration["AuthServer:MetadataAddress"], |         ConfigureDataProtection(context, configuration, hostingEnvironment); | ||||||
|             apiTitle: "Payment Service API" |         ConfigureDistributedLocking(context, configuration); | ||||||
|         ); |         ConfigureCors(context, configuration); | ||||||
|  |         ConfigureSwaggerServices(context, configuration); | ||||||
|  |     } | ||||||
|  |  | ||||||
|         // ֻ<><D6BB><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD> |     private void ConfigureCache(IConfiguration configuration) | ||||||
|         Configure<AbpBackgroundJobOptions>(options => options.IsJobExecutionEnabled = false); |     { | ||||||
|  |         Configure<AbpDistributedCacheOptions>(options => { options.KeyPrefix = "Payment:"; }); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     private void ConfigureVirtualFileSystem(ServiceConfigurationContext context) | ||||||
|  |     { | ||||||
|  |         var hostingEnvironment = context.Services.GetHostingEnvironment(); | ||||||
|  |  | ||||||
|  |         if (hostingEnvironment.IsDevelopment()) | ||||||
|  |         { | ||||||
|  |             Configure<AbpVirtualFileSystemOptions>(options => | ||||||
|  |             { | ||||||
|  |                 options.FileSets.ReplaceEmbeddedByPhysical<PaymentDomainSharedModule>( | ||||||
|  |                     Path.Combine(hostingEnvironment.ContentRootPath, | ||||||
|  |                         $"..{Path.DirectorySeparatorChar}KonSoft.Payment.Domain.Shared")); | ||||||
|  |                 options.FileSets.ReplaceEmbeddedByPhysical<PaymentDomainModule>( | ||||||
|  |                     Path.Combine(hostingEnvironment.ContentRootPath, | ||||||
|  |                         $"..{Path.DirectorySeparatorChar}KonSoft.Payment.Domain")); | ||||||
|  |                 options.FileSets.ReplaceEmbeddedByPhysical<PaymentApplicationContractsModule>( | ||||||
|  |                     Path.Combine(hostingEnvironment.ContentRootPath, | ||||||
|  |                         $"..{Path.DirectorySeparatorChar}KonSoft.Payment.Application.Contracts")); | ||||||
|  |                 options.FileSets.ReplaceEmbeddedByPhysical<PaymentApplicationModule>( | ||||||
|  |                     Path.Combine(hostingEnvironment.ContentRootPath, | ||||||
|  |                         $"..{Path.DirectorySeparatorChar}KonSoft.Payment.Application")); | ||||||
|  |             }); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     private void ConfigureConventionalControllers() | ||||||
|  |     { | ||||||
|  |         Configure<AbpAspNetCoreMvcOptions>(options => | ||||||
|  |         { | ||||||
|  |             options.ConventionalControllers.Create(typeof(PaymentApplicationModule).Assembly); | ||||||
|  |         }); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     private void ConfigureAuthentication(ServiceConfigurationContext context, IConfiguration configuration) | ||||||
|  |     { | ||||||
|  |         context.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) | ||||||
|  |             .AddAbpJwtBearer(options => | ||||||
|  |             { | ||||||
|  |                 options.Authority = configuration["AuthServer:Authority"]; | ||||||
|  |                 options.RequireHttpsMetadata = configuration.GetValue<bool>("AuthServer:RequireHttpsMetadata"); | ||||||
|  |                 options.Audience = "Payment"; | ||||||
|  |             }); | ||||||
|  |  | ||||||
|  |         context.Services.Configure<AbpClaimsPrincipalFactoryOptions>(options => | ||||||
|  |         { | ||||||
|  |             options.IsDynamicClaimsEnabled = true; | ||||||
|  |         }); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     private static void ConfigureSwaggerServices(ServiceConfigurationContext context, IConfiguration configuration) | ||||||
|  |     { | ||||||
|  |         context.Services.AddAbpSwaggerGenWithOAuth( | ||||||
|  |             configuration["AuthServer:Authority"]!, | ||||||
|  |             new Dictionary<string, string> | ||||||
|  |             { | ||||||
|  |                     {"Payment", "Payment API"} | ||||||
|  |             }, | ||||||
|  |             options => | ||||||
|  |             { | ||||||
|  |                 options.SwaggerDoc("v1", new OpenApiInfo { Title = "Payment API", Version = "v1" }); | ||||||
|  |                 options.DocInclusionPredicate((docName, description) => true); | ||||||
|  |                 options.CustomSchemaIds(type => type.FullName); | ||||||
|  |             }); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     private void ConfigureDataProtection( | ||||||
|  |         ServiceConfigurationContext context, | ||||||
|  |         IConfiguration configuration, | ||||||
|  |         IWebHostEnvironment hostingEnvironment) | ||||||
|  |     { | ||||||
|  |         var dataProtectionBuilder = context.Services.AddDataProtection().SetApplicationName("Payment"); | ||||||
|  |         if (!hostingEnvironment.IsDevelopment()) | ||||||
|  |         { | ||||||
|  |             var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]!); | ||||||
|  |             dataProtectionBuilder.PersistKeysToStackExchangeRedis(redis, "Payment-Protection-Keys"); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     private void ConfigureDistributedLocking( | ||||||
|  |         ServiceConfigurationContext context, | ||||||
|  |         IConfiguration configuration) | ||||||
|  |     { | ||||||
|  |         context.Services.AddSingleton<IDistributedLockProvider>(sp => | ||||||
|  |         { | ||||||
|  |             var connection = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]!); | ||||||
|  |             return new RedisDistributedSynchronizationProvider(connection.GetDatabase()); | ||||||
|  |         }); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     private void ConfigureCors(ServiceConfigurationContext context, IConfiguration configuration) | ||||||
|  |     { | ||||||
|  |         context.Services.AddCors(options => | ||||||
|  |         { | ||||||
|  |             options.AddDefaultPolicy(builder => | ||||||
|  |             { | ||||||
|  |                 builder | ||||||
|  |                     .WithOrigins(configuration["App:CorsOrigins"]? | ||||||
|  |                         .Split(",", StringSplitOptions.RemoveEmptyEntries) | ||||||
|  |                         .Select(o => o.RemovePostFix("/")) | ||||||
|  |                         .ToArray() ?? []) | ||||||
|  |                     .WithAbpExposedHeaders() | ||||||
|  |                     .SetIsOriginAllowedToAllowWildcardSubdomains() | ||||||
|  |                     .AllowAnyHeader() | ||||||
|  |                     .AllowAnyMethod() | ||||||
|  |                     .AllowCredentials(); | ||||||
|  |             }); | ||||||
|  |         }); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public override void OnApplicationInitialization(ApplicationInitializationContext context) |     public override void OnApplicationInitialization(ApplicationInitializationContext context) | ||||||
| @ -52,7 +193,7 @@ public class PaymentHttpApiHostModule : AbpModule | |||||||
|         app.UseCors(); |         app.UseCors(); | ||||||
|         app.UseAuthentication(); |         app.UseAuthentication(); | ||||||
|  |  | ||||||
|         if (KonSoftConsts.MultiTenancyEnabled) |         if (MultiTenancyConsts.IsEnabled) | ||||||
|         { |         { | ||||||
|             app.UseMultiTenancy(); |             app.UseMultiTenancy(); | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -1,13 +1,27 @@ | |||||||
| { | { | ||||||
|   "$schema": "http://json.schemastore.org/launchsettings.json", |   "iisSettings": { | ||||||
|  |     "windowsAuthentication": false,  | ||||||
|  |     "anonymousAuthentication": true, | ||||||
|  |     "iisExpress": { | ||||||
|  |       "applicationUrl": "https://localhost:44326", | ||||||
|  |       "sslPort": 44326 | ||||||
|  |     } | ||||||
|  |   }, | ||||||
|   "profiles": { |   "profiles": { | ||||||
|     "http": { |     "IIS Express": { | ||||||
|       "commandName": "Project", |       "commandName": "IISExpress", | ||||||
|       "launchBrowser": true, |       "launchBrowser": true, | ||||||
|       "environmentVariables": { |       "environmentVariables": { | ||||||
|         "ASPNETCORE_ENVIRONMENT": "Development" |         "ASPNETCORE_ENVIRONMENT": "Development" | ||||||
|       }, |       } | ||||||
|       "applicationUrl": "https://localhost:44326" |     }, | ||||||
|  |     "KonSoft.Payment.HttpApi.Host": { | ||||||
|  |       "commandName": "Project", | ||||||
|  |       "launchBrowser": true, | ||||||
|  |       "applicationUrl": "https://localhost:44326", | ||||||
|  |       "environmentVariables": { | ||||||
|  |         "ASPNETCORE_ENVIRONMENT": "Development" | ||||||
|  |       } | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
| } | } | ||||||
| @ -8,6 +8,21 @@ | |||||||
|     <UserSecretsId>KonSoft.Report-4681b4fd-151f-4221-84a4-929d86723e4c</UserSecretsId> |     <UserSecretsId>KonSoft.Report-4681b4fd-151f-4221-84a4-929d86723e4c</UserSecretsId> | ||||||
|   </PropertyGroup> |   </PropertyGroup> | ||||||
|  |  | ||||||
|  |   <ItemGroup> | ||||||
|  |     <PackageReference Include="Serilog.AspNetCore" Version="8.0.0" /> | ||||||
|  |     <PackageReference Include="Serilog.Sinks.Async" Version="1.5.0" /> | ||||||
|  |     <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.4" /> | ||||||
|  |     <PackageReference Include="Microsoft.AspNetCore.DataProtection.StackExchangeRedis" Version="8.0.4" /> | ||||||
|  |     <PackageReference Include="DistributedLock.Redis" Version="1.0.2" /> | ||||||
|  |     <PackageReference Include="Volo.Abp.AspNetCore.Authentication.JwtBearer" Version="8.3.4" /> | ||||||
|  |     <PackageReference Include="Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy" Version="8.3.4" /> | ||||||
|  |     <PackageReference Include="Volo.Abp.Autofac" Version="8.3.4" /> | ||||||
|  |     <PackageReference Include="Volo.Abp.Caching.StackExchangeRedis" Version="8.3.4" /> | ||||||
|  |     <PackageReference Include="Volo.Abp.DistributedLocking" Version="8.3.4" /> | ||||||
|  |     <PackageReference Include="Volo.Abp.AspNetCore.Serilog" Version="8.3.4" /> | ||||||
|  |     <PackageReference Include="Volo.Abp.Swashbuckle" Version="8.3.4" /> | ||||||
|  |   </ItemGroup> | ||||||
|  |  | ||||||
|   <ItemGroup> |   <ItemGroup> | ||||||
|     <Compile Remove="Logs\**" /> |     <Compile Remove="Logs\**" /> | ||||||
|     <Content Remove="Logs\**" /> |     <Content Remove="Logs\**" /> | ||||||
| @ -19,7 +34,6 @@ | |||||||
|     <ProjectReference Include="..\..\modules\report\src\KonSoft.Report.Application\KonSoft.Report.Application.csproj" /> |     <ProjectReference Include="..\..\modules\report\src\KonSoft.Report.Application\KonSoft.Report.Application.csproj" /> | ||||||
|     <ProjectReference Include="..\..\modules\report\src\KonSoft.Report.EntityFrameworkCore\KonSoft.Report.EntityFrameworkCore.csproj" /> |     <ProjectReference Include="..\..\modules\report\src\KonSoft.Report.EntityFrameworkCore\KonSoft.Report.EntityFrameworkCore.csproj" /> | ||||||
|     <ProjectReference Include="..\..\modules\report\src\KonSoft.Report.HttpApi\KonSoft.Report.HttpApi.csproj" /> |     <ProjectReference Include="..\..\modules\report\src\KonSoft.Report.HttpApi\KonSoft.Report.HttpApi.csproj" /> | ||||||
|     <ProjectReference Include="..\..\shared\KonSoft.Shared.Hosting.Microservices\KonSoft.Shared.Hosting.Microservices.csproj" /> |  | ||||||
|   </ItemGroup> |   </ItemGroup> | ||||||
|  |  | ||||||
| </Project> | </Project> | ||||||
|  | |||||||
| @ -1,13 +1,27 @@ | |||||||
| { | { | ||||||
|   "$schema": "http://json.schemastore.org/launchsettings.json", |   "iisSettings": { | ||||||
|  |     "windowsAuthentication": false,  | ||||||
|  |     "anonymousAuthentication": true, | ||||||
|  |     "iisExpress": { | ||||||
|  |       "applicationUrl": "https://localhost:44320", | ||||||
|  |       "sslPort": 44320 | ||||||
|  |     } | ||||||
|  |   }, | ||||||
|   "profiles": { |   "profiles": { | ||||||
|     "http": { |     "IIS Express": { | ||||||
|       "commandName": "Project", |       "commandName": "IISExpress", | ||||||
|       "launchBrowser": true, |       "launchBrowser": true, | ||||||
|       "environmentVariables": { |       "environmentVariables": { | ||||||
|         "ASPNETCORE_ENVIRONMENT": "Development" |         "ASPNETCORE_ENVIRONMENT": "Development" | ||||||
|       }, |       } | ||||||
|       "applicationUrl": "https://localhost:44320" |     }, | ||||||
|  |     "KonSoft.Report.HttpApi.Host": { | ||||||
|  |       "commandName": "Project", | ||||||
|  |       "launchBrowser": true, | ||||||
|  |       "applicationUrl": "https://localhost:44320", | ||||||
|  |       "environmentVariables": { | ||||||
|  |         "ASPNETCORE_ENVIRONMENT": "Development" | ||||||
|  |       } | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
| } | } | ||||||
| @ -1,38 +1,179 @@ | |||||||
| using KonSoft.Report.EntityFrameworkCore; | using System; | ||||||
| using KonSoft.Shared.Hosting.AspNetCore; | using System.Collections.Generic; | ||||||
| using KonSoft.Shared.Hosting.Microservices; | using System.IO; | ||||||
|  | using System.Linq; | ||||||
|  | using Medallion.Threading; | ||||||
|  | using Medallion.Threading.Redis; | ||||||
|  | using Microsoft.AspNetCore.Authentication.JwtBearer; | ||||||
| using Microsoft.AspNetCore.Builder; | using Microsoft.AspNetCore.Builder; | ||||||
|  | using Microsoft.AspNetCore.Cors; | ||||||
|  | using Microsoft.AspNetCore.DataProtection; | ||||||
| using Microsoft.AspNetCore.Hosting; | using Microsoft.AspNetCore.Hosting; | ||||||
|  | using Microsoft.Extensions.Configuration; | ||||||
| using Microsoft.Extensions.DependencyInjection; | using Microsoft.Extensions.DependencyInjection; | ||||||
| using Microsoft.Extensions.Hosting; | using Microsoft.Extensions.Hosting; | ||||||
|  | using KonSoft.Report.EntityFrameworkCore; | ||||||
|  | using KonSoft.Report.MultiTenancy; | ||||||
|  | using StackExchange.Redis; | ||||||
|  | using Microsoft.OpenApi.Models; | ||||||
| using Volo.Abp; | using Volo.Abp; | ||||||
| using Volo.Abp.BackgroundJobs; | using Volo.Abp.AspNetCore.Authentication.JwtBearer; | ||||||
|  | using Volo.Abp.AspNetCore.Mvc; | ||||||
|  | using Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy; | ||||||
|  | using Volo.Abp.AspNetCore.Serilog; | ||||||
|  | using Volo.Abp.Autofac; | ||||||
|  | using Volo.Abp.Caching; | ||||||
|  | using Volo.Abp.Caching.StackExchangeRedis; | ||||||
|  | using Volo.Abp.DistributedLocking; | ||||||
|  | using Volo.Abp.Identity; | ||||||
|  | using Volo.Abp.Localization; | ||||||
| using Volo.Abp.Modularity; | using Volo.Abp.Modularity; | ||||||
|  | using Volo.Abp.Security.Claims; | ||||||
|  | using Volo.Abp.Swashbuckle; | ||||||
|  | using Volo.Abp.VirtualFileSystem; | ||||||
|  |  | ||||||
| namespace KonSoft.Report; | namespace KonSoft.Report; | ||||||
|  |  | ||||||
| [DependsOn( | [DependsOn( | ||||||
|     typeof(ReportHttpApiModule), |     typeof(ReportHttpApiModule), | ||||||
|  |     typeof(AbpAutofacModule), | ||||||
|  |     typeof(AbpCachingStackExchangeRedisModule), | ||||||
|  |     typeof(AbpDistributedLockingModule), | ||||||
|  |     typeof(AbpAspNetCoreMvcUiMultiTenancyModule), | ||||||
|  |     typeof(AbpAspNetCoreAuthenticationJwtBearerModule), | ||||||
|     typeof(ReportApplicationModule), |     typeof(ReportApplicationModule), | ||||||
|     typeof(ReportEntityFrameworkCoreModule), |     typeof(ReportEntityFrameworkCoreModule), | ||||||
|     typeof(KonSoftSharedHostingMicroservicesModule) |     typeof(AbpAspNetCoreSerilogModule), | ||||||
|  |     typeof(AbpSwashbuckleModule) | ||||||
| )] | )] | ||||||
| public class ReportHttpApiHostModule : AbpModule | public class ReportHttpApiHostModule : AbpModule | ||||||
| { | { | ||||||
|     public override void ConfigureServices(ServiceConfigurationContext context) |     public override void ConfigureServices(ServiceConfigurationContext context) | ||||||
|     { |     { | ||||||
|         var configuration = context.Services.GetConfiguration(); |         var configuration = context.Services.GetConfiguration(); | ||||||
|  |         var hostingEnvironment = context.Services.GetHostingEnvironment(); | ||||||
|  |  | ||||||
|         SwaggerConfigurationHelper.ConfigureWithOidc( |         ConfigureConventionalControllers(); | ||||||
|             context: context, |         ConfigureAuthentication(context, configuration); | ||||||
|             authority: configuration["AuthServer:Authority"]!, |         ConfigureCache(configuration); | ||||||
|             scopes: ["ReportService"], |         ConfigureVirtualFileSystem(context); | ||||||
|             discoveryEndpoint: configuration["AuthServer:MetadataAddress"], |         ConfigureDataProtection(context, configuration, hostingEnvironment); | ||||||
|             apiTitle: "Report Service API" |         ConfigureDistributedLocking(context, configuration); | ||||||
|         ); |         ConfigureCors(context, configuration); | ||||||
|  |         ConfigureSwaggerServices(context, configuration); | ||||||
|  |     } | ||||||
|  |  | ||||||
|         // ֻ<><D6BB><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD> |     private void ConfigureCache(IConfiguration configuration) | ||||||
|         Configure<AbpBackgroundJobOptions>(options => options.IsJobExecutionEnabled = false); |     { | ||||||
|  |         Configure<AbpDistributedCacheOptions>(options => { options.KeyPrefix = "Report:"; }); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     private void ConfigureVirtualFileSystem(ServiceConfigurationContext context) | ||||||
|  |     { | ||||||
|  |         var hostingEnvironment = context.Services.GetHostingEnvironment(); | ||||||
|  |  | ||||||
|  |         if (hostingEnvironment.IsDevelopment()) | ||||||
|  |         { | ||||||
|  |             Configure<AbpVirtualFileSystemOptions>(options => | ||||||
|  |             { | ||||||
|  |                 options.FileSets.ReplaceEmbeddedByPhysical<ReportDomainSharedModule>( | ||||||
|  |                     Path.Combine(hostingEnvironment.ContentRootPath, | ||||||
|  |                         $"..{Path.DirectorySeparatorChar}KonSoft.Report.Domain.Shared")); | ||||||
|  |                 options.FileSets.ReplaceEmbeddedByPhysical<ReportDomainModule>( | ||||||
|  |                     Path.Combine(hostingEnvironment.ContentRootPath, | ||||||
|  |                         $"..{Path.DirectorySeparatorChar}KonSoft.Report.Domain")); | ||||||
|  |                 options.FileSets.ReplaceEmbeddedByPhysical<ReportApplicationContractsModule>( | ||||||
|  |                     Path.Combine(hostingEnvironment.ContentRootPath, | ||||||
|  |                         $"..{Path.DirectorySeparatorChar}KonSoft.Report.Application.Contracts")); | ||||||
|  |                 options.FileSets.ReplaceEmbeddedByPhysical<ReportApplicationModule>( | ||||||
|  |                     Path.Combine(hostingEnvironment.ContentRootPath, | ||||||
|  |                         $"..{Path.DirectorySeparatorChar}KonSoft.Report.Application")); | ||||||
|  |             }); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     private void ConfigureConventionalControllers() | ||||||
|  |     { | ||||||
|  |         Configure<AbpAspNetCoreMvcOptions>(options => | ||||||
|  |         { | ||||||
|  |             options.ConventionalControllers.Create(typeof(ReportApplicationModule).Assembly); | ||||||
|  |         }); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     private void ConfigureAuthentication(ServiceConfigurationContext context, IConfiguration configuration) | ||||||
|  |     { | ||||||
|  |         context.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) | ||||||
|  |             .AddAbpJwtBearer(options => | ||||||
|  |             { | ||||||
|  |                 options.Authority = configuration["AuthServer:Authority"]; | ||||||
|  |                 options.RequireHttpsMetadata = configuration.GetValue<bool>("AuthServer:RequireHttpsMetadata"); | ||||||
|  |                 options.Audience = "Report"; | ||||||
|  |             }); | ||||||
|  |  | ||||||
|  |         context.Services.Configure<AbpClaimsPrincipalFactoryOptions>(options => | ||||||
|  |         { | ||||||
|  |             options.IsDynamicClaimsEnabled = true; | ||||||
|  |         }); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     private static void ConfigureSwaggerServices(ServiceConfigurationContext context, IConfiguration configuration) | ||||||
|  |     { | ||||||
|  |         context.Services.AddAbpSwaggerGenWithOAuth( | ||||||
|  |             configuration["AuthServer:Authority"]!, | ||||||
|  |             new Dictionary<string, string> | ||||||
|  |             { | ||||||
|  |                     {"Report", "Report API"} | ||||||
|  |             }, | ||||||
|  |             options => | ||||||
|  |             { | ||||||
|  |                 options.SwaggerDoc("v1", new OpenApiInfo { Title = "Report API", Version = "v1" }); | ||||||
|  |                 options.DocInclusionPredicate((docName, description) => true); | ||||||
|  |                 options.CustomSchemaIds(type => type.FullName); | ||||||
|  |             }); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     private void ConfigureDataProtection( | ||||||
|  |         ServiceConfigurationContext context, | ||||||
|  |         IConfiguration configuration, | ||||||
|  |         IWebHostEnvironment hostingEnvironment) | ||||||
|  |     { | ||||||
|  |         var dataProtectionBuilder = context.Services.AddDataProtection().SetApplicationName("Report"); | ||||||
|  |         if (!hostingEnvironment.IsDevelopment()) | ||||||
|  |         { | ||||||
|  |             var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]!); | ||||||
|  |             dataProtectionBuilder.PersistKeysToStackExchangeRedis(redis, "Report-Protection-Keys"); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     private void ConfigureDistributedLocking( | ||||||
|  |         ServiceConfigurationContext context, | ||||||
|  |         IConfiguration configuration) | ||||||
|  |     { | ||||||
|  |         context.Services.AddSingleton<IDistributedLockProvider>(sp => | ||||||
|  |         { | ||||||
|  |             var connection = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]!); | ||||||
|  |             return new RedisDistributedSynchronizationProvider(connection.GetDatabase()); | ||||||
|  |         }); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     private void ConfigureCors(ServiceConfigurationContext context, IConfiguration configuration) | ||||||
|  |     { | ||||||
|  |         context.Services.AddCors(options => | ||||||
|  |         { | ||||||
|  |             options.AddDefaultPolicy(builder => | ||||||
|  |             { | ||||||
|  |                 builder | ||||||
|  |                     .WithOrigins(configuration["App:CorsOrigins"]? | ||||||
|  |                         .Split(",", StringSplitOptions.RemoveEmptyEntries) | ||||||
|  |                         .Select(o => o.RemovePostFix("/")) | ||||||
|  |                         .ToArray() ?? []) | ||||||
|  |                     .WithAbpExposedHeaders() | ||||||
|  |                     .SetIsOriginAllowedToAllowWildcardSubdomains() | ||||||
|  |                     .AllowAnyHeader() | ||||||
|  |                     .AllowAnyMethod() | ||||||
|  |                     .AllowCredentials(); | ||||||
|  |             }); | ||||||
|  |         }); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public override void OnApplicationInitialization(ApplicationInitializationContext context) |     public override void OnApplicationInitialization(ApplicationInitializationContext context) | ||||||
| @ -52,7 +193,7 @@ public class ReportHttpApiHostModule : AbpModule | |||||||
|         app.UseCors(); |         app.UseCors(); | ||||||
|         app.UseAuthentication(); |         app.UseAuthentication(); | ||||||
|  |  | ||||||
|         if (KonSoftConsts.MultiTenancyEnabled) |         if (MultiTenancyConsts.IsEnabled) | ||||||
|         { |         { | ||||||
|             app.UseMultiTenancy(); |             app.UseMultiTenancy(); | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -8,6 +8,21 @@ | |||||||
|     <UserSecretsId>KonSoft.TenantManagement-4681b4fd-151f-4221-84a4-929d86723e4c</UserSecretsId> |     <UserSecretsId>KonSoft.TenantManagement-4681b4fd-151f-4221-84a4-929d86723e4c</UserSecretsId> | ||||||
|   </PropertyGroup> |   </PropertyGroup> | ||||||
|  |  | ||||||
|  |   <ItemGroup> | ||||||
|  |     <PackageReference Include="Serilog.AspNetCore" Version="8.0.0" /> | ||||||
|  |     <PackageReference Include="Serilog.Sinks.Async" Version="1.5.0" /> | ||||||
|  |     <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.4" /> | ||||||
|  |     <PackageReference Include="Microsoft.AspNetCore.DataProtection.StackExchangeRedis" Version="8.0.4" /> | ||||||
|  |     <PackageReference Include="DistributedLock.Redis" Version="1.0.2" /> | ||||||
|  |     <PackageReference Include="Volo.Abp.AspNetCore.Authentication.JwtBearer" Version="8.3.4" /> | ||||||
|  |     <PackageReference Include="Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy" Version="8.3.4" /> | ||||||
|  |     <PackageReference Include="Volo.Abp.Autofac" Version="8.3.4" /> | ||||||
|  |     <PackageReference Include="Volo.Abp.Caching.StackExchangeRedis" Version="8.3.4" /> | ||||||
|  |     <PackageReference Include="Volo.Abp.DistributedLocking" Version="8.3.4" /> | ||||||
|  |     <PackageReference Include="Volo.Abp.AspNetCore.Serilog" Version="8.3.4" /> | ||||||
|  |     <PackageReference Include="Volo.Abp.Swashbuckle" Version="8.3.4" /> | ||||||
|  |   </ItemGroup> | ||||||
|  |  | ||||||
|   <ItemGroup> |   <ItemGroup> | ||||||
|     <Compile Remove="Logs\**" /> |     <Compile Remove="Logs\**" /> | ||||||
|     <Content Remove="Logs\**" /> |     <Content Remove="Logs\**" /> | ||||||
| @ -19,7 +34,6 @@ | |||||||
|     <ProjectReference Include="..\..\modules\tenant-management\src\KonSoft.TenantManagement.Application\KonSoft.TenantManagement.Application.csproj" /> |     <ProjectReference Include="..\..\modules\tenant-management\src\KonSoft.TenantManagement.Application\KonSoft.TenantManagement.Application.csproj" /> | ||||||
|     <ProjectReference Include="..\..\modules\tenant-management\src\KonSoft.TenantManagement.EntityFrameworkCore\KonSoft.TenantManagement.EntityFrameworkCore.csproj" /> |     <ProjectReference Include="..\..\modules\tenant-management\src\KonSoft.TenantManagement.EntityFrameworkCore\KonSoft.TenantManagement.EntityFrameworkCore.csproj" /> | ||||||
|     <ProjectReference Include="..\..\modules\tenant-management\src\KonSoft.TenantManagement.HttpApi\KonSoft.TenantManagement.HttpApi.csproj" /> |     <ProjectReference Include="..\..\modules\tenant-management\src\KonSoft.TenantManagement.HttpApi\KonSoft.TenantManagement.HttpApi.csproj" /> | ||||||
|     <ProjectReference Include="..\..\shared\KonSoft.Shared.Hosting.Microservices\KonSoft.Shared.Hosting.Microservices.csproj" /> |  | ||||||
|   </ItemGroup> |   </ItemGroup> | ||||||
|  |  | ||||||
| </Project> | </Project> | ||||||
|  | |||||||
| @ -1,13 +1,27 @@ | |||||||
| { | { | ||||||
|   "$schema": "http://json.schemastore.org/launchsettings.json", |   "iisSettings": { | ||||||
|  |     "windowsAuthentication": false,  | ||||||
|  |     "anonymousAuthentication": true, | ||||||
|  |     "iisExpress": { | ||||||
|  |       "applicationUrl": "https://localhost:44348", | ||||||
|  |       "sslPort": 44348 | ||||||
|  |     } | ||||||
|  |   }, | ||||||
|   "profiles": { |   "profiles": { | ||||||
|     "http": { |     "IIS Express": { | ||||||
|       "commandName": "Project", |       "commandName": "IISExpress", | ||||||
|       "launchBrowser": true, |       "launchBrowser": true, | ||||||
|       "environmentVariables": { |       "environmentVariables": { | ||||||
|         "ASPNETCORE_ENVIRONMENT": "Development" |         "ASPNETCORE_ENVIRONMENT": "Development" | ||||||
|       }, |       } | ||||||
|       "applicationUrl": "https://localhost:44348" |     }, | ||||||
|  |     "KonSoft.TenantManagement.HttpApi.Host": { | ||||||
|  |       "commandName": "Project", | ||||||
|  |       "launchBrowser": true, | ||||||
|  |       "applicationUrl": "https://localhost:44348", | ||||||
|  |       "environmentVariables": { | ||||||
|  |         "ASPNETCORE_ENVIRONMENT": "Development" | ||||||
|  |       } | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
| } | } | ||||||
| @ -1,38 +1,179 @@ | |||||||
| using KonSoft.Shared.Hosting.AspNetCore; | using System; | ||||||
| using KonSoft.Shared.Hosting.Microservices; | using System.Collections.Generic; | ||||||
| using KonSoft.TenantManagement.EntityFrameworkCore; | using System.IO; | ||||||
|  | using System.Linq; | ||||||
|  | using Medallion.Threading; | ||||||
|  | using Medallion.Threading.Redis; | ||||||
|  | using Microsoft.AspNetCore.Authentication.JwtBearer; | ||||||
| using Microsoft.AspNetCore.Builder; | using Microsoft.AspNetCore.Builder; | ||||||
|  | using Microsoft.AspNetCore.Cors; | ||||||
|  | using Microsoft.AspNetCore.DataProtection; | ||||||
| using Microsoft.AspNetCore.Hosting; | using Microsoft.AspNetCore.Hosting; | ||||||
|  | using Microsoft.Extensions.Configuration; | ||||||
| using Microsoft.Extensions.DependencyInjection; | using Microsoft.Extensions.DependencyInjection; | ||||||
| using Microsoft.Extensions.Hosting; | using Microsoft.Extensions.Hosting; | ||||||
|  | using KonSoft.TenantManagement.EntityFrameworkCore; | ||||||
|  | using KonSoft.TenantManagement.MultiTenancy; | ||||||
|  | using StackExchange.Redis; | ||||||
|  | using Microsoft.OpenApi.Models; | ||||||
| using Volo.Abp; | using Volo.Abp; | ||||||
| using Volo.Abp.BackgroundJobs; | using Volo.Abp.AspNetCore.Authentication.JwtBearer; | ||||||
|  | using Volo.Abp.AspNetCore.Mvc; | ||||||
|  | using Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy; | ||||||
|  | using Volo.Abp.AspNetCore.Serilog; | ||||||
|  | using Volo.Abp.Autofac; | ||||||
|  | using Volo.Abp.Caching; | ||||||
|  | using Volo.Abp.Caching.StackExchangeRedis; | ||||||
|  | using Volo.Abp.DistributedLocking; | ||||||
|  | using Volo.Abp.Identity; | ||||||
|  | using Volo.Abp.Localization; | ||||||
| using Volo.Abp.Modularity; | using Volo.Abp.Modularity; | ||||||
|  | using Volo.Abp.Security.Claims; | ||||||
|  | using Volo.Abp.Swashbuckle; | ||||||
|  | using Volo.Abp.VirtualFileSystem; | ||||||
|  |  | ||||||
| namespace KonSoft.TenantManagement; | namespace KonSoft.TenantManagement; | ||||||
|  |  | ||||||
| [DependsOn( | [DependsOn( | ||||||
|     typeof(TenantManagementHttpApiModule), |     typeof(TenantManagementHttpApiModule), | ||||||
|  |     typeof(AbpAutofacModule), | ||||||
|  |     typeof(AbpCachingStackExchangeRedisModule), | ||||||
|  |     typeof(AbpDistributedLockingModule), | ||||||
|  |     typeof(AbpAspNetCoreMvcUiMultiTenancyModule), | ||||||
|  |     typeof(AbpAspNetCoreAuthenticationJwtBearerModule), | ||||||
|     typeof(TenantManagementApplicationModule), |     typeof(TenantManagementApplicationModule), | ||||||
|     typeof(TenantManagementEntityFrameworkCoreModule), |     typeof(TenantManagementEntityFrameworkCoreModule), | ||||||
|     typeof(KonSoftSharedHostingMicroservicesModule) |     typeof(AbpAspNetCoreSerilogModule), | ||||||
|  |     typeof(AbpSwashbuckleModule) | ||||||
| )] | )] | ||||||
| public class TenantManagementHttpApiHostModule : AbpModule | public class TenantManagementHttpApiHostModule : AbpModule | ||||||
| { | { | ||||||
|     public override void ConfigureServices(ServiceConfigurationContext context) |     public override void ConfigureServices(ServiceConfigurationContext context) | ||||||
|     { |     { | ||||||
|         var configuration = context.Services.GetConfiguration(); |         var configuration = context.Services.GetConfiguration(); | ||||||
|  |         var hostingEnvironment = context.Services.GetHostingEnvironment(); | ||||||
|  |  | ||||||
|         SwaggerConfigurationHelper.ConfigureWithOidc( |         ConfigureConventionalControllers(); | ||||||
|             context: context, |         ConfigureAuthentication(context, configuration); | ||||||
|             authority: configuration["AuthServer:Authority"]!, |         ConfigureCache(configuration); | ||||||
|             scopes: ["TenantManagementService"], |         ConfigureVirtualFileSystem(context); | ||||||
|             discoveryEndpoint: configuration["AuthServer:MetadataAddress"], |         ConfigureDataProtection(context, configuration, hostingEnvironment); | ||||||
|             apiTitle: "TenantManagement Service API" |         ConfigureDistributedLocking(context, configuration); | ||||||
|         ); |         ConfigureCors(context, configuration); | ||||||
|  |         ConfigureSwaggerServices(context, configuration); | ||||||
|  |     } | ||||||
|  |  | ||||||
|         // ֻ<><D6BB><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD> |     private void ConfigureCache(IConfiguration configuration) | ||||||
|         Configure<AbpBackgroundJobOptions>(options => options.IsJobExecutionEnabled = false); |     { | ||||||
|  |         Configure<AbpDistributedCacheOptions>(options => { options.KeyPrefix = "TenantManagement:"; }); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     private void ConfigureVirtualFileSystem(ServiceConfigurationContext context) | ||||||
|  |     { | ||||||
|  |         var hostingEnvironment = context.Services.GetHostingEnvironment(); | ||||||
|  |  | ||||||
|  |         if (hostingEnvironment.IsDevelopment()) | ||||||
|  |         { | ||||||
|  |             Configure<AbpVirtualFileSystemOptions>(options => | ||||||
|  |             { | ||||||
|  |                 options.FileSets.ReplaceEmbeddedByPhysical<TenantManagementDomainSharedModule>( | ||||||
|  |                     Path.Combine(hostingEnvironment.ContentRootPath, | ||||||
|  |                         $"..{Path.DirectorySeparatorChar}KonSoft.TenantManagement.Domain.Shared")); | ||||||
|  |                 options.FileSets.ReplaceEmbeddedByPhysical<TenantManagementDomainModule>( | ||||||
|  |                     Path.Combine(hostingEnvironment.ContentRootPath, | ||||||
|  |                         $"..{Path.DirectorySeparatorChar}KonSoft.TenantManagement.Domain")); | ||||||
|  |                 options.FileSets.ReplaceEmbeddedByPhysical<TenantManagementApplicationContractsModule>( | ||||||
|  |                     Path.Combine(hostingEnvironment.ContentRootPath, | ||||||
|  |                         $"..{Path.DirectorySeparatorChar}KonSoft.TenantManagement.Application.Contracts")); | ||||||
|  |                 options.FileSets.ReplaceEmbeddedByPhysical<TenantManagementApplicationModule>( | ||||||
|  |                     Path.Combine(hostingEnvironment.ContentRootPath, | ||||||
|  |                         $"..{Path.DirectorySeparatorChar}KonSoft.TenantManagement.Application")); | ||||||
|  |             }); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     private void ConfigureConventionalControllers() | ||||||
|  |     { | ||||||
|  |         Configure<AbpAspNetCoreMvcOptions>(options => | ||||||
|  |         { | ||||||
|  |             options.ConventionalControllers.Create(typeof(TenantManagementApplicationModule).Assembly); | ||||||
|  |         }); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     private void ConfigureAuthentication(ServiceConfigurationContext context, IConfiguration configuration) | ||||||
|  |     { | ||||||
|  |         context.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) | ||||||
|  |             .AddAbpJwtBearer(options => | ||||||
|  |             { | ||||||
|  |                 options.Authority = configuration["AuthServer:Authority"]; | ||||||
|  |                 options.RequireHttpsMetadata = configuration.GetValue<bool>("AuthServer:RequireHttpsMetadata"); | ||||||
|  |                 options.Audience = "TenantManagement"; | ||||||
|  |             }); | ||||||
|  |  | ||||||
|  |         context.Services.Configure<AbpClaimsPrincipalFactoryOptions>(options => | ||||||
|  |         { | ||||||
|  |             options.IsDynamicClaimsEnabled = true; | ||||||
|  |         }); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     private static void ConfigureSwaggerServices(ServiceConfigurationContext context, IConfiguration configuration) | ||||||
|  |     { | ||||||
|  |         context.Services.AddAbpSwaggerGenWithOAuth( | ||||||
|  |             configuration["AuthServer:Authority"]!, | ||||||
|  |             new Dictionary<string, string> | ||||||
|  |             { | ||||||
|  |                     {"TenantManagement", "TenantManagement API"} | ||||||
|  |             }, | ||||||
|  |             options => | ||||||
|  |             { | ||||||
|  |                 options.SwaggerDoc("v1", new OpenApiInfo { Title = "TenantManagement API", Version = "v1" }); | ||||||
|  |                 options.DocInclusionPredicate((docName, description) => true); | ||||||
|  |                 options.CustomSchemaIds(type => type.FullName); | ||||||
|  |             }); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     private void ConfigureDataProtection( | ||||||
|  |         ServiceConfigurationContext context, | ||||||
|  |         IConfiguration configuration, | ||||||
|  |         IWebHostEnvironment hostingEnvironment) | ||||||
|  |     { | ||||||
|  |         var dataProtectionBuilder = context.Services.AddDataProtection().SetApplicationName("TenantManagement"); | ||||||
|  |         if (!hostingEnvironment.IsDevelopment()) | ||||||
|  |         { | ||||||
|  |             var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]!); | ||||||
|  |             dataProtectionBuilder.PersistKeysToStackExchangeRedis(redis, "TenantManagement-Protection-Keys"); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     private void ConfigureDistributedLocking( | ||||||
|  |         ServiceConfigurationContext context, | ||||||
|  |         IConfiguration configuration) | ||||||
|  |     { | ||||||
|  |         context.Services.AddSingleton<IDistributedLockProvider>(sp => | ||||||
|  |         { | ||||||
|  |             var connection = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]!); | ||||||
|  |             return new RedisDistributedSynchronizationProvider(connection.GetDatabase()); | ||||||
|  |         }); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     private void ConfigureCors(ServiceConfigurationContext context, IConfiguration configuration) | ||||||
|  |     { | ||||||
|  |         context.Services.AddCors(options => | ||||||
|  |         { | ||||||
|  |             options.AddDefaultPolicy(builder => | ||||||
|  |             { | ||||||
|  |                 builder | ||||||
|  |                     .WithOrigins(configuration["App:CorsOrigins"]? | ||||||
|  |                         .Split(",", StringSplitOptions.RemoveEmptyEntries) | ||||||
|  |                         .Select(o => o.RemovePostFix("/")) | ||||||
|  |                         .ToArray() ?? []) | ||||||
|  |                     .WithAbpExposedHeaders() | ||||||
|  |                     .SetIsOriginAllowedToAllowWildcardSubdomains() | ||||||
|  |                     .AllowAnyHeader() | ||||||
|  |                     .AllowAnyMethod() | ||||||
|  |                     .AllowCredentials(); | ||||||
|  |             }); | ||||||
|  |         }); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public override void OnApplicationInitialization(ApplicationInitializationContext context) |     public override void OnApplicationInitialization(ApplicationInitializationContext context) | ||||||
| @ -52,7 +193,7 @@ public class TenantManagementHttpApiHostModule : AbpModule | |||||||
|         app.UseCors(); |         app.UseCors(); | ||||||
|         app.UseAuthentication(); |         app.UseAuthentication(); | ||||||
|  |  | ||||||
|         if (KonSoftConsts.MultiTenancyEnabled) |         if (MultiTenancyConsts.IsEnabled) | ||||||
|         { |         { | ||||||
|             app.UseMultiTenancy(); |             app.UseMultiTenancy(); | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -1,17 +0,0 @@ | |||||||
| using System; |  | ||||||
| using System.Collections.Generic; |  | ||||||
| using System.Linq; |  | ||||||
| using System.Text; |  | ||||||
| using System.Threading.Tasks; |  | ||||||
|  |  | ||||||
| namespace KonSoft.Admin.Dtos |  | ||||||
| { |  | ||||||
|     public class AddressDto |  | ||||||
|     { |  | ||||||
|         public string ContactName { get; set; } |  | ||||||
|         public string ContactPhone { get; set; } |  | ||||||
|         public string DetailAddress { get; set; } |  | ||||||
|         public string City { get; set; } |  | ||||||
|         public string District { get; set; } |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @ -1,25 +0,0 @@ | |||||||
| using System; |  | ||||||
| using System.Collections.Generic; |  | ||||||
| using System.ComponentModel.DataAnnotations; |  | ||||||
| using System.Linq; |  | ||||||
| using System.Text; |  | ||||||
| using System.Threading.Tasks; |  | ||||||
|  |  | ||||||
| namespace KonSoft.Admin.Dtos |  | ||||||
| { |  | ||||||
|     public class CreateOrderDto |  | ||||||
|     { |  | ||||||
|         [Required] |  | ||||||
|         public Guid CustomerId { get; set; } |  | ||||||
|         [Required] |  | ||||||
|         public Guid ServiceCategoryId { get; set; } |  | ||||||
|         [Required] |  | ||||||
|         public DateTime ServiceTime { get; set; } |  | ||||||
|         [Required] |  | ||||||
|         public decimal Amount { get; set; } |  | ||||||
|         [Required] |  | ||||||
|         public AddressDto Address { get; set; } |  | ||||||
|  |  | ||||||
|         public string Remark { get; set; } |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @ -1,14 +0,0 @@ | |||||||
| using System; |  | ||||||
| using System.Collections.Generic; |  | ||||||
| using System.Linq; |  | ||||||
| using System.Text; |  | ||||||
| using System.Threading.Tasks; |  | ||||||
|  |  | ||||||
| namespace KonSoft.Admin.Dtos |  | ||||||
| { |  | ||||||
|     public class CreateServiceCategoryDto |  | ||||||
|     { |  | ||||||
|         public string Name { get; set; } |  | ||||||
|         public Guid? ParentId { get; set; } |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @ -1,31 +0,0 @@ | |||||||
| using KonSoft.Admin.Enums; |  | ||||||
| using System; |  | ||||||
| using System.Collections.Generic; |  | ||||||
| using System.Linq; |  | ||||||
| using System.Text; |  | ||||||
| using System.Threading.Tasks; |  | ||||||
|  |  | ||||||
| namespace KonSoft.Admin.Dtos |  | ||||||
| { |  | ||||||
|     public class OrderDto |  | ||||||
|     { |  | ||||||
|         public Guid Id { get; set; } |  | ||||||
|         public string OrderSN { get; set; } |  | ||||||
|         public Guid CustomerId { get; set; } |  | ||||||
|         public Guid? WorkerId { get; set; } |  | ||||||
|         public ServiceCategoryDto? ServiceCategory { get; set; } |  | ||||||
|         public DateTime ServiceTime { get; set; } |  | ||||||
|         public OrderStatus Status { get; set; } |  | ||||||
|         public decimal Amount { get; set; } |  | ||||||
|         public decimal PaidAmount { get; set; } |  | ||||||
|         public string PaymentMethod { get; set; } |  | ||||||
|         public AddressDto Address { get; set; } |  | ||||||
|         public string Remark { get; set; } |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     public class PageListInput |  | ||||||
|     { |  | ||||||
|         public int Index { get; set; } |  | ||||||
|         public int PageSize { get; set; } |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @ -1,12 +0,0 @@ | |||||||
| using System; |  | ||||||
| using System.Collections.Generic; |  | ||||||
| using System.Linq; |  | ||||||
| using System.Text; |  | ||||||
| using System.Threading.Tasks; |  | ||||||
|  |  | ||||||
| namespace KonSoft.Admin.Dtos |  | ||||||
| { |  | ||||||
|     public class PayOrderDto |  | ||||||
|     { |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @ -1,17 +0,0 @@ | |||||||
| using System; |  | ||||||
| using System.Collections.Generic; |  | ||||||
| using System.Linq; |  | ||||||
| using System.Text; |  | ||||||
| using System.Threading.Tasks; |  | ||||||
|  |  | ||||||
| namespace KonSoft.Admin.Dtos |  | ||||||
| { |  | ||||||
|     public class ServiceCategoryDto |  | ||||||
|     { |  | ||||||
|         public Guid Id { get; set; } |  | ||||||
|         public string Name { get; set; } |  | ||||||
|         public Guid? ParentId { get; set; } |  | ||||||
|         public int Level { get; set; } |  | ||||||
|         public List<ServiceCategoryDto> Children { get; set; } = new List<ServiceCategoryDto>(); |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @ -1,17 +0,0 @@ | |||||||
| using KonSoft.Admin.Enums; |  | ||||||
| using System; |  | ||||||
| using System.Collections.Generic; |  | ||||||
| using System.Linq; |  | ||||||
| using System.Text; |  | ||||||
| using System.Threading.Tasks; |  | ||||||
| using Volo.Abp.Application.Dtos; |  | ||||||
|  |  | ||||||
| namespace KonSoft.Admin.Dtos |  | ||||||
| { |  | ||||||
|     public class WorkerDto : EntityDto<Guid> |  | ||||||
|     { |  | ||||||
|         public string Name { get; set; } |  | ||||||
|         public string Phone { get; set; } |  | ||||||
|         public List<Guid> SkillCategoryIds { get; set; } = new();  // 擅长服务类型 |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @ -1,26 +0,0 @@ | |||||||
| using KonSoft.Admin.Dtos; |  | ||||||
| using System; |  | ||||||
| using System.Collections.Generic; |  | ||||||
| using System.Linq; |  | ||||||
| using System.Text; |  | ||||||
| using System.Threading.Tasks; |  | ||||||
| using Volo.Abp.Application.Services; |  | ||||||
|  |  | ||||||
| namespace KonSoft.Admin.IApplicationServices |  | ||||||
| { |  | ||||||
|     public interface IOrderAppService : IApplicationService |  | ||||||
|     { |  | ||||||
|         /// <summary> |  | ||||||
|         /// 创建订单 |  | ||||||
|         /// </summary> |  | ||||||
|         /// <param name="input"></param> |  | ||||||
|         /// <returns></returns> |  | ||||||
|         Task<OrderDto> CreateAsync(CreateOrderDto input); |  | ||||||
|         Task<OrderDto> PayAsync(Guid orderId, PayOrderDto input); |  | ||||||
|         Task AssignAsync(Guid orderId, Guid workerId); |  | ||||||
|         Task StartServiceAsync(Guid orderId); |  | ||||||
|         Task CompleteServiceAsync(Guid orderId); |  | ||||||
|         Task ConfirmAsync(Guid orderId); |  | ||||||
|         Task CancelAsync(Guid orderId, string reason); |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @ -1,16 +0,0 @@ | |||||||
| using KonSoft.Admin.Dtos; |  | ||||||
| using System; |  | ||||||
| using System.Collections.Generic; |  | ||||||
| using System.Linq; |  | ||||||
| using System.Text; |  | ||||||
| using System.Threading.Tasks; |  | ||||||
|  |  | ||||||
| namespace KonSoft.Admin.IApplicationServices |  | ||||||
| { |  | ||||||
|     public interface IServiceCategoryAppService |  | ||||||
|     { |  | ||||||
|         Task<ServiceCategoryDto> CreateAsync(CreateServiceCategoryDto input); |  | ||||||
|         Task DeleteAsync(Guid id); |  | ||||||
|         Task<List<ServiceCategoryDto>> GetTreeAsync(); |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @ -1,13 +0,0 @@ | |||||||
| using System; |  | ||||||
| using System.Collections.Generic; |  | ||||||
| using System.Linq; |  | ||||||
| using System.Text; |  | ||||||
| using System.Threading.Tasks; |  | ||||||
| using Volo.Abp.Application.Services; |  | ||||||
|  |  | ||||||
| namespace KonSoft.Admin.IApplicationServices |  | ||||||
| { |  | ||||||
|     public interface IWorkerAppService : IApplicationService |  | ||||||
|     { |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @ -1,15 +0,0 @@ | |||||||
| using System; |  | ||||||
| using System.Collections.Generic; |  | ||||||
| using System.Linq; |  | ||||||
| using System.Text; |  | ||||||
| using System.Threading.Tasks; |  | ||||||
|  |  | ||||||
| namespace KonSoft.Admin.IApplicationServices |  | ||||||
| { |  | ||||||
|     public interface IWorkerAssignmentService |  | ||||||
|     { |  | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @ -1,6 +1,4 @@ | |||||||
| using AutoMapper; | using AutoMapper; | ||||||
| using KonSoft.Admin.Dtos; |  | ||||||
| using KonSoft.Admin.Entities; |  | ||||||
|  |  | ||||||
| namespace KonSoft.Admin; | namespace KonSoft.Admin; | ||||||
|  |  | ||||||
| @ -11,10 +9,5 @@ public class AdminApplicationAutoMapperProfile : Profile | |||||||
|         /* You can configure your AutoMapper mapping configuration here. |         /* You can configure your AutoMapper mapping configuration here. | ||||||
|          * Alternatively, you can split your mapping configurations |          * Alternatively, you can split your mapping configurations | ||||||
|          * into multiple profile classes for a better organization. */ |          * into multiple profile classes for a better organization. */ | ||||||
|  |  | ||||||
|         CreateMap<Order, OrderDto>(); |  | ||||||
|         //CreateMap<CreateOrderDto, Order>(); |  | ||||||
|         CreateMap<AddressDto, AddressInfo>(); |  | ||||||
|         CreateMap<ServiceCategoryDto, ServiceCategory>(); |  | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | |||||||
| @ -1,168 +0,0 @@ | |||||||
| using KonSoft.Admin.Dtos; |  | ||||||
| using KonSoft.Admin.Entities; |  | ||||||
| using KonSoft.Admin.IApplicationServices; |  | ||||||
| using KonSoft.Admin.Repositories; |  | ||||||
| using System; |  | ||||||
| using System.Collections.Generic; |  | ||||||
| using System.Linq; |  | ||||||
| using System.Text; |  | ||||||
| using System.Threading.Tasks; |  | ||||||
| using Volo.Abp; |  | ||||||
| using Volo.Abp.Application.Dtos; |  | ||||||
| using Volo.Abp.Application.Services; |  | ||||||
| using Volo.Abp.Domain.Repositories; |  | ||||||
| using Volo.Abp.ObjectMapping; |  | ||||||
|  |  | ||||||
| namespace KonSoft.Admin.ApplicationServices |  | ||||||
| { |  | ||||||
|     public class OrderAppService(IOrderRepository orderRepository) : ApplicationService, IOrderAppService |  | ||||||
|     { |  | ||||||
|         private readonly IOrderRepository _orderRepository = orderRepository; |  | ||||||
|  |  | ||||||
|         /// <summary> |  | ||||||
|         /// 分配师傅 |  | ||||||
|         /// </summary> |  | ||||||
|         /// <param name="orderId"></param> |  | ||||||
|         /// <param name="workerId"></param> |  | ||||||
|         /// <returns></returns> |  | ||||||
|         /// <exception cref="NotImplementedException"></exception> |  | ||||||
|         public async Task AssignAsync(Guid orderId, Guid workerId) |  | ||||||
|         { |  | ||||||
|             var order = await _orderRepository.GetAsync(o => o.Id == orderId); |  | ||||||
|             order.AssignWorker(workerId); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         /// <summary> |  | ||||||
|         /// 取消订单 |  | ||||||
|         /// </summary> |  | ||||||
|         /// <param name="orderId"></param> |  | ||||||
|         /// <param name="reason"></param> |  | ||||||
|         /// <returns></returns> |  | ||||||
|         /// <exception cref="NotImplementedException"></exception> |  | ||||||
|         public async Task CancelAsync(Guid orderId, string reason) |  | ||||||
|         { |  | ||||||
|             var order = await _orderRepository.GetAsync(o => o.Id == orderId); |  | ||||||
|             order.Cancel(reason); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         /// <summary> |  | ||||||
|         /// 完成订单 |  | ||||||
|         /// </summary> |  | ||||||
|         /// <param name="orderId"></param> |  | ||||||
|         /// <returns></returns> |  | ||||||
|         /// <exception cref="NotImplementedException"></exception> |  | ||||||
|         public async Task CompleteServiceAsync(Guid orderId) |  | ||||||
|         { |  | ||||||
|             var order = await _orderRepository.GetAsync(o => o.Id == orderId); |  | ||||||
|             order.CompleteService(); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         /// <summary> |  | ||||||
|         /// 确认订单 |  | ||||||
|         /// </summary> |  | ||||||
|         /// <param name="orderId"></param> |  | ||||||
|         /// <returns></returns> |  | ||||||
|         /// <exception cref="NotImplementedException"></exception> |  | ||||||
|         public async Task ConfirmAsync(Guid orderId) |  | ||||||
|         { |  | ||||||
|             var order = await _orderRepository.GetAsync(o => o.Id == orderId); |  | ||||||
|             order.ConfirmCompletion(); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         /// <summary> |  | ||||||
|         /// 创建订单 |  | ||||||
|         /// </summary> |  | ||||||
|         /// <param name="input"></param> |  | ||||||
|         /// <returns></returns> |  | ||||||
|         /// <exception cref="NotImplementedException"></exception> |  | ||||||
|         public async Task<OrderDto> CreateAsync(CreateOrderDto input) |  | ||||||
|         { |  | ||||||
|             // 生成订单号 TODO |  | ||||||
|             var orderSN = "SN001"; |  | ||||||
|             var address = ObjectMapper.Map<AddressDto, AddressInfo>(input.Address); |  | ||||||
|             var order = new Order(Guid.NewGuid(), orderSN, input.CustomerId, input.ServiceCategoryId, input.ServiceTime, input.Amount, address, input.Remark); |  | ||||||
|  |  | ||||||
|             await _orderRepository.InsertAsync(order); |  | ||||||
|             return ObjectMapper.Map<Order, OrderDto>(order); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         /// <summary> |  | ||||||
|         /// 根据订单ID删除订单 |  | ||||||
|         /// </summary> |  | ||||||
|         /// <param name="id">订单ID</param> |  | ||||||
|         public async Task DeleteAsync(params Guid[] ids) |  | ||||||
|         { |  | ||||||
|             // 根据ID删除订单 |  | ||||||
|             await _orderRepository.DeleteAsync(x => ids.Contains(x.Id)); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         /// <summary> |  | ||||||
|         /// 修改订单信息 |  | ||||||
|         /// </summary> |  | ||||||
|         /// <param name="input">订单DTO对象</param>s |  | ||||||
|         public async Task EditAsync(OrderDto input) |  | ||||||
|         { |  | ||||||
|             // 根据ID查询订单,如果不存在则抛出异常【修改前端必然看到了,数据若查不到提示自定义异常信息】 |  | ||||||
|             var order = await _orderRepository.FindAsync(o => o.Id == input.Id) ?? |  | ||||||
|                 throw new BusinessException("订单找不到").WithData("Id", input.Id); |  | ||||||
|  |  | ||||||
|             // 将输入的DTO字段映射到订单实体 |  | ||||||
|             ObjectMapper.Map(input, order); |  | ||||||
|  |  | ||||||
|             // 更新订单 |  | ||||||
|             await _orderRepository.UpdateAsync(order); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         /// <summary> |  | ||||||
|         /// 支付 |  | ||||||
|         /// </summary> |  | ||||||
|         /// <param name="orderId"></param> |  | ||||||
|         /// <param name="input"></param> |  | ||||||
|         /// <returns></returns> |  | ||||||
|         /// <exception cref="NotImplementedException"></exception> |  | ||||||
|         public Task<OrderDto> PayAsync(Guid orderId, PayOrderDto input) |  | ||||||
|         { |  | ||||||
|             throw new NotImplementedException(); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         /// <summary> |  | ||||||
|         /// 开始订单 |  | ||||||
|         /// </summary> |  | ||||||
|         /// <param name="orderId"></param> |  | ||||||
|         /// <returns></returns> |  | ||||||
|         /// <exception cref="NotImplementedException"></exception> |  | ||||||
|         public async Task StartServiceAsync(Guid orderId) |  | ||||||
|         { |  | ||||||
|             var order = await _orderRepository.GetAsync(o => o.Id == orderId); |  | ||||||
|             order.StartService(); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         /// <summary> |  | ||||||
|         /// 根据订单ID获取单个订单 |  | ||||||
|         /// </summary> |  | ||||||
|         public async Task<OrderDto> GetAsync(Guid id) |  | ||||||
|         { |  | ||||||
|             // 根据ID从数据库查询订单 |  | ||||||
|             var order = await _orderRepository.GetAsync(o => o.Id == id); |  | ||||||
|  |  | ||||||
|             // 转换为OrderDto返回 |  | ||||||
|             return ObjectMapper.Map<Order, OrderDto>(order); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         /// <summary> |  | ||||||
|         /// 获取所有订单列表 |  | ||||||
|         /// </summary> |  | ||||||
|         public async Task<PagedResultDto<OrderDto>> GetListAsync(PageListInput input) |  | ||||||
|         { |  | ||||||
|             var skipCount = (input.Index - 1) * input.PageSize; |  | ||||||
|             // 查询所有订单 |  | ||||||
|             var orders = await _orderRepository.GetPagedListAsync(skipCount, input.PageSize, "Id"); |  | ||||||
|  |  | ||||||
|             var totalCount = await _orderRepository.CountAsync(); |  | ||||||
|  |  | ||||||
|             var orderDtos = ObjectMapper.Map<List<Order>, List<OrderDto>>(orders); |  | ||||||
|  |  | ||||||
|             return new PagedResultDto<OrderDto>(totalCount, orderDtos); |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @ -1,75 +0,0 @@ | |||||||
| using KonSoft.Admin.Dtos; |  | ||||||
| using KonSoft.Admin.Entities; |  | ||||||
| using KonSoft.Admin.IApplicationServices; |  | ||||||
| using System; |  | ||||||
| using System.Collections.Generic; |  | ||||||
| using System.Linq; |  | ||||||
| using System.Text; |  | ||||||
| using System.Threading.Tasks; |  | ||||||
| using Volo.Abp.Application.Services; |  | ||||||
| using Volo.Abp.Domain.Repositories; |  | ||||||
|  |  | ||||||
| namespace KonSoft.Admin.ApplicationServices |  | ||||||
| { |  | ||||||
|     public class ServiceCategoryAppService : ApplicationService, IServiceCategoryAppService |  | ||||||
|     { |  | ||||||
|         private readonly IRepository<ServiceCategory, Guid> _repository; |  | ||||||
|  |  | ||||||
|  |  | ||||||
|         public ServiceCategoryAppService(IRepository<ServiceCategory, Guid> repository) |  | ||||||
|         { |  | ||||||
|             _repository = repository; |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         public async Task<ServiceCategoryDto> CreateAsync(CreateServiceCategoryDto input) |  | ||||||
|         { |  | ||||||
|             ServiceCategory parent = null; |  | ||||||
|             if (input.ParentId.HasValue) |  | ||||||
|             { |  | ||||||
|                 parent = await _repository.GetAsync(input.ParentId.Value); |  | ||||||
|             } |  | ||||||
|  |  | ||||||
|             var category = new ServiceCategory(Guid.NewGuid(), input.Name); |  | ||||||
|             category.SetParent(parent); |  | ||||||
|  |  | ||||||
|  |  | ||||||
|             await _repository.InsertAsync(category); |  | ||||||
|  |  | ||||||
|  |  | ||||||
|             return ObjectMapper.Map<ServiceCategory, ServiceCategoryDto>(category); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         public async Task DeleteAsync(Guid id) |  | ||||||
|         { |  | ||||||
|             var hasChildren = await _repository.AnyAsync(c => c.ParentId == id); |  | ||||||
|             if (hasChildren) throw new InvalidOperationException("存在子节点无法删除!"); |  | ||||||
|  |  | ||||||
|  |  | ||||||
|             await _repository.DeleteAsync(o => o.Id == id); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         public async Task<List<ServiceCategoryDto>> GetTreeAsync() |  | ||||||
|         { |  | ||||||
|             var allCategories = await _repository.GetListAsync(); |  | ||||||
|  |  | ||||||
|             // 构建树 |  | ||||||
|             var lookup = allCategories.ToDictionary(c => c.Id, c => ObjectMapper.Map<ServiceCategory, ServiceCategoryDto>(c)); |  | ||||||
|             var rootList = new List<ServiceCategoryDto>(); |  | ||||||
|  |  | ||||||
|  |  | ||||||
|             foreach (var dto in lookup.Values) |  | ||||||
|             { |  | ||||||
|                 if (dto.ParentId.HasValue && lookup.ContainsKey(dto.ParentId.Value)) |  | ||||||
|                 { |  | ||||||
|                     lookup[dto.ParentId.Value].Children.Add(dto); |  | ||||||
|                 } |  | ||||||
|                 else |  | ||||||
|                 { |  | ||||||
|                     rootList.Add(dto); |  | ||||||
|                 } |  | ||||||
|             } |  | ||||||
|  |  | ||||||
|             return rootList.OrderBy(c => c.Name).ToList(); |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @ -1,20 +0,0 @@ | |||||||
| using KonSoft.Admin.Dtos; |  | ||||||
| using KonSoft.Admin.Entities; |  | ||||||
| using KonSoft.Admin.IApplicationServices; |  | ||||||
| using System; |  | ||||||
| using System.Collections.Generic; |  | ||||||
| using System.Linq; |  | ||||||
| using System.Text; |  | ||||||
| using System.Threading.Tasks; |  | ||||||
| using Volo.Abp.Application.Services; |  | ||||||
| using Volo.Abp.Domain.Repositories; |  | ||||||
|  |  | ||||||
| namespace KonSoft.Admin.ApplicationServices |  | ||||||
| { |  | ||||||
|     public class WorkerAppService : CrudAppService<Worker, WorkerDto, Guid>, IWorkerAppService |  | ||||||
|     { |  | ||||||
|         public WorkerAppService(IRepository<Worker, Guid> repository) : base(repository) |  | ||||||
|         { |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @ -1,27 +0,0 @@ | |||||||
| using KonSoft.Admin.Entities; |  | ||||||
| using KonSoft.Admin.IApplicationServices; |  | ||||||
| using System; |  | ||||||
| using System.Collections.Generic; |  | ||||||
| using System.Linq; |  | ||||||
| using System.Text; |  | ||||||
| using System.Threading.Tasks; |  | ||||||
| using Volo.Abp.Application.Services; |  | ||||||
| using Volo.Abp.Domain.Repositories; |  | ||||||
|  |  | ||||||
| namespace KonSoft.Admin.ApplicationServices |  | ||||||
| { |  | ||||||
|     /// <summary> |  | ||||||
|     /// 分配家政人员 TODO |  | ||||||
|     /// </summary> |  | ||||||
|     public class WorkerAssignmentService : ApplicationService, IWorkerAssignmentService |  | ||||||
|     { |  | ||||||
|         private readonly IRepository<Worker, Guid> _workerRepository; |  | ||||||
|         private readonly IRepository<Order, Guid> _orderRepository; |  | ||||||
|  |  | ||||||
|         public WorkerAssignmentService(IRepository<Worker, Guid> workerRepository, IRepository<Order, Guid> orderRepository) |  | ||||||
|         { |  | ||||||
|             _workerRepository = workerRepository; |  | ||||||
|             _orderRepository = orderRepository; |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @ -6,8 +6,8 @@ | |||||||
|     <RootNamespace>KonSoft.Admin</RootNamespace> |     <RootNamespace>KonSoft.Admin</RootNamespace> | ||||||
|   </PropertyGroup> |   </PropertyGroup> | ||||||
|   <ItemGroup> |   <ItemGroup> | ||||||
|     <ProjectReference Include="..\KonSoft.Admin.Domain\KonSoft.Admin.Domain.csproj" /> |     <ProjectReference Include="..\KonSoft.Admin.Domain\KonSoft.Admin.Domain.csproj"/> | ||||||
|     <ProjectReference Include="..\KonSoft.Admin.Application.Contracts\KonSoft.Admin.Application.Contracts.csproj" /> |     <ProjectReference Include="..\KonSoft.Admin.Application.Contracts\KonSoft.Admin.Application.Contracts.csproj"/> | ||||||
|   </ItemGroup> |   </ItemGroup> | ||||||
|   <ItemGroup> |   <ItemGroup> | ||||||
|     <PackageReference Include="Volo.Abp.Account.Application" Version="8.3.4" /> |     <PackageReference Include="Volo.Abp.Account.Application" Version="8.3.4" /> | ||||||
|  | |||||||
| @ -1,22 +0,0 @@ | |||||||
| using System; |  | ||||||
| using System.Collections.Generic; |  | ||||||
| using System.Linq; |  | ||||||
| using System.Text; |  | ||||||
| using System.Threading.Tasks; |  | ||||||
|  |  | ||||||
| namespace KonSoft.Admin.Enums |  | ||||||
| { |  | ||||||
|     public enum OrderStatus |  | ||||||
|     { |  | ||||||
|         PendingPayment,      // 待支付 |  | ||||||
|         PaidWaitingAssign,   // 已支付待派单 |  | ||||||
|         AssignedWaitingService, // 已派单待服务 |  | ||||||
|         InService,           // 服务中 |  | ||||||
|         WaitingConfirm,      // 待用户确认 |  | ||||||
|         Completed,           // 已完成 |  | ||||||
|         Canceled,            // 已取消 |  | ||||||
|         Refunding,           // 退款中 |  | ||||||
|         Refunded             // 已退款 |  | ||||||
|  |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @ -0,0 +1,10 @@ | |||||||
|  | namespace KonSoft.Admin.MultiTenancy; | ||||||
|  |  | ||||||
|  | public static class MultiTenancyConsts | ||||||
|  | { | ||||||
|  |     /* Enable/disable multi-tenancy easily in a single point. | ||||||
|  |      * If you will never need to multi-tenancy, you can remove | ||||||
|  |      * related modules and code parts, including this file. | ||||||
|  |      */ | ||||||
|  |     public const bool IsEnabled = true; | ||||||
|  | } | ||||||
| @ -1,5 +1,6 @@ | |||||||
| using Microsoft.Extensions.DependencyInjection; | using Microsoft.Extensions.DependencyInjection; | ||||||
| using Microsoft.Extensions.DependencyInjection.Extensions; | using Microsoft.Extensions.DependencyInjection.Extensions; | ||||||
|  | using KonSoft.Admin.MultiTenancy; | ||||||
| using Volo.Abp.AuditLogging; | using Volo.Abp.AuditLogging; | ||||||
| using Volo.Abp.BackgroundJobs; | using Volo.Abp.BackgroundJobs; | ||||||
| using Volo.Abp.Emailing; | using Volo.Abp.Emailing; | ||||||
| @ -55,6 +56,10 @@ public class AdminDomainModule : AbpModule | |||||||
|             options.Languages.Add(new LanguageInfo("es", "es", "Español")); |             options.Languages.Add(new LanguageInfo("es", "es", "Español")); | ||||||
|         }); |         }); | ||||||
|  |  | ||||||
|  |         Configure<AbpMultiTenancyOptions>(options => | ||||||
|  |         { | ||||||
|  |             options.IsEnabled = MultiTenancyConsts.IsEnabled; | ||||||
|  |         }); | ||||||
|  |  | ||||||
| #if DEBUG | #if DEBUG | ||||||
|         context.Services.Replace(ServiceDescriptor.Singleton<IEmailSender, NullEmailSender>()); |         context.Services.Replace(ServiceDescriptor.Singleton<IEmailSender, NullEmailSender>()); | ||||||
|  | |||||||
| @ -1,60 +0,0 @@ | |||||||
| using System; |  | ||||||
| using System.Collections.Generic; |  | ||||||
| using System.Linq; |  | ||||||
| using System.Text; |  | ||||||
| using System.Threading.Tasks; |  | ||||||
| using Volo.Abp.Domain.Entities; |  | ||||||
| using Volo.Abp.Domain.Values; |  | ||||||
|  |  | ||||||
| namespace KonSoft.Admin.Entities |  | ||||||
| { |  | ||||||
|     /// <summary> |  | ||||||
|     /// 地址 |  | ||||||
|     /// </summary> |  | ||||||
|     public class AddressInfo :  ValueObject |  | ||||||
|     { |  | ||||||
|         /// <summary> |  | ||||||
|         /// 联系人 |  | ||||||
|         /// </summary> |  | ||||||
|         public string ContactName { get; private set; } |  | ||||||
|         /// <summary> |  | ||||||
|         /// 手机号 |  | ||||||
|         /// </summary> |  | ||||||
|         public string ContactPhone { get; private set; } |  | ||||||
|         /// <summary> |  | ||||||
|         /// 详细地址 |  | ||||||
|         /// </summary> |  | ||||||
|         public string DetailAddress { get; private set; } |  | ||||||
|         /// <summary> |  | ||||||
|         /// 城市 |  | ||||||
|         /// </summary> |  | ||||||
|         public string City { get; private set; } |  | ||||||
|         /// <summary> |  | ||||||
|         /// 区域 |  | ||||||
|         /// </summary> |  | ||||||
|         public string District { get; private set; } |  | ||||||
|  |  | ||||||
|  |  | ||||||
|         public AddressInfo() { } |  | ||||||
|  |  | ||||||
|         public AddressInfo(string contactName, string contactPhone, string detailAddress, string city, string district) |  | ||||||
|         { |  | ||||||
|             ContactName = contactName; |  | ||||||
|             ContactPhone = contactPhone; |  | ||||||
|             DetailAddress = detailAddress; |  | ||||||
|             City = city; |  | ||||||
|             District = district; |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|  |  | ||||||
|         protected override IEnumerable<object> GetAtomicValues() |  | ||||||
|         { |  | ||||||
|             yield return ContactName; |  | ||||||
|             yield return ContactPhone; |  | ||||||
|             yield return DetailAddress; |  | ||||||
|             yield return City; |  | ||||||
|             yield return District; |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @ -1,157 +0,0 @@ | |||||||
| using KonSoft.Admin.Enums; |  | ||||||
| using System; |  | ||||||
| using System.Collections.Generic; |  | ||||||
| using System.Linq; |  | ||||||
| using System.Text; |  | ||||||
| using System.Threading.Tasks; |  | ||||||
| using Volo.Abp.Domain.Entities.Auditing; |  | ||||||
| using Volo.Abp.Identity; |  | ||||||
|  |  | ||||||
| namespace KonSoft.Admin.Entities |  | ||||||
| { |  | ||||||
|     public class Order : FullAuditedAggregateRoot<Guid> |  | ||||||
|     { |  | ||||||
|         /// <summary> |  | ||||||
|         /// 订单编号 |  | ||||||
|         /// </summary> |  | ||||||
|         public string OrderSN { get; private set; } |  | ||||||
|  |  | ||||||
|         /// <summary> |  | ||||||
|         /// 用户ID |  | ||||||
|         /// </summary> |  | ||||||
|         public Guid  CustomerId { get; private set; } |  | ||||||
|         /// <summary> |  | ||||||
|         /// 家政人员ID |  | ||||||
|         /// </summary> |  | ||||||
|         public Guid? WorkerId { get; private set; } |  | ||||||
|  |  | ||||||
|         ///// <summary> |  | ||||||
|         ///// 用户ID |  | ||||||
|         ///// </summary> |  | ||||||
|         //public virtual IdentityUser Customer { get; private set; } |  | ||||||
|         ///// <summary> |  | ||||||
|         ///// 家政人员ID |  | ||||||
|         ///// </summary> |  | ||||||
|         //public virtual IdentityUser? Worker { get; private set; } |  | ||||||
|         /// <summary> |  | ||||||
|         /// 服务项目ID |  | ||||||
|         /// </summary> |  | ||||||
|         public Guid ServiceCategoryId { get; private set; } |  | ||||||
|  |  | ||||||
|         public virtual ServiceCategory ServiceCategory { get; private set; } |  | ||||||
|  |  | ||||||
|         /// <summary> |  | ||||||
|         /// 服务预约时间 |  | ||||||
|         /// </summary> |  | ||||||
|         public DateTime ServiceTime { get; private set; } |  | ||||||
|  |  | ||||||
|         public OrderStatus Status { get; private set; } |  | ||||||
|  |  | ||||||
|         /// <summary> |  | ||||||
|         /// 应付金额 |  | ||||||
|         /// </summary> |  | ||||||
|         public decimal Amount { get; private set; } |  | ||||||
|         /// <summary> |  | ||||||
|         /// 实付金额 |  | ||||||
|         /// </summary> |  | ||||||
|         public decimal PaidAmount { get; private set; } |  | ||||||
|         /// <summary> |  | ||||||
|         /// 支付方式 |  | ||||||
|         /// </summary> |  | ||||||
|         public string PaymentMethod { get; private set; } |  | ||||||
|         /// <summary> |  | ||||||
|         /// 地址 |  | ||||||
|         /// </summary> |  | ||||||
|         public AddressInfo Address { get; private set; } |  | ||||||
|  |  | ||||||
|         /// <summary> |  | ||||||
|         /// 备注 |  | ||||||
|         /// </summary> |  | ||||||
|         public string? Remark { get; private set; } |  | ||||||
|         /// <summary> |  | ||||||
|         /// 取消原因 |  | ||||||
|         /// </summary> |  | ||||||
|         public string? CancelReason { get; private set; } |  | ||||||
|  |  | ||||||
|         protected Order() { } |  | ||||||
|  |  | ||||||
|  |  | ||||||
|         public Order(Guid id, string orderSN, Guid customerId, Guid serviceCategoryId, DateTime serviceTime, decimal amount, AddressInfo address, string remark = null) |  | ||||||
|         : base(id) |  | ||||||
|         { |  | ||||||
|             OrderSN = orderSN; |  | ||||||
|             CustomerId = customerId; |  | ||||||
|             ServiceCategoryId = serviceCategoryId; |  | ||||||
|             ServiceTime = serviceTime; |  | ||||||
|             Amount = amount; |  | ||||||
|             Address = address; |  | ||||||
|             Remark = remark; |  | ||||||
|             Status = OrderStatus.PendingPayment; |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|  |  | ||||||
|         public void MarkPaid(decimal paidAmount, string method) |  | ||||||
|         { |  | ||||||
|             if (Status != OrderStatus.PendingPayment) |  | ||||||
|                 throw new InvalidOperationException("订单不在待付款状态"); |  | ||||||
|  |  | ||||||
|  |  | ||||||
|             PaidAmount = paidAmount; |  | ||||||
|             PaymentMethod = method; |  | ||||||
|             Status = OrderStatus.PaidWaitingAssign; |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|  |  | ||||||
|         public void AssignWorker(Guid workerId) |  | ||||||
|         { |  | ||||||
|             if (Status != OrderStatus.PaidWaitingAssign) |  | ||||||
|                 throw new InvalidOperationException("订单无法分配师傅"); |  | ||||||
|  |  | ||||||
|  |  | ||||||
|             WorkerId = workerId; |  | ||||||
|             Status = OrderStatus.AssignedWaitingService; |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|  |  | ||||||
|         public void StartService() |  | ||||||
|         { |  | ||||||
|             if (Status != OrderStatus.AssignedWaitingService) |  | ||||||
|                 throw new InvalidOperationException("订单无法开始"); |  | ||||||
|  |  | ||||||
|  |  | ||||||
|             Status = OrderStatus.InService; |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|  |  | ||||||
|         public void CompleteService() |  | ||||||
|         { |  | ||||||
|             if (Status != OrderStatus.InService) |  | ||||||
|                 throw new InvalidOperationException("订单未开始服务,无法完成"); |  | ||||||
|  |  | ||||||
|  |  | ||||||
|             Status = OrderStatus.WaitingConfirm; |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|  |  | ||||||
|         public void ConfirmCompletion() |  | ||||||
|         { |  | ||||||
|             if (Status != OrderStatus.WaitingConfirm) |  | ||||||
|                 throw new InvalidOperationException("订单无法确认"); |  | ||||||
|  |  | ||||||
|  |  | ||||||
|             Status = OrderStatus.Completed; |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|  |  | ||||||
|         public void Cancel(string reason) |  | ||||||
|         { |  | ||||||
|             // 若已完成或退款中则不可取消 |  | ||||||
|             if (Status == OrderStatus.Completed || Status == OrderStatus.Refunding || Status == OrderStatus.Refunded) |  | ||||||
|                 throw new InvalidOperationException("订单无法被取消"); |  | ||||||
|  |  | ||||||
|  |  | ||||||
|             CancelReason = reason; |  | ||||||
|             Status = OrderStatus.Canceled; |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @ -1,46 +0,0 @@ | |||||||
| using System; |  | ||||||
| using System.Collections.Generic; |  | ||||||
| using System.Linq; |  | ||||||
| using System.Text; |  | ||||||
| using System.Threading.Tasks; |  | ||||||
| using Volo.Abp.Domain.Entities.Auditing; |  | ||||||
|  |  | ||||||
| namespace KonSoft.Admin.Entities |  | ||||||
| { |  | ||||||
|     public class ServiceCategory : FullAuditedAggregateRoot<Guid> |  | ||||||
|     { |  | ||||||
|         public string Name { get; private set; } |  | ||||||
|         public Guid? ParentId { get; private set; } |  | ||||||
|         public string Path { get; private set; } |  | ||||||
|         public int Level { get; private set; } |  | ||||||
|  |  | ||||||
|         protected ServiceCategory() { } |  | ||||||
|  |  | ||||||
|         public ServiceCategory(Guid id, string name) |  | ||||||
|             : base(id) |  | ||||||
|         { |  | ||||||
|             Name = name; |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         public ServiceCategory(Guid id, string name, Guid? parentId = null, string path = null, int level = 0) : base(id) |  | ||||||
|         { |  | ||||||
|             Name = name; |  | ||||||
|             ParentId = parentId; |  | ||||||
|             Path = path ?? id.ToString(); |  | ||||||
|             Level = level; |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|  |  | ||||||
|         public void UpdateName(string name) => Name = name; |  | ||||||
|  |  | ||||||
|  |  | ||||||
|         public void SetParent(ServiceCategory parent) |  | ||||||
|         { |  | ||||||
|             ParentId = parent?.Id; |  | ||||||
|             Level = (parent?.Level ?? 0) + 1; |  | ||||||
|             Path = parent != null ? $"{parent.Path}/{Id}" : Id.ToString(); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|  |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @ -1,34 +0,0 @@ | |||||||
| using KonSoft.Admin.Enums; |  | ||||||
| using System; |  | ||||||
| using System.Collections.Generic; |  | ||||||
| using System.Linq; |  | ||||||
| using System.Text; |  | ||||||
| using System.Threading.Tasks; |  | ||||||
| using Volo.Abp.Domain.Entities.Auditing; |  | ||||||
|  |  | ||||||
| namespace KonSoft.Admin.Entities |  | ||||||
| { |  | ||||||
|     /// <summary> |  | ||||||
|     /// 家政人员 |  | ||||||
|     /// </summary> |  | ||||||
|     public class Worker : FullAuditedAggregateRoot<Guid> |  | ||||||
|     { |  | ||||||
|         public string Name { get; private set; } |  | ||||||
|         public string Phone { get; private set; } |  | ||||||
|         public decimal Rating { get; private set; }  // 评分 |  | ||||||
|         public List<Guid> SkillCategoryIds { get; private set; } = new List<Guid>(); |  | ||||||
|  |  | ||||||
|         public Worker() { } |  | ||||||
|  |  | ||||||
|  |  | ||||||
|         public void UpdateRating(decimal newRating) |  | ||||||
|         { |  | ||||||
|             Rating = newRating; |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         public bool CanPerform(Guid serviceCategoryId) |  | ||||||
|         { |  | ||||||
|             return SkillCategoryIds.Contains(serviceCategoryId); |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @ -1,14 +0,0 @@ | |||||||
| using KonSoft.Admin.Entities; |  | ||||||
| using System; |  | ||||||
| using System.Collections.Generic; |  | ||||||
| using System.Linq; |  | ||||||
| using System.Text; |  | ||||||
| using System.Threading.Tasks; |  | ||||||
| using Volo.Abp.Domain.Repositories; |  | ||||||
|  |  | ||||||
| namespace KonSoft.Admin.Repositories |  | ||||||
| { |  | ||||||
|     public interface IOrderRepository : IRepository<Order> |  | ||||||
|     { |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @ -1,5 +1,4 @@ | |||||||
| using KonSoft.Admin.Entities; | using Microsoft.EntityFrameworkCore; | ||||||
| using Microsoft.EntityFrameworkCore; |  | ||||||
| using Volo.Abp.AuditLogging.EntityFrameworkCore; | using Volo.Abp.AuditLogging.EntityFrameworkCore; | ||||||
| using Volo.Abp.BackgroundJobs.EntityFrameworkCore; | using Volo.Abp.BackgroundJobs.EntityFrameworkCore; | ||||||
| using Volo.Abp.Data; | using Volo.Abp.Data; | ||||||
| @ -54,12 +53,6 @@ public class AdminDbContext : | |||||||
|  |  | ||||||
|     #endregion |     #endregion | ||||||
|  |  | ||||||
|     #region 订单 |  | ||||||
|     public DbSet<Order> Order { get; set; } |  | ||||||
|     public DbSet<Worker> Worker { get; set; } |  | ||||||
|     public DbSet<ServiceCategory> ServiceCategory { get; set; } |  | ||||||
|     #endregion |  | ||||||
|  |  | ||||||
|     public AdminDbContext(DbContextOptions<AdminDbContext> options) |     public AdminDbContext(DbContextOptions<AdminDbContext> options) | ||||||
|         : base(options) |         : base(options) | ||||||
|     { |     { | ||||||
|  | |||||||
| @ -1,52 +0,0 @@ | |||||||
| using KonSoft.Admin.Entities; |  | ||||||
| using Microsoft.EntityFrameworkCore; |  | ||||||
| using System; |  | ||||||
| using System.Collections.Generic; |  | ||||||
| using System.Diagnostics.CodeAnalysis; |  | ||||||
| using System.Linq; |  | ||||||
| using System.Text; |  | ||||||
| using System.Threading.Tasks; |  | ||||||
| using Volo.Abp; |  | ||||||
|  |  | ||||||
| namespace KonSoft.Admin.EntityFrameworkCore.Configures |  | ||||||
| { |  | ||||||
|     public static class ApplicationDbContextModelBuilderExtensions |  | ||||||
|     { |  | ||||||
|         public static void ConfigureApplication([NotNull] this ModelBuilder builder) |  | ||||||
|         { |  | ||||||
|             Check.NotNull(builder, nameof(builder)); |  | ||||||
|  |  | ||||||
|             builder.Entity<Order>(b => |  | ||||||
|             { |  | ||||||
|                 b.ToTable(AdminConsts.DbTablePrefix + nameof(Order) + AdminConsts.DbSchema); |  | ||||||
|  |  | ||||||
|                 b.OwnsOne(o => o.Address, a => |  | ||||||
|                 { |  | ||||||
|                     a.Property(p => p.ContactName).HasColumnName("ContactName").HasMaxLength(50); |  | ||||||
|                     a.Property(p => p.ContactPhone).HasColumnName("ContactPhone").HasMaxLength(20); |  | ||||||
|                     a.Property(p => p.DetailAddress).HasColumnName("DetailAddress").HasMaxLength(200); |  | ||||||
|                     a.Property(p => p.City).HasColumnName("City").HasMaxLength(50); |  | ||||||
|                     a.Property(p => p.District).HasColumnName("District").HasMaxLength(50); |  | ||||||
|                 }); |  | ||||||
|             }); |  | ||||||
|  |  | ||||||
|             builder.Entity<Worker>(b => |  | ||||||
|             { |  | ||||||
|                 b.ToTable(AdminConsts.DbTablePrefix + nameof(Worker) + AdminConsts.DbSchema); |  | ||||||
|  |  | ||||||
|  |  | ||||||
|             }); |  | ||||||
|  |  | ||||||
|  |  | ||||||
|             builder.Entity<ServiceCategory>(b => |  | ||||||
|             { |  | ||||||
|                 b.ToTable(AdminConsts.DbTablePrefix + nameof(ServiceCategory) + AdminConsts.DbSchema); |  | ||||||
|  |  | ||||||
|  |  | ||||||
|             }); |  | ||||||
|  |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|  |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @ -1,21 +0,0 @@ | |||||||
| using KonSoft.Admin.Entities; |  | ||||||
| using KonSoft.Admin.Repositories; |  | ||||||
| using System; |  | ||||||
| using System.Collections.Generic; |  | ||||||
| using System.Linq; |  | ||||||
| using System.Text; |  | ||||||
| using System.Threading; |  | ||||||
| using System.Threading.Tasks; |  | ||||||
| using Volo.Abp.Domain.Repositories; |  | ||||||
| using Volo.Abp.Domain.Repositories.EntityFrameworkCore; |  | ||||||
| using Volo.Abp.EntityFrameworkCore; |  | ||||||
|  |  | ||||||
| namespace KonSoft.Admin.EntityFrameworkCore.Repositories |  | ||||||
| { |  | ||||||
|     public class OrderRepository : EfCoreRepository<AdminDbContext, Order>, IOrderRepository |  | ||||||
|     { |  | ||||||
|         public OrderRepository(IDbContextProvider<AdminDbContext> dbContextProvider) : base(dbContextProvider) |  | ||||||
|         { |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @ -1,27 +0,0 @@ | |||||||
| using System; |  | ||||||
| using Microsoft.AspNetCore.Builder; |  | ||||||
| using Microsoft.Extensions.DependencyInjection; |  | ||||||
| using Swashbuckle.AspNetCore.SwaggerUI; |  | ||||||
| using Volo.Abp.Swashbuckle; |  | ||||||
|  |  | ||||||
| namespace KonSoft.Shared.Hosting.AspNetCore; |  | ||||||
|  |  | ||||||
| public static class AbpSwaggerUIBuilderExtensions |  | ||||||
| { |  | ||||||
|     public static IApplicationBuilder UseAbpSwaggerWithCustomScriptUI( |  | ||||||
|         this IApplicationBuilder app, |  | ||||||
|         Action<SwaggerUIOptions>? setupAction = null) |  | ||||||
|     { |  | ||||||
|         var resolver = app.ApplicationServices.GetService<ISwaggerHtmlResolver>(); |  | ||||||
|  |  | ||||||
|         return app.UseSwaggerUI(options => |  | ||||||
|         { |  | ||||||
|             options.InjectJavascript("ui/abp.js"); |  | ||||||
|             options.InjectJavascript("ui/abp.swagger.js"); |  | ||||||
|             options.InjectJavascript("ui/requestinterceptor.js"); |  | ||||||
|             options.IndexStream = () => resolver?.Resolver(); |  | ||||||
|  |  | ||||||
|             setupAction?.Invoke(options); |  | ||||||
|         }); |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @ -1,24 +0,0 @@ | |||||||
| using System.Threading.Tasks; |  | ||||||
| using Microsoft.AspNetCore.Builder; |  | ||||||
| using Microsoft.Extensions.DependencyInjection; |  | ||||||
| using Microsoft.Extensions.Hosting; |  | ||||||
| using Serilog; |  | ||||||
| using Volo.Abp.Modularity; |  | ||||||
|  |  | ||||||
| namespace KonSoft.Shared.Hosting.AspNetCore; |  | ||||||
|  |  | ||||||
| public static class ApplicationBuilderHelper |  | ||||||
| { |  | ||||||
|     public static async Task<WebApplication> BuildApplicationAsync<TStartupModule>(string[] args) |  | ||||||
|         where TStartupModule : IAbpModule |  | ||||||
|     { |  | ||||||
|         var builder = WebApplication.CreateBuilder(args); |  | ||||||
|         builder.Host |  | ||||||
|             .AddAppSettingsSecretsJson() |  | ||||||
|             .UseAutofac() |  | ||||||
|             .UseSerilog(); |  | ||||||
|  |  | ||||||
|         await builder.AddApplicationAsync<TStartupModule>(); |  | ||||||
|         return builder.Build(); |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @ -1,36 +0,0 @@ | |||||||
| <Project Sdk="Microsoft.NET.Sdk"> |  | ||||||
|  |  | ||||||
|   <PropertyGroup> |  | ||||||
|     <TargetFramework>net8.0</TargetFramework> |  | ||||||
| 		<RootNamespace>KonSoft.Shared.Hosting.AspNetCore</RootNamespace> |  | ||||||
| 	  <Nullable>enable</Nullable> |  | ||||||
|   </PropertyGroup> |  | ||||||
|  |  | ||||||
|   <ItemGroup> |  | ||||||
|     <ProjectReference Include="..\KonSoft.Shared.Hosting\KonSoft.Shared.Hosting.csproj" /> |  | ||||||
|     <ProjectReference Include="..\KonSoft.Shared.Localization\KonSoft.Shared.Localization.csproj" /> |  | ||||||
|   </ItemGroup> |  | ||||||
|  |  | ||||||
| 	<ItemGroup> |  | ||||||
| 		<PackageReference Include="Serilog.AspNetCore" Version="8.0.1" /> |  | ||||||
| 		<PackageReference Include="Volo.Abp.AspNetCore.Serilog" Version="8.3.4" /> |  | ||||||
| 		<PackageReference Include="Volo.Abp.AspNetCore.MultiTenancy" Version="8.3.4" /> |  | ||||||
| 		<PackageReference Include="Volo.Abp.Swashbuckle" Version="8.3.4" /> |  | ||||||
| 	</ItemGroup> |  | ||||||
|  |  | ||||||
| 	<ItemGroup> |  | ||||||
| 		<None Remove="wwwroot\swagger\ui\requestinterceptor.js" /> |  | ||||||
| 	</ItemGroup> |  | ||||||
|  |  | ||||||
| 	<ItemGroup> |  | ||||||
| 		<Content Include="wwwroot\swagger\ui\requestinterceptor.js"> |  | ||||||
| 			<ExcludeFromSingleFile>true</ExcludeFromSingleFile> |  | ||||||
| 			<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory> |  | ||||||
| 		</Content> |  | ||||||
| 	</ItemGroup> |  | ||||||
|  |  | ||||||
| 	<ItemGroup> |  | ||||||
| 		<EmbeddedResource Include="wwwroot\swagger\ui\requestinterceptor.js" /> |  | ||||||
| 	</ItemGroup> |  | ||||||
|  |  | ||||||
| </Project> |  | ||||||
| @ -1,11 +0,0 @@ | |||||||
| using Volo.Abp.DependencyInjection; |  | ||||||
| using Volo.Abp.Ui.Branding; |  | ||||||
|  |  | ||||||
| namespace KonSoft.Shared.Hosting.AspNetCore |  | ||||||
| { |  | ||||||
|     [Dependency(ReplaceServices = true)] |  | ||||||
|     public class KonSoftBrandingProvider : DefaultBrandingProvider |  | ||||||
|     { |  | ||||||
|         public override string AppName => "KonSoft"; |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @ -1,8 +0,0 @@ | |||||||
| namespace KonSoft.Shared.Hosting.AspNetCore; |  | ||||||
|  |  | ||||||
| public static class KonSoftConsts |  | ||||||
| { |  | ||||||
|     public const string AuthServerAudience = "KonSoft"; |  | ||||||
|     public const string AnonymousUserClaimName = "anonymous_id"; |  | ||||||
|     public const bool MultiTenancyEnabled = true; |  | ||||||
| } |  | ||||||
| @ -1,32 +0,0 @@ | |||||||
| using KonSoft.Shared.Localization; |  | ||||||
| using Volo.Abp.AspNetCore.Serilog; |  | ||||||
| using Volo.Abp.Modularity; |  | ||||||
| using Volo.Abp.MultiTenancy; |  | ||||||
| using Volo.Abp.Swashbuckle; |  | ||||||
| using Volo.Abp.VirtualFileSystem; |  | ||||||
|  |  | ||||||
| namespace KonSoft.Shared.Hosting.AspNetCore |  | ||||||
| { |  | ||||||
|     [DependsOn( |  | ||||||
|         typeof(KonSoftSharedLocalizationModule), |  | ||||||
|         typeof(KonSoftSharedHostingModule), |  | ||||||
|         typeof(AbpAspNetCoreSerilogModule), |  | ||||||
|         typeof(AbpSwashbuckleModule), |  | ||||||
|         typeof(AbpMultiTenancyModule) |  | ||||||
|     )] |  | ||||||
|     public class KonSoftSharedHostingAspNetCoreModule : AbpModule |  | ||||||
|     { |  | ||||||
|         public override void ConfigureServices(ServiceConfigurationContext context) |  | ||||||
|         { |  | ||||||
|             Configure<AbpVirtualFileSystemOptions>(options => |  | ||||||
|             { |  | ||||||
|                 options.FileSets.AddEmbedded<KonSoftSharedHostingAspNetCoreModule>("KonSoft.Shared.Hosting.AspNetCore"); |  | ||||||
|             }); |  | ||||||
|  |  | ||||||
|             Configure<AbpMultiTenancyOptions>(options => |  | ||||||
|             { |  | ||||||
|                 options.IsEnabled = KonSoftConsts.MultiTenancyEnabled; |  | ||||||
|             }); |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @ -1,24 +0,0 @@ | |||||||
| using Serilog; |  | ||||||
| using Serilog.Events; |  | ||||||
|  |  | ||||||
| namespace KonSoft.Shared.Hosting.AspNetCore; |  | ||||||
|  |  | ||||||
| public static class SerilogConfigurationHelper |  | ||||||
| { |  | ||||||
|     public static void Configure(string applicationName) |  | ||||||
|     { |  | ||||||
|         Log.Logger = new LoggerConfiguration() |  | ||||||
| #if DEBUG |  | ||||||
|             .MinimumLevel.Debug() |  | ||||||
| #else |  | ||||||
|                 .MinimumLevel.Information() |  | ||||||
| #endif |  | ||||||
|             .MinimumLevel.Override("Microsoft", LogEventLevel.Information) |  | ||||||
|             .MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning) |  | ||||||
|             .Enrich.FromLogContext() |  | ||||||
|             .Enrich.WithProperty("Application", $"{applicationName}") |  | ||||||
|             .WriteTo.Async(c => c.File("Logs/logs.txt")) |  | ||||||
|             .WriteTo.Async(c => c.Console()) |  | ||||||
|             .CreateLogger(); |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @ -1,32 +0,0 @@ | |||||||
| using Microsoft.Extensions.DependencyInjection; |  | ||||||
| using Microsoft.OpenApi.Models; |  | ||||||
| using Volo.Abp.Modularity; |  | ||||||
|  |  | ||||||
| namespace KonSoft.Shared.Hosting.AspNetCore; |  | ||||||
|  |  | ||||||
| public static class SwaggerConfigurationHelper |  | ||||||
| { |  | ||||||
|     public static void ConfigureWithOidc( |  | ||||||
|         ServiceConfigurationContext context, |  | ||||||
|         string authority, |  | ||||||
|         string[] scopes, |  | ||||||
|         string apiTitle, |  | ||||||
|         string apiVersion = "v1", |  | ||||||
|         string apiName = "v1", |  | ||||||
|         string[]? flows = null, |  | ||||||
|         string? discoveryEndpoint = null |  | ||||||
|     ) |  | ||||||
|     { |  | ||||||
|         context.Services.AddAbpSwaggerGenWithOidc( |  | ||||||
|             authority: authority, |  | ||||||
|             scopes: scopes, |  | ||||||
|             flows: flows, |  | ||||||
|             discoveryEndpoint: discoveryEndpoint, |  | ||||||
|             options => |  | ||||||
|             { |  | ||||||
|                 options.SwaggerDoc(apiName, new OpenApiInfo { Title = apiTitle, Version = apiVersion }); |  | ||||||
|                 options.DocInclusionPredicate((docName, description) => true); |  | ||||||
|                 options.CustomSchemaIds(type => type.FullName); |  | ||||||
|             }); |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @ -1,9 +0,0 @@ | |||||||
| const originalFetch = window.fetch; |  | ||||||
|  |  | ||||||
| window.fetch = function (input, init) { |  | ||||||
|     if (init !== undefined && init.headers['RequestVerificationToken'] !== undefined) { |  | ||||||
|         delete init.headers['RequestVerificationToken']; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     return originalFetch.apply(this, arguments); |  | ||||||
| }; |  | ||||||
| @ -1,7 +0,0 @@ | |||||||
| namespace KonSoft.Shared.Hosting.Gateways |  | ||||||
| { |  | ||||||
|     public class Class1 |  | ||||||
|     { |  | ||||||
|  |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @ -1,109 +0,0 @@ | |||||||
| using Microsoft.EntityFrameworkCore; |  | ||||||
| using Microsoft.Extensions.DependencyInjection; |  | ||||||
| using Serilog; |  | ||||||
| using System; |  | ||||||
| using System.Linq; |  | ||||||
| using System.Threading.Tasks; |  | ||||||
| using Volo.Abp; |  | ||||||
| using Volo.Abp.Data; |  | ||||||
| using Volo.Abp.DependencyInjection; |  | ||||||
| using Volo.Abp.DistributedLocking; |  | ||||||
| using Volo.Abp.EventBus.Distributed; |  | ||||||
| using Volo.Abp.MultiTenancy; |  | ||||||
| using Volo.Abp.Uow; |  | ||||||
|  |  | ||||||
| namespace KonSoft.Shared.Hosting.Microservices.DbMigrations.EfCore |  | ||||||
| { |  | ||||||
|     public abstract class PendingEfCoreMigrationsChecker<TDbContext> : ITransientDependency |  | ||||||
|         where TDbContext : DbContext |  | ||||||
|     { |  | ||||||
|         protected IUnitOfWorkManager UnitOfWorkManager { get; } |  | ||||||
|         protected IServiceProvider ServiceProvider { get; } |  | ||||||
|         protected ICurrentTenant CurrentTenant { get; } |  | ||||||
|         protected IDistributedEventBus DistributedEventBus { get; } |  | ||||||
|         protected IAbpDistributedLock DistributedLockProvider { get; } |  | ||||||
|         protected string DatabaseName { get; } |  | ||||||
|  |  | ||||||
|         protected PendingEfCoreMigrationsChecker( |  | ||||||
|             IUnitOfWorkManager unitOfWorkManager, |  | ||||||
|             IServiceProvider serviceProvider, |  | ||||||
|             ICurrentTenant currentTenant, |  | ||||||
|             IDistributedEventBus distributedEventBus, |  | ||||||
|             IAbpDistributedLock abpDistributedLock, |  | ||||||
|             string databaseName) |  | ||||||
|         { |  | ||||||
|             UnitOfWorkManager = unitOfWorkManager; |  | ||||||
|             ServiceProvider = serviceProvider; |  | ||||||
|             CurrentTenant = currentTenant; |  | ||||||
|             DistributedEventBus = distributedEventBus; |  | ||||||
|             DistributedLockProvider = abpDistributedLock; |  | ||||||
|             DatabaseName = databaseName; |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         public virtual async Task CheckAndApplyDatabaseMigrationsAsync() |  | ||||||
|         { |  | ||||||
|             await TryAsync(LockAndApplyDatabaseMigrationsAsync); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         protected async Task TryAsync(Func<Task> task, int retryCount = 3) |  | ||||||
|         { |  | ||||||
|             try |  | ||||||
|             { |  | ||||||
|                 await task(); |  | ||||||
|             } |  | ||||||
|             catch (Exception ex) |  | ||||||
|             { |  | ||||||
|                 retryCount--; |  | ||||||
|  |  | ||||||
|                 if (retryCount <= 0) |  | ||||||
|                 { |  | ||||||
|                     throw; |  | ||||||
|                 } |  | ||||||
|  |  | ||||||
|                 Log.Warning($"{ex.GetType().Name} has been thrown. The operation will be tried {retryCount} times more. Exception:\n{ex.Message}"); |  | ||||||
|  |  | ||||||
|                 await Task.Delay(RandomHelper.GetRandom(5000, 15000)); |  | ||||||
|  |  | ||||||
|                 await TryAsync(task, retryCount); |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         protected virtual async Task LockAndApplyDatabaseMigrationsAsync() |  | ||||||
|         { |  | ||||||
|             await using (var handle = await DistributedLockProvider.TryAcquireAsync("Migration_" + DatabaseName)) |  | ||||||
|             { |  | ||||||
|                 Log.Information($"Lock is acquired for db migration and seeding on database named: {DatabaseName}..."); |  | ||||||
|  |  | ||||||
|                 if (handle is null) |  | ||||||
|                 { |  | ||||||
|                     Log.Information($"Handle is null because of the locking for : {DatabaseName}"); |  | ||||||
|                     return; |  | ||||||
|                 } |  | ||||||
|  |  | ||||||
|                 using (CurrentTenant.Change(null)) |  | ||||||
|                 { |  | ||||||
|                     // Create database tables if needed |  | ||||||
|                     using (var uow = UnitOfWorkManager.Begin(requiresNew: true, isTransactional: false)) |  | ||||||
|                     { |  | ||||||
|                         var dbContext = ServiceProvider.GetRequiredService<TDbContext>(); |  | ||||||
|  |  | ||||||
|                         var pendingMigrations = await dbContext |  | ||||||
|                             .Database |  | ||||||
|                             .GetPendingMigrationsAsync(); |  | ||||||
|  |  | ||||||
|                         if (pendingMigrations.Any()) |  | ||||||
|                         { |  | ||||||
|                             await dbContext.Database.MigrateAsync(); |  | ||||||
|                         } |  | ||||||
|  |  | ||||||
|                         await uow.CompleteAsync(); |  | ||||||
|                     } |  | ||||||
|  |  | ||||||
|                     await ServiceProvider.GetRequiredService<IDataSeeder>() |  | ||||||
|                         .SeedAsync(); |  | ||||||
|                 } |  | ||||||
|                 Log.Information($"Lock is released for db migration and seeding on database named: {DatabaseName}..."); |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @ -1,28 +0,0 @@ | |||||||
| <Project Sdk="Microsoft.NET.Sdk"> |  | ||||||
|  |  | ||||||
|   <PropertyGroup> |  | ||||||
|     <TargetFramework>net8.0</TargetFramework> |  | ||||||
| 		<RootNamespace>KonSoft.Shared.Hosting.Microservices</RootNamespace> |  | ||||||
| 	  <Nullable>enable</Nullable> |  | ||||||
|   </PropertyGroup> |  | ||||||
|  |  | ||||||
|   <ItemGroup> |  | ||||||
|     <ProjectReference Include="..\KonSoft.Shared.Hosting.AspNetCore\KonSoft.Shared.Hosting.AspNetCore.csproj" /> |  | ||||||
|   </ItemGroup> |  | ||||||
|  |  | ||||||
| 	<ItemGroup> |  | ||||||
| 		<PackageReference Include="Microsoft.AspNetCore.DataProtection.StackExchangeRedis" Version="8.0.4" /> |  | ||||||
| 		<PackageReference Include="DistributedLock.Redis" Version="1.1.0" /> |  | ||||||
| 	</ItemGroup> |  | ||||||
|  |  | ||||||
| 	<ItemGroup> |  | ||||||
| 		<PackageReference Include="Volo.Abp.AspNetCore.Authentication.JwtBearer" Version="8.3.4" /> |  | ||||||
| 		<PackageReference Include="Volo.Abp.EventBus.RabbitMQ" Version="8.3.4" /> |  | ||||||
| 		<PackageReference Include="Volo.Abp.BackgroundJobs.RabbitMQ" Version="8.3.4" /> |  | ||||||
| 		<PackageReference Include="Volo.Abp.Caching.StackExchangeRedis" Version="8.3.4" /> |  | ||||||
| 		<PackageReference Include="Volo.Abp.EntityFrameworkCore" Version="8.3.4" /> |  | ||||||
| 		<PackageReference Include="Volo.Abp.DistributedLocking" Version="8.3.4" /> |  | ||||||
| 		<PackageReference Include="Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy" Version="8.3.4" /> |  | ||||||
| 	</ItemGroup> |  | ||||||
|  |  | ||||||
| </Project> |  | ||||||
| @ -1,104 +0,0 @@ | |||||||
| using KonSoft.Shared.Hosting.AspNetCore; |  | ||||||
| using Medallion.Threading; |  | ||||||
| using Medallion.Threading.Redis; |  | ||||||
| using Microsoft.AspNetCore.Authentication.JwtBearer; |  | ||||||
| using Microsoft.AspNetCore.Cors; |  | ||||||
| using Microsoft.AspNetCore.DataProtection; |  | ||||||
| using Microsoft.Extensions.Configuration; |  | ||||||
| using Microsoft.Extensions.DependencyInjection; |  | ||||||
| using StackExchange.Redis; |  | ||||||
| using System; |  | ||||||
| using System.Linq; |  | ||||||
| using Volo.Abp.AspNetCore.Authentication.JwtBearer; |  | ||||||
| using Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy; |  | ||||||
| using Volo.Abp.BackgroundJobs.RabbitMQ; |  | ||||||
| using Volo.Abp.Caching; |  | ||||||
| using Volo.Abp.Caching.StackExchangeRedis; |  | ||||||
| using Volo.Abp.DistributedLocking; |  | ||||||
| using Volo.Abp.EntityFrameworkCore; |  | ||||||
| using Volo.Abp.EventBus.RabbitMq; |  | ||||||
| using Volo.Abp.Modularity; |  | ||||||
| using Volo.Abp.Security.Claims; |  | ||||||
| using Volo.Abp.Swashbuckle; |  | ||||||
|  |  | ||||||
| namespace KonSoft.Shared.Hosting.Microservices |  | ||||||
| { |  | ||||||
|     [DependsOn( |  | ||||||
|         typeof(KonSoftSharedHostingAspNetCoreModule), |  | ||||||
|         typeof(AbpBackgroundJobsRabbitMqModule), |  | ||||||
|         typeof(AbpAspNetCoreAuthenticationJwtBearerModule), |  | ||||||
|         typeof(AbpEventBusRabbitMqModule), |  | ||||||
|         typeof(AbpCachingStackExchangeRedisModule), |  | ||||||
|         typeof(AbpDistributedLockingModule), |  | ||||||
|         typeof(AbpAspNetCoreMvcUiMultiTenancyModule), |  | ||||||
|         typeof(AbpEntityFrameworkCoreModule), |  | ||||||
|         typeof(AbpSwashbuckleModule) |  | ||||||
|     )] |  | ||||||
|     public class KonSoftSharedHostingMicroservicesModule : AbpModule |  | ||||||
|     { |  | ||||||
|         public override void ConfigureServices(ServiceConfigurationContext context) |  | ||||||
|         { |  | ||||||
|             var configuration = context.Services.GetConfiguration(); |  | ||||||
|             var hostingEnvironment = context.Services.GetHostingEnvironment(); |  | ||||||
|  |  | ||||||
|             ConfigureCache(); |  | ||||||
|             ConfigureDataProtection(context, configuration); |  | ||||||
|             ConfigureAuthentication(context, configuration); |  | ||||||
|             ConfigureCors(context, configuration); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         private void ConfigureCache() |  | ||||||
|         { |  | ||||||
|             Configure<AbpDistributedCacheOptions>(options => { options.KeyPrefix = "KonSoft:"; }); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         private void ConfigureDataProtection( |  | ||||||
|             ServiceConfigurationContext context, |  | ||||||
|             IConfiguration configuration) |  | ||||||
|         { |  | ||||||
|             context.Services.AddDataProtection().SetApplicationName("KonSoft") |  | ||||||
|                 .PersistKeysToStackExchangeRedis(ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]!), |  | ||||||
|                     "KonSoft-Protection-Keys"); |  | ||||||
|  |  | ||||||
|             context.Services.AddSingleton<IDistributedLockProvider>(_ => |  | ||||||
|                 new RedisDistributedSynchronizationProvider(ConnectionMultiplexer |  | ||||||
|                     .Connect(configuration["Redis:Configuration"]!).GetDatabase())); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         private void ConfigureAuthentication(ServiceConfigurationContext context, IConfiguration configuration) |  | ||||||
|         { |  | ||||||
|             context.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) |  | ||||||
|                 .AddAbpJwtBearer(options => |  | ||||||
|                 { |  | ||||||
|                     options.Authority = configuration["AuthServer:Authority"]; |  | ||||||
|                     options.RequireHttpsMetadata = configuration.GetValue<bool>("AuthServer:RequireHttpsMetadata"); |  | ||||||
|                     options.Audience = KonSoftConsts.AuthServerAudience; |  | ||||||
|                 }); |  | ||||||
|  |  | ||||||
|             context.Services.Configure<AbpClaimsPrincipalFactoryOptions>(options => |  | ||||||
|             { |  | ||||||
|                 options.IsDynamicClaimsEnabled = true; |  | ||||||
|             }); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         private void ConfigureCors(ServiceConfigurationContext context, IConfiguration configuration) |  | ||||||
|         { |  | ||||||
|             context.Services.AddCors(options => |  | ||||||
|             { |  | ||||||
|                 options.AddDefaultPolicy(builder => |  | ||||||
|                 { |  | ||||||
|                     builder |  | ||||||
|                         .WithOrigins(configuration["App:CorsOrigins"]? |  | ||||||
|                             .Split(",", StringSplitOptions.RemoveEmptyEntries) |  | ||||||
|                             .Select(o => o.RemovePostFix("/")) |  | ||||||
|                             .ToArray() ?? []) |  | ||||||
|                         .WithAbpExposedHeaders() |  | ||||||
|                         .SetIsOriginAllowedToAllowWildcardSubdomains() |  | ||||||
|                         .AllowAnyHeader() |  | ||||||
|                         .AllowAnyMethod() |  | ||||||
|                         .AllowCredentials(); |  | ||||||
|                 }); |  | ||||||
|             }); |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @ -1,21 +0,0 @@ | |||||||
| <Project Sdk="Microsoft.NET.Sdk"> |  | ||||||
|  |  | ||||||
| 	<PropertyGroup> |  | ||||||
| 		<TargetFramework>net8.0</TargetFramework> |  | ||||||
| 		<RootNamespace>KonSoft.Shared.Hosting</RootNamespace> |  | ||||||
| 		<Nullable>enable</Nullable> |  | ||||||
| 	</PropertyGroup> |  | ||||||
|  |  | ||||||
| 	<ItemGroup> |  | ||||||
| 		<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" /> |  | ||||||
| 		<PackageReference Include="Serilog.Sinks.Async" Version="1.5.0" /> |  | ||||||
| 		<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" /> |  | ||||||
| 		<PackageReference Include="Serilog.Sinks.Console" Version="5.0.0" /> |  | ||||||
| 	</ItemGroup> |  | ||||||
|  |  | ||||||
| 	<ItemGroup> |  | ||||||
| 		<PackageReference Include="Volo.Abp.Autofac" Version="8.3.4" /> |  | ||||||
| 		<PackageReference Include="Volo.Abp.Data" Version="8.3.4" /> |  | ||||||
| 	</ItemGroup> |  | ||||||
|  |  | ||||||
| </Project> |  | ||||||
| @ -1,21 +0,0 @@ | |||||||
| using Volo.Abp.Autofac; |  | ||||||
| using Volo.Abp.Data; |  | ||||||
| using Volo.Abp.Modularity; |  | ||||||
|  |  | ||||||
| namespace KonSoft.Shared.Hosting |  | ||||||
| { |  | ||||||
|     [DependsOn( |  | ||||||
|         typeof(AbpAutofacModule), |  | ||||||
|         typeof(AbpDataModule) |  | ||||||
|     )] |  | ||||||
|     public class KonSoftSharedHostingModule : AbpModule |  | ||||||
|     { |  | ||||||
|         public override void ConfigureServices(ServiceConfigurationContext context) |  | ||||||
|         { |  | ||||||
|             Configure<AbpDbConnectionOptions>(options => |  | ||||||
|             { |  | ||||||
|                 // TODO Mapping DbConnections |  | ||||||
|             }); |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @ -1,24 +0,0 @@ | |||||||
| <Project Sdk="Microsoft.NET.Sdk"> |  | ||||||
|  |  | ||||||
|   <PropertyGroup> |  | ||||||
|     <TargetFramework>net8.0</TargetFramework> |  | ||||||
| 		<RootNamespace>KonSoft.Shared.Localization</RootNamespace> |  | ||||||
| 	  <Nullable>enable</Nullable> |  | ||||||
|   </PropertyGroup> |  | ||||||
|  |  | ||||||
| 	<ItemGroup> |  | ||||||
| 		<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="8.0.4" /> |  | ||||||
| 		<PackageReference Include="Volo.Abp.Validation" Version="8.3.4" /> |  | ||||||
| 	</ItemGroup> |  | ||||||
|  |  | ||||||
| 	<ItemGroup> |  | ||||||
| 		<EmbeddedResource Include="Localization\EShopOnAbp\*.json" /> |  | ||||||
| 		<Content Remove="Localization\EShopOnAbp\*.json" /> |  | ||||||
| 	</ItemGroup> |  | ||||||
|  |  | ||||||
| 	<ItemGroup> |  | ||||||
| 	  <EmbeddedResource Include="Localization\KonSoft\en.json" /> |  | ||||||
| 	  <EmbeddedResource Include="Localization\KonSoft\zh-Hans.json" /> |  | ||||||
| 	</ItemGroup> |  | ||||||
|  |  | ||||||
| </Project> |  | ||||||
| @ -1,35 +0,0 @@ | |||||||
| using KonSoft.Shared.Localization.Localization; |  | ||||||
| using Volo.Abp.Localization; |  | ||||||
| using Volo.Abp.Modularity; |  | ||||||
| using Volo.Abp.Validation; |  | ||||||
| using Volo.Abp.Validation.Localization; |  | ||||||
| using Volo.Abp.VirtualFileSystem; |  | ||||||
|  |  | ||||||
| namespace KonSoft.Shared.Localization |  | ||||||
| { |  | ||||||
|  |  | ||||||
|     [DependsOn( |  | ||||||
|         typeof(AbpValidationModule) |  | ||||||
|     )] |  | ||||||
|     public class KonSoftSharedLocalizationModule : AbpModule |  | ||||||
|     { |  | ||||||
|         public override void ConfigureServices(ServiceConfigurationContext context) |  | ||||||
|         { |  | ||||||
|             Configure<AbpVirtualFileSystemOptions>(options => |  | ||||||
|             { |  | ||||||
|                 options.FileSets.AddEmbedded<KonSoftSharedLocalizationModule>(); |  | ||||||
|             }); |  | ||||||
|  |  | ||||||
|             Configure<AbpLocalizationOptions>(options => |  | ||||||
|             { |  | ||||||
|                 options.Resources |  | ||||||
|                     .Add<KonSoftResource>("en") |  | ||||||
|                     .AddBaseTypes( |  | ||||||
|                         typeof(AbpValidationResource) |  | ||||||
|                     ).AddVirtualJson("/Localization/KonSoft"); |  | ||||||
|  |  | ||||||
|                 options.DefaultResourceType = typeof(KonSoftResource); |  | ||||||
|             }); |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @ -1,9 +0,0 @@ | |||||||
| { |  | ||||||
|   "culture": "en", |  | ||||||
|   "texts": { |  | ||||||
|     "AppName": "Admin", |  | ||||||
|     "Menu:Home": "Home", |  | ||||||
|     "Welcome": "Welcome", |  | ||||||
|     "LongWelcomeMessage": "Welcome to the application. This is a startup project based on the ABP framework. For more information, visit abp.io." |  | ||||||
|   } |  | ||||||
| } |  | ||||||
| @ -1,9 +0,0 @@ | |||||||
| { |  | ||||||
|   "culture": "zh-Hans", |  | ||||||
|   "texts": { |  | ||||||
|     "AppName": "Admin", |  | ||||||
|     "Menu:Home": "首页", |  | ||||||
|     "Welcome": "欢迎", |  | ||||||
|     "LongWelcomeMessage": "欢迎使用本应用程序。这是一个基于 ABP 框架的启动项目。更多信息,请访问 abp.io。" |  | ||||||
|   } |  | ||||||
| } |  | ||||||
| @ -1,9 +0,0 @@ | |||||||
| using Volo.Abp.Localization; |  | ||||||
|  |  | ||||||
| namespace KonSoft.Shared.Localization.Localization |  | ||||||
| { |  | ||||||
|     [LocalizationResourceName("KonSoft")] |  | ||||||
|     public class KonSoftResource |  | ||||||
|     { |  | ||||||
|     } |  | ||||||
| } |  | ||||||
							
								
								
									
										7
									
								
								shared/KonSoft.Shared/Class1.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								shared/KonSoft.Shared/Class1.cs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,7 @@ | |||||||
|  | namespace KonSoft.Shared | ||||||
|  | { | ||||||
|  |     public class Class1 | ||||||
|  |     { | ||||||
|  |  | ||||||
|  |     } | ||||||
|  | } | ||||||
| @ -2,8 +2,8 @@ | |||||||
| 
 | 
 | ||||||
|   <PropertyGroup> |   <PropertyGroup> | ||||||
|     <TargetFramework>net8.0</TargetFramework> |     <TargetFramework>net8.0</TargetFramework> | ||||||
| 		<RootNamespace>KonSoft.Shared.Hosting.Gateways</RootNamespace> |     <ImplicitUsings>enable</ImplicitUsings> | ||||||
| 	  <Nullable>enable</Nullable> |     <Nullable>enable</Nullable> | ||||||
|   </PropertyGroup> |   </PropertyGroup> | ||||||
| 
 | 
 | ||||||
| </Project> | </Project> | ||||||
		Reference in New Issue
	
	Block a user