diff --git a/NPin.sln b/NPin.sln index ad25365..aa3046d 100644 --- a/NPin.sln +++ b/NPin.sln @@ -29,11 +29,21 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution common.props = common.props end.sh = end.sh start.sh = start.sh - using.props = using.props + usings.props = usings.props EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "module", "module", "{EEAD0AD4-0F90-46D9-A775-D88AE07E2869}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NPin.Domain.Shared", "src\NPin.Domain.Shared\NPin.Domain.Shared.csproj", "{9718B82F-B12A-4F4C-A22E-A0C10B49C54D}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NPin.Domain", "src\NPin.Domain\NPin.Domain.csproj", "{DDB9B331-3CB1-47C1-8AD8-96A3587A774D}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NPin.Application", "src\NPin.Application\NPin.Application.csproj", "{34CEB35B-97EF-41DB-B10B-DC83B2453E9D}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NPin.Application.Contracts", "src\NPin.Application.Contracts\NPin.Application.Contracts.csproj", "{C4D324BB-01B6-436F-9AA6-136C7D5438F6}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NPin.SqlSugarCore", "src\NPin.SqlSugarCore\NPin.SqlSugarCore.csproj", "{DC8E2E59-589F-4521-95E2-9CE7E1DD5541}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -80,6 +90,26 @@ Global {CE218FFC-52D5-4C6A-857D-5CAA649A3A2E}.Debug|Any CPU.Build.0 = Debug|Any CPU {CE218FFC-52D5-4C6A-857D-5CAA649A3A2E}.Release|Any CPU.ActiveCfg = Release|Any CPU {CE218FFC-52D5-4C6A-857D-5CAA649A3A2E}.Release|Any CPU.Build.0 = Release|Any CPU + {9718B82F-B12A-4F4C-A22E-A0C10B49C54D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9718B82F-B12A-4F4C-A22E-A0C10B49C54D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9718B82F-B12A-4F4C-A22E-A0C10B49C54D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9718B82F-B12A-4F4C-A22E-A0C10B49C54D}.Release|Any CPU.Build.0 = Release|Any CPU + {DDB9B331-3CB1-47C1-8AD8-96A3587A774D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DDB9B331-3CB1-47C1-8AD8-96A3587A774D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DDB9B331-3CB1-47C1-8AD8-96A3587A774D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DDB9B331-3CB1-47C1-8AD8-96A3587A774D}.Release|Any CPU.Build.0 = Release|Any CPU + {34CEB35B-97EF-41DB-B10B-DC83B2453E9D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {34CEB35B-97EF-41DB-B10B-DC83B2453E9D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {34CEB35B-97EF-41DB-B10B-DC83B2453E9D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {34CEB35B-97EF-41DB-B10B-DC83B2453E9D}.Release|Any CPU.Build.0 = Release|Any CPU + {C4D324BB-01B6-436F-9AA6-136C7D5438F6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C4D324BB-01B6-436F-9AA6-136C7D5438F6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C4D324BB-01B6-436F-9AA6-136C7D5438F6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C4D324BB-01B6-436F-9AA6-136C7D5438F6}.Release|Any CPU.Build.0 = Release|Any CPU + {DC8E2E59-589F-4521-95E2-9CE7E1DD5541}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DC8E2E59-589F-4521-95E2-9CE7E1DD5541}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DC8E2E59-589F-4521-95E2-9CE7E1DD5541}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DC8E2E59-589F-4521-95E2-9CE7E1DD5541}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(NestedProjects) = preSolution {088B4948-AE5B-45B3-A9FA-B853671CFA05} = {F2A0A89E-A2F9-48CF-AD38-0318B5ACD11C} @@ -92,5 +122,10 @@ Global {4C59B5B2-C140-48A7-ABFB-7581905BFDE4} = {F2A0A89E-A2F9-48CF-AD38-0318B5ACD11C} {BFDBFC7F-58D3-4816-AFA8-93265E28268C} = {F2A0A89E-A2F9-48CF-AD38-0318B5ACD11C} {CE218FFC-52D5-4C6A-857D-5CAA649A3A2E} = {F2A0A89E-A2F9-48CF-AD38-0318B5ACD11C} + {9718B82F-B12A-4F4C-A22E-A0C10B49C54D} = {86F61EBB-4ACC-459C-AB3C-C8D486C3017D} + {DDB9B331-3CB1-47C1-8AD8-96A3587A774D} = {86F61EBB-4ACC-459C-AB3C-C8D486C3017D} + {34CEB35B-97EF-41DB-B10B-DC83B2453E9D} = {86F61EBB-4ACC-459C-AB3C-C8D486C3017D} + {C4D324BB-01B6-436F-9AA6-136C7D5438F6} = {86F61EBB-4ACC-459C-AB3C-C8D486C3017D} + {DC8E2E59-589F-4521-95E2-9CE7E1DD5541} = {86F61EBB-4ACC-459C-AB3C-C8D486C3017D} EndGlobalSection EndGlobal diff --git a/src/NPin.Application.Contracts/NPin.Application.Contracts.csproj b/src/NPin.Application.Contracts/NPin.Application.Contracts.csproj new file mode 100644 index 0000000..84992ab --- /dev/null +++ b/src/NPin.Application.Contracts/NPin.Application.Contracts.csproj @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/src/NPin.Application.Contracts/NPinApplicationContractsModule.cs b/src/NPin.Application.Contracts/NPinApplicationContractsModule.cs new file mode 100644 index 0000000..e5a2bb6 --- /dev/null +++ b/src/NPin.Application.Contracts/NPinApplicationContractsModule.cs @@ -0,0 +1,15 @@ +using NPin.Domain.Shared; +using NPin.Framework.Ddd.Application.Contracts; + +namespace NPin.Application.Contracts; + +[DependsOn( + typeof(NPinDomainSharedModule), + // TODO RBAC + // TODO Bbs + // TODO Tenant + typeof(NPinFrameworkDddApplicationContractsModule))] +public class NPinApplicationContractsModule : AbpModule +{ + +} \ No newline at end of file diff --git a/src/NPin.Application/NPin.Application.csproj b/src/NPin.Application/NPin.Application.csproj new file mode 100644 index 0000000..e0e8cd2 --- /dev/null +++ b/src/NPin.Application/NPin.Application.csproj @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/src/NPin.Application/NPinApplicationModule.cs b/src/NPin.Application/NPinApplicationModule.cs new file mode 100644 index 0000000..c409886 --- /dev/null +++ b/src/NPin.Application/NPinApplicationModule.cs @@ -0,0 +1,9 @@ +using NPin.Application.Contracts; +using NPin.Framework.Ddd.Application.Contracts; + +namespace NPin.Application; + + +public class NPinApplicationModule: AbpModule +{ +} \ No newline at end of file diff --git a/src/NPin.Domain.Shared/NPin.Domain.Shared.csproj b/src/NPin.Domain.Shared/NPin.Domain.Shared.csproj new file mode 100644 index 0000000..b40bfea --- /dev/null +++ b/src/NPin.Domain.Shared/NPin.Domain.Shared.csproj @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/src/NPin.Domain.Shared/NPinDomainSharedModule.cs b/src/NPin.Domain.Shared/NPinDomainSharedModule.cs new file mode 100644 index 0000000..78f04bf --- /dev/null +++ b/src/NPin.Domain.Shared/NPinDomainSharedModule.cs @@ -0,0 +1,11 @@ +namespace NPin.Domain.Shared; + +[DependsOn( + typeof(NPinDomainSharedModule)) +// TODO RBAC +// TODO BBS +// TODO AuditLogging +] +public class NPinDomainSharedModule : AbpModule +{ +} \ No newline at end of file diff --git a/src/NPin.Domain/NPin.Domain.csproj b/src/NPin.Domain/NPin.Domain.csproj new file mode 100644 index 0000000..14d796e --- /dev/null +++ b/src/NPin.Domain/NPin.Domain.csproj @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/src/NPin.SqlSugarCore/NPin.SqlSugarCore.csproj b/src/NPin.SqlSugarCore/NPin.SqlSugarCore.csproj new file mode 100644 index 0000000..0090a15 --- /dev/null +++ b/src/NPin.SqlSugarCore/NPin.SqlSugarCore.csproj @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/src/NPin.Web/Dockerfile b/src/NPin.Web/Dockerfile index 3fe8b87..c52eb69 100644 --- a/src/NPin.Web/Dockerfile +++ b/src/NPin.Web/Dockerfile @@ -1,20 +1,47 @@ -FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base +#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging. + +FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base +USER app WORKDIR /app -EXPOSE 80 -EXPOSE 443 +EXPOSE 8080 FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build +ARG BUILD_CONFIGURATION=Release WORKDIR /src -COPY ["NPin/NPin.csproj", "NPin/"] -RUN dotnet restore "NPin/NPin.csproj" +COPY ["src/NPin.Web/NPin.Web.csproj", "src/NPin.Web/"] +COPY ["framework/NPin.Framework.AspNetCore.Authentication.OAuth/NPin.Framework.AspNetCore.Authentication.OAuth.csproj", "framework/NPin.Framework.AspNetCore.Authentication.OAuth/"] +COPY ["framework/NPin.Framework.AspNetCore/NPin.Framework.AspNetCore.csproj", "framework/NPin.Framework.AspNetCore/"] +COPY ["framework/NPin.Framework.Core/NPin.Framework.Core.csproj", "framework/NPin.Framework.Core/"] +COPY ["src/NPin.Application/NPin.Application.csproj", "src/NPin.Application/"] +COPY ["framework/NPin.Framework.Ddd.Application/NPin.Framework.Ddd.Application.csproj", "framework/NPin.Framework.Ddd.Application/"] +COPY ["framework/NPin.Framework.Ddd.Application.Contracts/NPin.Framework.Ddd.Application.Contracts.csproj", "framework/NPin.Framework.Ddd.Application.Contracts/"] +COPY ["module/bbs/NPin.Framework.Bbs.Application/NPin.Framework.Bbs.Application.csproj", "module/bbs/NPin.Framework.Bbs.Application/"] +COPY ["module/rbac/NPin.Framework.Rbac.Application/NPin.Framework.Rbac.Application.csproj", "module/rbac/NPin.Framework.Rbac.Application/"] +COPY ["module/rbac/NPin.Framework.Rbac.Application.Contracts/NPin.Framework.Rbac.Application.Contracts.csproj", "module/rbac/NPin.Framework.Rbac.Application.Contracts/"] +COPY ["module/rbac/NPin.Framework.Rbac.Domain.Shared/NPin.Framework.Rbac.Domain.Shared.csproj", "module/rbac/NPin.Framework.Rbac.Domain.Shared/"] +COPY ["framework/NPin.Framework.Mapster/NPin.Framework.Mapster.csproj", "framework/NPin.Framework.Mapster/"] +COPY ["framework/NPin.Framework.SqlSugarCore.Abstractions/NPin.Framework.SqlSugarCore.Abstractions.csproj", "framework/NPin.Framework.SqlSugarCore.Abstractions/"] +COPY ["module/rbac/NPin.Framework.Rbac.Domain/NPin.Framework.Rbac.Domain.csproj", "module/rbac/NPin.Framework.Rbac.Domain/"] +COPY ["module/bbs/NPin.Framework.Bbs.Application.Contracts/NPin.Framework.Bbs.Application.Contracts.csproj", "module/bbs/NPin.Framework.Bbs.Application.Contracts/"] +COPY ["module/bbs/NPin.Framework.Bbs.Domain.Shared/NPin.Framework.Bbs.Domain.Shared.csproj", "module/bbs/NPin.Framework.Bbs.Domain.Shared/"] +COPY ["module/bbs/NPin.Framework.Bbs.Domain/NPin.Framework.Bbs.Domain.csproj", "module/bbs/NPin.Framework.Bbs.Domain/"] +COPY ["src/NPin.Application.Contracts/NPin.Application.Contracts.csproj", "src/NPin.Application.Contracts/"] +COPY ["src/NPin.Domain.Shared/NPin.Domain.Shared.csproj", "src/NPin.Domain.Shared/"] +COPY ["src/NPin.Domain/NPin.Domain.csproj", "src/NPin.Domain/"] +COPY ["src/NPin.SqlSugarCore/NPin.SqlSugarCore.csproj", "src/NPin.SqlSugarCore/"] +COPY ["framework/NPin.Framework.SqlSugarCore/NPin.Framework.SqlSugarCore.csproj", "framework/NPin.Framework.SqlSugarCore/"] +COPY ["module/bbs/NPin.Framework.Bbs.SqlSugarCore/NPin.Framework.Bbs.SqlSugarCore.csproj", "module/bbs/NPin.Framework.Bbs.SqlSugarCore/"] +COPY ["module/rbac/NPin.Framework.Rbac.SqlSugarCore/NPin.Framework.Rbac.SqlSugarCore.csproj", "module/rbac/NPin.Framework.Rbac.SqlSugarCore/"] +RUN dotnet restore "./src/NPin.Web/./NPin.Web.csproj" COPY . . -WORKDIR "/src/NPin" -RUN dotnet build "NPin.csproj" -c Release -o /app/build +WORKDIR "/src/src/NPin.Web" +RUN dotnet build "./NPin.Web.csproj" -c $BUILD_CONFIGURATION -o /app/build FROM build AS publish -RUN dotnet publish "NPin.csproj" -c Release -o /app/publish +ARG BUILD_CONFIGURATION=Release +RUN dotnet publish "./NPin.Web.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false FROM base AS final WORKDIR /app COPY --from=publish /app/publish . -ENTRYPOINT ["dotnet", "NPin.dll"] +ENTRYPOINT ["dotnet", "NPin.Web.dll"] \ No newline at end of file diff --git a/src/NPin.Web/NPin.Web.csproj b/src/NPin.Web/NPin.Web.csproj index d4cb4c6..fd844b8 100644 --- a/src/NPin.Web/NPin.Web.csproj +++ b/src/NPin.Web/NPin.Web.csproj @@ -1,17 +1,45 @@ - - net8.0 - enable - enable - true Linux - NPin + ..\.. + + + + + + + + + + + + + + + + + + + + + + + Always + + + Always + + + + + + - - + + Always + diff --git a/src/NPin.Web/NPinWebModule.cs b/src/NPin.Web/NPinWebModule.cs new file mode 100644 index 0000000..b1664d0 --- /dev/null +++ b/src/NPin.Web/NPinWebModule.cs @@ -0,0 +1,10 @@ +using Volo.Abp.Modularity; + +namespace NPin; + +// [DependsOn( +// typeof(NPin))] +public class NPinWebModule: AbpModule +{ + +} \ No newline at end of file diff --git a/src/NPin.Web/Program.cs b/src/NPin.Web/Program.cs index 161f695..d1134c4 100644 --- a/src/NPin.Web/Program.cs +++ b/src/NPin.Web/Program.cs @@ -1,44 +1,42 @@ -var builder = WebApplication.CreateBuilder(args); -// Add services to the container. -// 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()) +using NPin; +using Serilog; +using Serilog.Events; + +// 创建日志 +Log.Logger = new LoggerConfiguration() + .MinimumLevel.Debug() + .MinimumLevel.Override("Microsoft", LogEventLevel.Information) + .MinimumLevel.Override("Microsoft.AspNetCore.Hosting.Diagnostics", LogEventLevel.Error) + .MinimumLevel.Override("Quartz", LogEventLevel.Warning) + // 可使用{SourceContext}记录 + .Enrich.FromLogContext() + .WriteTo.Async(c => c.File("logs/log-.txt", rollingInterval: RollingInterval.Day, + restrictedToMinimumLevel: LogEventLevel.Debug)) + .WriteTo.Async(c => c.File("logs/error-.txt", rollingInterval: RollingInterval.Day, + restrictedToMinimumLevel: LogEventLevel.Error)) + .WriteTo.Async(c => c.Console()) + .CreateLogger(); + +try { - app.UseSwagger(); - app.UseSwaggerUI(); -} + Log.Information("NPin-Framework (Abp.vNext) 启动!"); -app.UseHttpsRedirection(); + var builder = WebApplication.CreateBuilder(args); + builder.WebHost.UseUrls(builder.Configuration["App:SelfUrl"]); + builder.Host.UseAutofac(); + builder.Host.UseSerilog(); -var summaries = new[] + await builder.Services.AddApplicationAsync(); + var app = builder.Build(); + await app.InitializeApplicationAsync(); + await app.RunAsync(); +} +catch (Exception ex) { - "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" -}; - -app.MapGet("/weatherforecast", () => - { - var forecast = Enumerable.Range(1, 5).Select(index => - new WeatherForecast - ( - DateOnly.FromDateTime(DateTime.Now.AddDays(index)), - Random.Shared.Next(-20, 55), - summaries[Random.Shared.Next(summaries.Length)] - )) - .ToArray(); - return forecast; - }) - .WithName("GetWeatherForecast") - .WithOpenApi(); - -app.Run(); - -record WeatherForecast(DateOnly Date, int TemperatureC, string? Summary) + Log.Fatal(ex, "NPin-Framework (Abp.vNext) 爆炸!"); +} +finally { - public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); + Log.CloseAndFlush(); } \ No newline at end of file diff --git a/src/NPin.Web/appsettings.json b/src/NPin.Web/appsettings.json index 10f68b8..f2c126b 100644 --- a/src/NPin.Web/appsettings.json +++ b/src/NPin.Web/appsettings.json @@ -1,9 +1,24 @@ { "Logging": { "LogLevel": { - "Default": "Information", + // "Default": "Information", + "Default": "Debug", "Microsoft.AspNetCore": "Warning" } }, - "AllowedHosts": "*" + "AllowedHosts": "*", + "App": { + "SelfUrl": "http://*:19001", + "CorsOrigins": "http://localhost:19001;http://localhost:18000" + }, + "DbList": [ + "Sqlite", + "Mysql", + "Sqlserver", + "Oracle", + "Postgresql" + ], + "DbConnOptions": { + + } } diff --git a/src/NPin.Web/ip2region.db b/src/NPin.Web/ip2region.db new file mode 100644 index 0000000..0fc60e6 Binary files /dev/null and b/src/NPin.Web/ip2region.db differ diff --git a/src/NPin.Web/wwwroot/logo.png b/src/NPin.Web/wwwroot/logo.png new file mode 100644 index 0000000..d80f2a3 Binary files /dev/null and b/src/NPin.Web/wwwroot/logo.png differ diff --git a/using.props b/usings.props similarity index 100% rename from using.props rename to usings.props