更改目录结构,分层基本已经完善

This reverts commit c905489ea5.
This commit is contained in:
橙子
2023-01-14 18:46:34 +08:00
parent 3a9ad5adb8
commit 1bd035e1ca
12 changed files with 66 additions and 48 deletions

View File

@@ -24,11 +24,14 @@ namespace Yi.Framework.Application.Student
_studentRepository = studentRepository;
_studentManager = studentManager;
}
public string PostShijie(IFormFile formFile)
/// <summary>
/// 你好世界
/// </summary>
/// <param name="aaa"></param>
/// <returns></returns>
public string PostShijie(string aaa)
{
var ss = formFile;
return "你好世界";
return aaa;
}
}
}

View File

@@ -9,5 +9,12 @@
服务实现
</summary>
</member>
<member name="M:Yi.Framework.Application.Student.StudentService.PostShijie(System.String)">
<summary>
你好世界
</summary>
<param name="aaa"></param>
<returns></returns>
</member>
</members>
</doc>

View File

@@ -10,6 +10,7 @@
<ItemGroup>
<ProjectReference Include="..\Yi.Framework.Application.Contracts\Yi.Framework.Application.Contracts.csproj" />
<ProjectReference Include="..\Yi.Framework.AspNetCore\Yi.Framework.AspNetCore.csproj" />
<ProjectReference Include="..\Yi.Framework.Core.AutoMapper\Yi.Framework.Core.AutoMapper.csproj" />
<ProjectReference Include="..\Yi.Framework.Domain\Yi.Framework.Domain.csproj" />
</ItemGroup>

View File

@@ -29,15 +29,19 @@ namespace Microsoft.Extensions.DependencyInjection
//添加注释服务
//为 Swagger JSON and UI设置xml文档注释路径
//获取应用程序所在目录(绝对路径不受工作目录影响建议采用此方法获取路径使用windwos&Linux
var basePath = Path.GetDirectoryName(typeof(Program).Assembly.Location);
if (basePath is null)
if (basePath is not null)
{
throw new Exception("未找到swagger文件");
foreach (var item in Directory.GetFiles(basePath, "*.xml"))
{
c.IncludeXmlComments(item, true);
}
}
var apiXmlPath = Path.Combine(basePath, @"SwaggerDoc.xml");//控制器层注释
//var entityXmlPath = Path.Combine(basePath, @"SwaggerDoc.xml");//实体注释
//c.IncludeXmlComments(apiXmlPath, true);//true表示显示控制器注释
//c.IncludeXmlComments(apiXmlPath, true);
//控制器层注释
//var entityXmlPath = Path.Combine(basePath, @"SwaggerDoc.xml");//实体注释
//c.IncludeXmlComments(apiXmlPath, true);//true表示显示控制器注释
//c.IncludeXmlComments(apiXmlPath, true);
//这里路径应该动态获取,先暂时写死
//c.IncludeXmlComments("E:\\Yi\\src\\Yi.Framework\\Yi.Framework.Application\\SwaggerDoc.xml", true);

View File

@@ -9,6 +9,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Cors" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.0" />
<PackageReference Include="NET.AutoApi" Version="1.0.4" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
</ItemGroup>

View File

@@ -22,7 +22,7 @@ namespace Yi.Framework.Autofac.Extensions
{
if (a.FullName is not null)
{
profileList.AddRange(AssemblyHelper.GetClassByBaseClassesAndInterfaces(a.FullName, typeof(Profile)));
profileList.AddRange(AssemblyHelper.GetClassByInterfaces(a.FullName, typeof(Profile)));
}
});

View File

@@ -6,6 +6,10 @@
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Yi.Framework.Core\Yi.Framework.Core.csproj" />
</ItemGroup>

View File

@@ -1,5 +1,4 @@
using AutoMapper.Internal;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
@@ -42,7 +41,7 @@ namespace Yi.Framework.Core.Helper
).ToList();
}
public static List<Type> GetClassByBaseClassesAndInterfaces(string assemblyFile, Type type)
public static List<Type> GetClassByInterfaces(string assemblyFile, Type type)
{
Assembly assembly = Assembly.Load(assemblyFile);
@@ -51,7 +50,7 @@ namespace Yi.Framework.Core.Helper
List<Type> typeList = assembly.GetTypes().Where(m => m.IsClass).ToList();
foreach (var t in typeList)
{
var data = t.BaseClassesAndInterfaces();
var data = t.GetInterfaces();
if (data.Contains(type))
{
resList.Add(t);

View File

@@ -11,8 +11,6 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.0" />
<PackageReference Include="NET.AutoApi" Version="1.0.3" />
<PackageReference Include="SqlSugarCoreNoDrive" Version="5.1.3.43" />
<PackageReference Include="StartupModules" Version="4.0.0" />
</ItemGroup>

View File

@@ -16,6 +16,7 @@ using Yi.Framework.Domain.Shared;
using Yi.Framework.Sqlsugar;
using Yi.Framework.Web;
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD>еĵط<C4B5>
var builder = WebApplication.CreateBuilder(args);
builder.WebHost.UseUrls(builder.Configuration.GetValue<string>("StartUrl"));
@@ -31,40 +32,17 @@ builder.UseYiModules(
typeof(YiFrameworkDomainSharedModule).Assembly,
typeof(YiFrameworkDomainModule).Assembly,
typeof(YiFrameworkApplicationContractsModule).Assembly,
typeof(YiFrameworkApplicationModule).Assembly
typeof(YiFrameworkApplicationModule).Assembly,
typeof(YiFrameworkWebModule).Assembly
);
//ʹ<><CAB9>autofac
builder.Host.UseAutoFacServerProviderFactory();
//<2F><><EFBFBD>ӿ<EFBFBD><D3BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>붯̬api
builder.Services.AddControllers();
builder.Services.AddAutoApiService(opt =>
{
//NETServiceTest<73><74><EFBFBD>ڳ<EFBFBD><DAB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӽ<EFBFBD><D3BD><EFBFBD>̬api<70><69><EFBFBD><EFBFBD>
opt.CreateConventional(typeof(YiFrameworkApplicationModule).Assembly);
});
//<2F><><EFBFBD><EFBFBD>swagger
builder.Services.AddSwaggerServer<YiFrameworkApplicationModule>();
var app = builder.Build();
app.Services.GetRequiredService<IRepository<TestEntity>>();
//if (app.Environment.IsDevelopment())
{
app.UseSwaggerServer();
}
app.UseHttpsRedirection();
app.UseAuthorization();
app.UseRouting();
//ʹ<>ö<EFBFBD>̬api
app.UseAutoApiService();
app.MapControllers();
app.Run();

View File

@@ -8,7 +8,6 @@
<ItemGroup>
<ProjectReference Include="..\Yi.Framework.Application\Yi.Framework.Application.csproj" />
<ProjectReference Include="..\Yi.Framework.AspNetCore\Yi.Framework.AspNetCore.csproj" />
<ProjectReference Include="..\Yi.Framework.Core.Autofac\Yi.Framework.Core.Autofac.csproj" />
<ProjectReference Include="..\Yi.Framework.Sqlsugar\Yi.Framework.Sqlsugar.csproj" />
</ItemGroup>

View File

@@ -1,17 +1,41 @@
using StartupModules;
using AspNetCore.Microsoft.AspNetCore.Builder;
using StartupModules;
using Yi.Framework.Application;
namespace Yi.Framework.Web
{
/// <summary>
/// 这里是最后执行的模块
/// </summary>
public class YiFrameworkWebModule : IStartupModule
{
public void ConfigureServices(IServiceCollection services, ConfigureServicesContext context)
{
//添加控制器与动态api
services.AddControllers();
services.AddAutoApiService(opt =>
{
//NETServiceTest所在程序集添加进动态api配置
opt.CreateConventional(typeof(YiFrameworkApplicationModule).Assembly, option => option.RootPath = string.Empty);
});
//添加swagger
services.AddSwaggerServer<YiFrameworkApplicationModule>();
}
public void Configure(IApplicationBuilder app, ConfigureMiddlewareContext context)
{
Console.WriteLine("还有谁");
//if (app.Environment.IsDevelopment())
{
app.UseSwaggerServer();
}
app.UseHttpsRedirection();
app.UseAuthorization();
app.UseRouting();
}
}
}