diff --git a/README.md b/README.md index e95ae73..4d2ce89 100644 --- a/README.md +++ b/README.md @@ -1 +1,111 @@ -# Hua.Cli \ No newline at end of file +# Hua.Cli + +面向 .NET 生态的全局命令行工具(Global .NET CLI Tool),为开发者提供项目脚手架生成和依赖版本管理等基础开发工作流支持。 + +## 安装 + +```bash +dotnet tool install -g Hua.Cli +``` + +## 命令列表 + +| 命令 | 描述 | +|---|---| +| `hua help` | 显示帮助信息 | +| `hua new` | 基于模板创建新项目/解决方案 | +| `hua update` | 更新项目 NuGet 包版本 | + +## 使用示例 + +### 创建新项目 + +```bash +# 创建标准分层应用 +hua new MyProject + +# 创建微服务解决方案 +hua new MyMicroservice -t ms + +# 指定模板和选项 +hua new MyProject -t app -db ef -u mvc + +# 指定输出目录 +hua new MyProject -o D:\Projects +``` + +### 更新依赖 + +```bash +# 更新到最新版本 +hua update + +# 更新到指定版本 +hua update -v 9.0.0 + +# 试运行 +hua update --dry-run +``` + +### 查看帮助 + +```bash +# 查看所有命令 +hua help + +# 查看指定命令的详细帮助 +hua help new +hua help update +``` + +## 项目结构 + +``` +Hua.Cli/ +├── src/ +│ ├── Hua.Cli/ # 启动入口 +│ └── Hua.Cli.Core/ # 核心逻辑 +│ └── Hua/Cli/ +│ ├── Args/ # 命令行参数解析 +│ ├── Commands/ # 命令实现 (help/new/update) +│ ├── Configuration/ # 配置管理 +│ ├── Http/ # HTTP 客户端 +│ ├── ProjectBuilding/ # 项目构建流水线引擎 +│ ├── ProjectModification/ # 项目修改工具 +│ ├── Utils/ # 工具类 +│ └── Version/ # 版本管理 +└── test/ + └── Hua.Cli.Tests/ # 单元测试 +``` + +## 技术栈 + +- **目标框架**: .NET 9.0 +- **依赖注入**: Autofac (Volo.Abp.Autofac) +- **日志**: Serilog +- **模板引擎**: 自研文件替换引擎 +- **NuGet**: NuGet.Versioning + NuGet.Protocol + +## 架构设计 + +本项目借鉴 [Volo.Abp.Cli](https://github.com/abpframework/abp) 的分层插件化架构设计: + +- **命令模式**: 所有操作封装为 `IConsoleCommand` 实现,通过 `CommandSelector` 动态路由 +- **流水线模式**: 项目构建采用 `ProjectBuildPipeline` 串联多个 `ProjectBuildPipelineStep` +- **策略模式**: 不同模板通过继承 `TemplateInfo` 基类实现各自构建步骤 + +## 开发 + +```bash +# 还原依赖 +dotnet restore + +# 编译 +dotnet build + +# 运行测试 +dotnet test + +# 本地运行 +dotnet run --project src/Hua.Cli -- help +``` diff --git a/docs/PRD.md b/docs/PRD.md index 0854396..3f357dd 100644 --- a/docs/PRD.md +++ b/docs/PRD.md @@ -70,6 +70,9 @@ hua new <模板名> [选项] | 模板名 | 描述 | 优先级 | |---|---|---| | `app` | 标准分层应用(Application / Application.Contracts / Domain / Domain.Shared / EntityFrameworkCore / Web / HttpApi) | P0 | +| `ms` | 微服务解决方案(shared + microservices + gateways + applications + modules) | P0 | + +模板使用 .NET 自定义模板机制(`.template.config/template.json`),通过 `dotnet new` 引擎创建项目,`sourceName` 自动替换命名空间和项目名。 #### 3.2.2 `hua update` — 更新依赖 diff --git a/src/Hua.Cli.Core/Hua.Cli.Core.csproj b/src/Hua.Cli.Core/Hua.Cli.Core.csproj index 85e4c89..846aff9 100644 --- a/src/Hua.Cli.Core/Hua.Cli.Core.csproj +++ b/src/Hua.Cli.Core/Hua.Cli.Core.csproj @@ -20,4 +20,8 @@ + + + + diff --git a/src/Hua.Cli.Core/Hua/Cli/Commands/NewCommand.cs b/src/Hua.Cli.Core/Hua/Cli/Commands/NewCommand.cs index d8a2551..a2dff0e 100644 --- a/src/Hua.Cli.Core/Hua/Cli/Commands/NewCommand.cs +++ b/src/Hua.Cli.Core/Hua/Cli/Commands/NewCommand.cs @@ -114,6 +114,7 @@ public class NewCommand : IConsoleCommand, ITransientDependency Options: -t|--template (default: app) + Available: app, ms -v|--version Semantic version number -o|--output Output directory -db|--database-provider Database provider (ef) @@ -127,6 +128,7 @@ Examples: hua new MyProject hua new MyProject -t app -db ef -u mvc + hua new MyProject -t ms hua new MyProject -o D:\Projects"; } diff --git a/src/Hua.Cli.Core/Hua/Cli/ProjectBuilding/TemplateInfoProvider.cs b/src/Hua.Cli.Core/Hua/Cli/ProjectBuilding/TemplateInfoProvider.cs index fece073..baf0f75 100644 --- a/src/Hua.Cli.Core/Hua/Cli/ProjectBuilding/TemplateInfoProvider.cs +++ b/src/Hua.Cli.Core/Hua/Cli/ProjectBuilding/TemplateInfoProvider.cs @@ -1,5 +1,6 @@ using System.Threading.Tasks; using Volo.Abp.Cli.ProjectBuilding.Templates.App; +using Volo.Abp.Cli.ProjectBuilding.Templates.Ms; using Volo.Abp.DependencyInjection; namespace Volo.Abp.Cli.ProjectBuilding; @@ -11,6 +12,7 @@ public class TemplateInfoProvider : ITemplateInfoProvider, ITransientDependency TemplateInfo? template = name switch { "app" => new AppTemplate(), + "ms" => new MicroserviceTemplate(), _ => null }; diff --git a/src/Hua.Cli.Core/Hua/Cli/ProjectBuilding/TemplateProjectBuilder.cs b/src/Hua.Cli.Core/Hua/Cli/ProjectBuilding/TemplateProjectBuilder.cs index d5b776d..86ba7dc 100644 --- a/src/Hua.Cli.Core/Hua/Cli/ProjectBuilding/TemplateProjectBuilder.cs +++ b/src/Hua.Cli.Core/Hua/Cli/ProjectBuilding/TemplateProjectBuilder.cs @@ -1,6 +1,9 @@ +using System; using System.IO; +using System.Reflection; using System.Threading.Tasks; using Volo.Abp.Cli.ProjectBuilding.Building; +using Volo.Abp.Cli.Utils; using Volo.Abp.DependencyInjection; namespace Volo.Abp.Cli.ProjectBuilding; @@ -9,13 +12,16 @@ public class TemplateProjectBuilder : ITransientDependency { protected ISourceCodeStore SourceCodeStore { get; } protected TemplateProjectBuildPipelineBuilder PipelineBuilder { get; } + protected ICmdHelper CmdHelper { get; } public TemplateProjectBuilder( ISourceCodeStore sourceCodeStore, - TemplateProjectBuildPipelineBuilder pipelineBuilder) + TemplateProjectBuildPipelineBuilder pipelineBuilder, + ICmdHelper cmdHelper) { SourceCodeStore = sourceCodeStore; PipelineBuilder = pipelineBuilder; + CmdHelper = cmdHelper; } public async Task BuildAsync(ProjectBuildArgs args) @@ -25,6 +31,12 @@ public class TemplateProjectBuilder : ITransientDependency return; } + if (args.Template.Name == "ms") + { + await BuildMicroserviceAsync(args); + return; + } + var templatePath = await SourceCodeStore.GetAsync( args.Template.Name, args.Version); @@ -43,4 +55,75 @@ public class TemplateProjectBuilder : ITransientDependency var pipeline = PipelineBuilder.Build(context); await pipeline.ExecuteAsync(); } + + private async Task BuildMicroserviceAsync(ProjectBuildArgs args) + { + var templateDir = ResolveTemplateDirectory(); + + if (!Directory.Exists(templateDir)) + { + throw new FileNotFoundException( + $"Microservice template not found at: {templateDir}. " + + "Ensure the 'templates/ms' directory exists alongside the tool."); + } + + // Install the template + var installResult = await CmdHelper.RunAsync($"dotnet new install \"{templateDir}\""); + if (!installResult.IsSuccess) + { + throw new InvalidOperationException( + $"Failed to install microservice template: {installResult.Error}"); + } + + try + { + // Run dotnet new with the template + var outputDir = args.OutputDirectory; + var projectName = args.ProjectName; + + var newResult = await CmdHelper.RunAsync( + $"dotnet new hua-ms -n \"{projectName}\" -o \"{outputDir}\""); + + if (!newResult.IsSuccess) + { + throw new InvalidOperationException( + $"Failed to create project: {newResult.Error}"); + } + } + finally + { + // Uninstall the template to clean up + await CmdHelper.RunAsync($"dotnet new uninstall \"{templateDir}\""); + } + } + + private static string ResolveTemplateDirectory() + { + var assemblyDir = Path.GetDirectoryName( + Assembly.GetExecutingAssembly().Location) ?? "."; + + // First, check relative to the assembly directory (works for published output + // where templates/ms is copied alongside the assembly via CopyToOutputDirectory) + var assemblyRelativePath = Path.Combine(assemblyDir, "templates", "ms"); + if (Directory.Exists(assemblyRelativePath)) + { + return assemblyRelativePath; + } + + // Fall back to upward traversal (works in development when templates/ms + // lives in the repository root above bin/Debug/net9.0) + var directory = new DirectoryInfo(assemblyDir); + while (directory != null) + { + var templatePath = Path.Combine(directory.FullName, "templates", "ms"); + if (Directory.Exists(templatePath)) + { + return templatePath; + } + + directory = directory.Parent; + } + + return assemblyRelativePath; + } } diff --git a/src/Hua.Cli.Core/Hua/Cli/ProjectBuilding/Templates/Ms/MicroserviceTemplate.cs b/src/Hua.Cli.Core/Hua/Cli/ProjectBuilding/Templates/Ms/MicroserviceTemplate.cs new file mode 100644 index 0000000..b09b874 --- /dev/null +++ b/src/Hua.Cli.Core/Hua/Cli/ProjectBuilding/Templates/Ms/MicroserviceTemplate.cs @@ -0,0 +1,11 @@ +namespace Volo.Abp.Cli.ProjectBuilding.Templates.Ms; + +public class MicroserviceTemplate : TemplateInfo +{ + public MicroserviceTemplate() + : base("ms", + "Microservice solution (gateways + microservices + applications + shared)", + null) + { + } +} diff --git a/templates/ms/.template.config/template.json b/templates/ms/.template.config/template.json new file mode 100644 index 0000000..378414d --- /dev/null +++ b/templates/ms/.template.config/template.json @@ -0,0 +1,35 @@ +{ + "$schema": "http://json.schemastore.org/template", + "author": "Hua", + "classifications": ["Hua", "Microservice", "Web", "Solution"], + "identity": "Hua.Microservice.Template", + "name": "Hua Microservice Solution", + "shortName": "hua-ms", + "sourceName": "Company.Project", + "preferNameDirectory": true, + "tags": { + "language": "C#", + "type": "project" + }, + "symbols": { + "databaseProvider": { + "type": "parameter", + "datatype": "choice", + "choices": [ + { "choice": "ef", "description": "Entity Framework Core" } + ], + "defaultValue": "ef", + "description": "Database provider" + }, + "uiFramework": { + "type": "parameter", + "datatype": "choice", + "choices": [ + { "choice": "mvc", "description": "ASP.NET Core MVC" }, + { "choice": "none", "description": "No UI" } + ], + "defaultValue": "mvc", + "description": "UI framework" + } + } +} diff --git a/templates/ms/applications/Company.Project.AuthServer.Host/AuthServerHostModule.cs b/templates/ms/applications/Company.Project.AuthServer.Host/AuthServerHostModule.cs new file mode 100644 index 0000000..03f1d3a --- /dev/null +++ b/templates/ms/applications/Company.Project.AuthServer.Host/AuthServerHostModule.cs @@ -0,0 +1,48 @@ +using Microsoft.Extensions.DependencyInjection; +using Company.Project.Shared; +using Volo.Abp; +using Volo.Abp.Account; +using Volo.Abp.Account.Web; +using Volo.Abp.AspNetCore.Mvc.UI.BasicTheme; +using Volo.Abp.Autofac; +using Volo.Abp.EntityFrameworkCore; +using Volo.Abp.EntityFrameworkCore.SqlServer; +using Volo.Abp.Identity; +using Volo.Abp.Identity.EntityFrameworkCore; +using Volo.Abp.IdentityServer.EntityFrameworkCore; +using Volo.Abp.Modularity; +using Volo.Abp.MultiTenancy; +using Volo.Abp.TenantManagement.EntityFrameworkCore; + +namespace Company.Project.AuthServer; + +[DependsOn( + typeof(AbpAutofacModule), + typeof(AbpAspNetCoreMvcUiBasicThemeModule), + typeof(AbpIdentityEntityFrameworkCoreModule), + typeof(AbpIdentityApplicationModule), + typeof(AbpIdentityServerEntityFrameworkCoreModule), + typeof(AbpAccountWebIdentityServerModule), + typeof(AbpTenantManagementEntityFrameworkCoreModule) +)] +public class AuthServerHostModule : AbpModule +{ + public override void ConfigureServices(ServiceConfigurationContext context) + { + Configure(options => + { + options.IsEnabled = ProjectConsts.IsMultiTenancyEnabled; + }); + + Configure(options => options.UseSqlServer()); + } + + public override void OnApplicationInitialization(ApplicationInitializationContext context) + { + var app = context.GetApplicationBuilder(); + app.UseStaticFiles(); + app.UseRouting(); + app.UseIdentityServer(); + app.UseConfiguredEndpoints(); + } +} diff --git a/templates/ms/applications/Company.Project.AuthServer.Host/Company.Project.AuthServer.Host.csproj b/templates/ms/applications/Company.Project.AuthServer.Host/Company.Project.AuthServer.Host.csproj new file mode 100644 index 0000000..f93830d --- /dev/null +++ b/templates/ms/applications/Company.Project.AuthServer.Host/Company.Project.AuthServer.Host.csproj @@ -0,0 +1,16 @@ + + + net8.0 + Company.Project.AuthServer + + + + + + + + + + + + diff --git a/templates/ms/applications/Company.Project.AuthServer.Host/Program.cs b/templates/ms/applications/Company.Project.AuthServer.Host/Program.cs new file mode 100644 index 0000000..2b8f108 --- /dev/null +++ b/templates/ms/applications/Company.Project.AuthServer.Host/Program.cs @@ -0,0 +1,34 @@ +using System; +using System.IO; +using Microsoft.AspNetCore.Builder; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Serilog; +using Volo.Abp; + +namespace Company.Project.AuthServer; + +public class Program +{ + public static void Main(string[] args) + { + var configuration = new ConfigurationBuilder() + .SetBasePath(Directory.GetCurrentDirectory()) + .AddJsonFile("appsettings.json") + .Build(); + + Log.Logger = new LoggerConfiguration() + .ReadFrom.Configuration(configuration) + .CreateLogger(); + + try { CreateHostBuilder(args).Build().Run(); } + catch (Exception ex) { Log.Fatal(ex, "Host terminated unexpectedly"); } + finally { Log.CloseAndFlush(); } + } + + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .UseAutofac().UseSerilog() + .ConfigureWebHostDefaults(webBuilder => webBuilder.UseStartup()); +} diff --git a/templates/ms/applications/Company.Project.AuthServer.Host/Startup.cs b/templates/ms/applications/Company.Project.AuthServer.Host/Startup.cs new file mode 100644 index 0000000..b10adad --- /dev/null +++ b/templates/ms/applications/Company.Project.AuthServer.Host/Startup.cs @@ -0,0 +1,18 @@ +using Microsoft.AspNetCore.Builder; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; + +namespace Company.Project.AuthServer; + +public class Startup +{ + public void ConfigureServices(IServiceCollection services) + { + services.AddApplication(); + } + + public void Configure(IApplicationBuilder app, IHostEnvironment env) + { + app.InitializeApplication(); + } +} diff --git a/templates/ms/applications/Company.Project.AuthServer.Host/appsettings.json b/templates/ms/applications/Company.Project.AuthServer.Host/appsettings.json new file mode 100644 index 0000000..7f07a66 --- /dev/null +++ b/templates/ms/applications/Company.Project.AuthServer.Host/appsettings.json @@ -0,0 +1,7 @@ +{ + "ConnectionStrings": { + "Default": "Server=(LocalDb)\\MSSQLLocalDB;Database=Company.Project_AuthServer;Trusted_Connection=True" + }, + "Serilog": { "MinimumLevel": { "Default": "Information" } }, + "AllowedHosts": "*" +} diff --git a/templates/ms/applications/Company.Project.BackendAdminApp.Host/BackendAdminAppHostModule.cs b/templates/ms/applications/Company.Project.BackendAdminApp.Host/BackendAdminAppHostModule.cs new file mode 100644 index 0000000..8d6708c --- /dev/null +++ b/templates/ms/applications/Company.Project.BackendAdminApp.Host/BackendAdminAppHostModule.cs @@ -0,0 +1,43 @@ +using Company.Project.Shared; +using ProductManagement; +using ProductManagement.Web; +using Volo.Abp; +using Volo.Abp.AspNetCore.Mvc.Client; +using Volo.Abp.AspNetCore.Mvc.UI.BasicTheme; +using Volo.Abp.Autofac; +using Volo.Abp.Http.Client.IdentityModel.Web; +using Volo.Abp.Identity.Web; +using Volo.Abp.Modularity; +using Volo.Abp.MultiTenancy; +using Volo.Abp.TenantManagement.Web; + +namespace Company.Project.BackendAdminApp; + +[DependsOn( + typeof(AbpAutofacModule), + typeof(AbpAspNetCoreMvcClientModule), + typeof(AbpAspNetCoreMvcUiBasicThemeModule), + typeof(AbpHttpClientIdentityModelWebModule), + typeof(AbpIdentityWebModule), + typeof(AbpTenantManagementWebModule), + typeof(ProductManagementHttpApiClientModule), + typeof(ProductManagementWebModule) +)] +public class BackendAdminAppHostModule : AbpModule +{ + public override void ConfigureServices(ServiceConfigurationContext context) + { + Configure(options => + { + options.IsEnabled = ProjectConsts.IsMultiTenancyEnabled; + }); + } + + public override void OnApplicationInitialization(ApplicationInitializationContext context) + { + var app = context.GetApplicationBuilder(); + app.UseStaticFiles(); + app.UseRouting(); + app.UseConfiguredEndpoints(); + } +} diff --git a/templates/ms/applications/Company.Project.BackendAdminApp.Host/Company.Project.BackendAdminApp.Host.csproj b/templates/ms/applications/Company.Project.BackendAdminApp.Host/Company.Project.BackendAdminApp.Host.csproj new file mode 100644 index 0000000..bff00ae --- /dev/null +++ b/templates/ms/applications/Company.Project.BackendAdminApp.Host/Company.Project.BackendAdminApp.Host.csproj @@ -0,0 +1,18 @@ + + + net8.0 + Company.Project.BackendAdminApp + + + + + + + + + + + + + + diff --git a/templates/ms/applications/Company.Project.BackendAdminApp.Host/Program.cs b/templates/ms/applications/Company.Project.BackendAdminApp.Host/Program.cs new file mode 100644 index 0000000..aef4091 --- /dev/null +++ b/templates/ms/applications/Company.Project.BackendAdminApp.Host/Program.cs @@ -0,0 +1,34 @@ +using System; +using System.IO; +using Microsoft.AspNetCore.Builder; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Serilog; +using Volo.Abp; + +namespace Company.Project.BackendAdminApp; + +public class Program +{ + public static void Main(string[] args) + { + var configuration = new ConfigurationBuilder() + .SetBasePath(Directory.GetCurrentDirectory()) + .AddJsonFile("appsettings.json") + .Build(); + + Log.Logger = new LoggerConfiguration() + .ReadFrom.Configuration(configuration) + .CreateLogger(); + + try { CreateHostBuilder(args).Build().Run(); } + catch (Exception ex) { Log.Fatal(ex, "Host terminated unexpectedly"); } + finally { Log.CloseAndFlush(); } + } + + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .UseAutofac().UseSerilog() + .ConfigureWebHostDefaults(webBuilder => webBuilder.UseStartup()); +} diff --git a/templates/ms/applications/Company.Project.BackendAdminApp.Host/Startup.cs b/templates/ms/applications/Company.Project.BackendAdminApp.Host/Startup.cs new file mode 100644 index 0000000..c9d3f7e --- /dev/null +++ b/templates/ms/applications/Company.Project.BackendAdminApp.Host/Startup.cs @@ -0,0 +1,18 @@ +using Microsoft.AspNetCore.Builder; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; + +namespace Company.Project.BackendAdminApp; + +public class Startup +{ + public void ConfigureServices(IServiceCollection services) + { + services.AddApplication(); + } + + public void Configure(IApplicationBuilder app, IHostEnvironment env) + { + app.InitializeApplication(); + } +} diff --git a/templates/ms/gateways/Company.Project.InternalGateway.Host/Company.Project.InternalGateway.Host.csproj b/templates/ms/gateways/Company.Project.InternalGateway.Host/Company.Project.InternalGateway.Host.csproj new file mode 100644 index 0000000..d1d56a5 --- /dev/null +++ b/templates/ms/gateways/Company.Project.InternalGateway.Host/Company.Project.InternalGateway.Host.csproj @@ -0,0 +1,16 @@ + + + net8.0 + Company.Project.InternalGateway + + + + + + + + + + + + diff --git a/templates/ms/gateways/Company.Project.InternalGateway.Host/InternalGatewayHostModule.cs b/templates/ms/gateways/Company.Project.InternalGateway.Host/InternalGatewayHostModule.cs new file mode 100644 index 0000000..471da51 --- /dev/null +++ b/templates/ms/gateways/Company.Project.InternalGateway.Host/InternalGatewayHostModule.cs @@ -0,0 +1,47 @@ +using Microsoft.Extensions.DependencyInjection; +using Microsoft.OpenApi.Models; +using Company.Project.Shared; +using Volo.Abp; +using Volo.Abp.AspNetCore.MultiTenancy; +using Volo.Abp.AspNetCore.Mvc; +using Volo.Abp.Autofac; +using Volo.Abp.Modularity; +using Volo.Abp.MultiTenancy; +using Ocelot.DependencyInjection; +using Ocelot.Middleware; + +namespace Company.Project.InternalGateway; + +[DependsOn( + typeof(AbpAutofacModule), + typeof(AbpAspNetCoreMvcModule), + typeof(AbpAspNetCoreMultiTenancyModule) +)] +public class InternalGatewayHostModule : AbpModule +{ + public override void ConfigureServices(ServiceConfigurationContext context) + { + var configuration = context.Services.GetConfiguration(); + + Configure(options => + { + options.IsEnabled = ProjectConsts.IsMultiTenancyEnabled; + }); + + context.Services.AddSwaggerGen(options => + { + options.SwaggerDoc("v1", new OpenApiInfo { Title = "Internal Gateway API", Version = "v1" }); + }); + + context.Services.AddOcelot(configuration); + } + + public override void OnApplicationInitialization(ApplicationInitializationContext context) + { + var app = context.GetApplicationBuilder(); + app.UseRouting(); + app.UseSwagger(); + app.UseSwaggerUI(options => options.SwaggerEndpoint("/swagger/v1/swagger.json", "Internal Gateway")); + app.UseOcelot().Wait(); + } +} diff --git a/templates/ms/gateways/Company.Project.InternalGateway.Host/Program.cs b/templates/ms/gateways/Company.Project.InternalGateway.Host/Program.cs new file mode 100644 index 0000000..652565d --- /dev/null +++ b/templates/ms/gateways/Company.Project.InternalGateway.Host/Program.cs @@ -0,0 +1,44 @@ +using System; +using System.IO; +using Microsoft.AspNetCore.Builder; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Serilog; +using Volo.Abp; + +namespace Company.Project.InternalGateway; + +public class Program +{ + public static void Main(string[] args) + { + var configuration = new ConfigurationBuilder() + .SetBasePath(Directory.GetCurrentDirectory()) + .AddJsonFile("appsettings.json") + .Build(); + + Log.Logger = new LoggerConfiguration() + .ReadFrom.Configuration(configuration) + .CreateLogger(); + + try + { + CreateHostBuilder(args).Build().Run(); + } + catch (Exception ex) + { + Log.Fatal(ex, "Host terminated unexpectedly"); + } + finally + { + Log.CloseAndFlush(); + } + } + + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .UseAutofac() + .UseSerilog() + .ConfigureWebHostDefaults(webBuilder => webBuilder.UseStartup()); +} diff --git a/templates/ms/gateways/Company.Project.InternalGateway.Host/Startup.cs b/templates/ms/gateways/Company.Project.InternalGateway.Host/Startup.cs new file mode 100644 index 0000000..0b9efa5 --- /dev/null +++ b/templates/ms/gateways/Company.Project.InternalGateway.Host/Startup.cs @@ -0,0 +1,18 @@ +using Microsoft.AspNetCore.Builder; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; + +namespace Company.Project.InternalGateway; + +public class Startup +{ + public void ConfigureServices(IServiceCollection services) + { + services.AddApplication(); + } + + public void Configure(IApplicationBuilder app, IHostEnvironment env) + { + app.InitializeApplication(); + } +} diff --git a/templates/ms/gateways/Company.Project.InternalGateway.Host/appsettings.json b/templates/ms/gateways/Company.Project.InternalGateway.Host/appsettings.json new file mode 100644 index 0000000..9a1a457 --- /dev/null +++ b/templates/ms/gateways/Company.Project.InternalGateway.Host/appsettings.json @@ -0,0 +1,9 @@ +{ + "Redis": { "Configuration": "localhost" }, + "Serilog": { "MinimumLevel": { "Default": "Information" } }, + "Routes": [ + { "DownstreamPathTemplate": "/api/identity/{everything}", "DownstreamScheme": "https", "DownstreamHostAndPorts": [{ "Host": "localhost", "Port": 44368 }], "UpstreamPathTemplate": "/api/identity/{everything}", "UpstreamHttpMethod": ["Get", "Post", "Put", "Delete"] }, + { "DownstreamPathTemplate": "/api/product-management/{everything}", "DownstreamScheme": "https", "DownstreamHostAndPorts": [{ "Host": "localhost", "Port": 44344 }], "UpstreamPathTemplate": "/api/product-management/{everything}", "UpstreamHttpMethod": ["Get", "Post", "Put", "Delete"] } + ], + "AllowedHosts": "*" +} diff --git a/templates/ms/gateways/Company.Project.PublicWebGateway.Host/Company.Project.PublicWebGateway.Host.csproj b/templates/ms/gateways/Company.Project.PublicWebGateway.Host/Company.Project.PublicWebGateway.Host.csproj new file mode 100644 index 0000000..4951c8e --- /dev/null +++ b/templates/ms/gateways/Company.Project.PublicWebGateway.Host/Company.Project.PublicWebGateway.Host.csproj @@ -0,0 +1,14 @@ + + + net8.0 + Company.Project.PublicWebGateway + + + + + + + + + + diff --git a/templates/ms/gateways/Company.Project.PublicWebGateway.Host/Program.cs b/templates/ms/gateways/Company.Project.PublicWebGateway.Host/Program.cs new file mode 100644 index 0000000..555dd4a --- /dev/null +++ b/templates/ms/gateways/Company.Project.PublicWebGateway.Host/Program.cs @@ -0,0 +1,34 @@ +using System; +using System.IO; +using Microsoft.AspNetCore.Builder; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Serilog; +using Volo.Abp; + +namespace Company.Project.PublicWebGateway; + +public class Program +{ + public static void Main(string[] args) + { + var configuration = new ConfigurationBuilder() + .SetBasePath(Directory.GetCurrentDirectory()) + .AddJsonFile("appsettings.json") + .Build(); + + Log.Logger = new LoggerConfiguration() + .ReadFrom.Configuration(configuration) + .CreateLogger(); + + try { CreateHostBuilder(args).Build().Run(); } + catch (Exception ex) { Log.Fatal(ex, "Host terminated unexpectedly"); } + finally { Log.CloseAndFlush(); } + } + + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .UseAutofac().UseSerilog() + .ConfigureWebHostDefaults(webBuilder => webBuilder.UseStartup()); +} diff --git a/templates/ms/gateways/Company.Project.PublicWebGateway.Host/PublicWebGatewayHostModule.cs b/templates/ms/gateways/Company.Project.PublicWebGateway.Host/PublicWebGatewayHostModule.cs new file mode 100644 index 0000000..a6391f0 --- /dev/null +++ b/templates/ms/gateways/Company.Project.PublicWebGateway.Host/PublicWebGatewayHostModule.cs @@ -0,0 +1,39 @@ +using Microsoft.Extensions.DependencyInjection; +using Company.Project.Shared; +using Volo.Abp; +using Volo.Abp.AspNetCore.MultiTenancy; +using Volo.Abp.AspNetCore.Mvc; +using Volo.Abp.Autofac; +using Volo.Abp.Modularity; +using Volo.Abp.MultiTenancy; +using Ocelot.DependencyInjection; +using Ocelot.Middleware; + +namespace Company.Project.PublicWebGateway; + +[DependsOn( + typeof(AbpAutofacModule), + typeof(AbpAspNetCoreMvcModule), + typeof(AbpAspNetCoreMultiTenancyModule) +)] +public class PublicWebGatewayHostModule : AbpModule +{ + public override void ConfigureServices(ServiceConfigurationContext context) + { + var configuration = context.Services.GetConfiguration(); + + Configure(options => + { + options.IsEnabled = ProjectConsts.IsMultiTenancyEnabled; + }); + + context.Services.AddOcelot(configuration); + } + + public override void OnApplicationInitialization(ApplicationInitializationContext context) + { + var app = context.GetApplicationBuilder(); + app.UseRouting(); + app.UseOcelot().Wait(); + } +} diff --git a/templates/ms/gateways/Company.Project.PublicWebGateway.Host/Startup.cs b/templates/ms/gateways/Company.Project.PublicWebGateway.Host/Startup.cs new file mode 100644 index 0000000..e4d884d --- /dev/null +++ b/templates/ms/gateways/Company.Project.PublicWebGateway.Host/Startup.cs @@ -0,0 +1,18 @@ +using Microsoft.AspNetCore.Builder; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; + +namespace Company.Project.PublicWebGateway; + +public class Startup +{ + public void ConfigureServices(IServiceCollection services) + { + services.AddApplication(); + } + + public void Configure(IApplicationBuilder app, IHostEnvironment env) + { + app.InitializeApplication(); + } +} diff --git a/templates/ms/gateways/Company.Project.PublicWebGateway.Host/appsettings.json b/templates/ms/gateways/Company.Project.PublicWebGateway.Host/appsettings.json new file mode 100644 index 0000000..bfcd929 --- /dev/null +++ b/templates/ms/gateways/Company.Project.PublicWebGateway.Host/appsettings.json @@ -0,0 +1,7 @@ +{ + "Redis": { "Configuration": "localhost" }, + "Routes": [ + { "DownstreamPathTemplate": "/api/product-management/{everything}", "DownstreamScheme": "https", "DownstreamHostAndPorts": [{ "Host": "localhost", "Port": 44344 }], "UpstreamPathTemplate": "/api/product-management/{everything}", "UpstreamHttpMethod": ["Get"] } + ], + "AllowedHosts": "*" +} diff --git a/templates/ms/microservices/Company.Project.IdentityService.Host/Company.Project.IdentityService.Host.csproj b/templates/ms/microservices/Company.Project.IdentityService.Host/Company.Project.IdentityService.Host.csproj new file mode 100644 index 0000000..5531ef7 --- /dev/null +++ b/templates/ms/microservices/Company.Project.IdentityService.Host/Company.Project.IdentityService.Host.csproj @@ -0,0 +1,21 @@ + + + net8.0 + Company.Project.IdentityService + + + + + + + + + + + + + + + + + diff --git a/templates/ms/microservices/Company.Project.IdentityService.Host/IdentityServiceHostModule.cs b/templates/ms/microservices/Company.Project.IdentityService.Host/IdentityServiceHostModule.cs new file mode 100644 index 0000000..49f950e --- /dev/null +++ b/templates/ms/microservices/Company.Project.IdentityService.Host/IdentityServiceHostModule.cs @@ -0,0 +1,61 @@ +using Microsoft.Extensions.DependencyInjection; +using Microsoft.OpenApi.Models; +using Company.Project.Shared; +using Volo.Abp; +using Volo.Abp.AspNetCore.MultiTenancy; +using Volo.Abp.AspNetCore.Mvc; +using Volo.Abp.Autofac; +using Volo.Abp.EntityFrameworkCore; +using Volo.Abp.EntityFrameworkCore.SqlServer; +using Volo.Abp.EventBus.RabbitMq; +using Volo.Abp.Identity; +using Volo.Abp.Identity.EntityFrameworkCore; +using Volo.Abp.Modularity; +using Volo.Abp.MultiTenancy; +using Volo.Abp.PermissionManagement.EntityFrameworkCore; +using Volo.Abp.SettingManagement.EntityFrameworkCore; +using Volo.Abp.TenantManagement.EntityFrameworkCore; + +namespace Company.Project.IdentityService; + +[DependsOn( + typeof(AbpAutofacModule), + typeof(AbpAspNetCoreMvcModule), + typeof(AbpAspNetCoreMultiTenancyModule), + typeof(AbpEntityFrameworkCoreSqlServerModule), + typeof(AbpEventBusRabbitMqModule), + typeof(AbpIdentityApplicationModule), + typeof(AbpIdentityHttpApiModule), + typeof(AbpIdentityEntityFrameworkCoreModule), + typeof(AbpTenantManagementEntityFrameworkCoreModule), + typeof(AbpPermissionManagementEntityFrameworkCoreModule), + typeof(AbpSettingManagementEntityFrameworkCoreModule) +)] +public class IdentityServiceHostModule : AbpModule +{ + public override void ConfigureServices(ServiceConfigurationContext context) + { + var configuration = context.Services.GetConfiguration(); + + Configure(options => + { + options.IsEnabled = ProjectConsts.IsMultiTenancyEnabled; + }); + + context.Services.AddSwaggerGen(options => + { + options.SwaggerDoc("v1", new OpenApiInfo { Title = "Identity Service API", Version = "v1" }); + }); + + Configure(options => options.UseSqlServer()); + } + + public override void OnApplicationInitialization(ApplicationInitializationContext context) + { + var app = context.GetApplicationBuilder(); + app.UseRouting(); + app.UseSwagger(); + app.UseSwaggerUI(options => options.SwaggerEndpoint("/swagger/v1/swagger.json", "Identity Service API")); + app.UseConfiguredEndpoints(); + } +} diff --git a/templates/ms/microservices/Company.Project.IdentityService.Host/Program.cs b/templates/ms/microservices/Company.Project.IdentityService.Host/Program.cs new file mode 100644 index 0000000..a31161b --- /dev/null +++ b/templates/ms/microservices/Company.Project.IdentityService.Host/Program.cs @@ -0,0 +1,44 @@ +using System; +using System.IO; +using Microsoft.AspNetCore.Builder; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Serilog; +using Volo.Abp; + +namespace Company.Project.IdentityService; + +public class Program +{ + public static void Main(string[] args) + { + var configuration = new ConfigurationBuilder() + .SetBasePath(Directory.GetCurrentDirectory()) + .AddJsonFile("appsettings.json") + .Build(); + + Log.Logger = new LoggerConfiguration() + .ReadFrom.Configuration(configuration) + .CreateLogger(); + + try + { + CreateHostBuilder(args).Build().Run(); + } + catch (Exception ex) + { + Log.Fatal(ex, "Host terminated unexpectedly"); + } + finally + { + Log.CloseAndFlush(); + } + } + + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .UseAutofac() + .UseSerilog() + .ConfigureWebHostDefaults(webBuilder => webBuilder.UseStartup()); +} diff --git a/templates/ms/microservices/Company.Project.IdentityService.Host/Startup.cs b/templates/ms/microservices/Company.Project.IdentityService.Host/Startup.cs new file mode 100644 index 0000000..2267952 --- /dev/null +++ b/templates/ms/microservices/Company.Project.IdentityService.Host/Startup.cs @@ -0,0 +1,18 @@ +using Microsoft.AspNetCore.Builder; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; + +namespace Company.Project.IdentityService; + +public class Startup +{ + public void ConfigureServices(IServiceCollection services) + { + services.AddApplication(); + } + + public void Configure(IApplicationBuilder app, IHostEnvironment env) + { + app.InitializeApplication(); + } +} diff --git a/templates/ms/microservices/Company.Project.IdentityService.Host/appsettings.json b/templates/ms/microservices/Company.Project.IdentityService.Host/appsettings.json new file mode 100644 index 0000000..0a3b542 --- /dev/null +++ b/templates/ms/microservices/Company.Project.IdentityService.Host/appsettings.json @@ -0,0 +1,21 @@ +{ + "ConnectionStrings": { + "Default": "Server=(LocalDb)\\MSSQLLocalDB;Database=Company.Project_Identity;Trusted_Connection=True" + }, + "Redis": { + "Configuration": "localhost" + }, + "RabbitMQ": { + "Connections": { + "Default": { "HostName": "localhost" } + }, + "EventBus": { + "ClientName": "Company.Project_Identity", + "ExchangeName": "Company.Project" + } + }, + "Serilog": { + "MinimumLevel": { "Default": "Information" } + }, + "AllowedHosts": "*" +} diff --git a/templates/ms/microservices/Company.Project.ProductService.Host/Company.Project.ProductService.Host.csproj b/templates/ms/microservices/Company.Project.ProductService.Host/Company.Project.ProductService.Host.csproj new file mode 100644 index 0000000..31b3582 --- /dev/null +++ b/templates/ms/microservices/Company.Project.ProductService.Host/Company.Project.ProductService.Host.csproj @@ -0,0 +1,19 @@ + + + net8.0 + Company.Project.ProductService + + + + + + + + + + + + + + + diff --git a/templates/ms/microservices/Company.Project.ProductService.Host/ProductServiceHostModule.cs b/templates/ms/microservices/Company.Project.ProductService.Host/ProductServiceHostModule.cs new file mode 100644 index 0000000..ba58119 --- /dev/null +++ b/templates/ms/microservices/Company.Project.ProductService.Host/ProductServiceHostModule.cs @@ -0,0 +1,55 @@ +using Microsoft.Extensions.DependencyInjection; +using Microsoft.OpenApi.Models; +using Company.Project.Shared; +using ProductManagement; +using ProductManagement.EntityFrameworkCore; +using Volo.Abp; +using Volo.Abp.AspNetCore.MultiTenancy; +using Volo.Abp.AspNetCore.Mvc; +using Volo.Abp.Autofac; +using Volo.Abp.EntityFrameworkCore; +using Volo.Abp.EntityFrameworkCore.SqlServer; +using Volo.Abp.EventBus.RabbitMq; +using Volo.Abp.Modularity; +using Volo.Abp.MultiTenancy; + +namespace Company.Project.ProductService; + +[DependsOn( + typeof(AbpAutofacModule), + typeof(AbpAspNetCoreMvcModule), + typeof(AbpAspNetCoreMultiTenancyModule), + typeof(AbpEntityFrameworkCoreSqlServerModule), + typeof(AbpEventBusRabbitMqModule), + typeof(ProductManagementApplicationModule), + typeof(ProductManagementHttpApiModule), + typeof(ProductManagementEntityFrameworkCoreModule) +)] +public class ProductServiceHostModule : AbpModule +{ + public override void ConfigureServices(ServiceConfigurationContext context) + { + var configuration = context.Services.GetConfiguration(); + + Configure(options => + { + options.IsEnabled = ProjectConsts.IsMultiTenancyEnabled; + }); + + context.Services.AddSwaggerGen(options => + { + options.SwaggerDoc("v1", new OpenApiInfo { Title = "Product Service API", Version = "v1" }); + }); + + Configure(options => options.UseSqlServer()); + } + + public override void OnApplicationInitialization(ApplicationInitializationContext context) + { + var app = context.GetApplicationBuilder(); + app.UseRouting(); + app.UseSwagger(); + app.UseSwaggerUI(options => options.SwaggerEndpoint("/swagger/v1/swagger.json", "Product Service API")); + app.UseConfiguredEndpoints(); + } +} diff --git a/templates/ms/microservices/Company.Project.ProductService.Host/Program.cs b/templates/ms/microservices/Company.Project.ProductService.Host/Program.cs new file mode 100644 index 0000000..3d0f149 --- /dev/null +++ b/templates/ms/microservices/Company.Project.ProductService.Host/Program.cs @@ -0,0 +1,44 @@ +using System; +using System.IO; +using Microsoft.AspNetCore.Builder; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Serilog; +using Volo.Abp; + +namespace Company.Project.ProductService; + +public class Program +{ + public static void Main(string[] args) + { + var configuration = new ConfigurationBuilder() + .SetBasePath(Directory.GetCurrentDirectory()) + .AddJsonFile("appsettings.json") + .Build(); + + Log.Logger = new LoggerConfiguration() + .ReadFrom.Configuration(configuration) + .CreateLogger(); + + try + { + CreateHostBuilder(args).Build().Run(); + } + catch (Exception ex) + { + Log.Fatal(ex, "Host terminated unexpectedly"); + } + finally + { + Log.CloseAndFlush(); + } + } + + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .UseAutofac() + .UseSerilog() + .ConfigureWebHostDefaults(webBuilder => webBuilder.UseStartup()); +} diff --git a/templates/ms/microservices/Company.Project.ProductService.Host/Startup.cs b/templates/ms/microservices/Company.Project.ProductService.Host/Startup.cs new file mode 100644 index 0000000..6d7c71f --- /dev/null +++ b/templates/ms/microservices/Company.Project.ProductService.Host/Startup.cs @@ -0,0 +1,18 @@ +using Microsoft.AspNetCore.Builder; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; + +namespace Company.Project.ProductService; + +public class Startup +{ + public void ConfigureServices(IServiceCollection services) + { + services.AddApplication(); + } + + public void Configure(IApplicationBuilder app, IHostEnvironment env) + { + app.InitializeApplication(); + } +} diff --git a/templates/ms/microservices/Company.Project.ProductService.Host/appsettings.json b/templates/ms/microservices/Company.Project.ProductService.Host/appsettings.json new file mode 100644 index 0000000..6d4df10 --- /dev/null +++ b/templates/ms/microservices/Company.Project.ProductService.Host/appsettings.json @@ -0,0 +1,21 @@ +{ + "ConnectionStrings": { + "Default": "Server=(LocalDb)\\MSSQLLocalDB;Database=Company.Project_ProductManagement;Trusted_Connection=True" + }, + "Redis": { + "Configuration": "localhost" + }, + "RabbitMQ": { + "Connections": { + "Default": { "HostName": "localhost" } + }, + "EventBus": { + "ClientName": "Company.Project_Product", + "ExchangeName": "Company.Project" + } + }, + "Serilog": { + "MinimumLevel": { "Default": "Information" } + }, + "AllowedHosts": "*" +} diff --git a/templates/ms/modules/product/src/ProductManagement.Application.Contracts/IProductAppService.cs b/templates/ms/modules/product/src/ProductManagement.Application.Contracts/IProductAppService.cs new file mode 100644 index 0000000..2946918 --- /dev/null +++ b/templates/ms/modules/product/src/ProductManagement.Application.Contracts/IProductAppService.cs @@ -0,0 +1,17 @@ +using System; +using Volo.Abp.Application.Dtos; +using Volo.Abp.Application.Services; + +namespace ProductManagement; + +public interface IProductAppService : + ICrudAppService +{ +} + +public class CreateUpdateProductDto +{ + public string Name { get; set; } = string.Empty; + public decimal Price { get; set; } + public int StockCount { get; set; } +} diff --git a/templates/ms/modules/product/src/ProductManagement.Application.Contracts/ProductDto.cs b/templates/ms/modules/product/src/ProductManagement.Application.Contracts/ProductDto.cs new file mode 100644 index 0000000..1d84427 --- /dev/null +++ b/templates/ms/modules/product/src/ProductManagement.Application.Contracts/ProductDto.cs @@ -0,0 +1,11 @@ +using System; +using Volo.Abp.Application.Dtos; + +namespace ProductManagement; + +public class ProductDto : FullAuditedEntityDto +{ + public string Name { get; set; } = string.Empty; + public decimal Price { get; set; } + public int StockCount { get; set; } +} diff --git a/templates/ms/modules/product/src/ProductManagement.Application.Contracts/ProductManagement.Application.Contracts.csproj b/templates/ms/modules/product/src/ProductManagement.Application.Contracts/ProductManagement.Application.Contracts.csproj new file mode 100644 index 0000000..5753226 --- /dev/null +++ b/templates/ms/modules/product/src/ProductManagement.Application.Contracts/ProductManagement.Application.Contracts.csproj @@ -0,0 +1,7 @@ + + netstandard2.0 + + + + + diff --git a/templates/ms/modules/product/src/ProductManagement.Application.Contracts/ProductManagementApplicationContractsModule.cs b/templates/ms/modules/product/src/ProductManagement.Application.Contracts/ProductManagementApplicationContractsModule.cs new file mode 100644 index 0000000..9cacb01 --- /dev/null +++ b/templates/ms/modules/product/src/ProductManagement.Application.Contracts/ProductManagementApplicationContractsModule.cs @@ -0,0 +1,6 @@ +using Volo.Abp.Modularity; + +namespace ProductManagement; + +[DependsOn(typeof(ProductManagementDomainSharedModule))] +public class ProductManagementApplicationContractsModule : AbpModule { } diff --git a/templates/ms/modules/product/src/ProductManagement.Application/ProductAppService.cs b/templates/ms/modules/product/src/ProductManagement.Application/ProductAppService.cs new file mode 100644 index 0000000..d28a2ea --- /dev/null +++ b/templates/ms/modules/product/src/ProductManagement.Application/ProductAppService.cs @@ -0,0 +1,14 @@ +using System; +using Volo.Abp.Application.Dtos; +using Volo.Abp.Application.Services; +using Volo.Abp.Domain.Repositories; + +namespace ProductManagement; + +public class ProductAppService : + CrudAppService, + IProductAppService +{ + public ProductAppService(IRepository repository) + : base(repository) { } +} diff --git a/templates/ms/modules/product/src/ProductManagement.Application/ProductManagement.Application.csproj b/templates/ms/modules/product/src/ProductManagement.Application/ProductManagement.Application.csproj new file mode 100644 index 0000000..c0500ae --- /dev/null +++ b/templates/ms/modules/product/src/ProductManagement.Application/ProductManagement.Application.csproj @@ -0,0 +1,8 @@ + + net8.0 + + + + + + diff --git a/templates/ms/modules/product/src/ProductManagement.Application/ProductManagementApplicationModule.cs b/templates/ms/modules/product/src/ProductManagement.Application/ProductManagementApplicationModule.cs new file mode 100644 index 0000000..61ba2a2 --- /dev/null +++ b/templates/ms/modules/product/src/ProductManagement.Application/ProductManagementApplicationModule.cs @@ -0,0 +1,9 @@ +using Volo.Abp.Modularity; + +namespace ProductManagement; + +[DependsOn( + typeof(ProductManagementDomainModule), + typeof(ProductManagementApplicationContractsModule) +)] +public class ProductManagementApplicationModule : AbpModule { } diff --git a/templates/ms/modules/product/src/ProductManagement.Domain.Shared/ProductManagement.Domain.Shared.csproj b/templates/ms/modules/product/src/ProductManagement.Domain.Shared/ProductManagement.Domain.Shared.csproj new file mode 100644 index 0000000..08dafea --- /dev/null +++ b/templates/ms/modules/product/src/ProductManagement.Domain.Shared/ProductManagement.Domain.Shared.csproj @@ -0,0 +1,6 @@ + + netstandard2.0 + + + + diff --git a/templates/ms/modules/product/src/ProductManagement.Domain.Shared/ProductManagementDomainSharedModule.cs b/templates/ms/modules/product/src/ProductManagement.Domain.Shared/ProductManagementDomainSharedModule.cs new file mode 100644 index 0000000..19fe49b --- /dev/null +++ b/templates/ms/modules/product/src/ProductManagement.Domain.Shared/ProductManagementDomainSharedModule.cs @@ -0,0 +1,7 @@ +using Volo.Abp.Modularity; +using Volo.Abp.Localization; + +namespace ProductManagement; + +[DependsOn(typeof(AbpLocalizationModule))] +public class ProductManagementDomainSharedModule : AbpModule { } diff --git a/templates/ms/modules/product/src/ProductManagement.Domain/Product.cs b/templates/ms/modules/product/src/ProductManagement.Domain/Product.cs new file mode 100644 index 0000000..efb9009 --- /dev/null +++ b/templates/ms/modules/product/src/ProductManagement.Domain/Product.cs @@ -0,0 +1,11 @@ +using System; +using Volo.Abp.Domain.Entities.Auditing; + +namespace ProductManagement; + +public class Product : FullAuditedAggregateRoot +{ + public string Name { get; set; } = string.Empty; + public decimal Price { get; set; } + public int StockCount { get; set; } +} diff --git a/templates/ms/modules/product/src/ProductManagement.Domain/ProductManagement.Domain.csproj b/templates/ms/modules/product/src/ProductManagement.Domain/ProductManagement.Domain.csproj new file mode 100644 index 0000000..42c1096 --- /dev/null +++ b/templates/ms/modules/product/src/ProductManagement.Domain/ProductManagement.Domain.csproj @@ -0,0 +1,7 @@ + + net8.0 + + + + + diff --git a/templates/ms/modules/product/src/ProductManagement.Domain/ProductManagementDomainModule.cs b/templates/ms/modules/product/src/ProductManagement.Domain/ProductManagementDomainModule.cs new file mode 100644 index 0000000..cfd0591 --- /dev/null +++ b/templates/ms/modules/product/src/ProductManagement.Domain/ProductManagementDomainModule.cs @@ -0,0 +1,6 @@ +using Volo.Abp.Modularity; + +namespace ProductManagement; + +[DependsOn(typeof(ProductManagementDomainSharedModule))] +public class ProductManagementDomainModule : AbpModule { } diff --git a/templates/ms/modules/product/src/ProductManagement.EntityFrameworkCore/ProductManagement.EntityFrameworkCore.csproj b/templates/ms/modules/product/src/ProductManagement.EntityFrameworkCore/ProductManagement.EntityFrameworkCore.csproj new file mode 100644 index 0000000..882cba9 --- /dev/null +++ b/templates/ms/modules/product/src/ProductManagement.EntityFrameworkCore/ProductManagement.EntityFrameworkCore.csproj @@ -0,0 +1,11 @@ + + net8.0 + + + + all + runtime; build; native; contentfiles; analyzers + + + + diff --git a/templates/ms/modules/product/src/ProductManagement.EntityFrameworkCore/ProductManagementDbContext.cs b/templates/ms/modules/product/src/ProductManagement.EntityFrameworkCore/ProductManagementDbContext.cs new file mode 100644 index 0000000..09b7362 --- /dev/null +++ b/templates/ms/modules/product/src/ProductManagement.EntityFrameworkCore/ProductManagementDbContext.cs @@ -0,0 +1,22 @@ +using Microsoft.EntityFrameworkCore; +using Volo.Abp.EntityFrameworkCore; + +namespace ProductManagement.EntityFrameworkCore; + +public class ProductManagementDbContext : AbpDbContext +{ + public DbSet Products { get; set; } + + public ProductManagementDbContext(DbContextOptions options) + : base(options) { } + + protected override void OnModelCreating(ModelBuilder builder) + { + base.OnModelCreating(builder); + builder.Entity(b => + { + b.ToTable("PmProducts"); + b.Property(x => x.Name).IsRequired().HasMaxLength(128); + }); + } +} diff --git a/templates/ms/modules/product/src/ProductManagement.EntityFrameworkCore/ProductManagementEntityFrameworkCoreModule.cs b/templates/ms/modules/product/src/ProductManagement.EntityFrameworkCore/ProductManagementEntityFrameworkCoreModule.cs new file mode 100644 index 0000000..46516a6 --- /dev/null +++ b/templates/ms/modules/product/src/ProductManagement.EntityFrameworkCore/ProductManagementEntityFrameworkCoreModule.cs @@ -0,0 +1,6 @@ +using Volo.Abp.Modularity; + +namespace ProductManagement.EntityFrameworkCore; + +[DependsOn(typeof(ProductManagementDomainModule))] +public class ProductManagementEntityFrameworkCoreModule : AbpModule { } diff --git a/templates/ms/modules/product/src/ProductManagement.HttpApi.Client/ProductManagement.HttpApi.Client.csproj b/templates/ms/modules/product/src/ProductManagement.HttpApi.Client/ProductManagement.HttpApi.Client.csproj new file mode 100644 index 0000000..8b1194b --- /dev/null +++ b/templates/ms/modules/product/src/ProductManagement.HttpApi.Client/ProductManagement.HttpApi.Client.csproj @@ -0,0 +1,7 @@ + + net8.0 + + + + + diff --git a/templates/ms/modules/product/src/ProductManagement.HttpApi.Client/ProductManagementHttpApiClientModule.cs b/templates/ms/modules/product/src/ProductManagement.HttpApi.Client/ProductManagementHttpApiClientModule.cs new file mode 100644 index 0000000..8bb29a2 --- /dev/null +++ b/templates/ms/modules/product/src/ProductManagement.HttpApi.Client/ProductManagementHttpApiClientModule.cs @@ -0,0 +1,6 @@ +using Volo.Abp.Modularity; + +namespace ProductManagement; + +[DependsOn(typeof(ProductManagementApplicationContractsModule))] +public class ProductManagementHttpApiClientModule : AbpModule { } diff --git a/templates/ms/modules/product/src/ProductManagement.HttpApi/ProductManagement.HttpApi.csproj b/templates/ms/modules/product/src/ProductManagement.HttpApi/ProductManagement.HttpApi.csproj new file mode 100644 index 0000000..507f48e --- /dev/null +++ b/templates/ms/modules/product/src/ProductManagement.HttpApi/ProductManagement.HttpApi.csproj @@ -0,0 +1,7 @@ + + net8.0 + + + + + diff --git a/templates/ms/modules/product/src/ProductManagement.HttpApi/ProductManagementHttpApiModule.cs b/templates/ms/modules/product/src/ProductManagement.HttpApi/ProductManagementHttpApiModule.cs new file mode 100644 index 0000000..07c1060 --- /dev/null +++ b/templates/ms/modules/product/src/ProductManagement.HttpApi/ProductManagementHttpApiModule.cs @@ -0,0 +1,6 @@ +using Volo.Abp.Modularity; + +namespace ProductManagement; + +[DependsOn(typeof(ProductManagementApplicationContractsModule))] +public class ProductManagementHttpApiModule : AbpModule { } diff --git a/templates/ms/modules/product/src/ProductManagement.Web/ProductManagement.Web.csproj b/templates/ms/modules/product/src/ProductManagement.Web/ProductManagement.Web.csproj new file mode 100644 index 0000000..e459720 --- /dev/null +++ b/templates/ms/modules/product/src/ProductManagement.Web/ProductManagement.Web.csproj @@ -0,0 +1,11 @@ + + + net8.0 + Library + + + + + + + diff --git a/templates/ms/modules/product/src/ProductManagement.Web/ProductManagementWebModule.cs b/templates/ms/modules/product/src/ProductManagement.Web/ProductManagementWebModule.cs new file mode 100644 index 0000000..4e39dbc --- /dev/null +++ b/templates/ms/modules/product/src/ProductManagement.Web/ProductManagementWebModule.cs @@ -0,0 +1,6 @@ +using Volo.Abp.Modularity; + +namespace ProductManagement; + +[DependsOn(typeof(ProductManagementHttpApiModule))] +public class ProductManagementWebModule : AbpModule { } diff --git a/templates/ms/shared/Company.Project.Shared/Company.Project.Shared.csproj b/templates/ms/shared/Company.Project.Shared/Company.Project.Shared.csproj new file mode 100644 index 0000000..95e3d2c --- /dev/null +++ b/templates/ms/shared/Company.Project.Shared/Company.Project.Shared.csproj @@ -0,0 +1,6 @@ + + + net8.0 + Company.Project.Shared + + diff --git a/templates/ms/shared/Company.Project.Shared/ProjectConsts.cs b/templates/ms/shared/Company.Project.Shared/ProjectConsts.cs new file mode 100644 index 0000000..dd9ae11 --- /dev/null +++ b/templates/ms/shared/Company.Project.Shared/ProjectConsts.cs @@ -0,0 +1,6 @@ +namespace Company.Project.Shared; + +public static class ProjectConsts +{ + public const bool IsMultiTenancyEnabled = true; +}