Compare commits
1 Commits
ab1ffad658
...
dv_karl
| Author | SHA1 | Date | |
|---|---|---|---|
| fdfb005974 |
2
.gitignore
vendored
2
.gitignore
vendored
@ -263,5 +263,3 @@ src/KonSoft.Admin.Blazor.Server.Tiered/Logs/*
|
||||
|
||||
# Use abp install-libs to restore.
|
||||
**/wwwroot/libs/*
|
||||
|
||||
**/Logs/*
|
||||
0
KonSoft.BackgroundJobs
Normal file
0
KonSoft.BackgroundJobs
Normal file
0
KonSoft.BackgroundWorker
Normal file
0
KonSoft.BackgroundWorker
Normal file
60
KonSoft.sln
60
KonSoft.sln
@ -1,7 +1,7 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.14.36414.22
|
||||
VisualStudioVersion = 17.14.36414.22 d17.14
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "applications", "applications", "{02EA681E-C7D8-13C7-8484-4AC65E1B71E8}"
|
||||
EndProject
|
||||
@ -49,6 +49,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{E67FA5C3-132
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{1C06151A-45F0-4D48-8303-3D4CBE9517F7}"
|
||||
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}"
|
||||
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}"
|
||||
@ -183,27 +185,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KonSoft.Report.HttpApi.Host
|
||||
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}"
|
||||
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
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KonSoft.Shared.DbMigrator", "shared\KonSoft.Shared.DbMigrator\KonSoft.Shared.DbMigrator.csproj", "{AFCC65BC-8477-819B-2575-674AC9D2FDDD}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution items", "Solution items", "{72B7AEA8-8968-469E-AFFC-170E572D640F}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
.gitignore = .gitignore
|
||||
adminservice.Jenkinsfile = adminservice.Jenkinsfile
|
||||
authserver.Jenkinsfile = authserver.Jenkinsfile
|
||||
docker-compose.yml = docker-compose.yml
|
||||
internalgateway.Jenkinsfile = internalgateway.Jenkinsfile
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@ -222,6 +203,10 @@ Global
|
||||
{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.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.Build.0 = Debug|Any CPU
|
||||
{9D9D979A-AFC7-F9D0-2D23-8809E83F9EF9}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
@ -490,30 +475,6 @@ Global
|
||||
{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.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
|
||||
{AFCC65BC-8477-819B-2575-674AC9D2FDDD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{AFCC65BC-8477-819B-2575-674AC9D2FDDD}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{AFCC65BC-8477-819B-2575-674AC9D2FDDD}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{AFCC65BC-8477-819B-2575-674AC9D2FDDD}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
@ -537,6 +498,7 @@ Global
|
||||
{6C762F40-30BB-4CDA-951B-01D45F7C2B53} = {AAF02051-771B-4CC0-BD17-1A3643F83E09}
|
||||
{E67FA5C3-132C-4F47-B6A6-8FA4376C70BB} = {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}
|
||||
{9F68B0E2-0B1D-E0E8-1BE7-079F693A4643} = {EBCB740D-07E7-4CED-A422-90EB824B9021}
|
||||
{D1A86C77-533D-5B68-04F1-7F7BFBF56AC7} = {EBCB740D-07E7-4CED-A422-90EB824B9021}
|
||||
@ -604,12 +566,6 @@ Global
|
||||
{9A034977-0FBC-A3C8-8432-9FDD073F215A} = {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}
|
||||
{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}
|
||||
{AFCC65BC-8477-819B-2575-674AC9D2FDDD} = {7EFFD2C6-2041-4967-A715-0F817D70C433}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {28315BFD-90E7-4E14-A2EA-F3D23AF4126F}
|
||||
|
||||
@ -20,6 +20,4 @@
|
||||
<s:String x:Key="/Default/CodeStyle/Generate/=Overrides/Options/=Async/@EntryIndexedValue">False</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Generate/=Overrides/Options/=Mutable/@EntryIndexedValue">False</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=SQL/@EntryIndexedValue">SQL</s:String>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Consts/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Iddict/@EntryIndexedValue">True</s:Boolean>
|
||||
</wpf:ResourceDictionary>
|
||||
@ -1,27 +0,0 @@
|
||||
pipeline {
|
||||
agent any
|
||||
|
||||
stages {
|
||||
|
||||
stage('Deploy') {
|
||||
steps {
|
||||
script {
|
||||
try {
|
||||
sh '/usr/libexec/docker/cli-plugins/docker-compose -f ./docker-compose.yml up --build -d adminservice'
|
||||
} catch (Exception e) {
|
||||
error "部署失败: ${e.message}"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Health Check') {
|
||||
steps {
|
||||
script {
|
||||
sleep time: 30, unit: 'SECONDS'
|
||||
sh 'docker ps | grep adminservice'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1 +0,0 @@
|
||||
registry "https://registry.npmmirror.com"
|
||||
@ -2,51 +2,22 @@ FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
|
||||
USER $APP_UID
|
||||
WORKDIR /app
|
||||
EXPOSE 8080
|
||||
EXPOSE 8081
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
|
||||
ARG BUILD_CONFIGURATION=Release
|
||||
ARG NODE_VERSION=16.13.0
|
||||
ARG YARN_VERSION=1.22.15
|
||||
RUN echo "deb https://mirrors.huaweicloud.com/debian/ bookworm main contrib non-free non-free-firmware" > /etc/apt/sources.list && \
|
||||
echo "deb https://mirrors.huaweicloud.com/debian/ bookworm-updates main contrib non-free non-free-firmware" >> /etc/apt/sources.list && \
|
||||
echo "deb https://mirrors.huaweicloud.com/debian/ bookworm-backports main contrib non-free non-free-firmware" >> /etc/apt/sources.list && \
|
||||
echo "deb https://mirrors.huaweicloud.com/debian-security bookworm-security main contrib non-free non-free-firmware" >> /etc/apt/sources.list && \
|
||||
apt-get update -yq && \
|
||||
apt-get install -yq curl gnupg && \
|
||||
curl -sL https://deb.nodesource.com/setup_16.x | bash - && \
|
||||
apt-get install -yq nodejs && \
|
||||
npm install -g yarn@${YARN_VERSION} && \
|
||||
apt-get clean && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
ARG BUILD_CONFIGURATION=Release
|
||||
WORKDIR /src
|
||||
COPY ["NuGet.Config", "."]
|
||||
COPY ["applications/KonSoft.AuthServer/KonSoft.AuthServer.csproj", "applications/KonSoft.AuthServer/"]
|
||||
COPY ["modules/admin/src/KonSoft.Admin.Application/KonSoft.Admin.Application.csproj", "modules/admin/src/KonSoft.Admin.Application/"]
|
||||
COPY ["modules/admin/src/KonSoft.Admin.Domain/KonSoft.Admin.Domain.csproj", "modules/admin/src/KonSoft.Admin.Domain/"]
|
||||
COPY ["modules/admin/src/KonSoft.Admin.Domain.Shared/KonSoft.Admin.Domain.Shared.csproj", "modules/admin/src/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.EntityFrameworkCore/KonSoft.Admin.EntityFrameworkCore.csproj", "modules/admin/src/KonSoft.Admin.EntityFrameworkCore/"]
|
||||
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"
|
||||
COPY . .
|
||||
WORKDIR "/src/applications/KonSoft.AuthServer"
|
||||
RUN dotnet nuget locals all --clear
|
||||
RUN dotnet nuget add source https://mirrors.huaweicloud.com/repository/nuget/v3/index.json -n HuaweiCloud
|
||||
RUN dotnet tool install -g Volo.Abp.Cli --version 8.3.4
|
||||
ENV PATH="$PATH:/root/.dotnet/tools"
|
||||
RUN abp install-libs
|
||||
RUN dotnet build "./KonSoft.AuthServer.csproj" -c $BUILD_CONFIGURATION -o /app/build
|
||||
|
||||
# 此阶段用于发布要复制到最终阶段的服务项目
|
||||
FROM build AS publish
|
||||
ARG BUILD_CONFIGURATION=Release
|
||||
RUN dotnet publish "./KonSoft.AuthServer.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
|
||||
|
||||
# 此阶段在生产中使用,或在常规模式下从 VS 运行时使用(在不使用调试配置时为默认值)
|
||||
FROM base AS final
|
||||
WORKDIR /app
|
||||
COPY --from=publish /app/publish .
|
||||
|
||||
@ -39,11 +39,22 @@
|
||||
</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" />
|
||||
</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.Application" Version="8.3.4" />
|
||||
<PackageReference Include="Volo.Abp.Account.HttpApi" Version="8.3.4" />
|
||||
@ -58,10 +69,4 @@
|
||||
<PackageReference Include="Volo.Abp.OpenIddict.EntityFrameworkCore" Version="8.3.4" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<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="..\..\shared\KonSoft.Shared.Hosting.Microservices\KonSoft.Shared.Hosting.Microservices.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@ -1,17 +1,15 @@
|
||||
using KonSoft.Admin;
|
||||
using KonSoft.Admin.EntityFrameworkCore;
|
||||
using KonSoft.Shared.Hosting.AspNetCore;
|
||||
using KonSoft.Shared.Hosting.Microservices;
|
||||
using KonSoft.Shared.Localization.Localization;
|
||||
using Localization.Resources.AbpUi;
|
||||
using Medallion.Threading;
|
||||
using Medallion.Threading.Redis;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Cors;
|
||||
using Microsoft.AspNetCore.HttpOverrides;
|
||||
using Microsoft.AspNetCore.DataProtection;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using StackExchange.Redis;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using Volo.Abp;
|
||||
using Volo.Abp.Account;
|
||||
using Volo.Abp.Account.Localization;
|
||||
@ -20,25 +18,32 @@ 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.Shared;
|
||||
using Volo.Abp.AspNetCore.Serilog;
|
||||
using Volo.Abp.Auditing;
|
||||
using Volo.Abp.Autofac;
|
||||
using Volo.Abp.BackgroundJobs;
|
||||
using Volo.Abp.Caching;
|
||||
using Volo.Abp.Caching.StackExchangeRedis;
|
||||
using Volo.Abp.DistributedLocking;
|
||||
using Volo.Abp.Localization;
|
||||
using Volo.Abp.Modularity;
|
||||
using Volo.Abp.OpenIddict;
|
||||
using Volo.Abp.Security.Claims;
|
||||
using IPNetwork = Microsoft.AspNetCore.HttpOverrides.IPNetwork;
|
||||
using Volo.Abp.UI.Navigation.Urls;
|
||||
using Volo.Abp.VirtualFileSystem;
|
||||
|
||||
namespace KonSoft;
|
||||
|
||||
[DependsOn(
|
||||
typeof(AbpAutofacModule),
|
||||
typeof(AbpCachingStackExchangeRedisModule),
|
||||
typeof(AbpDistributedLockingModule),
|
||||
typeof(AbpAccountWebOpenIddictModule),
|
||||
typeof(AbpAccountApplicationModule),
|
||||
typeof(AbpAccountHttpApiModule),
|
||||
typeof(AdminApplicationModule),
|
||||
typeof(AdminEntityFrameworkCoreModule),
|
||||
typeof(AbpAccountHttpApiModule),
|
||||
typeof(AbpAspNetCoreMvcUiBasicThemeModule),
|
||||
typeof(KonSoftSharedHostingMicroservicesModule)
|
||||
)]
|
||||
typeof(AbpAspNetCoreSerilogModule)
|
||||
)]
|
||||
public class KonSoftAuthServerModule : AbpModule
|
||||
{
|
||||
public override void PreConfigureServices(ServiceConfigurationContext context)
|
||||
@ -58,16 +63,6 @@ public class KonSoftAuthServerModule : AbpModule
|
||||
|
||||
if (!hostingEnvironment.IsDevelopment())
|
||||
{
|
||||
PreConfigure<ForwardedHeadersOptions>(options =>
|
||||
{
|
||||
options.ForwardedHeaders = ForwardedHeaders.XForwardedFor |
|
||||
ForwardedHeaders.XForwardedProto |
|
||||
ForwardedHeaders.XForwardedHost;
|
||||
|
||||
options.KnownNetworks.Add(new IPNetwork(IPAddress.Parse("::ffff:127.0.0.1"), 104));
|
||||
options.KnownProxies.Add(IPAddress.Parse("::ffff:127.0.0.1"));
|
||||
});
|
||||
|
||||
PreConfigure<AbpOpenIddictAspNetCoreOptions>(options =>
|
||||
{
|
||||
options.AddDevelopmentEncryptionAndSigningCertificate = false;
|
||||
@ -75,8 +70,7 @@ public class KonSoftAuthServerModule : AbpModule
|
||||
|
||||
PreConfigure<OpenIddictServerBuilder>(serverBuilder =>
|
||||
{
|
||||
serverBuilder.AddProductionEncryptionAndSigningCertificate("openiddict.pfx",
|
||||
"59464dba-b66e-48cd-8b81-2e4a9c08c977");
|
||||
serverBuilder.AddProductionEncryptionAndSigningCertificate("openiddict.pfx", "59464dba-b66e-48cd-8b81-2e4a9c08c977");
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -100,21 +94,46 @@ public class KonSoftAuthServerModule : AbpModule
|
||||
{
|
||||
options.StyleBundles.Configure(
|
||||
BasicThemeBundles.Styles.Global,
|
||||
bundle => { bundle.AddFiles("/global-styles.css"); }
|
||||
bundle =>
|
||||
{
|
||||
bundle.AddFiles("/global-styles.css");
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
Configure<AbpAuditingOptions>(options =>
|
||||
{
|
||||
options.IsEnabledForGetRequests = true;
|
||||
options.ApplicationName = "AuthServer";
|
||||
options.IsEnabledForGetRequests = true;
|
||||
options.ApplicationName = "AuthServer";
|
||||
});
|
||||
|
||||
Configure<AbpBackgroundJobOptions>(options => { options.IsJobExecutionEnabled = false; });
|
||||
|
||||
context.Services.Configure<AbpClaimsPrincipalFactoryOptions>(options =>
|
||||
Configure<AppUrlOptions>(options =>
|
||||
{
|
||||
options.IsDynamicClaimsEnabled = true;
|
||||
options.Applications["MVC"].RootUrl = configuration["App:SelfUrl"];
|
||||
options.RedirectAllowedUrls.AddRange(configuration["App:RedirectAllowedUrls"]?.Split(',') ?? []);
|
||||
});
|
||||
|
||||
Configure<AbpBackgroundJobOptions>(options =>
|
||||
{
|
||||
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 =>
|
||||
@ -126,7 +145,7 @@ public class KonSoftAuthServerModule : AbpModule
|
||||
configuration["App:CorsOrigins"]?
|
||||
.Split(",", StringSplitOptions.RemoveEmptyEntries)
|
||||
.Select(o => o.RemovePostFix("/"))
|
||||
.ToArray() ?? Array.Empty<string>()
|
||||
.ToArray() ?? []
|
||||
)
|
||||
.WithAbpExposedHeaders()
|
||||
.SetIsOriginAllowedToAllowWildcardSubdomains()
|
||||
@ -135,6 +154,11 @@ public class KonSoftAuthServerModule : AbpModule
|
||||
.AllowCredentials();
|
||||
});
|
||||
});
|
||||
|
||||
context.Services.Configure<AbpClaimsPrincipalFactoryOptions>(options =>
|
||||
{
|
||||
options.IsDynamicClaimsEnabled = true;
|
||||
});
|
||||
}
|
||||
|
||||
public override void OnApplicationInitialization(ApplicationInitializationContext context)
|
||||
@ -142,16 +166,17 @@ public class KonSoftAuthServerModule : AbpModule
|
||||
var app = context.GetApplicationBuilder();
|
||||
var env = context.GetEnvironment();
|
||||
|
||||
app.UseForwardedHeaders();
|
||||
app.Use(async (ctx, next) =>
|
||||
if (env.IsDevelopment())
|
||||
{
|
||||
ctx.Request.Scheme = "https";
|
||||
await next();
|
||||
});
|
||||
app.UseDeveloperExceptionPage();
|
||||
}
|
||||
|
||||
app.UseDeveloperExceptionPage();
|
||||
app.UseAbpRequestLocalization();
|
||||
app.UseErrorPage();
|
||||
|
||||
if (!env.IsDevelopment())
|
||||
{
|
||||
app.UseErrorPage();
|
||||
}
|
||||
|
||||
app.UseCorrelationId();
|
||||
app.UseStaticFiles();
|
||||
@ -160,7 +185,7 @@ public class KonSoftAuthServerModule : AbpModule
|
||||
app.UseAuthentication();
|
||||
app.UseAbpOpenIddictValidation();
|
||||
|
||||
if (KonSoftConsts.MultiTenancyEnabled)
|
||||
if (MultiTenancyConsts.IsEnabled)
|
||||
{
|
||||
app.UseMultiTenancy();
|
||||
}
|
||||
@ -173,4 +198,4 @@ public class KonSoftAuthServerModule : AbpModule
|
||||
app.UseAbpSerilogEnrichers();
|
||||
app.UseConfiguredEndpoints();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,14 +1,14 @@
|
||||
using KonSoft.Shared.Localization.Localization;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using KonSoft.Localization;
|
||||
using Volo.Abp.Ui.Branding;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
|
||||
namespace KonSoft;
|
||||
|
||||
[Dependency(ReplaceServices = true)]
|
||||
public class KonSoftBrandingProvider : DefaultBrandingProvider
|
||||
{
|
||||
private readonly IStringLocalizer<KonSoftResource> _localizer;
|
||||
private IStringLocalizer<KonSoftResource> _localizer;
|
||||
|
||||
public KonSoftBrandingProvider(IStringLocalizer<KonSoftResource> localizer)
|
||||
{
|
||||
@ -16,4 +16,4 @@ public class KonSoftBrandingProvider : DefaultBrandingProvider
|
||||
}
|
||||
|
||||
public override string AppName => _localizer["AppName"];
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,13 +1,12 @@
|
||||
@page
|
||||
@using System.Net
|
||||
@using KonSoft.Shared.Localization.Localization
|
||||
@using Microsoft.AspNetCore.Http.Extensions
|
||||
@using Microsoft.AspNetCore.Mvc.Localization
|
||||
@using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Grid
|
||||
@using KonSoft.Pages
|
||||
@using KonSoft.Localization
|
||||
@using Volo.Abp.Users
|
||||
@using Volo.Abp.AspNetCore.Mvc.UI.Theming
|
||||
@using Volo.Abp.Ui.Branding
|
||||
@using Volo.Abp.Users
|
||||
@model KonSoft.Pages.IndexModel
|
||||
@model IndexModel
|
||||
@inject IHtmlLocalizer<KonSoftResource> L
|
||||
@inject ICurrentUser CurrentUser
|
||||
@inject IBrandingProvider BrandingProvider
|
||||
@ -46,32 +45,32 @@
|
||||
<abp-row>
|
||||
<abp-column size="_6">
|
||||
<div class="mr-auto p-2 float-start">
|
||||
<div class="">
|
||||
@if (CurrentUser.IsAuthenticated)
|
||||
{
|
||||
<div class="">
|
||||
<a abp-button="Outline_Primary" asp-controller="Manage" asp-action="Index" asp-area="Account" class="me-2">@L["MyAccount"]</a>
|
||||
<a abp-button="Primary" asp-controller="Logout" asp-action="Index" asp-area="Account" asp-route-returnUrl="/">@L["Logout"]</a>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<a abp-button="Primary" asp-controller="Login" asp-action="Index" asp-area="Account">@L["Login"]</a>
|
||||
}
|
||||
</div>
|
||||
<div class="">
|
||||
@if (CurrentUser.IsAuthenticated)
|
||||
{
|
||||
<div class="">
|
||||
<a abp-button="Outline_Primary" asp-controller="Manage" asp-action="Index" asp-area="Account" class="me-2">@L["MyAccount"]</a>
|
||||
<a abp-button="Primary" asp-controller="Logout" asp-action="Index" asp-area="Account" asp-route-returnUrl="/" >@L["Logout"]</a>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<a abp-button="Primary" asp-controller="Login" asp-action="Index" asp-area="Account">@L["Login"]</a>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</abp-column>
|
||||
|
||||
<abp-column size="_6">
|
||||
<div class="ml-auto p-2 float-end">
|
||||
<abp-dropdown>
|
||||
<abp-dropdown-button text="@Model.CurrentLanguage"/>
|
||||
@if (Model.Languages != null)
|
||||
<abp-dropdown-button text="@Model.CurrentLanguage" />
|
||||
@if (@Model.Languages != null)
|
||||
{
|
||||
<abp-dropdown-menu>
|
||||
@foreach (var language in Model.Languages)
|
||||
{
|
||||
var languageUrl = Url.Content($"~/Abp/Languages/Switch?culture={language.CultureName}&uiCulture={language.UiCultureName}&returnUrl={WebUtility.UrlEncode(Request.GetEncodedPathAndQuery())}");
|
||||
var languageUrl = Url.Content($"~/Abp/Languages/Switch?culture={language.CultureName}&uiCulture={language.UiCultureName}&returnUrl={System.Net.WebUtility.UrlEncode(Request.GetEncodedPathAndQuery())}");
|
||||
<abp-dropdown-item href="@languageUrl">@language.DisplayName</abp-dropdown-item>
|
||||
}
|
||||
</abp-dropdown-menu>
|
||||
@ -83,18 +82,18 @@
|
||||
|
||||
@if (Model.Applications != null)
|
||||
{
|
||||
<hr class="m-2"/>
|
||||
<hr class="m-2" />
|
||||
|
||||
<abp-row class="mt-3">
|
||||
@foreach (var application in Model.Applications)
|
||||
{
|
||||
<abp-column size-md="@ColumnSize._4" class="mb-2">
|
||||
<abp-column size-md="@Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Grid.ColumnSize._4" class="mb-2">
|
||||
<abp-card>
|
||||
<abp-card-body>
|
||||
@{
|
||||
var clientUri = application.ClientUri.Contains("Swagger") ? application.ClientUri.EnsureEndsWith('/') + "swagger/index.html" : application.ClientUri;
|
||||
@{
|
||||
var clientUri = application.ClientUri.Contains("Swagger") ? application.ClientUri.EnsureEndsWith('/') + "swagger/index.html" : application.ClientUri;
|
||||
}
|
||||
|
||||
|
||||
@if (!application.LogoUri.IsNullOrEmpty())
|
||||
{
|
||||
<div class="mx-auto">
|
||||
@ -116,4 +115,4 @@
|
||||
</div>
|
||||
</abp-row>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -9,12 +9,6 @@ namespace KonSoft.Pages;
|
||||
|
||||
public class IndexModel : AbpPageModel
|
||||
{
|
||||
public IndexModel(IOpenIddictApplicationRepository openIdApplicationRepository, ILanguageProvider languageProvider)
|
||||
{
|
||||
OpenIdApplicationRepository = openIdApplicationRepository;
|
||||
LanguageProvider = languageProvider;
|
||||
}
|
||||
|
||||
public List<OpenIddictApplication>? Applications { get; protected set; }
|
||||
|
||||
public IReadOnlyList<LanguageInfo>? Languages { get; protected set; }
|
||||
@ -25,6 +19,12 @@ public class IndexModel : AbpPageModel
|
||||
|
||||
protected ILanguageProvider LanguageProvider { get; }
|
||||
|
||||
public IndexModel(IOpenIddictApplicationRepository openIdApplicationRepository, ILanguageProvider languageProvider)
|
||||
{
|
||||
OpenIdApplicationRepository = openIdApplicationRepository;
|
||||
LanguageProvider = languageProvider;
|
||||
}
|
||||
|
||||
public async Task OnGetAsync()
|
||||
{
|
||||
Applications = await OpenIdApplicationRepository.GetListAsync();
|
||||
@ -32,4 +32,4 @@ public class IndexModel : AbpPageModel
|
||||
Languages = await LanguageProvider.GetLanguagesAsync();
|
||||
CurrentLanguage = CultureInfo.CurrentCulture.DisplayName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,37 +1,56 @@
|
||||
using KonSoft.Shared.Hosting.AspNetCore;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Serilog;
|
||||
using System;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Serilog;
|
||||
using Serilog.Events;
|
||||
|
||||
namespace KonSoft;
|
||||
|
||||
public class Program
|
||||
{
|
||||
public static async Task<int> Main(string[] args)
|
||||
public async static Task<int> Main(string[] args)
|
||||
{
|
||||
var assemblyName = typeof(Program).Assembly.GetName().Name!;
|
||||
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()
|
||||
.WriteTo.Async(c => c.File("Logs/logs.txt"))
|
||||
.WriteTo.Async(c => c.Console())
|
||||
.CreateLogger();
|
||||
|
||||
SerilogConfigurationHelper.Configure(assemblyName);
|
||||
try
|
||||
{
|
||||
Log.Information($"Starting {assemblyName}.");
|
||||
var app = await ApplicationBuilderHelper
|
||||
.BuildApplicationAsync<KonSoftAuthServerModule>(args);
|
||||
Log.Information("Starting KonSoft.AuthServer.");
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
builder.Host.AddAppSettingsSecretsJson()
|
||||
.UseAutofac()
|
||||
.UseSerilog();
|
||||
await builder.AddApplicationAsync<KonSoftAuthServerModule>();
|
||||
var app = builder.Build();
|
||||
await app.InitializeApplicationAsync();
|
||||
app.MapGet("/heath", () => "Online");
|
||||
await app.RunAsync();
|
||||
|
||||
return 0;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Fatal(ex, $"{assemblyName} terminated unexpectedly!");
|
||||
if (ex is HostAbortedException)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
|
||||
Log.Fatal(ex, "KonSoft.AuthServer terminated unexpectedly!");
|
||||
return 1;
|
||||
}
|
||||
finally
|
||||
{
|
||||
await Log.CloseAndFlushAsync();
|
||||
Log.CloseAndFlush();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,13 @@
|
||||
{
|
||||
"profiles": {
|
||||
"http": {
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"KonSoft.AuthServer": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
@ -20,5 +27,12 @@
|
||||
"useSSL": true
|
||||
}
|
||||
},
|
||||
"$schema": "http://json.schemastore.org/launchsettings.json"
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "https://localhost:44322",
|
||||
"sslPort": 44322
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,8 +1,17 @@
|
||||
{
|
||||
"AgileConfig": {
|
||||
"appId": "KonSoft.Admin.HttpApi.Host",
|
||||
"name": "KonSoft.Admin.HttpApi.Host",
|
||||
"nodes": "https://config.konsoft.top/",
|
||||
"secret": "DBE31703-14F9-4B01-893D-900B8380CE04"
|
||||
"App": {
|
||||
"SelfUrl": "https://localhost:44322",
|
||||
"ClientUrl": "http://localhost:4200",
|
||||
"CorsOrigins": "https://*.KonSoft.com,http://localhost:4200,https://localhost:44316,https://localhost:44370",
|
||||
"RedirectAllowedUrls": "http://localhost:4200,https://localhost:44319,https://localhost:44316,https://localhost:44347"
|
||||
},
|
||||
"ConnectionStrings": {
|
||||
"Default": "Host=localhost;Port=5432;Database=KonSoft;User ID=root;Password=myPassword;"
|
||||
},
|
||||
"Redis": {
|
||||
"Configuration": "127.0.0.1"
|
||||
},
|
||||
"StringEncryption": {
|
||||
"DefaultPassPhrase": "kxtywyrXW4i7vijT"
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,20 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<configuration>
|
||||
<location path="." inheritInChildApplications="false">
|
||||
<system.webServer>
|
||||
<handlers>
|
||||
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
|
||||
</handlers>
|
||||
<aspNetCore processPath="dotnet" arguments=".\KonSoft.AuthServer.dll" stdoutLogEnabled="false"
|
||||
stdoutLogFile=".\Logs\stdout" hostingModel="inprocess" />
|
||||
</system.webServer>
|
||||
</location>
|
||||
<system.webServer>
|
||||
<httpProtocol>
|
||||
<customHeaders>
|
||||
<remove name="x-powered-by" />
|
||||
</customHeaders>
|
||||
</httpProtocol>
|
||||
</system.webServer>
|
||||
</configuration>
|
||||
<location path="." inheritInChildApplications="false">
|
||||
<system.webServer>
|
||||
<handlers>
|
||||
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
|
||||
</handlers>
|
||||
<aspNetCore processPath="dotnet" arguments=".\KonSoft.AuthServer.dll" stdoutLogEnabled="false" stdoutLogFile=".\Logs\stdout" hostingModel="inprocess" />
|
||||
</system.webServer>
|
||||
</location>
|
||||
<system.webServer>
|
||||
<httpProtocol>
|
||||
<customHeaders>
|
||||
<remove name="x-powered-by" />
|
||||
</customHeaders>
|
||||
</httpProtocol>
|
||||
</system.webServer>
|
||||
</configuration>
|
||||
|
||||
@ -1,32 +1,33 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace KonSoft.BackgroundJobs.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class WeatherForecastController : ControllerBase
|
||||
namespace KonSoft.BackgroundJobs.Controllers
|
||||
{
|
||||
private static readonly string[] Summaries =
|
||||
[
|
||||
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
|
||||
];
|
||||
|
||||
private readonly ILogger<WeatherForecastController> _logger;
|
||||
|
||||
public WeatherForecastController(ILogger<WeatherForecastController> logger)
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class WeatherForecastController : ControllerBase
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
private static readonly string[] Summaries =
|
||||
[
|
||||
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
|
||||
];
|
||||
|
||||
[HttpGet(Name = "GetWeatherForecast")]
|
||||
public IEnumerable<WeatherForecast> Get()
|
||||
{
|
||||
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
|
||||
private readonly ILogger<WeatherForecastController> _logger;
|
||||
|
||||
public WeatherForecastController(ILogger<WeatherForecastController> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
[HttpGet(Name = "GetWeatherForecast")]
|
||||
public IEnumerable<WeatherForecast> Get()
|
||||
{
|
||||
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
|
||||
{
|
||||
Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
|
||||
TemperatureC = Random.Shared.Next(-20, 55),
|
||||
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
|
||||
})
|
||||
.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -22,4 +22,4 @@ app.UseAuthorization();
|
||||
|
||||
app.MapControllers();
|
||||
|
||||
app.Run();
|
||||
app.Run();
|
||||
|
||||
@ -1,5 +1,13 @@
|
||||
{
|
||||
"$schema": "http://json.schemastore.org/launchsettings.json",
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:4773",
|
||||
"sslPort": 44380
|
||||
}
|
||||
},
|
||||
"profiles": {
|
||||
"http": {
|
||||
"commandName": "Project",
|
||||
@ -10,6 +18,24 @@
|
||||
"environmentVariables": {
|
||||
"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,12 +1,13 @@
|
||||
namespace KonSoft.BackgroundJobs;
|
||||
|
||||
public class WeatherForecast
|
||||
namespace KonSoft.BackgroundJobs
|
||||
{
|
||||
public DateOnly Date { get; set; }
|
||||
public class WeatherForecast
|
||||
{
|
||||
public DateOnly Date { get; set; }
|
||||
|
||||
public int TemperatureC { get; set; }
|
||||
public int TemperatureC { get; set; }
|
||||
|
||||
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
|
||||
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
|
||||
|
||||
public string? Summary { get; set; }
|
||||
}
|
||||
public string? Summary { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,32 +1,33 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace KonSoft.BackgroundWorker.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class WeatherForecastController : ControllerBase
|
||||
namespace KonSoft.BackgroundWorker.Controllers
|
||||
{
|
||||
private static readonly string[] Summaries =
|
||||
[
|
||||
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
|
||||
];
|
||||
|
||||
private readonly ILogger<WeatherForecastController> _logger;
|
||||
|
||||
public WeatherForecastController(ILogger<WeatherForecastController> logger)
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class WeatherForecastController : ControllerBase
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
private static readonly string[] Summaries =
|
||||
[
|
||||
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
|
||||
];
|
||||
|
||||
[HttpGet(Name = "GetWeatherForecast")]
|
||||
public IEnumerable<WeatherForecast> Get()
|
||||
{
|
||||
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
|
||||
private readonly ILogger<WeatherForecastController> _logger;
|
||||
|
||||
public WeatherForecastController(ILogger<WeatherForecastController> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
[HttpGet(Name = "GetWeatherForecast")]
|
||||
public IEnumerable<WeatherForecast> Get()
|
||||
{
|
||||
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
|
||||
{
|
||||
Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
|
||||
TemperatureC = Random.Shared.Next(-20, 55),
|
||||
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
|
||||
})
|
||||
.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -22,4 +22,4 @@ app.UseAuthorization();
|
||||
|
||||
app.MapControllers();
|
||||
|
||||
app.Run();
|
||||
app.Run();
|
||||
|
||||
@ -1,5 +1,13 @@
|
||||
{
|
||||
"$schema": "http://json.schemastore.org/launchsettings.json",
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:22937",
|
||||
"sslPort": 44300
|
||||
}
|
||||
},
|
||||
"profiles": {
|
||||
"http": {
|
||||
"commandName": "Project",
|
||||
@ -10,6 +18,24 @@
|
||||
"environmentVariables": {
|
||||
"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,12 +1,13 @@
|
||||
namespace KonSoft.BackgroundWorker;
|
||||
|
||||
public class WeatherForecast
|
||||
namespace KonSoft.BackgroundWorker
|
||||
{
|
||||
public DateOnly Date { get; set; }
|
||||
public class WeatherForecast
|
||||
{
|
||||
public DateOnly Date { get; set; }
|
||||
|
||||
public int TemperatureC { get; set; }
|
||||
public int TemperatureC { get; set; }
|
||||
|
||||
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
|
||||
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
|
||||
|
||||
public string? Summary { get; set; }
|
||||
}
|
||||
public string? Summary { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,27 +0,0 @@
|
||||
pipeline {
|
||||
agent any
|
||||
|
||||
stages {
|
||||
|
||||
stage('Deploy') {
|
||||
steps {
|
||||
script {
|
||||
try {
|
||||
sh '/usr/libexec/docker/cli-plugins/docker-compose -f ./docker-compose.yml up --build -d authserver'
|
||||
} catch (Exception e) {
|
||||
error "部署失败: ${e.message}"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Health Check') {
|
||||
steps {
|
||||
script {
|
||||
sleep time: 30, unit: 'SECONDS'
|
||||
sh 'docker ps | grep authserver'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,90 +0,0 @@
|
||||
services:
|
||||
internalgateways:
|
||||
container_name: clean-internalgateways
|
||||
restart: unless-stopped
|
||||
build:
|
||||
context: .
|
||||
dockerfile: ./gateways/KonSoft.InternalGateway/Dockerfile
|
||||
environment:
|
||||
- ASPNETCORE_ENVIRONMENT=Test
|
||||
- AgileConfig__AppId=KonSoft.InternalGateway
|
||||
- AgileConfig__Name=KonSoft.InternalGateway
|
||||
- AgileConfig__Nodes=https://config.konsoft.top/
|
||||
- AgileConfig__Secret=DBE31703-14F9-4B01-893D-900B8380CE04
|
||||
ports:
|
||||
- 8080:8080
|
||||
networks:
|
||||
- konsoft-shared-network
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost:8080/health"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 40s
|
||||
logging:
|
||||
driver: "json-file"
|
||||
options:
|
||||
max-size: "10m"
|
||||
max-file: "3"
|
||||
|
||||
authserver:
|
||||
container_name: clean-authserver
|
||||
restart: unless-stopped
|
||||
build:
|
||||
context: .
|
||||
dockerfile: ./applications/KonSoft.AuthServer/Dockerfile
|
||||
environment:
|
||||
- ASPNETCORE_ENVIRONMENT=Test
|
||||
- AgileConfig__AppId=KonSoft.AuthServer
|
||||
- AgileConfig__Name=KonSoft.AuthServer
|
||||
- AgileConfig__Nodes=https://config.konsoft.top/
|
||||
- AgileConfig__Secret=DBE31703-14F9-4B01-893D-900B8380CE04
|
||||
ports:
|
||||
- 8081:8080
|
||||
volumes:
|
||||
- /etc/letsencrypt/archive/code.konsoft.top/openiddict.pfx:/app/openiddict.pfx
|
||||
networks:
|
||||
- konsoft-shared-network
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost:8080/health"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 40s
|
||||
logging:
|
||||
driver: "json-file"
|
||||
options:
|
||||
max-size: "10m"
|
||||
max-file: "3"
|
||||
|
||||
adminservice:
|
||||
container_name: clean-adminservice
|
||||
restart: unless-stopped
|
||||
build:
|
||||
context: .
|
||||
dockerfile: ./microservices/KonSoft.Admin.HttpApi.Host/Dockerfile
|
||||
environment:
|
||||
- ASPNETCORE_ENVIRONMENT=Test
|
||||
- AgileConfig__AppId=KonSoft.Admin.HttpApi.Host
|
||||
- AgileConfig__Name=KonSoft.Admin.HttpApi.Host
|
||||
- AgileConfig__Nodes=https://config.konsoft.top/
|
||||
- AgileConfig__Secret=DBE31703-14F9-4B01-893D-900B8380CE04
|
||||
networks:
|
||||
- konsoft-shared-network
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost:8080/health"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 40s
|
||||
logging:
|
||||
driver: "json-file"
|
||||
options:
|
||||
max-size: "10m"
|
||||
max-file: "3"
|
||||
|
||||
networks:
|
||||
konsoft-shared-network:
|
||||
name: konsoft-shared-network
|
||||
driver: bridge
|
||||
external: true
|
||||
@ -0,0 +1,33 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace KonSoft.InternalGateway.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class WeatherForecastController : ControllerBase
|
||||
{
|
||||
private static readonly string[] Summaries =
|
||||
[
|
||||
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
|
||||
];
|
||||
|
||||
private readonly ILogger<WeatherForecastController> _logger;
|
||||
|
||||
public WeatherForecastController(ILogger<WeatherForecastController> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
[HttpGet(Name = "GetWeatherForecast")]
|
||||
public IEnumerable<WeatherForecast> Get()
|
||||
{
|
||||
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
|
||||
{
|
||||
Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
|
||||
TemperatureC = Random.Shared.Next(-20, 55),
|
||||
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
|
||||
})
|
||||
.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,28 +0,0 @@
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
|
||||
USER $APP_UID
|
||||
WORKDIR /app
|
||||
EXPOSE 8080
|
||||
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
|
||||
ARG BUILD_CONFIGURATION=Release
|
||||
WORKDIR /src
|
||||
COPY ["NuGet.Config", "."]
|
||||
COPY ["gateways/KonSoft.InternalGateway/KonSoft.InternalGateway.csproj", "gateways/KonSoft.InternalGateway/"]
|
||||
COPY ["shared/KonSoft.Shared.Hosting.Gateways/KonSoft.Shared.Hosting.Gateways.csproj", "shared/KonSoft.Shared.Hosting.Gateways/"]
|
||||
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 "./gateways/KonSoft.InternalGateway/KonSoft.InternalGateway.csproj"
|
||||
COPY . .
|
||||
WORKDIR "/src/gateways/KonSoft.InternalGateway"
|
||||
RUN dotnet build "./KonSoft.InternalGateway.csproj" -c $BUILD_CONFIGURATION -o /app/build
|
||||
|
||||
FROM build AS publish
|
||||
ARG BUILD_CONFIGURATION=Release
|
||||
RUN dotnet publish "./KonSoft.InternalGateway.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
|
||||
|
||||
FROM base AS final
|
||||
WORKDIR /app
|
||||
COPY --from=publish /app/publish .
|
||||
ENTRYPOINT ["dotnet", "KonSoft.InternalGateway.dll"]
|
||||
@ -1,14 +0,0 @@
|
||||
using KonSoft.Admin;
|
||||
using KonSoft.Shared.Hosting.Gateways;
|
||||
using Volo.Abp.Modularity;
|
||||
|
||||
namespace KonSoft.InternalGateway
|
||||
{
|
||||
[DependsOn(
|
||||
typeof(KonSoftSharedHostingGatewaysModule),
|
||||
typeof(AdminHttpApiModule)
|
||||
)]
|
||||
public class InternalGatewayModule : AbpModule
|
||||
{
|
||||
}
|
||||
}
|
||||
@ -4,14 +4,10 @@
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<UserSecretsId>98521e87-fe4a-4555-8c3b-e83559a64e03</UserSecretsId>
|
||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||
<DockerfileContext>..\..</DockerfileContext>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\modules\admin\src\KonSoft.Admin.HttpApi\KonSoft.Admin.HttpApi.csproj" />
|
||||
<ProjectReference Include="..\..\shared\KonSoft.Shared.Hosting.Gateways\KonSoft.Shared.Hosting.Gateways.csproj" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@ -1,39 +1,25 @@
|
||||
using KonSoft.InternalGateway;
|
||||
using KonSoft.Shared.Hosting.AspNetCore;
|
||||
using Serilog;
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
var assemblyName = typeof(Program).Assembly.GetName().Name!;
|
||||
SerilogConfigurationHelper.Configure(assemblyName);
|
||||
// Add services to the container.
|
||||
|
||||
try
|
||||
builder.Services.AddControllers();
|
||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
builder.Configuration
|
||||
.AddAgileConfig(option =>
|
||||
{
|
||||
option.ENV = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? "Development";
|
||||
});
|
||||
builder.Host
|
||||
.AddAppSettingsSecretsJson()
|
||||
.UseAutofac()
|
||||
.UseSerilog();
|
||||
builder.Services.AddReverseProxy()
|
||||
.LoadFromConfig(builder.Configuration.GetSection("ReverseProxy"));
|
||||
await builder.AddApplicationAsync<InternalGatewayModule>();
|
||||
var app = builder.Build();
|
||||
await app.InitializeApplicationAsync();
|
||||
app.MapReverseProxy();
|
||||
app.MapGet("/heath", () => "Online");
|
||||
await app.RunAsync();
|
||||
|
||||
return 0;
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Fatal(ex, $"{assemblyName} terminated unexpectedly!");
|
||||
return 1;
|
||||
}
|
||||
finally
|
||||
{
|
||||
await Log.CloseAndFlushAsync();
|
||||
}
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
|
||||
app.UseAuthorization();
|
||||
|
||||
app.MapControllers();
|
||||
|
||||
app.Run();
|
||||
|
||||
@ -1,45 +1,4 @@
|
||||
{
|
||||
"profiles": {
|
||||
"http": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"dotnetRunMessages": true,
|
||||
"applicationUrl": "http://localhost:5090"
|
||||
},
|
||||
"https": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"dotnetRunMessages": true,
|
||||
"applicationUrl": "https://localhost:7264;http://localhost:5090"
|
||||
},
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"Container (Dockerfile)": {
|
||||
"commandName": "Docker",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_HTTPS_PORTS": "8081",
|
||||
"ASPNETCORE_HTTP_PORTS": "8080"
|
||||
},
|
||||
"publishAllPorts": true,
|
||||
"useSSL": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"$schema": "http://json.schemastore.org/launchsettings.json",
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
@ -48,5 +7,35 @@
|
||||
"applicationUrl": "http://localhost:15968",
|
||||
"sslPort": 44395
|
||||
}
|
||||
},
|
||||
"profiles": {
|
||||
"http": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"applicationUrl": "http://localhost:5090",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"https": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"applicationUrl": "https://localhost:7264;http://localhost:5090",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
13
gateways/KonSoft.InternalGateway/WeatherForecast.cs
Normal file
13
gateways/KonSoft.InternalGateway/WeatherForecast.cs
Normal file
@ -0,0 +1,13 @@
|
||||
namespace KonSoft.InternalGateway
|
||||
{
|
||||
public class WeatherForecast
|
||||
{
|
||||
public DateOnly Date { get; set; }
|
||||
|
||||
public int TemperatureC { get; set; }
|
||||
|
||||
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
|
||||
|
||||
public string? Summary { get; set; }
|
||||
}
|
||||
}
|
||||
@ -1,8 +1,9 @@
|
||||
{
|
||||
"AgileConfig": {
|
||||
"appId": "KonSoft.InternalGateway",
|
||||
"name": "KonSoft.InternalGateway",
|
||||
"nodes": "https://config.konsoft.top/",
|
||||
"secret": "DBE31703-14F9-4B01-893D-900B8380CE04"
|
||||
}
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
||||
|
||||
@ -1,32 +1,33 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace KonSoft.PublicGateway.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class WeatherForecastController : ControllerBase
|
||||
namespace KonSoft.PublicGateway.Controllers
|
||||
{
|
||||
private static readonly string[] Summaries =
|
||||
[
|
||||
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
|
||||
];
|
||||
|
||||
private readonly ILogger<WeatherForecastController> _logger;
|
||||
|
||||
public WeatherForecastController(ILogger<WeatherForecastController> logger)
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class WeatherForecastController : ControllerBase
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
private static readonly string[] Summaries =
|
||||
[
|
||||
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
|
||||
];
|
||||
|
||||
[HttpGet(Name = "GetWeatherForecast")]
|
||||
public IEnumerable<WeatherForecast> Get()
|
||||
{
|
||||
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
|
||||
private readonly ILogger<WeatherForecastController> _logger;
|
||||
|
||||
public WeatherForecastController(ILogger<WeatherForecastController> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
[HttpGet(Name = "GetWeatherForecast")]
|
||||
public IEnumerable<WeatherForecast> Get()
|
||||
{
|
||||
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
|
||||
{
|
||||
Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
|
||||
TemperatureC = Random.Shared.Next(-20, 55),
|
||||
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
|
||||
})
|
||||
.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -22,4 +22,4 @@ app.UseAuthorization();
|
||||
|
||||
app.MapControllers();
|
||||
|
||||
app.Run();
|
||||
app.Run();
|
||||
|
||||
@ -1,12 +1,13 @@
|
||||
namespace KonSoft.PublicGateway;
|
||||
|
||||
public class WeatherForecast
|
||||
namespace KonSoft.PublicGateway
|
||||
{
|
||||
public DateOnly Date { get; set; }
|
||||
public class WeatherForecast
|
||||
{
|
||||
public DateOnly Date { get; set; }
|
||||
|
||||
public int TemperatureC { get; set; }
|
||||
public int TemperatureC { get; set; }
|
||||
|
||||
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
|
||||
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
|
||||
|
||||
public string? Summary { get; set; }
|
||||
}
|
||||
public string? Summary { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,27 +0,0 @@
|
||||
pipeline {
|
||||
agent any
|
||||
|
||||
stages {
|
||||
|
||||
stage('Deploy') {
|
||||
steps {
|
||||
script {
|
||||
try {
|
||||
sh '/usr/libexec/docker/cli-plugins/docker-compose -f ./docker-compose.yml up --build -d internalgateways'
|
||||
} catch (Exception e) {
|
||||
error "部署失败: ${e.message}"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Health Check') {
|
||||
steps {
|
||||
script {
|
||||
sleep time: 30, unit: 'SECONDS'
|
||||
sh 'docker ps | grep internalgateways'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,37 +1,179 @@
|
||||
using KonSoft.Admin.EntityFrameworkCore;
|
||||
using KonSoft.Shared.Hosting.AspNetCore;
|
||||
using KonSoft.Shared.Hosting.Microservices;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
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.Cors;
|
||||
using Microsoft.AspNetCore.DataProtection;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
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.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.Security.Claims;
|
||||
using Volo.Abp.Swashbuckle;
|
||||
using Volo.Abp.VirtualFileSystem;
|
||||
|
||||
namespace KonSoft.Admin;
|
||||
|
||||
[DependsOn(
|
||||
typeof(AdminHttpApiModule),
|
||||
typeof(AbpAutofacModule),
|
||||
typeof(AbpCachingStackExchangeRedisModule),
|
||||
typeof(AbpDistributedLockingModule),
|
||||
typeof(AbpAspNetCoreMvcUiMultiTenancyModule),
|
||||
typeof(AbpAspNetCoreAuthenticationJwtBearerModule),
|
||||
typeof(AdminApplicationModule),
|
||||
typeof(AdminEntityFrameworkCoreModule),
|
||||
typeof(KonSoftSharedHostingMicroservicesModule)
|
||||
typeof(AbpAspNetCoreSerilogModule),
|
||||
typeof(AbpSwashbuckleModule)
|
||||
)]
|
||||
public class AdminHttpApiHostModule : AbpModule
|
||||
{
|
||||
public override void ConfigureServices(ServiceConfigurationContext context)
|
||||
{
|
||||
var configuration = context.Services.GetConfiguration();
|
||||
var hostingEnvironment = context.Services.GetHostingEnvironment();
|
||||
|
||||
SwaggerConfigurationHelper.ConfigureWithOidc(
|
||||
context,
|
||||
ConfigureConventionalControllers();
|
||||
ConfigureAuthentication(context, configuration);
|
||||
ConfigureCache(configuration);
|
||||
ConfigureVirtualFileSystem(context);
|
||||
ConfigureDataProtection(context, configuration, hostingEnvironment);
|
||||
ConfigureDistributedLocking(context, configuration);
|
||||
ConfigureCors(context, configuration);
|
||||
ConfigureSwaggerServices(context, configuration);
|
||||
}
|
||||
|
||||
private void ConfigureCache(IConfiguration configuration)
|
||||
{
|
||||
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"]!,
|
||||
["AdministrationService"],
|
||||
discoveryEndpoint: configuration["AuthServer:MetadataAddress"],
|
||||
apiTitle: "Administration Service API"
|
||||
);
|
||||
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);
|
||||
});
|
||||
}
|
||||
|
||||
// ֻ<><D6BB><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>
|
||||
Configure<AbpBackgroundJobOptions>(options => options.IsJobExecutionEnabled = false);
|
||||
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)
|
||||
@ -51,7 +193,7 @@ public class AdminHttpApiHostModule : AbpModule
|
||||
app.UseCors();
|
||||
app.UseAuthentication();
|
||||
|
||||
if (KonSoftConsts.MultiTenancyEnabled)
|
||||
if (MultiTenancyConsts.IsEnabled)
|
||||
{
|
||||
app.UseMultiTenancy();
|
||||
}
|
||||
@ -69,15 +211,9 @@ public class AdminHttpApiHostModule : AbpModule
|
||||
options.OAuthClientId(configuration["AuthServer:SwaggerClientId"]);
|
||||
options.OAuthScopes("Admin");
|
||||
});
|
||||
|
||||
|
||||
app.UseAuditing();
|
||||
app.UseAbpSerilogEnrichers();
|
||||
app.UseConfiguredEndpoints();
|
||||
}
|
||||
|
||||
//public override async Task OnPostApplicationInitializationAsync(ApplicationInitializationContext context)
|
||||
//{
|
||||
// await context.ServiceProvider.GetRequiredService<AdminPendingEfCoreMigrationsChecker>()
|
||||
// .CheckAndApplyDatabaseMigrationsAsync();
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,4 +9,4 @@ public class HomeController : AbpController
|
||||
{
|
||||
return Redirect("~/swagger");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,13 +0,0 @@
|
||||
using System.Threading.Tasks;
|
||||
using Volo.Abp.Data;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
|
||||
namespace KonSoft.Admin.DbMigrations;
|
||||
|
||||
public class AdminDataSeedContributor : IDataSeedContributor, ITransientDependency
|
||||
{
|
||||
public Task SeedAsync(DataSeedContext context)
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
@ -1,25 +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,7 +2,7 @@ FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
|
||||
USER $APP_UID
|
||||
WORKDIR /app
|
||||
EXPOSE 8080
|
||||
|
||||
EXPOSE 8081
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
|
||||
ARG BUILD_CONFIGURATION=Release
|
||||
@ -15,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.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 ["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"
|
||||
COPY . .
|
||||
WORKDIR "/src/microservices/KonSoft.Admin.HttpApi.Host"
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
@ -10,6 +10,22 @@
|
||||
<DockerfileContext>..\..</DockerfileContext>
|
||||
</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>
|
||||
<Compile Remove="Logs\**" />
|
||||
<Content Remove="Logs\**" />
|
||||
@ -17,15 +33,10 @@
|
||||
<None Remove="Logs\**" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.22.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<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.HttpApi\KonSoft.Admin.HttpApi.csproj" />
|
||||
<ProjectReference Include="..\..\shared\KonSoft.Shared.Hosting.Microservices\KonSoft.Shared.Hosting.Microservices.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,29 +1,56 @@
|
||||
using KonSoft.Admin;
|
||||
using KonSoft.Shared.Hosting.AspNetCore;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Serilog;
|
||||
using System;
|
||||
using Serilog.Events;
|
||||
|
||||
var assemblyName = typeof(Program).Assembly.GetName().Name!;
|
||||
namespace KonSoft.Admin;
|
||||
|
||||
SerilogConfigurationHelper.Configure(assemblyName);
|
||||
try
|
||||
public class Program
|
||||
{
|
||||
Log.Information($"Starting {assemblyName}.");
|
||||
var app = await ApplicationBuilderHelper
|
||||
.BuildApplicationAsync<AdminHttpApiHostModule>(args);
|
||||
await app.InitializeApplicationAsync();
|
||||
app.MapGet("/heath", () => "Online");
|
||||
await app.RunAsync();
|
||||
public async static Task<int> Main(string[] args)
|
||||
{
|
||||
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()
|
||||
.WriteTo.Async(c => c.File("Logs/logs.txt"))
|
||||
.WriteTo.Async(c => c.Console())
|
||||
.CreateLogger();
|
||||
|
||||
return 0;
|
||||
try
|
||||
{
|
||||
Log.Information("Starting KonSoft.Admin.HttpApi.Host.");
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
builder.Host.AddAppSettingsSecretsJson()
|
||||
.UseAutofac()
|
||||
.UseSerilog();
|
||||
await builder.AddApplicationAsync<AdminHttpApiHostModule>();
|
||||
var app = builder.Build();
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Fatal(ex, $"{assemblyName} terminated unexpectedly!");
|
||||
return 1;
|
||||
}
|
||||
finally
|
||||
{
|
||||
await Log.CloseAndFlushAsync();
|
||||
}
|
||||
@ -1,6 +1,13 @@
|
||||
{
|
||||
"profiles": {
|
||||
"http": {
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"KonSoft.Admin.HttpApi.Host": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
@ -20,5 +27,12 @@
|
||||
"useSSL": true
|
||||
}
|
||||
},
|
||||
"$schema": "http://json.schemastore.org/launchsettings.json"
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "https://localhost:44354",
|
||||
"sslPort": 44354
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,13 +1,19 @@
|
||||
{
|
||||
"AgileConfig": {
|
||||
"appId": "KonSoft.Admin.HttpApi.Host",
|
||||
"name": "KonSoft.Admin.HttpApi.Host",
|
||||
"nodes": "https://config.konsoft.top/",
|
||||
"secret": "DBE31703-14F9-4B01-893D-900B8380CE04"
|
||||
"App": {
|
||||
"CorsOrigins": "https://*.Admin.com,https://localhost:44357"
|
||||
},
|
||||
"ConnectionStrings": {
|
||||
"Default": "Host=localhost;Port=5432;Database=Admin;User ID=root;Password=myPassword;"
|
||||
},
|
||||
"Redis": {
|
||||
"Configuration": "127.0.0.1"
|
||||
},
|
||||
"AuthServer": {
|
||||
"Authority": "https://localhost:44322",
|
||||
"Authority": "https://localhost:44397",
|
||||
"RequireHttpsMetadata": true,
|
||||
"SwaggerClientId": "Admin_Swagger"
|
||||
},
|
||||
"StringEncryption": {
|
||||
"DefaultPassPhrase": "g3NdNOyDR9oYj0gK"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,20 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<configuration>
|
||||
<location path="." inheritInChildApplications="false">
|
||||
<system.webServer>
|
||||
<handlers>
|
||||
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
|
||||
</handlers>
|
||||
<aspNetCore processPath="dotnet" arguments=".\KonSoft.Admin.HttpApi.Host.dll" stdoutLogEnabled="false"
|
||||
stdoutLogFile=".\Logs\stdout" hostingModel="inprocess" />
|
||||
</system.webServer>
|
||||
</location>
|
||||
<system.webServer>
|
||||
<httpProtocol>
|
||||
<customHeaders>
|
||||
<remove name="x-powered-by" />
|
||||
</customHeaders>
|
||||
</httpProtocol>
|
||||
</system.webServer>
|
||||
</configuration>
|
||||
<location path="." inheritInChildApplications="false">
|
||||
<system.webServer>
|
||||
<handlers>
|
||||
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
|
||||
</handlers>
|
||||
<aspNetCore processPath="dotnet" arguments=".\KonSoft.Admin.HttpApi.Host.dll" stdoutLogEnabled="false" stdoutLogFile=".\Logs\stdout" hostingModel="inprocess" />
|
||||
</system.webServer>
|
||||
</location>
|
||||
<system.webServer>
|
||||
<httpProtocol>
|
||||
<customHeaders>
|
||||
<remove name="x-powered-by" />
|
||||
</customHeaders>
|
||||
</httpProtocol>
|
||||
</system.webServer>
|
||||
</configuration>
|
||||
|
||||
@ -9,4 +9,4 @@ public class HomeController : AbpController
|
||||
{
|
||||
return Redirect("~/swagger");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,37 +1,179 @@
|
||||
using KonSoft.Dispatch.EntityFrameworkCore;
|
||||
using KonSoft.Shared.Hosting.AspNetCore;
|
||||
using KonSoft.Shared.Hosting.Microservices;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
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.Cors;
|
||||
using Microsoft.AspNetCore.DataProtection;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
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.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.Security.Claims;
|
||||
using Volo.Abp.Swashbuckle;
|
||||
using Volo.Abp.VirtualFileSystem;
|
||||
|
||||
namespace KonSoft.Dispatch;
|
||||
|
||||
[DependsOn(
|
||||
typeof(DispatchHttpApiModule),
|
||||
typeof(AbpAutofacModule),
|
||||
typeof(AbpCachingStackExchangeRedisModule),
|
||||
typeof(AbpDistributedLockingModule),
|
||||
typeof(AbpAspNetCoreMvcUiMultiTenancyModule),
|
||||
typeof(AbpAspNetCoreAuthenticationJwtBearerModule),
|
||||
typeof(DispatchApplicationModule),
|
||||
typeof(DispatchEntityFrameworkCoreModule),
|
||||
typeof(KonSoftSharedHostingMicroservicesModule)
|
||||
typeof(AbpAspNetCoreSerilogModule),
|
||||
typeof(AbpSwashbuckleModule)
|
||||
)]
|
||||
public class DispatchHttpApiHostModule : AbpModule
|
||||
{
|
||||
public override void ConfigureServices(ServiceConfigurationContext context)
|
||||
{
|
||||
var configuration = context.Services.GetConfiguration();
|
||||
var hostingEnvironment = context.Services.GetHostingEnvironment();
|
||||
|
||||
SwaggerConfigurationHelper.ConfigureWithOidc(
|
||||
context,
|
||||
ConfigureConventionalControllers();
|
||||
ConfigureAuthentication(context, configuration);
|
||||
ConfigureCache(configuration);
|
||||
ConfigureVirtualFileSystem(context);
|
||||
ConfigureDataProtection(context, configuration, hostingEnvironment);
|
||||
ConfigureDistributedLocking(context, configuration);
|
||||
ConfigureCors(context, configuration);
|
||||
ConfigureSwaggerServices(context, configuration);
|
||||
}
|
||||
|
||||
private void ConfigureCache(IConfiguration configuration)
|
||||
{
|
||||
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"]!,
|
||||
["DispatchService"],
|
||||
discoveryEndpoint: configuration["AuthServer:MetadataAddress"],
|
||||
apiTitle: "Dispatch Service API"
|
||||
);
|
||||
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);
|
||||
});
|
||||
}
|
||||
|
||||
// ֻ<><D6BB><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>
|
||||
Configure<AbpBackgroundJobOptions>(options => options.IsJobExecutionEnabled = false);
|
||||
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)
|
||||
@ -51,7 +193,7 @@ public class DispatchHttpApiHostModule : AbpModule
|
||||
app.UseCors();
|
||||
app.UseAuthentication();
|
||||
|
||||
if (KonSoftConsts.MultiTenancyEnabled)
|
||||
if (MultiTenancyConsts.IsEnabled)
|
||||
{
|
||||
app.UseMultiTenancy();
|
||||
}
|
||||
@ -74,4 +216,4 @@ public class DispatchHttpApiHostModule : AbpModule
|
||||
app.UseAbpSerilogEnrichers();
|
||||
app.UseConfiguredEndpoints();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
@ -8,6 +8,21 @@
|
||||
<UserSecretsId>KonSoft.Dispatch-4681b4fd-151f-4221-84a4-929d86723e4c</UserSecretsId>
|
||||
</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>
|
||||
<Compile 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.EntityFrameworkCore\KonSoft.Dispatch.EntityFrameworkCore.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>
|
||||
|
||||
</Project>
|
||||
|
||||
@ -10,7 +10,7 @@ namespace KonSoft.Dispatch;
|
||||
|
||||
public class Program
|
||||
{
|
||||
public static async Task<int> Main(string[] args)
|
||||
public async static Task<int> Main(string[] args)
|
||||
{
|
||||
Log.Logger = new LoggerConfiguration()
|
||||
#if DEBUG
|
||||
@ -53,4 +53,4 @@ public class Program
|
||||
Log.CloseAndFlush();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,13 +1,27 @@
|
||||
{
|
||||
"$schema": "http://json.schemastore.org/launchsettings.json",
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "https://localhost:44331",
|
||||
"sslPort": 44331
|
||||
}
|
||||
},
|
||||
"profiles": {
|
||||
"http": {
|
||||
"commandName": "Project",
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"applicationUrl": "https://localhost:44331"
|
||||
}
|
||||
},
|
||||
"KonSoft.Dispatch.HttpApi.Host": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"applicationUrl": "https://localhost:44331",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,20 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<configuration>
|
||||
<location path="." inheritInChildApplications="false">
|
||||
<system.webServer>
|
||||
<handlers>
|
||||
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
|
||||
</handlers>
|
||||
<aspNetCore processPath="dotnet" arguments=".\KonSoft.Dispatch.HttpApi.Host.dll" stdoutLogEnabled="false"
|
||||
stdoutLogFile=".\Logs\stdout" hostingModel="inprocess" />
|
||||
</system.webServer>
|
||||
</location>
|
||||
<system.webServer>
|
||||
<httpProtocol>
|
||||
<customHeaders>
|
||||
<remove name="x-powered-by" />
|
||||
</customHeaders>
|
||||
</httpProtocol>
|
||||
</system.webServer>
|
||||
</configuration>
|
||||
<location path="." inheritInChildApplications="false">
|
||||
<system.webServer>
|
||||
<handlers>
|
||||
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
|
||||
</handlers>
|
||||
<aspNetCore processPath="dotnet" arguments=".\KonSoft.Dispatch.HttpApi.Host.dll" stdoutLogEnabled="false" stdoutLogFile=".\Logs\stdout" hostingModel="inprocess" />
|
||||
</system.webServer>
|
||||
</location>
|
||||
<system.webServer>
|
||||
<httpProtocol>
|
||||
<customHeaders>
|
||||
<remove name="x-powered-by" />
|
||||
</customHeaders>
|
||||
</httpProtocol>
|
||||
</system.webServer>
|
||||
</configuration>
|
||||
|
||||
@ -9,4 +9,4 @@ public class HomeController : AbpController
|
||||
{
|
||||
return Redirect("~/swagger");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -8,6 +8,21 @@
|
||||
<UserSecretsId>KonSoft.Payment-4681b4fd-151f-4221-84a4-929d86723e4c</UserSecretsId>
|
||||
</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>
|
||||
<Compile 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.EntityFrameworkCore\KonSoft.Payment.EntityFrameworkCore.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>
|
||||
|
||||
</Project>
|
||||
|
||||
@ -1,37 +1,179 @@
|
||||
using KonSoft.Payment.EntityFrameworkCore;
|
||||
using KonSoft.Shared.Hosting.AspNetCore;
|
||||
using KonSoft.Shared.Hosting.Microservices;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
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.Cors;
|
||||
using Microsoft.AspNetCore.DataProtection;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
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.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.Security.Claims;
|
||||
using Volo.Abp.Swashbuckle;
|
||||
using Volo.Abp.VirtualFileSystem;
|
||||
|
||||
namespace KonSoft.Payment;
|
||||
|
||||
[DependsOn(
|
||||
typeof(PaymentHttpApiModule),
|
||||
typeof(AbpAutofacModule),
|
||||
typeof(AbpCachingStackExchangeRedisModule),
|
||||
typeof(AbpDistributedLockingModule),
|
||||
typeof(AbpAspNetCoreMvcUiMultiTenancyModule),
|
||||
typeof(AbpAspNetCoreAuthenticationJwtBearerModule),
|
||||
typeof(PaymentApplicationModule),
|
||||
typeof(PaymentEntityFrameworkCoreModule),
|
||||
typeof(KonSoftSharedHostingMicroservicesModule)
|
||||
typeof(AbpAspNetCoreSerilogModule),
|
||||
typeof(AbpSwashbuckleModule)
|
||||
)]
|
||||
public class PaymentHttpApiHostModule : AbpModule
|
||||
{
|
||||
public override void ConfigureServices(ServiceConfigurationContext context)
|
||||
{
|
||||
var configuration = context.Services.GetConfiguration();
|
||||
var hostingEnvironment = context.Services.GetHostingEnvironment();
|
||||
|
||||
SwaggerConfigurationHelper.ConfigureWithOidc(
|
||||
context,
|
||||
ConfigureConventionalControllers();
|
||||
ConfigureAuthentication(context, configuration);
|
||||
ConfigureCache(configuration);
|
||||
ConfigureVirtualFileSystem(context);
|
||||
ConfigureDataProtection(context, configuration, hostingEnvironment);
|
||||
ConfigureDistributedLocking(context, configuration);
|
||||
ConfigureCors(context, configuration);
|
||||
ConfigureSwaggerServices(context, configuration);
|
||||
}
|
||||
|
||||
private void ConfigureCache(IConfiguration configuration)
|
||||
{
|
||||
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"]!,
|
||||
["PaymentService"],
|
||||
discoveryEndpoint: configuration["AuthServer:MetadataAddress"],
|
||||
apiTitle: "Payment Service API"
|
||||
);
|
||||
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);
|
||||
});
|
||||
}
|
||||
|
||||
// ֻ<><D6BB><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>
|
||||
Configure<AbpBackgroundJobOptions>(options => options.IsJobExecutionEnabled = false);
|
||||
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)
|
||||
@ -51,7 +193,7 @@ public class PaymentHttpApiHostModule : AbpModule
|
||||
app.UseCors();
|
||||
app.UseAuthentication();
|
||||
|
||||
if (KonSoftConsts.MultiTenancyEnabled)
|
||||
if (MultiTenancyConsts.IsEnabled)
|
||||
{
|
||||
app.UseMultiTenancy();
|
||||
}
|
||||
@ -74,4 +216,4 @@ public class PaymentHttpApiHostModule : AbpModule
|
||||
app.UseAbpSerilogEnrichers();
|
||||
app.UseConfiguredEndpoints();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,7 +10,7 @@ namespace KonSoft.Payment;
|
||||
|
||||
public class Program
|
||||
{
|
||||
public static async Task<int> Main(string[] args)
|
||||
public async static Task<int> Main(string[] args)
|
||||
{
|
||||
Log.Logger = new LoggerConfiguration()
|
||||
#if DEBUG
|
||||
@ -53,4 +53,4 @@ public class Program
|
||||
Log.CloseAndFlush();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,13 +1,27 @@
|
||||
{
|
||||
"$schema": "http://json.schemastore.org/launchsettings.json",
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "https://localhost:44326",
|
||||
"sslPort": 44326
|
||||
}
|
||||
},
|
||||
"profiles": {
|
||||
"http": {
|
||||
"commandName": "Project",
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"applicationUrl": "https://localhost:44326"
|
||||
}
|
||||
},
|
||||
"KonSoft.Payment.HttpApi.Host": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"applicationUrl": "https://localhost:44326",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,20 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<configuration>
|
||||
<location path="." inheritInChildApplications="false">
|
||||
<system.webServer>
|
||||
<handlers>
|
||||
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
|
||||
</handlers>
|
||||
<aspNetCore processPath="dotnet" arguments=".\KonSoft.Payment.HttpApi.Host.dll" stdoutLogEnabled="false"
|
||||
stdoutLogFile=".\Logs\stdout" hostingModel="inprocess" />
|
||||
</system.webServer>
|
||||
</location>
|
||||
<system.webServer>
|
||||
<httpProtocol>
|
||||
<customHeaders>
|
||||
<remove name="x-powered-by" />
|
||||
</customHeaders>
|
||||
</httpProtocol>
|
||||
</system.webServer>
|
||||
</configuration>
|
||||
<location path="." inheritInChildApplications="false">
|
||||
<system.webServer>
|
||||
<handlers>
|
||||
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
|
||||
</handlers>
|
||||
<aspNetCore processPath="dotnet" arguments=".\KonSoft.Payment.HttpApi.Host.dll" stdoutLogEnabled="false" stdoutLogFile=".\Logs\stdout" hostingModel="inprocess" />
|
||||
</system.webServer>
|
||||
</location>
|
||||
<system.webServer>
|
||||
<httpProtocol>
|
||||
<customHeaders>
|
||||
<remove name="x-powered-by" />
|
||||
</customHeaders>
|
||||
</httpProtocol>
|
||||
</system.webServer>
|
||||
</configuration>
|
||||
|
||||
@ -9,4 +9,4 @@ public class HomeController : AbpController
|
||||
{
|
||||
return Redirect("~/swagger");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -8,6 +8,21 @@
|
||||
<UserSecretsId>KonSoft.Report-4681b4fd-151f-4221-84a4-929d86723e4c</UserSecretsId>
|
||||
</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>
|
||||
<Compile 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.EntityFrameworkCore\KonSoft.Report.EntityFrameworkCore.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>
|
||||
|
||||
</Project>
|
||||
|
||||
@ -10,7 +10,7 @@ namespace KonSoft.Report;
|
||||
|
||||
public class Program
|
||||
{
|
||||
public static async Task<int> Main(string[] args)
|
||||
public async static Task<int> Main(string[] args)
|
||||
{
|
||||
Log.Logger = new LoggerConfiguration()
|
||||
#if DEBUG
|
||||
@ -53,4 +53,4 @@ public class Program
|
||||
Log.CloseAndFlush();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,13 +1,27 @@
|
||||
{
|
||||
"$schema": "http://json.schemastore.org/launchsettings.json",
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "https://localhost:44320",
|
||||
"sslPort": 44320
|
||||
}
|
||||
},
|
||||
"profiles": {
|
||||
"http": {
|
||||
"commandName": "Project",
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"applicationUrl": "https://localhost:44320"
|
||||
}
|
||||
},
|
||||
"KonSoft.Report.HttpApi.Host": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"applicationUrl": "https://localhost:44320",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,37 +1,179 @@
|
||||
using KonSoft.Report.EntityFrameworkCore;
|
||||
using KonSoft.Shared.Hosting.AspNetCore;
|
||||
using KonSoft.Shared.Hosting.Microservices;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
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.Cors;
|
||||
using Microsoft.AspNetCore.DataProtection;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
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.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.Security.Claims;
|
||||
using Volo.Abp.Swashbuckle;
|
||||
using Volo.Abp.VirtualFileSystem;
|
||||
|
||||
namespace KonSoft.Report;
|
||||
|
||||
[DependsOn(
|
||||
typeof(ReportHttpApiModule),
|
||||
typeof(AbpAutofacModule),
|
||||
typeof(AbpCachingStackExchangeRedisModule),
|
||||
typeof(AbpDistributedLockingModule),
|
||||
typeof(AbpAspNetCoreMvcUiMultiTenancyModule),
|
||||
typeof(AbpAspNetCoreAuthenticationJwtBearerModule),
|
||||
typeof(ReportApplicationModule),
|
||||
typeof(ReportEntityFrameworkCoreModule),
|
||||
typeof(KonSoftSharedHostingMicroservicesModule)
|
||||
typeof(AbpAspNetCoreSerilogModule),
|
||||
typeof(AbpSwashbuckleModule)
|
||||
)]
|
||||
public class ReportHttpApiHostModule : AbpModule
|
||||
{
|
||||
public override void ConfigureServices(ServiceConfigurationContext context)
|
||||
{
|
||||
var configuration = context.Services.GetConfiguration();
|
||||
var hostingEnvironment = context.Services.GetHostingEnvironment();
|
||||
|
||||
SwaggerConfigurationHelper.ConfigureWithOidc(
|
||||
context,
|
||||
ConfigureConventionalControllers();
|
||||
ConfigureAuthentication(context, configuration);
|
||||
ConfigureCache(configuration);
|
||||
ConfigureVirtualFileSystem(context);
|
||||
ConfigureDataProtection(context, configuration, hostingEnvironment);
|
||||
ConfigureDistributedLocking(context, configuration);
|
||||
ConfigureCors(context, configuration);
|
||||
ConfigureSwaggerServices(context, configuration);
|
||||
}
|
||||
|
||||
private void ConfigureCache(IConfiguration configuration)
|
||||
{
|
||||
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"]!,
|
||||
["ReportService"],
|
||||
discoveryEndpoint: configuration["AuthServer:MetadataAddress"],
|
||||
apiTitle: "Report Service API"
|
||||
);
|
||||
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);
|
||||
});
|
||||
}
|
||||
|
||||
// ֻ<><D6BB><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>
|
||||
Configure<AbpBackgroundJobOptions>(options => options.IsJobExecutionEnabled = false);
|
||||
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)
|
||||
@ -51,7 +193,7 @@ public class ReportHttpApiHostModule : AbpModule
|
||||
app.UseCors();
|
||||
app.UseAuthentication();
|
||||
|
||||
if (KonSoftConsts.MultiTenancyEnabled)
|
||||
if (MultiTenancyConsts.IsEnabled)
|
||||
{
|
||||
app.UseMultiTenancy();
|
||||
}
|
||||
@ -74,4 +216,4 @@ public class ReportHttpApiHostModule : AbpModule
|
||||
app.UseAbpSerilogEnrichers();
|
||||
app.UseConfiguredEndpoints();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,20 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<configuration>
|
||||
<location path="." inheritInChildApplications="false">
|
||||
<system.webServer>
|
||||
<handlers>
|
||||
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
|
||||
</handlers>
|
||||
<aspNetCore processPath="dotnet" arguments=".\KonSoft.Report.HttpApi.Host.dll" stdoutLogEnabled="false"
|
||||
stdoutLogFile=".\Logs\stdout" hostingModel="inprocess" />
|
||||
</system.webServer>
|
||||
</location>
|
||||
<system.webServer>
|
||||
<httpProtocol>
|
||||
<customHeaders>
|
||||
<remove name="x-powered-by" />
|
||||
</customHeaders>
|
||||
</httpProtocol>
|
||||
</system.webServer>
|
||||
</configuration>
|
||||
<location path="." inheritInChildApplications="false">
|
||||
<system.webServer>
|
||||
<handlers>
|
||||
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
|
||||
</handlers>
|
||||
<aspNetCore processPath="dotnet" arguments=".\KonSoft.Report.HttpApi.Host.dll" stdoutLogEnabled="false" stdoutLogFile=".\Logs\stdout" hostingModel="inprocess" />
|
||||
</system.webServer>
|
||||
</location>
|
||||
<system.webServer>
|
||||
<httpProtocol>
|
||||
<customHeaders>
|
||||
<remove name="x-powered-by" />
|
||||
</customHeaders>
|
||||
</httpProtocol>
|
||||
</system.webServer>
|
||||
</configuration>
|
||||
|
||||
@ -9,4 +9,4 @@ public class HomeController : AbpController
|
||||
{
|
||||
return Redirect("~/swagger");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -8,6 +8,21 @@
|
||||
<UserSecretsId>KonSoft.TenantManagement-4681b4fd-151f-4221-84a4-929d86723e4c</UserSecretsId>
|
||||
</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>
|
||||
<Compile 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.EntityFrameworkCore\KonSoft.TenantManagement.EntityFrameworkCore.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>
|
||||
|
||||
</Project>
|
||||
|
||||
@ -10,7 +10,7 @@ namespace KonSoft.TenantManagement;
|
||||
|
||||
public class Program
|
||||
{
|
||||
public static async Task<int> Main(string[] args)
|
||||
public async static Task<int> Main(string[] args)
|
||||
{
|
||||
Log.Logger = new LoggerConfiguration()
|
||||
#if DEBUG
|
||||
@ -53,4 +53,4 @@ public class Program
|
||||
Log.CloseAndFlush();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,13 +1,27 @@
|
||||
{
|
||||
"$schema": "http://json.schemastore.org/launchsettings.json",
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "https://localhost:44348",
|
||||
"sslPort": 44348
|
||||
}
|
||||
},
|
||||
"profiles": {
|
||||
"http": {
|
||||
"commandName": "Project",
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"applicationUrl": "https://localhost:44348"
|
||||
}
|
||||
},
|
||||
"KonSoft.TenantManagement.HttpApi.Host": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"applicationUrl": "https://localhost:44348",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,37 +1,179 @@
|
||||
using KonSoft.Shared.Hosting.AspNetCore;
|
||||
using KonSoft.Shared.Hosting.Microservices;
|
||||
using KonSoft.TenantManagement.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
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.Cors;
|
||||
using Microsoft.AspNetCore.DataProtection;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
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.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.Security.Claims;
|
||||
using Volo.Abp.Swashbuckle;
|
||||
using Volo.Abp.VirtualFileSystem;
|
||||
|
||||
namespace KonSoft.TenantManagement;
|
||||
|
||||
[DependsOn(
|
||||
typeof(TenantManagementHttpApiModule),
|
||||
typeof(AbpAutofacModule),
|
||||
typeof(AbpCachingStackExchangeRedisModule),
|
||||
typeof(AbpDistributedLockingModule),
|
||||
typeof(AbpAspNetCoreMvcUiMultiTenancyModule),
|
||||
typeof(AbpAspNetCoreAuthenticationJwtBearerModule),
|
||||
typeof(TenantManagementApplicationModule),
|
||||
typeof(TenantManagementEntityFrameworkCoreModule),
|
||||
typeof(KonSoftSharedHostingMicroservicesModule)
|
||||
typeof(AbpAspNetCoreSerilogModule),
|
||||
typeof(AbpSwashbuckleModule)
|
||||
)]
|
||||
public class TenantManagementHttpApiHostModule : AbpModule
|
||||
{
|
||||
public override void ConfigureServices(ServiceConfigurationContext context)
|
||||
{
|
||||
var configuration = context.Services.GetConfiguration();
|
||||
var hostingEnvironment = context.Services.GetHostingEnvironment();
|
||||
|
||||
SwaggerConfigurationHelper.ConfigureWithOidc(
|
||||
context,
|
||||
ConfigureConventionalControllers();
|
||||
ConfigureAuthentication(context, configuration);
|
||||
ConfigureCache(configuration);
|
||||
ConfigureVirtualFileSystem(context);
|
||||
ConfigureDataProtection(context, configuration, hostingEnvironment);
|
||||
ConfigureDistributedLocking(context, configuration);
|
||||
ConfigureCors(context, configuration);
|
||||
ConfigureSwaggerServices(context, configuration);
|
||||
}
|
||||
|
||||
private void ConfigureCache(IConfiguration configuration)
|
||||
{
|
||||
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"]!,
|
||||
["TenantManagementService"],
|
||||
discoveryEndpoint: configuration["AuthServer:MetadataAddress"],
|
||||
apiTitle: "TenantManagement Service API"
|
||||
);
|
||||
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);
|
||||
});
|
||||
}
|
||||
|
||||
// ֻ<><D6BB><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>
|
||||
Configure<AbpBackgroundJobOptions>(options => options.IsJobExecutionEnabled = false);
|
||||
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)
|
||||
@ -51,7 +193,7 @@ public class TenantManagementHttpApiHostModule : AbpModule
|
||||
app.UseCors();
|
||||
app.UseAuthentication();
|
||||
|
||||
if (KonSoftConsts.MultiTenancyEnabled)
|
||||
if (MultiTenancyConsts.IsEnabled)
|
||||
{
|
||||
app.UseMultiTenancy();
|
||||
}
|
||||
@ -74,4 +216,4 @@ public class TenantManagementHttpApiHostModule : AbpModule
|
||||
app.UseAbpSerilogEnrichers();
|
||||
app.UseConfiguredEndpoints();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,20 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<configuration>
|
||||
<location path="." inheritInChildApplications="false">
|
||||
<system.webServer>
|
||||
<handlers>
|
||||
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
|
||||
</handlers>
|
||||
<aspNetCore processPath="dotnet" arguments=".\KonSoft.TenantManagement.HttpApi.Host.dll" stdoutLogEnabled="false"
|
||||
stdoutLogFile=".\Logs\stdout" hostingModel="inprocess" />
|
||||
</system.webServer>
|
||||
</location>
|
||||
<system.webServer>
|
||||
<httpProtocol>
|
||||
<customHeaders>
|
||||
<remove name="x-powered-by" />
|
||||
</customHeaders>
|
||||
</httpProtocol>
|
||||
</system.webServer>
|
||||
</configuration>
|
||||
<location path="." inheritInChildApplications="false">
|
||||
<system.webServer>
|
||||
<handlers>
|
||||
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
|
||||
</handlers>
|
||||
<aspNetCore processPath="dotnet" arguments=".\KonSoft.TenantManagement.HttpApi.Host.dll" stdoutLogEnabled="false" stdoutLogFile=".\Logs\stdout" hostingModel="inprocess" />
|
||||
</system.webServer>
|
||||
</location>
|
||||
<system.webServer>
|
||||
<httpProtocol>
|
||||
<customHeaders>
|
||||
<remove name="x-powered-by" />
|
||||
</customHeaders>
|
||||
</httpProtocol>
|
||||
</system.webServer>
|
||||
</configuration>
|
||||
|
||||
@ -25,4 +25,4 @@ public class AdminApplicationContractsModule : AbpModule
|
||||
{
|
||||
AdminDtoExtensions.Configure();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,26 +1,28 @@
|
||||
using Volo.Abp.Threading;
|
||||
using Volo.Abp.Identity;
|
||||
using Volo.Abp.ObjectExtending;
|
||||
using Volo.Abp.Threading;
|
||||
|
||||
namespace KonSoft.Admin;
|
||||
|
||||
public static class AdminDtoExtensions
|
||||
{
|
||||
private static readonly OneTimeRunner OneTimeRunner = new();
|
||||
private static readonly OneTimeRunner OneTimeRunner = new OneTimeRunner();
|
||||
|
||||
public static void Configure()
|
||||
{
|
||||
OneTimeRunner.Run(() =>
|
||||
{
|
||||
/* You can add extension properties to DTOs
|
||||
* defined in the depended modules.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* ObjectExtensionManager.Instance
|
||||
* .AddOrUpdateProperty<IdentityRoleDto, string>("Title");
|
||||
*
|
||||
* See the documentation for more:
|
||||
* https://docs.abp.io/en/abp/latest/Object-Extensions
|
||||
*/
|
||||
/* You can add extension properties to DTOs
|
||||
* defined in the depended modules.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* ObjectExtensionManager.Instance
|
||||
* .AddOrUpdateProperty<IdentityRoleDto, string>("Title");
|
||||
*
|
||||
* See the documentation for more:
|
||||
* https://docs.abp.io/en/abp/latest/Object-Extensions
|
||||
*/
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,10 +0,0 @@
|
||||
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,19 +0,0 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
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,9 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace KonSoft.Admin.Dtos;
|
||||
|
||||
public class CreateServiceCategoryDto
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public Guid? ParentId { get; set; }
|
||||
}
|
||||
@ -1,20 +0,0 @@
|
||||
using System;
|
||||
using KonSoft.Admin.Enums;
|
||||
|
||||
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; }
|
||||
}
|
||||
@ -1,5 +0,0 @@
|
||||
namespace KonSoft.Admin.Dtos;
|
||||
|
||||
public class PayOrderDto
|
||||
{
|
||||
}
|
||||
@ -1,60 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace KonSoft.Admin.Dtos;
|
||||
|
||||
public class ProductDto : CreateProductDto
|
||||
{
|
||||
/// <summary>
|
||||
/// 嵌套子类
|
||||
/// </summary>
|
||||
public List<CreateProductDto> Children { get; set; } = new();
|
||||
}
|
||||
|
||||
public class CreateProductDto
|
||||
{
|
||||
/// <summary>
|
||||
/// 分类名称
|
||||
/// </summary>
|
||||
public string Name { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 商品编码
|
||||
/// </summary>
|
||||
public string Code { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 商品价格
|
||||
/// </summary>
|
||||
public decimal Price { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 商品描述
|
||||
/// </summary>
|
||||
public string Description { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 分类类型(大类或小类)
|
||||
/// </summary>
|
||||
public string Type { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 父分类ID
|
||||
/// </summary>
|
||||
public Guid? ParentId { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 商品状态(在售/下架等)
|
||||
/// </summary>
|
||||
public string Status { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 排序字段
|
||||
/// </summary>
|
||||
public int Order { get; private set; }
|
||||
}
|
||||
|
||||
public class UpdateProductDto : CreateProductDto
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
}
|
||||
@ -1,13 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
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();
|
||||
}
|
||||
@ -1,12 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
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,28 +0,0 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using KonSoft.Admin.Dtos;
|
||||
using Volo.Abp.Application.Dtos;
|
||||
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);
|
||||
Task DeleteAsync(params Guid[] ids);
|
||||
Task EditAsync(OrderDto input);
|
||||
Task<OrderDto> GetAsync(Guid id);
|
||||
Task<PagedResultDto<OrderDto>> GetListAsync(PagedResultRequestDto input);
|
||||
}
|
||||
@ -1,16 +0,0 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using KonSoft.Admin.Dtos;
|
||||
using Volo.Abp.Application.Dtos;
|
||||
using Volo.Abp.Application.Services;
|
||||
|
||||
namespace KonSoft.Admin.IApplicationServices;
|
||||
|
||||
public interface IProductAppService : IApplicationService
|
||||
{
|
||||
Task CreateAsync(CreateProductDto input);
|
||||
Task UpdateAsync(UpdateProductDto input);
|
||||
Task DeleteAsync(Guid id);
|
||||
Task<ProductDto> GetAsync(Guid id);
|
||||
Task<PagedResultDto<ProductDto>> GetListAsync(PagedResultRequestDto input);
|
||||
}
|
||||
@ -1,13 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using KonSoft.Admin.Dtos;
|
||||
|
||||
namespace KonSoft.Admin.IApplicationServices;
|
||||
|
||||
public interface IServiceCategoryAppService
|
||||
{
|
||||
Task<ServiceCategoryDto> CreateAsync(CreateServiceCategoryDto input);
|
||||
Task DeleteAsync(Guid id);
|
||||
Task<List<ServiceCategoryDto>> GetTreeAsync();
|
||||
}
|
||||
@ -1,7 +0,0 @@
|
||||
using Volo.Abp.Application.Services;
|
||||
|
||||
namespace KonSoft.Admin.IApplicationServices;
|
||||
|
||||
public interface IWorkerAppService : IApplicationService
|
||||
{
|
||||
}
|
||||
@ -1,5 +0,0 @@
|
||||
namespace KonSoft.Admin.IApplicationServices;
|
||||
|
||||
public interface IWorkerAssignmentService
|
||||
{
|
||||
}
|
||||
@ -17,4 +17,4 @@ public class AdminPermissionDefinitionProvider : PermissionDefinitionProvider
|
||||
{
|
||||
return LocalizableString.Create<AdminResource>(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,4 +6,4 @@ public static class AdminPermissions
|
||||
|
||||
//Add your own permission names. Example:
|
||||
//public const string MyPermission1 = GroupName + ".MyPermission1";
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,7 @@
|
||||
using KonSoft.Admin.Localization;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using KonSoft.Admin.Localization;
|
||||
using Volo.Abp.Application.Services;
|
||||
|
||||
namespace KonSoft.Admin;
|
||||
@ -11,4 +14,4 @@ public abstract class AdminAppService : ApplicationService
|
||||
{
|
||||
LocalizationResource = typeof(AdminResource);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,4 @@
|
||||
using AutoMapper;
|
||||
using KonSoft.Admin.Dtos;
|
||||
using KonSoft.Admin.Entities;
|
||||
using KonSoft.Admin.ValueObjects;
|
||||
|
||||
namespace KonSoft.Admin;
|
||||
|
||||
@ -12,10 +9,5 @@ public class AdminApplicationAutoMapperProfile : Profile
|
||||
/* You can configure your AutoMapper mapping configuration here.
|
||||
* Alternatively, you can split your mapping configurations
|
||||
* into multiple profile classes for a better organization. */
|
||||
|
||||
CreateMap<Order, OrderDto>();
|
||||
//CreateMap<CreateOrderDto, Order>();
|
||||
CreateMap<AddressDto, AddressInfo>();
|
||||
CreateMap<ServiceCategoryDto, ServiceCategory>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,11 +18,14 @@ namespace KonSoft.Admin;
|
||||
typeof(AbpTenantManagementApplicationModule),
|
||||
typeof(AbpFeatureManagementApplicationModule),
|
||||
typeof(AbpSettingManagementApplicationModule)
|
||||
)]
|
||||
)]
|
||||
public class AdminApplicationModule : AbpModule
|
||||
{
|
||||
public override void ConfigureServices(ServiceConfigurationContext context)
|
||||
{
|
||||
Configure<AbpAutoMapperOptions>(options => { options.AddMaps<AdminApplicationModule>(); });
|
||||
Configure<AbpAutoMapperOptions>(options =>
|
||||
{
|
||||
options.AddMaps<AdminApplicationModule>();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,167 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using KonSoft.Admin.Dtos;
|
||||
using KonSoft.Admin.Entities;
|
||||
using KonSoft.Admin.IApplicationServices;
|
||||
using KonSoft.Admin.IRepositories;
|
||||
using KonSoft.Admin.ValueObjects;
|
||||
using Volo.Abp;
|
||||
using Volo.Abp.Application.Dtos;
|
||||
using Volo.Abp.Application.Services;
|
||||
using Volo.Abp.Domain.Repositories;
|
||||
|
||||
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(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(PagedResultRequestDto input)
|
||||
{
|
||||
// 查询所有订单
|
||||
var orders = await _orderRepository.GetPagedListAsync(input.SkipCount, input.MaxResultCount, "Id");
|
||||
|
||||
var totalCount = await _orderRepository.CountAsync();
|
||||
|
||||
var orderDtos = ObjectMapper.Map<List<Order>, List<OrderDto>>(orders);
|
||||
|
||||
return new PagedResultDto<OrderDto>(totalCount, orderDtos);
|
||||
}
|
||||
}
|
||||
@ -1,102 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using KonSoft.Admin.Dtos;
|
||||
using KonSoft.Admin.Entities;
|
||||
using KonSoft.Admin.IApplicationServices;
|
||||
using KonSoft.Admin.IRepositories;
|
||||
using Volo.Abp;
|
||||
using Volo.Abp.Application.Dtos;
|
||||
using Volo.Abp.Application.Services;
|
||||
using Volo.Abp.Domain.Repositories;
|
||||
|
||||
namespace KonSoft.Admin.ApplicationServices;
|
||||
|
||||
public class ProductAppAppService(IProductRepository repository) : ApplicationService, IProductAppService
|
||||
{
|
||||
private readonly IProductRepository repository = repository;
|
||||
|
||||
/// <summary>
|
||||
/// 创建产品
|
||||
/// </summary>
|
||||
public async Task CreateAsync(CreateProductDto input)
|
||||
{
|
||||
var id = Guid.NewGuid();
|
||||
var product = new Product(id, input.Name, input.Code, input.Price, input.Description, input.Type,
|
||||
input.ParentId, input.Status, input.Order);
|
||||
await repository.InsertAsync(product);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除
|
||||
/// </summary>
|
||||
public async Task DeleteAsync(Guid id)
|
||||
{
|
||||
await repository.DeleteAsync(x => x.Id == id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询
|
||||
/// </summary>
|
||||
public async Task<ProductDto> GetAsync(Guid id)
|
||||
{
|
||||
var product = await repository.GetAsync(x => x.Id == id);
|
||||
return ObjectMapper.Map<Product, ProductDto>(product);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询集合
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<PagedResultDto<ProductDto>> GetListAsync(PagedResultRequestDto input)
|
||||
{
|
||||
var query = await repository.GetPageRootListAsync(input.SkipCount, input.MaxResultCount,
|
||||
x => x.ParentId == null);
|
||||
var all = await repository.GetListAsync(x => x.ParentId != null);
|
||||
foreach (var item in query)
|
||||
{
|
||||
BuildChildren(item, all);
|
||||
}
|
||||
|
||||
var totalCount = await repository.CountAsync(x => x.ParentId == null);
|
||||
|
||||
var productDtos = ObjectMapper.Map<List<Product>, List<ProductDto>>(query);
|
||||
|
||||
return new PagedResultDto<ProductDto>(totalCount, productDtos);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
public async Task UpdateAsync(UpdateProductDto input)
|
||||
{
|
||||
// 根据ID查询订单,如果不存在则抛出异常【修改前端必然看到了,数据若查不到提示自定义异常信息】
|
||||
var order = await repository.FindAsync(o => o.Id == input.Id) ??
|
||||
throw new BusinessException("商品找不到").WithData("Id", input.Id);
|
||||
|
||||
// 将输入的DTO字段映射到订单实体
|
||||
ObjectMapper.Map(input, order);
|
||||
|
||||
// 更新订单
|
||||
await repository.UpdateAsync(order);
|
||||
}
|
||||
|
||||
private static void BuildChildren(Product parent, List<Product> all)
|
||||
{
|
||||
var children = all
|
||||
.Where(x => x.ParentId == parent.Id)
|
||||
.OrderBy(x => x.Order)
|
||||
.ToList();
|
||||
|
||||
parent.Children = children;
|
||||
|
||||
foreach (var child in children)
|
||||
{
|
||||
BuildChildren(child, all); // 递归
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,77 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using KonSoft.Admin.Dtos;
|
||||
using KonSoft.Admin.Entities;
|
||||
using KonSoft.Admin.IApplicationServices;
|
||||
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();
|
||||
}
|
||||
}
|
||||
@ -6,8 +6,8 @@
|
||||
<RootNamespace>KonSoft.Admin</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\KonSoft.Admin.Domain\KonSoft.Admin.Domain.csproj" />
|
||||
<ProjectReference Include="..\KonSoft.Admin.Application.Contracts\KonSoft.Admin.Application.Contracts.csproj" />
|
||||
<ProjectReference Include="..\KonSoft.Admin.Domain\KonSoft.Admin.Domain.csproj"/>
|
||||
<ProjectReference Include="..\KonSoft.Admin.Application.Contracts\KonSoft.Admin.Application.Contracts.csproj"/>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Volo.Abp.Account.Application" Version="8.3.4" />
|
||||
|
||||
@ -1,3 +1,2 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
[assembly: InternalsVisibleToAttribute("KonSoft.Admin.Application.Tests")]
|
||||
[assembly:InternalsVisibleToAttribute("KonSoft.Admin.Application.Tests")]
|
||||
|
||||
@ -3,4 +3,4 @@
|
||||
public static class AdminDomainErrorCodes
|
||||
{
|
||||
/* You can add your business exception error codes here, as constants */
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user