feat(cli): add ms microservice template support
1. 新增`ms`微服务模板,包含共享项目、微服务、网关、应用等完整架构 2. 为`hua new`命令添加`ms`模板选项并更新文档 3. 将模板文件嵌入CLI项目输出目录 4. 实现微服务模板的项目构建逻辑,自动安装并使用dotnet自定义模板创建项目
This commit is contained in:
+17
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using Volo.Abp.Application.Dtos;
|
||||
using Volo.Abp.Application.Services;
|
||||
|
||||
namespace ProductManagement;
|
||||
|
||||
public interface IProductAppService :
|
||||
ICrudAppService<ProductDto, Guid, PagedAndSortedResultRequestDto, CreateUpdateProductDto>
|
||||
{
|
||||
}
|
||||
|
||||
public class CreateUpdateProductDto
|
||||
{
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public decimal Price { get; set; }
|
||||
public int StockCount { get; set; }
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
using System;
|
||||
using Volo.Abp.Application.Dtos;
|
||||
|
||||
namespace ProductManagement;
|
||||
|
||||
public class ProductDto : FullAuditedEntityDto<Guid>
|
||||
{
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public decimal Price { get; set; }
|
||||
public int StockCount { get; set; }
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup><TargetFramework>netstandard2.0</TargetFramework></PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Volo.Abp.Ddd.Application" Version="9.0.0" />
|
||||
<ProjectReference Include="..\ProductManagement.Domain.Shared\ProductManagement.Domain.Shared.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
using Volo.Abp.Modularity;
|
||||
|
||||
namespace ProductManagement;
|
||||
|
||||
[DependsOn(typeof(ProductManagementDomainSharedModule))]
|
||||
public class ProductManagementApplicationContractsModule : AbpModule { }
|
||||
@@ -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<Product, ProductDto, Guid, PagedAndSortedResultRequestDto, CreateUpdateProductDto>,
|
||||
IProductAppService
|
||||
{
|
||||
public ProductAppService(IRepository<Product, Guid> repository)
|
||||
: base(repository) { }
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup><TargetFramework>net8.0</TargetFramework></PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Volo.Abp.AutoMapper" Version="9.0.0" />
|
||||
<ProjectReference Include="..\ProductManagement.Application.Contracts\ProductManagement.Application.Contracts.csproj" />
|
||||
<ProjectReference Include="..\ProductManagement.Domain\ProductManagement.Domain.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
using Volo.Abp.Modularity;
|
||||
|
||||
namespace ProductManagement;
|
||||
|
||||
[DependsOn(
|
||||
typeof(ProductManagementDomainModule),
|
||||
typeof(ProductManagementApplicationContractsModule)
|
||||
)]
|
||||
public class ProductManagementApplicationModule : AbpModule { }
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup><TargetFramework>netstandard2.0</TargetFramework></PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Volo.Abp.Localization" Version="9.0.0" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
using Volo.Abp.Modularity;
|
||||
using Volo.Abp.Localization;
|
||||
|
||||
namespace ProductManagement;
|
||||
|
||||
[DependsOn(typeof(AbpLocalizationModule))]
|
||||
public class ProductManagementDomainSharedModule : AbpModule { }
|
||||
@@ -0,0 +1,11 @@
|
||||
using System;
|
||||
using Volo.Abp.Domain.Entities.Auditing;
|
||||
|
||||
namespace ProductManagement;
|
||||
|
||||
public class Product : FullAuditedAggregateRoot<Guid>
|
||||
{
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public decimal Price { get; set; }
|
||||
public int StockCount { get; set; }
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup><TargetFramework>net8.0</TargetFramework></PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Volo.Abp.EntityFrameworkCore" Version="9.0.0" />
|
||||
<ProjectReference Include="..\ProductManagement.Domain.Shared\ProductManagement.Domain.Shared.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
using Volo.Abp.Modularity;
|
||||
|
||||
namespace ProductManagement;
|
||||
|
||||
[DependsOn(typeof(ProductManagementDomainSharedModule))]
|
||||
public class ProductManagementDomainModule : AbpModule { }
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup><TargetFramework>net8.0</TargetFramework></PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Volo.Abp.EntityFrameworkCore.SqlServer" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||
</PackageReference>
|
||||
<ProjectReference Include="..\ProductManagement.Domain\ProductManagement.Domain.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Volo.Abp.EntityFrameworkCore;
|
||||
|
||||
namespace ProductManagement.EntityFrameworkCore;
|
||||
|
||||
public class ProductManagementDbContext : AbpDbContext<ProductManagementDbContext>
|
||||
{
|
||||
public DbSet<Product> Products { get; set; }
|
||||
|
||||
public ProductManagementDbContext(DbContextOptions<ProductManagementDbContext> options)
|
||||
: base(options) { }
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder builder)
|
||||
{
|
||||
base.OnModelCreating(builder);
|
||||
builder.Entity<Product>(b =>
|
||||
{
|
||||
b.ToTable("PmProducts");
|
||||
b.Property(x => x.Name).IsRequired().HasMaxLength(128);
|
||||
});
|
||||
}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
using Volo.Abp.Modularity;
|
||||
|
||||
namespace ProductManagement.EntityFrameworkCore;
|
||||
|
||||
[DependsOn(typeof(ProductManagementDomainModule))]
|
||||
public class ProductManagementEntityFrameworkCoreModule : AbpModule { }
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup><TargetFramework>net8.0</TargetFramework></PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Volo.Abp.Http.Client" Version="9.0.0" />
|
||||
<ProjectReference Include="..\ProductManagement.Application.Contracts\ProductManagement.Application.Contracts.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
using Volo.Abp.Modularity;
|
||||
|
||||
namespace ProductManagement;
|
||||
|
||||
[DependsOn(typeof(ProductManagementApplicationContractsModule))]
|
||||
public class ProductManagementHttpApiClientModule : AbpModule { }
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup><TargetFramework>net8.0</TargetFramework></PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Volo.Abp.AspNetCore.Mvc" Version="9.0.0" />
|
||||
<ProjectReference Include="..\ProductManagement.Application.Contracts\ProductManagement.Application.Contracts.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
using Volo.Abp.Modularity;
|
||||
|
||||
namespace ProductManagement;
|
||||
|
||||
[DependsOn(typeof(ProductManagementApplicationContractsModule))]
|
||||
public class ProductManagementHttpApiModule : AbpModule { }
|
||||
@@ -0,0 +1,11 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<OutputType>Library</OutputType>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Volo.Abp.AutoMapper" Version="9.0.0" />
|
||||
<PackageReference Include="Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared" Version="9.0.0" />
|
||||
<ProjectReference Include="..\ProductManagement.HttpApi\ProductManagement.HttpApi.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,6 @@
|
||||
using Volo.Abp.Modularity;
|
||||
|
||||
namespace ProductManagement;
|
||||
|
||||
[DependsOn(typeof(ProductManagementHttpApiModule))]
|
||||
public class ProductManagementWebModule : AbpModule { }
|
||||
Reference in New Issue
Block a user