Compare commits

...

19 Commits

Author SHA1 Message Date
151384da99 Merge branch 'master' of https://git.konsoft.top/konsoft/KonSoft.Clean 2025-10-19 22:48:14 +08:00
72701be91d feat support adminservice jenkins pipeline 2025-10-19 22:48:11 +08:00
281d300292 chore 重构测试环境发布 2025-10-19 19:19:58 +08:00
6a4aa91e01 feat 增加配置中心支持 2025-10-17 19:11:13 +08:00
28954870f6 feat 移除订单编号字段并优化订单创建逻辑
- 移除了 `Order` 实体中的 `OrderSN` 字段及相关逻辑。
- 修改 `Order` 构造函数,简化参数,新增默认状态字段。
- 更新 `AddressInfo` 属性访问修饰符为 `private set`。
- 调整 `OrderAppService` 的订单创建逻辑,适配新构造函数。
- 更新数据库迁移路径,新增迁移文件 `20251017042956_V1.0.0`。
- 新增 `AppOrder`、`AppProduct`、`AppServiceCategory` 表。
- 在 `AbpUsers` 表中新增字段以支持用户扩展。
- 更新实体配置,统一命名约定,支持扩展映射。
- 添加 `AdminDataSeedContributor` 类,预留数据种子逻辑。
2025-10-17 13:24:27 +08:00
89c8236f99 chore 重构数据库迁移逻辑并优化实体配置 2025-10-16 22:03:06 +08:00
69d2b460b6 chore 调整authserver服务Docker支持 2025-10-16 13:11:28 +08:00
1f5bc3e971 chore 优化代码 2025-10-16 10:30:51 +08:00
f1c609b4be upd:新增了家政用户实体,并添加了仓储,修改了之前的文件名字和db上下文里面的命名 2025-10-15 22:35:53 +08:00
1419e37ed5 product 2025-10-15 20:28:06 +08:00
4e465563c4 Merge branch 'master' of https://git.konsoft.top/konsoft/KonSoft.Clean 2025-10-15 16:50:33 +08:00
8bb4f18be3 分页 2025-10-15 16:50:24 +08:00
2709816ccd Merge branch 'master' of https://git.konsoft.top/konsoft/KonSoft.Clean 2025-10-15 16:19:02 +08:00
ea0d6d21f0 feat 新增admin服务种子数据执行者 2025-10-15 16:18:59 +08:00
36759da784 订单-删改查 2025-10-15 16:12:17 +08:00
26db968945 chore 优化启动配置文件 2025-10-12 18:30:12 +08:00
dbde1486e2 chore 调整nuget包版本 2025-10-12 15:40:33 +08:00
b545a603b0 Merge pull request 'add: 师傅实体和服务类型' (#4) from dv_onion into master
Reviewed-on: #4
2025-10-06 15:59:36 +08:00
6f2a1d1990 Merge pull request 'add: Order' (#3) from dv_onion into master
Reviewed-on: #3
2025-10-06 15:02:59 +08:00
396 changed files with 5845 additions and 3532 deletions

View File

@ -20,4 +20,5 @@
<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>
</wpf:ResourceDictionary>

32
adminservice.Jenkinsfile Normal file
View File

@ -0,0 +1,32 @@
pipeline {
agent any
stages {
stage('Clone') {
steps {
checkout scm
}
}
stage('Deploy') {
steps {
script {
try {
sh 'docker compose up -d adminservice -- build'
} catch (Exception e) {
error "部署失败: ${e.message}"
}
}
}
}
stage('Health Check') {
steps {
script {
sleep time: 30, unit: 'SECONDS'
sh 'docker ps | grep adminservice'
}
}
}
}
}

View File

@ -1,23 +1,41 @@
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 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 ["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 tool install -g Volo.Abp.Cli \
&& export PATH="$PATH:/root/.dotnet/tools" \
&& 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 .

View File

@ -40,21 +40,10 @@
<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.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" />

View File

@ -26,7 +26,7 @@ namespace KonSoft;
typeof(AbpAccountApplicationModule),
typeof(AbpAccountHttpApiModule),
typeof(KonSoftSharedHostingMicroservicesModule)
)]
)]
public class KonSoftAuthServerModule : AbpModule
{
public override void PreConfigureServices(ServiceConfigurationContext context)
@ -53,7 +53,8 @@ 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");
});
}
}
@ -77,10 +78,7 @@ public class KonSoftAuthServerModule : AbpModule
{
options.StyleBundles.Configure(
BasicThemeBundles.Styles.Global,
bundle =>
{
bundle.AddFiles("/global-styles.css");
}
bundle => { bundle.AddFiles("/global-styles.css"); }
);
});
@ -90,10 +88,7 @@ public class KonSoftAuthServerModule : AbpModule
options.ApplicationName = "AuthServer";
});
Configure<AbpBackgroundJobOptions>(options =>
{
options.IsJobExecutionEnabled = false;
});
Configure<AbpBackgroundJobOptions>(options => { options.IsJobExecutionEnabled = false; });
context.Services.Configure<AbpClaimsPrincipalFactoryOptions>(options =>
{

View File

@ -8,7 +8,7 @@ namespace KonSoft;
[Dependency(ReplaceServices = true)]
public class KonSoftBrandingProvider : DefaultBrandingProvider
{
private IStringLocalizer<KonSoftResource> _localizer;
private readonly IStringLocalizer<KonSoftResource> _localizer;
public KonSoftBrandingProvider(IStringLocalizer<KonSoftResource> localizer)
{

View File

@ -1,12 +1,13 @@
@page
@using System.Net
@using KonSoft.Shared.Localization.Localization
@using Microsoft.AspNetCore.Http.Extensions
@using Microsoft.AspNetCore.Mvc.Localization
@using KonSoft.Pages
@using KonSoft.Shared.Localization.Localization
@using Volo.Abp.Users
@using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Grid
@using Volo.Abp.AspNetCore.Mvc.UI.Theming
@using Volo.Abp.Ui.Branding
@model IndexModel
@using Volo.Abp.Users
@model KonSoft.Pages.IndexModel
@inject IHtmlLocalizer<KonSoftResource> L
@inject ICurrentUser CurrentUser
@inject IBrandingProvider BrandingProvider
@ -50,7 +51,7 @@
{
<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>
<a abp-button="Primary" asp-controller="Logout" asp-action="Index" asp-area="Account" asp-route-returnUrl="/">@L["Logout"]</a>
</div>
}
else
@ -64,13 +65,13 @@
<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={System.Net.WebUtility.UrlEncode(Request.GetEncodedPathAndQuery())}");
var languageUrl = Url.Content($"~/Abp/Languages/Switch?culture={language.CultureName}&uiCulture={language.UiCultureName}&returnUrl={WebUtility.UrlEncode(Request.GetEncodedPathAndQuery())}");
<abp-dropdown-item href="@languageUrl">@language.DisplayName</abp-dropdown-item>
}
</abp-dropdown-menu>
@ -82,12 +83,12 @@
@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="@Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Grid.ColumnSize._4" class="mb-2">
<abp-column size-md="@ColumnSize._4" class="mb-2">
<abp-card>
<abp-card-body>
@{

View File

@ -9,6 +9,12 @@ 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; }
@ -19,12 +25,6 @@ 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();

View File

@ -10,7 +10,7 @@ namespace KonSoft;
public class Program
{
public async static Task<int> Main(string[] args)
public static async Task<int> Main(string[] args)
{
Log.Logger = new LoggerConfiguration()
#if DEBUG

View File

@ -1,38 +1,13 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"KonSoft.AuthServer": {
"http": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:44322"
},
"Container (Dockerfile)": {
"commandName": "Docker",
"launchBrowser": true,
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}",
"environmentVariables": {
"ASPNETCORE_HTTPS_PORTS": "8081",
"ASPNETCORE_HTTP_PORTS": "8080"
},
"publishAllPorts": true,
"useSSL": true
}
},
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "https://localhost:44322",
"sslPort": 44322
}
}
}

View File

@ -1,11 +1,13 @@
<?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" />
<aspNetCore processPath="dotnet" arguments=".\KonSoft.AuthServer.dll" stdoutLogEnabled="false"
stdoutLogFile=".\Logs\stdout" hostingModel="inprocess" />
</system.webServer>
</location>
<system.webServer>

View File

@ -1,11 +1,11 @@
using Microsoft.AspNetCore.Mvc;
namespace KonSoft.BackgroundJobs.Controllers
namespace KonSoft.BackgroundJobs.Controllers;
[ApiController]
[Route("[controller]")]
public class WeatherForecastController : ControllerBase
{
[ApiController]
[Route("[controller]")]
public class WeatherForecastController : ControllerBase
{
private static readonly string[] Summaries =
[
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
@ -29,5 +29,4 @@ namespace KonSoft.BackgroundJobs.Controllers
})
.ToArray();
}
}
}

View File

@ -1,13 +1,5 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:4773",
"sslPort": 44380
}
},
"profiles": {
"http": {
"commandName": "Project",
@ -18,24 +10,6 @@
"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"
}
}
}
}

View File

@ -1,7 +1,7 @@
namespace KonSoft.BackgroundJobs
namespace KonSoft.BackgroundJobs;
public class WeatherForecast
{
public class WeatherForecast
{
public DateOnly Date { get; set; }
public int TemperatureC { get; set; }
@ -9,5 +9,4 @@ namespace KonSoft.BackgroundJobs
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
public string? Summary { get; set; }
}
}

View File

@ -1,11 +1,11 @@
using Microsoft.AspNetCore.Mvc;
namespace KonSoft.BackgroundWorker.Controllers
namespace KonSoft.BackgroundWorker.Controllers;
[ApiController]
[Route("[controller]")]
public class WeatherForecastController : ControllerBase
{
[ApiController]
[Route("[controller]")]
public class WeatherForecastController : ControllerBase
{
private static readonly string[] Summaries =
[
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
@ -29,5 +29,4 @@ namespace KonSoft.BackgroundWorker.Controllers
})
.ToArray();
}
}
}

View File

@ -1,13 +1,5 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:22937",
"sslPort": 44300
}
},
"profiles": {
"http": {
"commandName": "Project",
@ -18,24 +10,6 @@
"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"
}
}
}
}

View File

@ -1,7 +1,7 @@
namespace KonSoft.BackgroundWorker
namespace KonSoft.BackgroundWorker;
public class WeatherForecast
{
public class WeatherForecast
{
public DateOnly Date { get; set; }
public int TemperatureC { get; set; }
@ -9,5 +9,4 @@ namespace KonSoft.BackgroundWorker
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
public string? Summary { get; set; }
}
}

39
docker-compose.yml Normal file
View File

@ -0,0 +1,39 @@
services:
internalgateways:
container_name: clean-internalgateways
restart: always
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
authserver:
container_name: clean-authserver
restart: always
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
adminservice:
container_name: clean-adminservice
restart: always
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

View File

@ -1,33 +0,0 @@
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();
}
}
}

View File

@ -0,0 +1,29 @@
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
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"]

View File

@ -0,0 +1,17 @@
using KonSoft.Shared.Hosting.Gateways;
using Volo.Abp;
using Volo.Abp.Modularity;
namespace KonSoft.InternalGateway
{
[DependsOn(
typeof(KonSoftSharedHostingGatewaysModule)
)]
public class InternalGatewayModule : AbpModule
{
public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
}
}
}

View File

@ -4,10 +4,18 @@
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>98521e87-fe4a-4555-8c3b-e83559a64e03</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<DockerfileContext>..\..</DockerfileContext>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.22.1" />
<PackageReference Include="Yarp.ReverseProxy" Version="2.3.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\shared\KonSoft.Shared.Hosting.Gateways\KonSoft.Shared.Hosting.Gateways.csproj" />
</ItemGroup>
</Project>

View File

@ -1,25 +1,37 @@
var builder = WebApplication.CreateBuilder(args);
using KonSoft.InternalGateway;
using KonSoft.Shared.Hosting.AspNetCore;
using Serilog;
// Add services to the container.
var assemblyName = typeof(Program).Assembly.GetName().Name!;
SerilogConfigurationHelper.Configure(assemblyName);
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())
try
{
app.UseSwagger();
app.UseSwaggerUI();
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();
await app.RunAsync();
return 0;
}
catch (Exception ex)
{
Log.Fatal(ex, $"{assemblyName} terminated unexpectedly!");
return 1;
}
finally
{
await Log.CloseAndFlushAsync();
}
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
app.Run();

View File

@ -1,33 +1,24 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:15968",
"sslPort": 44395
}
},
{
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "http://localhost:5090",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"dotnetRunMessages": true,
"applicationUrl": "http://localhost:5090"
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "https://localhost:7264;http://localhost:5090",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"dotnetRunMessages": true,
"applicationUrl": "https://localhost:7264;http://localhost:5090"
},
"IIS Express": {
"commandName": "IISExpress",
@ -36,6 +27,26 @@
"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,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:15968",
"sslPort": 44395
}
}
}

View File

@ -1,13 +0,0 @@
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; }
}
}

View File

@ -1,9 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
"AgileConfig": {
"appId": "KonSoft.InternalGateway",
"name": "KonSoft.InternalGateway",
"nodes": "https://config.konsoft.top/",
"secret": "DBE31703-14F9-4B01-893D-900B8380CE04"
}
},
"AllowedHosts": "*"
}

View File

@ -1,11 +1,11 @@
using Microsoft.AspNetCore.Mvc;
namespace KonSoft.PublicGateway.Controllers
namespace KonSoft.PublicGateway.Controllers;
[ApiController]
[Route("[controller]")]
public class WeatherForecastController : ControllerBase
{
[ApiController]
[Route("[controller]")]
public class WeatherForecastController : ControllerBase
{
private static readonly string[] Summaries =
[
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
@ -29,5 +29,4 @@ namespace KonSoft.PublicGateway.Controllers
})
.ToArray();
}
}
}

View File

@ -1,7 +1,7 @@
namespace KonSoft.PublicGateway
namespace KonSoft.PublicGateway;
public class WeatherForecast
{
public class WeatherForecast
{
public DateOnly Date { get; set; }
public int TemperatureC { get; set; }
@ -9,5 +9,4 @@ namespace KonSoft.PublicGateway
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
public string? Summary { get; set; }
}
}

View File

@ -23,9 +23,9 @@ public class AdminHttpApiHostModule : AbpModule
var configuration = context.Services.GetConfiguration();
SwaggerConfigurationHelper.ConfigureWithOidc(
context: context,
authority: configuration["AuthServer:Authority"]!,
scopes: ["AdministrationService"],
context,
configuration["AuthServer:Authority"]!,
["AdministrationService"],
discoveryEndpoint: configuration["AuthServer:MetadataAddress"],
apiTitle: "Administration Service API"
);
@ -74,4 +74,10 @@ public class AdminHttpApiHostModule : AbpModule
app.UseAbpSerilogEnrichers();
app.UseConfiguredEndpoints();
}
//public override async Task OnPostApplicationInitializationAsync(ApplicationInitializationContext context)
//{
// await context.ServiceProvider.GetRequiredService<AdminPendingEfCoreMigrationsChecker>()
// .CheckAndApplyDatabaseMigrationsAsync();
//}
}

View File

@ -0,0 +1,13 @@
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;
}
}

View File

@ -0,0 +1,25 @@
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")
{
}
}

View File

@ -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,6 +15,10 @@ 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"

View File

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
@ -17,6 +17,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" />

View File

@ -1,8 +1,8 @@
using KonSoft.Admin;
using System;
using KonSoft.Admin;
using KonSoft.Shared.Hosting.AspNetCore;
using Microsoft.AspNetCore.Builder;
using Serilog;
using System;
var assemblyName = typeof(Program).Assembly.GetName().Name!;

View File

@ -1,6 +1,6 @@
{
"profiles": {
"KonSoft.Admin.HttpApi.Host": {
"http": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
@ -19,5 +19,6 @@
"publishAllPorts": true,
"useSSL": true
}
}
},
"$schema": "http://json.schemastore.org/launchsettings.json"
}

View File

@ -1,29 +1,13 @@
{
"App": {
"CorsOrigins": "https://*.KonSoft.top"
},
"ConnectionStrings": {
"Default": "Host=1.94.99.47;Port=26666;Database=Clean;User ID=postgres;Password=zzx7845zzx;"
},
"Redis": {
"Configuration": "1.94.99.47:26668"
"AgileConfig": {
"appId": "KonSoft.Admin.HttpApi.Host",
"name": "KonSoft.Admin.HttpApi.Host",
"nodes": "https://config.konsoft.top/",
"secret": "DBE31703-14F9-4B01-893D-900B8380CE04"
},
"AuthServer": {
"Authority": "https://localhost:44397",
"Authority": "https://localhost:44322",
"RequireHttpsMetadata": true,
"SwaggerClientId": "Admin_Swagger"
},
"StringEncryption": {
"DefaultPassPhrase": "g3NdNOyDR9oYj0gK"
},
"RabbitMQ": {
"Connections": {
"Default": {
"HostName": "1.94.99.47",
"Port": 26667,
"UserName": "admin",
"Password": "zzx7845zzx"
}
}
}
}

View File

@ -1,11 +1,13 @@
<?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" />
<aspNetCore processPath="dotnet" arguments=".\KonSoft.Admin.HttpApi.Host.dll" stdoutLogEnabled="false"
stdoutLogFile=".\Logs\stdout" hostingModel="inprocess" />
</system.webServer>
</location>
<system.webServer>

View File

@ -1,179 +1,37 @@
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 KonSoft.Dispatch.EntityFrameworkCore;
using KonSoft.Shared.Hosting.AspNetCore;
using KonSoft.Shared.Hosting.Microservices;
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.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.BackgroundJobs;
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(AbpAspNetCoreSerilogModule),
typeof(AbpSwashbuckleModule)
typeof(KonSoftSharedHostingMicroservicesModule)
)]
public class DispatchHttpApiHostModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
var configuration = context.Services.GetConfiguration();
var hostingEnvironment = context.Services.GetHostingEnvironment();
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(
SwaggerConfigurationHelper.ConfigureWithOidc(
context,
configuration["AuthServer:Authority"]!,
new Dictionary<string, string>
{
{"Dispatch", "Dispatch API"}
},
options =>
{
options.SwaggerDoc("v1", new OpenApiInfo { Title = "Dispatch API", Version = "v1" });
options.DocInclusionPredicate((docName, description) => true);
options.CustomSchemaIds(type => type.FullName);
});
}
["DispatchService"],
discoveryEndpoint: configuration["AuthServer:MetadataAddress"],
apiTitle: "Dispatch Service API"
);
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();
});
});
// ֻ<><D6BB><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>
Configure<AbpBackgroundJobOptions>(options => options.IsJobExecutionEnabled = false);
}
public override void OnApplicationInitialization(ApplicationInitializationContext context)
@ -193,7 +51,7 @@ public class DispatchHttpApiHostModule : AbpModule
app.UseCors();
app.UseAuthentication();
if (MultiTenancyConsts.IsEnabled)
if (KonSoftConsts.MultiTenancyEnabled)
{
app.UseMultiTenancy();
}

View File

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
@ -8,21 +8,6 @@
<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\**" />
@ -34,6 +19,7 @@
<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>

View File

@ -10,7 +10,7 @@ namespace KonSoft.Dispatch;
public class Program
{
public async static Task<int> Main(string[] args)
public static async Task<int> Main(string[] args)
{
Log.Logger = new LoggerConfiguration()
#if DEBUG

View File

@ -1,27 +1,13 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "https://localhost:44331",
"sslPort": 44331
}
},
"$schema": "http://json.schemastore.org/launchsettings.json",
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"KonSoft.Dispatch.HttpApi.Host": {
"http": {
"commandName": "Project",
"launchBrowser": true,
"applicationUrl": "https://localhost:44331",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"applicationUrl": "https://localhost:44331"
}
}
}

View File

@ -1,11 +1,13 @@
<?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" />
<aspNetCore processPath="dotnet" arguments=".\KonSoft.Dispatch.HttpApi.Host.dll" stdoutLogEnabled="false"
stdoutLogFile=".\Logs\stdout" hostingModel="inprocess" />
</system.webServer>
</location>
<system.webServer>

View File

@ -8,21 +8,6 @@
<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\**" />
@ -34,6 +19,7 @@
<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>

View File

@ -1,179 +1,37 @@
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 KonSoft.Payment.EntityFrameworkCore;
using KonSoft.Shared.Hosting.AspNetCore;
using KonSoft.Shared.Hosting.Microservices;
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.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.BackgroundJobs;
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(AbpAspNetCoreSerilogModule),
typeof(AbpSwashbuckleModule)
typeof(KonSoftSharedHostingMicroservicesModule)
)]
public class PaymentHttpApiHostModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
var configuration = context.Services.GetConfiguration();
var hostingEnvironment = context.Services.GetHostingEnvironment();
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(
SwaggerConfigurationHelper.ConfigureWithOidc(
context,
configuration["AuthServer:Authority"]!,
new Dictionary<string, string>
{
{"Payment", "Payment API"}
},
options =>
{
options.SwaggerDoc("v1", new OpenApiInfo { Title = "Payment API", Version = "v1" });
options.DocInclusionPredicate((docName, description) => true);
options.CustomSchemaIds(type => type.FullName);
});
}
["PaymentService"],
discoveryEndpoint: configuration["AuthServer:MetadataAddress"],
apiTitle: "Payment Service API"
);
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();
});
});
// ֻ<><D6BB><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>
Configure<AbpBackgroundJobOptions>(options => options.IsJobExecutionEnabled = false);
}
public override void OnApplicationInitialization(ApplicationInitializationContext context)
@ -193,7 +51,7 @@ public class PaymentHttpApiHostModule : AbpModule
app.UseCors();
app.UseAuthentication();
if (MultiTenancyConsts.IsEnabled)
if (KonSoftConsts.MultiTenancyEnabled)
{
app.UseMultiTenancy();
}

View File

@ -10,7 +10,7 @@ namespace KonSoft.Payment;
public class Program
{
public async static Task<int> Main(string[] args)
public static async Task<int> Main(string[] args)
{
Log.Logger = new LoggerConfiguration()
#if DEBUG

View File

@ -1,27 +1,13 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "https://localhost:44326",
"sslPort": 44326
}
},
"$schema": "http://json.schemastore.org/launchsettings.json",
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"KonSoft.Payment.HttpApi.Host": {
"http": {
"commandName": "Project",
"launchBrowser": true,
"applicationUrl": "https://localhost:44326",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"applicationUrl": "https://localhost:44326"
}
}
}

View File

@ -1,11 +1,13 @@
<?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" />
<aspNetCore processPath="dotnet" arguments=".\KonSoft.Payment.HttpApi.Host.dll" stdoutLogEnabled="false"
stdoutLogFile=".\Logs\stdout" hostingModel="inprocess" />
</system.webServer>
</location>
<system.webServer>

View File

@ -8,21 +8,6 @@
<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\**" />
@ -34,6 +19,7 @@
<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>

View File

@ -10,7 +10,7 @@ namespace KonSoft.Report;
public class Program
{
public async static Task<int> Main(string[] args)
public static async Task<int> Main(string[] args)
{
Log.Logger = new LoggerConfiguration()
#if DEBUG

View File

@ -1,27 +1,13 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "https://localhost:44320",
"sslPort": 44320
}
},
"$schema": "http://json.schemastore.org/launchsettings.json",
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"KonSoft.Report.HttpApi.Host": {
"http": {
"commandName": "Project",
"launchBrowser": true,
"applicationUrl": "https://localhost:44320",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"applicationUrl": "https://localhost:44320"
}
}
}

View File

@ -1,179 +1,37 @@
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 KonSoft.Report.EntityFrameworkCore;
using KonSoft.Shared.Hosting.AspNetCore;
using KonSoft.Shared.Hosting.Microservices;
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.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.BackgroundJobs;
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(AbpAspNetCoreSerilogModule),
typeof(AbpSwashbuckleModule)
typeof(KonSoftSharedHostingMicroservicesModule)
)]
public class ReportHttpApiHostModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
var configuration = context.Services.GetConfiguration();
var hostingEnvironment = context.Services.GetHostingEnvironment();
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(
SwaggerConfigurationHelper.ConfigureWithOidc(
context,
configuration["AuthServer:Authority"]!,
new Dictionary<string, string>
{
{"Report", "Report API"}
},
options =>
{
options.SwaggerDoc("v1", new OpenApiInfo { Title = "Report API", Version = "v1" });
options.DocInclusionPredicate((docName, description) => true);
options.CustomSchemaIds(type => type.FullName);
});
}
["ReportService"],
discoveryEndpoint: configuration["AuthServer:MetadataAddress"],
apiTitle: "Report Service API"
);
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();
});
});
// ֻ<><D6BB><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>
Configure<AbpBackgroundJobOptions>(options => options.IsJobExecutionEnabled = false);
}
public override void OnApplicationInitialization(ApplicationInitializationContext context)
@ -193,7 +51,7 @@ public class ReportHttpApiHostModule : AbpModule
app.UseCors();
app.UseAuthentication();
if (MultiTenancyConsts.IsEnabled)
if (KonSoftConsts.MultiTenancyEnabled)
{
app.UseMultiTenancy();
}

View File

@ -1,11 +1,13 @@
<?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" />
<aspNetCore processPath="dotnet" arguments=".\KonSoft.Report.HttpApi.Host.dll" stdoutLogEnabled="false"
stdoutLogFile=".\Logs\stdout" hostingModel="inprocess" />
</system.webServer>
</location>
<system.webServer>

View File

@ -8,21 +8,6 @@
<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\**" />
@ -34,6 +19,7 @@
<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>

View File

@ -10,7 +10,7 @@ namespace KonSoft.TenantManagement;
public class Program
{
public async static Task<int> Main(string[] args)
public static async Task<int> Main(string[] args)
{
Log.Logger = new LoggerConfiguration()
#if DEBUG

View File

@ -1,27 +1,13 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "https://localhost:44348",
"sslPort": 44348
}
},
"$schema": "http://json.schemastore.org/launchsettings.json",
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"KonSoft.TenantManagement.HttpApi.Host": {
"http": {
"commandName": "Project",
"launchBrowser": true,
"applicationUrl": "https://localhost:44348",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"applicationUrl": "https://localhost:44348"
}
}
}

View File

@ -1,179 +1,37 @@
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 KonSoft.Shared.Hosting.AspNetCore;
using KonSoft.Shared.Hosting.Microservices;
using KonSoft.TenantManagement.EntityFrameworkCore;
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.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.BackgroundJobs;
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(AbpAspNetCoreSerilogModule),
typeof(AbpSwashbuckleModule)
typeof(KonSoftSharedHostingMicroservicesModule)
)]
public class TenantManagementHttpApiHostModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
var configuration = context.Services.GetConfiguration();
var hostingEnvironment = context.Services.GetHostingEnvironment();
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(
SwaggerConfigurationHelper.ConfigureWithOidc(
context,
configuration["AuthServer:Authority"]!,
new Dictionary<string, string>
{
{"TenantManagement", "TenantManagement API"}
},
options =>
{
options.SwaggerDoc("v1", new OpenApiInfo { Title = "TenantManagement API", Version = "v1" });
options.DocInclusionPredicate((docName, description) => true);
options.CustomSchemaIds(type => type.FullName);
});
}
["TenantManagementService"],
discoveryEndpoint: configuration["AuthServer:MetadataAddress"],
apiTitle: "TenantManagement Service API"
);
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();
});
});
// ֻ<><D6BB><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>
Configure<AbpBackgroundJobOptions>(options => options.IsJobExecutionEnabled = false);
}
public override void OnApplicationInitialization(ApplicationInitializationContext context)
@ -193,7 +51,7 @@ public class TenantManagementHttpApiHostModule : AbpModule
app.UseCors();
app.UseAuthentication();
if (MultiTenancyConsts.IsEnabled)
if (KonSoftConsts.MultiTenancyEnabled)
{
app.UseMultiTenancy();
}

View File

@ -1,11 +1,13 @@
<?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" />
<aspNetCore processPath="dotnet" arguments=".\KonSoft.TenantManagement.HttpApi.Host.dll" stdoutLogEnabled="false"
stdoutLogFile=".\Logs\stdout" hostingModel="inprocess" />
</system.webServer>
</location>
<system.webServer>

View File

@ -1,12 +1,10 @@
using Volo.Abp.Identity;
using Volo.Abp.ObjectExtending;
using Volo.Abp.Threading;
using Volo.Abp.Threading;
namespace KonSoft.Admin;
public static class AdminDtoExtensions
{
private static readonly OneTimeRunner OneTimeRunner = new OneTimeRunner();
private static readonly OneTimeRunner OneTimeRunner = new();
public static void Configure()
{

View File

@ -1,17 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace KonSoft.Admin.Dtos;
namespace KonSoft.Admin.Dtos
public class AddressDto
{
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; }
}
}

View File

@ -1,25 +1,19 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace KonSoft.Admin.Dtos
namespace KonSoft.Admin.Dtos;
public class CreateOrderDto
{
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; }
[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; }
}
}

View File

@ -1,14 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace KonSoft.Admin.Dtos
namespace KonSoft.Admin.Dtos;
public class CreateServiceCategoryDto
{
public class CreateServiceCategoryDto
{
public string Name { get; set; }
public Guid? ParentId { get; set; }
}
}

View File

@ -1,14 +1,10 @@
using KonSoft.Admin.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System;
using KonSoft.Admin.Enums;
namespace KonSoft.Admin.Dtos
namespace KonSoft.Admin.Dtos;
public class OrderDto
{
public class OrderDto
{
public Guid Id { get; set; }
public string OrderSN { get; set; }
public Guid CustomerId { get; set; }
@ -21,5 +17,4 @@ namespace KonSoft.Admin.Dtos
public string PaymentMethod { get; set; }
public AddressDto Address { get; set; }
public string Remark { get; set; }
}
}

View File

@ -1,12 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace KonSoft.Admin.Dtos;
namespace KonSoft.Admin.Dtos
public class PayOrderDto
{
public class PayOrderDto
{
}
}

View File

@ -0,0 +1,60 @@
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; }
}

View File

@ -1,17 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace KonSoft.Admin.Dtos
namespace KonSoft.Admin.Dtos;
public class ServiceCategoryDto
{
public class ServiceCategoryDto
{
public Guid Id { get; set; }
public string Name { get; set; }
public Guid? ParentId { get; set; }
public int Level { get; set; }
public List<ServiceCategoryDto> Children { get; set; } = new List<ServiceCategoryDto>();
}
public List<ServiceCategoryDto> Children { get; set; } = new();
}

View File

@ -1,17 +1,12 @@
using KonSoft.Admin.Enums;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;
namespace KonSoft.Admin.Dtos
namespace KonSoft.Admin.Dtos;
public class WorkerDto : EntityDto<Guid>
{
public class WorkerDto : EntityDto<Guid>
{
public string Name { get; set; }
public string Phone { get; set; }
public List<Guid> SkillCategoryIds { get; set; } = new(); // 擅长服务类型
}
}

View File

@ -1,26 +1,28 @@
using KonSoft.Admin.Dtos;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System;
using System.Threading.Tasks;
using KonSoft.Admin.Dtos;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
namespace KonSoft.Admin.IApplicationServices
namespace KonSoft.Admin.IApplicationServices;
public interface IOrderAppService : IApplicationService
{
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);
}

View File

@ -0,0 +1,16 @@
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);
}

View File

@ -1,16 +1,13 @@
using KonSoft.Admin.Dtos;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using KonSoft.Admin.Dtos;
namespace KonSoft.Admin.IApplicationServices
namespace KonSoft.Admin.IApplicationServices;
public interface IServiceCategoryAppService
{
public interface IServiceCategoryAppService
{
Task<ServiceCategoryDto> CreateAsync(CreateServiceCategoryDto input);
Task DeleteAsync(Guid id);
Task<List<ServiceCategoryDto>> GetTreeAsync();
}
}

View File

@ -1,13 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Application.Services;
using Volo.Abp.Application.Services;
namespace KonSoft.Admin.IApplicationServices
namespace KonSoft.Admin.IApplicationServices;
public interface IWorkerAppService : IApplicationService
{
public interface IWorkerAppService : IApplicationService
{
}
}

View File

@ -1,15 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace KonSoft.Admin.IApplicationServices;
namespace KonSoft.Admin.IApplicationServices
public interface IWorkerAssignmentService
{
public interface IWorkerAssignmentService
{
}
}

View File

@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using KonSoft.Admin.Localization;
using KonSoft.Admin.Localization;
using Volo.Abp.Application.Services;
namespace KonSoft.Admin;

View File

@ -1,6 +1,7 @@
using AutoMapper;
using KonSoft.Admin.Dtos;
using KonSoft.Admin.Entities;
using KonSoft.Admin.ValueObjects;
namespace KonSoft.Admin;

View File

@ -18,14 +18,11 @@ 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>(); });
}
}

View File

@ -1,25 +1,23 @@
using KonSoft.Admin.Dtos;
using KonSoft.Admin.Entities;
using KonSoft.Admin.IApplicationServices;
using KonSoft.Admin.Repositories;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
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.ObjectMapping;
using Volo.Abp.Domain.Repositories;
namespace KonSoft.Admin.ApplicationServices
namespace KonSoft.Admin.ApplicationServices;
public class OrderAppService(IOrderRepository orderRepository) : ApplicationService, IOrderAppService
{
public class OrderAppService : ApplicationService, IOrderAppService
{
private readonly IOrderRepository _orderRepository;
private readonly IOrderRepository _orderRepository = orderRepository;
public OrderAppService(IOrderRepository orderRepository)
{
_orderRepository = orderRepository;
}
/// <summary>
/// 分配师傅
/// </summary>
@ -45,6 +43,7 @@ namespace KonSoft.Admin.ApplicationServices
var order = await _orderRepository.GetAsync(o => o.Id == orderId);
order.Cancel(reason);
}
/// <summary>
/// 完成订单
/// </summary>
@ -56,6 +55,7 @@ namespace KonSoft.Admin.ApplicationServices
var order = await _orderRepository.GetAsync(o => o.Id == orderId);
order.CompleteService();
}
/// <summary>
/// 确认订单
/// </summary>
@ -67,6 +67,7 @@ namespace KonSoft.Admin.ApplicationServices
var order = await _orderRepository.GetAsync(o => o.Id == orderId);
order.ConfirmCompletion();
}
/// <summary>
/// 创建订单
/// </summary>
@ -78,11 +79,41 @@ namespace KonSoft.Admin.ApplicationServices
// 生成订单号 TODO
var orderSN = "SN001";
var address = ObjectMapper.Map<AddressDto, AddressInfo>(input.Address);
var order = new Order(Guid.NewGuid(), orderSN, input.CustomerId, input.ServiceCategoryId, input.ServiceTime, input.Amount, address, input.Remark);
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>
@ -94,6 +125,7 @@ namespace KonSoft.Admin.ApplicationServices
{
throw new NotImplementedException();
}
/// <summary>
/// 开始订单
/// </summary>
@ -106,10 +138,30 @@ namespace KonSoft.Admin.ApplicationServices
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);
}
}

View File

@ -0,0 +1,102 @@
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); // 递归
}
}
}

View File

@ -1,18 +1,17 @@
using KonSoft.Admin.Dtos;
using KonSoft.Admin.Entities;
using KonSoft.Admin.IApplicationServices;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
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
namespace KonSoft.Admin.ApplicationServices;
public class ServiceCategoryAppService : ApplicationService, IServiceCategoryAppService
{
public class ServiceCategoryAppService : ApplicationService, IServiceCategoryAppService
{
private readonly IRepository<ServiceCategory, Guid> _repository;
@ -42,7 +41,10 @@ namespace KonSoft.Admin.ApplicationServices
public async Task DeleteAsync(Guid id)
{
var hasChildren = await _repository.AnyAsync(c => c.ParentId == id);
if (hasChildren) throw new InvalidOperationException("存在子节点无法删除!");
if (hasChildren)
{
throw new InvalidOperationException("存在子节点无法删除!");
}
await _repository.DeleteAsync(o => o.Id == id);
@ -53,7 +55,8 @@ namespace KonSoft.Admin.ApplicationServices
var allCategories = await _repository.GetListAsync();
// 构建树
var lookup = allCategories.ToDictionary(c => c.Id, c => ObjectMapper.Map<ServiceCategory, ServiceCategoryDto>(c));
var lookup =
allCategories.ToDictionary(c => c.Id, c => ObjectMapper.Map<ServiceCategory, ServiceCategoryDto>(c));
var rootList = new List<ServiceCategoryDto>();
@ -71,5 +74,4 @@ namespace KonSoft.Admin.ApplicationServices
return rootList.OrderBy(c => c.Name).ToList();
}
}
}

View File

@ -1,20 +0,0 @@
using KonSoft.Admin.Dtos;
using KonSoft.Admin.Entities;
using KonSoft.Admin.IApplicationServices;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Application.Services;
using Volo.Abp.Domain.Repositories;
namespace KonSoft.Admin.ApplicationServices
{
public class WorkerAppService : CrudAppService<Worker, WorkerDto, Guid>, IWorkerAppService
{
public WorkerAppService(IRepository<Worker, Guid> repository) : base(repository)
{
}
}
}

View File

@ -1,27 +0,0 @@
using KonSoft.Admin.Entities;
using KonSoft.Admin.IApplicationServices;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Application.Services;
using Volo.Abp.Domain.Repositories;
namespace KonSoft.Admin.ApplicationServices
{
/// <summary>
/// 分配家政人员 TODO
/// </summary>
public class WorkerAssignmentService : ApplicationService, IWorkerAssignmentService
{
private readonly IRepository<Worker, Guid> _workerRepository;
private readonly IRepository<Order, Guid> _orderRepository;
public WorkerAssignmentService(IRepository<Worker, Guid> workerRepository, IRepository<Order, Guid> orderRepository)
{
_workerRepository = workerRepository;
_orderRepository = orderRepository;
}
}
}

View File

@ -1,2 +1,3 @@
using System.Runtime.CompilerServices;
[assembly:InternalsVisibleToAttribute("KonSoft.Admin.Application.Tests")]
[assembly: InternalsVisibleToAttribute("KonSoft.Admin.Application.Tests")]

View File

@ -24,7 +24,7 @@ namespace KonSoft.Admin;
typeof(AbpPermissionManagementDomainSharedModule),
typeof(AbpSettingManagementDomainSharedModule),
typeof(AbpTenantManagementDomainSharedModule)
)]
)]
public class AdminDomainSharedModule : AbpModule
{
public override void PreConfigureServices(ServiceConfigurationContext context)
@ -35,10 +35,7 @@ public class AdminDomainSharedModule : AbpModule
public override void ConfigureServices(ServiceConfigurationContext context)
{
Configure<AbpVirtualFileSystemOptions>(options =>
{
options.FileSets.AddEmbedded<AdminDomainSharedModule>();
});
Configure<AbpVirtualFileSystemOptions>(options => { options.FileSets.AddEmbedded<AdminDomainSharedModule>(); });
Configure<AbpLocalizationOptions>(options =>
{

View File

@ -4,7 +4,7 @@ namespace KonSoft.Admin;
public static class AdminGlobalFeatureConfigurator
{
private static readonly OneTimeRunner OneTimeRunner = new OneTimeRunner();
private static readonly OneTimeRunner OneTimeRunner = new();
public static void Configure()
{

View File

@ -1,13 +1,10 @@
using System.ComponentModel.DataAnnotations;
using Volo.Abp.Identity;
using Volo.Abp.ObjectExtending;
using Volo.Abp.Threading;
using Volo.Abp.Threading;
namespace KonSoft.Admin;
public static class AdminModuleExtensionConfigurator
{
private static readonly OneTimeRunner OneTimeRunner = new OneTimeRunner();
private static readonly OneTimeRunner OneTimeRunner = new();
public static void Configure()
{

View File

@ -1,13 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace KonSoft.Admin.Enums;
namespace KonSoft.Admin.Enums
public enum OrderStatus
{
public enum OrderStatus
{
PendingPayment, // 待支付
PaidWaitingAssign, // 已支付待派单
AssignedWaitingService, // 已派单待服务
@ -17,6 +11,4 @@ namespace KonSoft.Admin.Enums
Canceled, // 已取消
Refunding, // 退款中
Refunded // 已退款
}
}

View File

@ -5,5 +5,4 @@ namespace KonSoft.Admin.Localization;
[LocalizationResourceName("Admin")]
public class AdminResource
{
}

View File

@ -3,6 +3,6 @@
public static class AdminConsts
{
public const string DbTablePrefix = "App";
public const string DbSchema = null;
public const string DbSchema = "";
public const string ConnectionStringName = "Default";
}

View File

@ -7,7 +7,6 @@ using Volo.Abp.FeatureManagement;
using Volo.Abp.Identity;
using Volo.Abp.Localization;
using Volo.Abp.Modularity;
using Volo.Abp.MultiTenancy;
using Volo.Abp.OpenIddict;
using Volo.Abp.PermissionManagement.Identity;
using Volo.Abp.PermissionManagement.OpenIddict;

View File

@ -17,12 +17,11 @@ namespace KonSoft.Admin.Data;
public class AdminDbMigrationService : ITransientDependency
{
public ILogger<AdminDbMigrationService> Logger { get; set; }
private readonly ICurrentTenant _currentTenant;
private readonly IDataSeeder _dataSeeder;
private readonly IEnumerable<IAdminDbSchemaMigrator> _dbSchemaMigrators;
private readonly ITenantRepository _tenantRepository;
private readonly ICurrentTenant _currentTenant;
public AdminDbMigrationService(
IDataSeeder dataSeeder,
@ -38,6 +37,8 @@ public class AdminDbMigrationService : ITransientDependency
Logger = NullLogger<AdminDbMigrationService>.Instance;
}
public ILogger<AdminDbMigrationService> Logger { get; set; }
public async Task MigrateAsync()
{
var initialMigrationAdded = AddInitialMigrationIfNotExist();
@ -52,7 +53,7 @@ public class AdminDbMigrationService : ITransientDependency
await MigrateDatabaseSchemaAsync();
await SeedDataAsync();
Logger.LogInformation($"Successfully completed host database migrations.");
Logger.LogInformation("Successfully completed host database migrations.");
var tenants = await _tenantRepository.GetListAsync(includeDetails: true);
@ -101,8 +102,10 @@ public class AdminDbMigrationService : ITransientDependency
Logger.LogInformation($"Executing {(tenant == null ? "host" : tenant.Name + " tenant")} database seed...");
await _dataSeeder.SeedAsync(new DataSeedContext(tenant?.Id)
.WithProperty(IdentityDataSeedContributor.AdminEmailPropertyName, IdentityDataSeedContributor.AdminEmailDefaultValue)
.WithProperty(IdentityDataSeedContributor.AdminPasswordPropertyName, IdentityDataSeedContributor.AdminPasswordDefaultValue)
.WithProperty(IdentityDataSeedContributor.AdminEmailPropertyName,
IdentityDataSeedContributor.AdminEmailDefaultValue)
.WithProperty(IdentityDataSeedContributor.AdminPasswordPropertyName,
IdentityDataSeedContributor.AdminPasswordDefaultValue)
);
}
@ -127,11 +130,9 @@ public class AdminDbMigrationService : ITransientDependency
AddInitialMigration();
return true;
}
else
{
return false;
}
}
catch (Exception e)
{
Logger.LogWarning("Couldn't determinate if any migrations exist : " + e.Message);
@ -149,7 +150,8 @@ public class AdminDbMigrationService : ITransientDependency
private bool MigrationsFolderExists()
{
var dbMigrationsProjectFolder = GetEntityFrameworkCoreProjectFolderPath();
return dbMigrationsProjectFolder != null && Directory.Exists(Path.Combine(dbMigrationsProjectFolder, "Migrations"));
return dbMigrationsProjectFolder != null &&
Directory.Exists(Path.Combine(dbMigrationsProjectFolder, "Migrations"));
}
private void AddInitialMigration()
@ -207,7 +209,8 @@ public class AdminDbMigrationService : ITransientDependency
{
currentDirectory = Directory.GetParent(currentDirectory.FullName);
if (currentDirectory != null && Directory.GetFiles(currentDirectory.FullName).FirstOrDefault(f => f.EndsWith(".sln")) != null)
if (currentDirectory != null &&
Directory.GetFiles(currentDirectory.FullName).FirstOrDefault(f => f.EndsWith(".sln")) != null)
{
return currentDirectory.FullName;
}

View File

@ -1,60 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Domain.Entities;
using Volo.Abp.Domain.Values;
namespace KonSoft.Admin.Entities
{
/// <summary>
/// 地址
/// </summary>
public class AddressInfo : ValueObject
{
/// <summary>
/// 联系人
/// </summary>
public string ContactName { get; private set; }
/// <summary>
/// 手机号
/// </summary>
public string ContactPhone { get; private set; }
/// <summary>
/// 详细地址
/// </summary>
public string DetailAddress { get; private set; }
/// <summary>
/// 城市
/// </summary>
public string City { get; private set; }
/// <summary>
/// 区域
/// </summary>
public string District { get; private set; }
public AddressInfo() { }
public AddressInfo(string contactName, string contactPhone, string detailAddress, string city, string district)
{
ContactName = contactName;
ContactPhone = contactPhone;
DetailAddress = detailAddress;
City = city;
District = district;
}
protected override IEnumerable<object> GetAtomicValues()
{
yield return ContactName;
yield return ContactPhone;
yield return DetailAddress;
yield return City;
yield return District;
}
}
}

View File

@ -0,0 +1,24 @@
using Volo.Abp.Identity;
namespace KonSoft.Admin.Entities;
/// <summary>
/// 家政服务工人实体
/// </summary>
public class HouseholdWorker : IdentityUser
{
/// <summary>
/// 接单数
/// </summary>
public int OrderCount { get; set; }
/// <summary>
/// 职业
/// </summary>
public required string Profession { get; set; }
/// <summary>
/// 能力范围
/// </summary>
public required string ScopeOfCompetence { get; set; }
}

View File

@ -1,85 +1,20 @@
using KonSoft.Admin.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System;
using KonSoft.Admin.Enums;
using KonSoft.Admin.ValueObjects;
using Volo.Abp.Domain.Entities.Auditing;
using Volo.Abp.Identity;
namespace KonSoft.Admin.Entities
namespace KonSoft.Admin.Entities;
public class Order : FullAuditedAggregateRoot<Guid>
{
public class Order : FullAuditedAggregateRoot<Guid>
private Order()
{
/// <summary>
/// 订单编号
/// </summary>
public string OrderSN { get; private set; }
/// <summary>
/// 用户ID
/// </summary>
public Guid CustomerId { get; private set; }
/// <summary>
/// 家政人员ID
/// </summary>
public Guid? WorkerId { get; private set; }
///// <summary>
///// 用户ID
///// </summary>
//public virtual IdentityUser Customer { get; private set; }
///// <summary>
///// 家政人员ID
///// </summary>
//public virtual IdentityUser? Worker { get; private set; }
/// <summary>
/// 服务项目ID
/// </summary>
public Guid ServiceCategoryId { get; private set; }
public virtual ServiceCategory ServiceCategory { get; private set; }
/// <summary>
/// 服务预约时间
/// </summary>
public DateTime ServiceTime { get; private set; }
public OrderStatus Status { get; private set; }
/// <summary>
/// 应付金额
/// </summary>
public decimal Amount { get; private set; }
/// <summary>
/// 实付金额
/// </summary>
public decimal PaidAmount { get; private set; }
/// <summary>
/// 支付方式
/// </summary>
public string PaymentMethod { get; private set; }
/// <summary>
/// 地址
/// </summary>
public AddressInfo Address { get; private set; }
/// <summary>
/// 备注
/// </summary>
public string? Remark { get; private set; }
/// <summary>
/// 取消原因
/// </summary>
public string? CancelReason { get; private set; }
protected Order() { }
}
public Order(Guid id, string orderSN, Guid customerId, Guid serviceCategoryId, DateTime serviceTime, decimal amount, AddressInfo address, string remark = null)
: base(id)
public Order(Guid customerId, Guid serviceCategoryId, DateTime serviceTime, decimal amount,
AddressInfo address, string? remark = null)
{
OrderSN = orderSN;
CustomerId = customerId;
ServiceCategoryId = serviceCategoryId;
ServiceTime = serviceTime;
@ -89,11 +24,68 @@ namespace KonSoft.Admin.Entities
Status = OrderStatus.PendingPayment;
}
/// <summary>
/// 用户ID
/// </summary>
public Guid CustomerId { get; private set; }
/// <summary>
/// 家政人员ID
/// </summary>
public Guid? WorkerId { get; private set; }
/// <summary>
/// 服务项目ID
/// </summary>
public Guid ServiceCategoryId { get; private set; }
/// <summary>
/// 服务预约时间
/// </summary>
public DateTime ServiceTime { get; private set; }
/// <summary>
/// 订单状态
/// </summary>
public OrderStatus Status { get; private set; }
/// <summary>
/// 应付金额
/// </summary>
public decimal Amount { get; private set; }
/// <summary>
/// 实付金额
/// </summary>
public decimal PaidAmount { get; private set; }
/// <summary>
/// 支付方式
/// </summary>
public string PaymentMethod { get; private set; }
/// <summary>
/// 地址
/// </summary>
public AddressInfo Address { get; private set; }
/// <summary>
/// 备注
/// </summary>
public string? Remark { get; private set; }
/// <summary>
/// 取消原因
/// </summary>
public string? CancelReason { get; private set; }
public void MarkPaid(decimal paidAmount, string method)
{
if (Status != OrderStatus.PendingPayment)
{
throw new InvalidOperationException("订单不在待付款状态");
}
PaidAmount = paidAmount;
@ -105,7 +97,9 @@ namespace KonSoft.Admin.Entities
public void AssignWorker(Guid workerId)
{
if (Status != OrderStatus.PaidWaitingAssign)
{
throw new InvalidOperationException("订单无法分配师傅");
}
WorkerId = workerId;
@ -116,7 +110,9 @@ namespace KonSoft.Admin.Entities
public void StartService()
{
if (Status != OrderStatus.AssignedWaitingService)
{
throw new InvalidOperationException("订单无法开始");
}
Status = OrderStatus.InService;
@ -126,7 +122,9 @@ namespace KonSoft.Admin.Entities
public void CompleteService()
{
if (Status != OrderStatus.InService)
{
throw new InvalidOperationException("订单未开始服务,无法完成");
}
Status = OrderStatus.WaitingConfirm;
@ -136,7 +134,9 @@ namespace KonSoft.Admin.Entities
public void ConfirmCompletion()
{
if (Status != OrderStatus.WaitingConfirm)
{
throw new InvalidOperationException("订单无法确认");
}
Status = OrderStatus.Completed;
@ -147,11 +147,12 @@ namespace KonSoft.Admin.Entities
{
// 若已完成或退款中则不可取消
if (Status == OrderStatus.Completed || Status == OrderStatus.Refunding || Status == OrderStatus.Refunded)
{
throw new InvalidOperationException("订单无法被取消");
}
CancelReason = reason;
Status = OrderStatus.Canceled;
}
}
}

View File

@ -0,0 +1,105 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using Volo.Abp.Domain.Entities.Auditing;
namespace KonSoft.Admin.Entities;
public class Product(
Guid id,
string name,
string code,
decimal price,
string description,
string type,
Guid? parentId,
string status = "在售",
int order = 0) : FullAuditedAggregateRoot<Guid>(id)
{
/// <summary>
/// 分类名称
/// </summary>
public string Name { get; private set; } = name;
/// <summary>
/// 商品编码
/// </summary>
public string Code { get; private set; } = code;
/// <summary>
/// 商品价格
/// </summary>
public decimal Price { get; private set; } = price;
/// <summary>
/// 商品描述
/// </summary>
public string Description { get; private set; } = description;
/// <summary>
/// 分类类型(大类或小类)
/// </summary>
public string Type { get; private set; } = type;
/// <summary>
/// 父分类ID
/// </summary>
public Guid? ParentId { get; private set; } = parentId;
/// <summary>
/// 商品状态(在售/下架等)
/// </summary>
public string Status { get; private set; } = status;
/// <summary>
/// 排序字段
/// </summary>
public int Order { get; private set; } = order;
[NotMapped] public List<Product> Children { get; set; } = new();
/// <summary>
/// 修改商品信息
/// </summary>
public void Update(string name, string code, decimal price, string description, int order)
{
Name = name;
Code = code;
Price = price;
Description = description;
Order = order;
}
/// <summary>
/// 修改商品分类
/// </summary>
public void ChangeCategory(string type, Guid? parentId)
{
Type = type;
ParentId = parentId;
}
/// <summary>
/// 上架商品
/// </summary>
public void PutOnSale()
{
Status = "在售";
}
/// <summary>
/// 下架商品
/// </summary>
public void TakeOffSale()
{
Status = "下架";
}
/// <summary>
/// 修改价格
/// </summary>
public void ChangePrice(decimal newPrice)
{
Price = newPrice;
}
}

View File

@ -1,20 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Domain.Entities.Auditing;
namespace KonSoft.Admin.Entities
{
public class ServiceCategory : FullAuditedAggregateRoot<Guid>
{
public string Name { get; private set; }
public Guid? ParentId { get; private set; }
public string Path { get; private set; }
public int Level { get; private set; }
namespace KonSoft.Admin.Entities;
protected ServiceCategory() { }
public class ServiceCategory : FullAuditedAggregateRoot<Guid>
{
protected ServiceCategory()
{
}
public ServiceCategory(Guid id, string name)
: base(id)
@ -30,8 +23,16 @@ namespace KonSoft.Admin.Entities
Level = level;
}
public string Name { get; private set; }
public Guid? ParentId { get; private set; }
public string Path { get; private set; }
public int Level { get; private set; }
public void UpdateName(string name) => Name = name;
public void UpdateName(string name)
{
Name = name;
}
public void SetParent(ServiceCategory parent)
@ -40,7 +41,4 @@ namespace KonSoft.Admin.Entities
Level = (parent?.Level ?? 0) + 1;
Path = parent != null ? $"{parent.Path}/{Id}" : Id.ToString();
}
}
}

View File

@ -1,34 +0,0 @@
using KonSoft.Admin.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Domain.Entities.Auditing;
namespace KonSoft.Admin.Entities
{
/// <summary>
/// 家政人员
/// </summary>
public class Worker : FullAuditedAggregateRoot<Guid>
{
public string Name { get; private set; }
public string Phone { get; private set; }
public decimal Rating { get; private set; } // 评分
public List<Guid> SkillCategoryIds { get; private set; } = new List<Guid>();
public Worker() { }
public void UpdateRating(decimal newRating)
{
Rating = newRating;
}
public bool CanPerform(Guid serviceCategoryId)
{
return SkillCategoryIds.Contains(serviceCategoryId);
}
}
}

View File

@ -0,0 +1,8 @@
using KonSoft.Admin.Entities;
using Volo.Abp.Domain.Repositories;
namespace KonSoft.Admin.IRepositories;
public interface IHouseholdWorkerRepository : IRepository<HouseholdWorker>
{
}

View File

@ -0,0 +1,8 @@
using KonSoft.Admin.Entities;
using Volo.Abp.Domain.Repositories;
namespace KonSoft.Admin.IRepositories;
public interface IOrderRepository : IRepository<Order>
{
}

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Threading.Tasks;
using KonSoft.Admin.Entities;
using Volo.Abp.Domain.Repositories;
namespace KonSoft.Admin.IRepositories;
public interface IProductRepository : IRepository<Product>
{
Task<List<Product>> GetPageRootListAsync(int skipCount, int maxResult, Expression<Func<Product, bool>> where);
}

View File

@ -23,12 +23,12 @@ namespace KonSoft.Admin.OpenIddict;
*/
public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDependency
{
private readonly IAbpApplicationManager _applicationManager;
private readonly IConfiguration _configuration;
private readonly IOpenIddictApplicationRepository _openIddictApplicationRepository;
private readonly IAbpApplicationManager _applicationManager;
private readonly IOpenIddictScopeRepository _openIddictScopeRepository;
private readonly IOpenIddictScopeManager _scopeManager;
private readonly IPermissionDataSeeder _permissionDataSeeder;
private readonly IOpenIddictScopeManager _scopeManager;
private readonly IStringLocalizer<OpenIddictResponse> L;
public OpenIddictDataSeedContributor(
@ -38,7 +38,7 @@ public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDep
IOpenIddictScopeRepository openIddictScopeRepository,
IOpenIddictScopeManager scopeManager,
IPermissionDataSeeder permissionDataSeeder,
IStringLocalizer<OpenIddictResponse> l )
IStringLocalizer<OpenIddictResponse> l)
{
_configuration = configuration;
_openIddictApplicationRepository = openIddictApplicationRepository;
@ -60,7 +60,8 @@ public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDep
{
if (await _openIddictScopeRepository.FindByNameAsync("Admin") == null)
{
await _scopeManager.CreateAsync(new OpenIddictScopeDescriptor {
await _scopeManager.CreateAsync(new OpenIddictScopeDescriptor
{
Name = "Admin", DisplayName = "Admin API", Resources = { "Admin" }
});
}
@ -68,7 +69,8 @@ public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDep
private async Task CreateApplicationsAsync()
{
var commonScopes = new List<string> {
var commonScopes = new List<string>
{
OpenIddictConstants.Permissions.Scopes.Address,
OpenIddictConstants.Permissions.Scopes.Email,
OpenIddictConstants.Permissions.Scopes.Phone,
@ -80,10 +82,6 @@ public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDep
var configurationSection = _configuration.GetSection("OpenIddict:Applications");
// Swagger Client
var swaggerClientId = configurationSection["Admin_Swagger:ClientId"];
if (!swaggerClientId.IsNullOrWhiteSpace())
@ -91,13 +89,13 @@ public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDep
var swaggerRootUrl = configurationSection["Admin_Swagger:RootUrl"]?.TrimEnd('/');
await CreateApplicationAsync(
name: swaggerClientId!,
type: OpenIddictConstants.ClientTypes.Public,
consentType: OpenIddictConstants.ConsentTypes.Implicit,
displayName: "Swagger Application",
secret: null,
grantTypes: [OpenIddictConstants.GrantTypes.AuthorizationCode],
scopes: commonScopes,
swaggerClientId!,
OpenIddictConstants.ClientTypes.Public,
OpenIddictConstants.ConsentTypes.Implicit,
"Swagger Application",
null,
[OpenIddictConstants.GrantTypes.AuthorizationCode],
commonScopes,
redirectUri: $"{swaggerRootUrl}/swagger/oauth2-redirect.html",
clientUri: swaggerRootUrl
);
@ -131,13 +129,14 @@ public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDep
var client = await _openIddictApplicationRepository.FindByClientIdAsync(name);
var application = new AbpApplicationDescriptor {
var application = new AbpApplicationDescriptor
{
ClientId = name,
ClientType = type,
ClientSecret = secret,
ConsentType = consentType,
DisplayName = displayName,
ClientUri = clientUri,
ClientUri = clientUri
};
Check.NotNullOrEmpty(grantTypes, nameof(grantTypes));
@ -160,7 +159,8 @@ public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDep
application.Permissions.Add(OpenIddictConstants.Permissions.Endpoints.Logout);
}
var buildInGrantTypes = new[] {
var buildInGrantTypes = new[]
{
OpenIddictConstants.GrantTypes.Implicit, OpenIddictConstants.GrantTypes.Password,
OpenIddictConstants.GrantTypes.AuthorizationCode, OpenIddictConstants.GrantTypes.ClientCredentials,
OpenIddictConstants.GrantTypes.DeviceCode, OpenIddictConstants.GrantTypes.RefreshToken
@ -233,7 +233,8 @@ public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDep
}
}
var buildInScopes = new[] {
var buildInScopes = new[]
{
OpenIddictConstants.Permissions.Scopes.Address, OpenIddictConstants.Permissions.Scopes.Email,
OpenIddictConstants.Permissions.Scopes.Phone, OpenIddictConstants.Permissions.Scopes.Profile,
OpenIddictConstants.Permissions.Scopes.Roles
@ -289,8 +290,7 @@ public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDep
await _permissionDataSeeder.SeedAsync(
ClientPermissionValueProvider.ProviderName,
name,
permissions,
null
permissions
);
}
@ -302,8 +302,10 @@ public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDep
if (!HasSameRedirectUris(client, application))
{
client.RedirectUris = JsonSerializer.Serialize(application.RedirectUris.Select(q => q.ToString().TrimEnd('/')));
client.PostLogoutRedirectUris = JsonSerializer.Serialize(application.PostLogoutRedirectUris.Select(q => q.ToString().TrimEnd('/')));
client.RedirectUris =
JsonSerializer.Serialize(application.RedirectUris.Select(q => q.ToString().TrimEnd('/')));
client.PostLogoutRedirectUris =
JsonSerializer.Serialize(application.PostLogoutRedirectUris.Select(q => q.ToString().TrimEnd('/')));
await _applicationManager.UpdateAsync(client.ToModel());
}
@ -317,11 +319,13 @@ public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDep
private bool HasSameRedirectUris(OpenIddictApplication existingClient, AbpApplicationDescriptor application)
{
return existingClient.RedirectUris == JsonSerializer.Serialize(application.RedirectUris.Select(q => q.ToString().TrimEnd('/')));
return existingClient.RedirectUris ==
JsonSerializer.Serialize(application.RedirectUris.Select(q => q.ToString().TrimEnd('/')));
}
private bool HasSameScopes(OpenIddictApplication existingClient, AbpApplicationDescriptor application)
{
return existingClient.Permissions == JsonSerializer.Serialize(application.Permissions.Select(q => q.ToString().TrimEnd('/')));
return existingClient.Permissions ==
JsonSerializer.Serialize(application.Permissions.Select(q => q.ToString().TrimEnd('/')));
}
}

View File

@ -1,3 +1,4 @@
using System.Runtime.CompilerServices;
[assembly:InternalsVisibleToAttribute("KonSoft.Admin.Domain.Tests")]
[assembly:InternalsVisibleToAttribute("KonSoft.Admin.TestBase")]
[assembly: InternalsVisibleToAttribute("KonSoft.Admin.Domain.Tests")]
[assembly: InternalsVisibleToAttribute("KonSoft.Admin.TestBase")]

View File

@ -1,14 +0,0 @@
using KonSoft.Admin.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories;
namespace KonSoft.Admin.Repositories
{
public interface IOrderRepository : IRepository<Order>
{
}
}

Some files were not shown because too many files have changed in this diff Show More