@@ -24,11 +24,14 @@ namespace Yi.Framework.Application.Student
|
|||||||
_studentRepository = studentRepository;
|
_studentRepository = studentRepository;
|
||||||
_studentManager = studentManager;
|
_studentManager = studentManager;
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
public string PostShijie(IFormFile formFile)
|
/// 你好世界
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="aaa"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public string PostShijie(string aaa)
|
||||||
{
|
{
|
||||||
var ss = formFile;
|
return aaa;
|
||||||
return "你好世界";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,5 +9,12 @@
|
|||||||
服务实现
|
服务实现
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="M:Yi.Framework.Application.Student.StudentService.PostShijie(System.String)">
|
||||||
|
<summary>
|
||||||
|
你好世界
|
||||||
|
</summary>
|
||||||
|
<param name="aaa"></param>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
</members>
|
</members>
|
||||||
</doc>
|
</doc>
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Yi.Framework.Application.Contracts\Yi.Framework.Application.Contracts.csproj" />
|
<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.Core.AutoMapper\Yi.Framework.Core.AutoMapper.csproj" />
|
||||||
<ProjectReference Include="..\Yi.Framework.Domain\Yi.Framework.Domain.csproj" />
|
<ProjectReference Include="..\Yi.Framework.Domain\Yi.Framework.Domain.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
@@ -29,15 +29,19 @@ namespace Microsoft.Extensions.DependencyInjection
|
|||||||
//添加注释服务
|
//添加注释服务
|
||||||
//为 Swagger JSON and UI设置xml文档注释路径
|
//为 Swagger JSON and UI设置xml文档注释路径
|
||||||
//获取应用程序所在目录(绝对路径,不受工作目录影响,建议采用此方法获取路径使用windwos&Linux)
|
//获取应用程序所在目录(绝对路径,不受工作目录影响,建议采用此方法获取路径使用windwos&Linux)
|
||||||
|
|
||||||
var basePath = Path.GetDirectoryName(typeof(Program).Assembly.Location);
|
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");//实体注释
|
//var entityXmlPath = Path.Combine(basePath, @"SwaggerDoc.xml");//实体注释
|
||||||
//c.IncludeXmlComments(apiXmlPath, true);//true表示显示控制器注释
|
//c.IncludeXmlComments(apiXmlPath, true);//true表示显示控制器注释
|
||||||
//c.IncludeXmlComments(apiXmlPath, true);
|
//c.IncludeXmlComments(apiXmlPath, true);
|
||||||
|
|
||||||
//这里路径应该动态获取,先暂时写死
|
//这里路径应该动态获取,先暂时写死
|
||||||
//c.IncludeXmlComments("E:\\Yi\\src\\Yi.Framework\\Yi.Framework.Application\\SwaggerDoc.xml", true);
|
//c.IncludeXmlComments("E:\\Yi\\src\\Yi.Framework\\Yi.Framework.Application\\SwaggerDoc.xml", true);
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Cors" Version="2.2.0" />
|
<PackageReference Include="Microsoft.AspNetCore.Cors" Version="2.2.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.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" />
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ namespace Yi.Framework.Autofac.Extensions
|
|||||||
{
|
{
|
||||||
if (a.FullName is not null)
|
if (a.FullName is not null)
|
||||||
{
|
{
|
||||||
profileList.AddRange(AssemblyHelper.GetClassByBaseClassesAndInterfaces(a.FullName, typeof(Profile)));
|
profileList.AddRange(AssemblyHelper.GetClassByInterfaces(a.FullName, typeof(Profile)));
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -6,6 +6,10 @@
|
|||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Yi.Framework.Core\Yi.Framework.Core.csproj" />
|
<ProjectReference Include="..\Yi.Framework.Core\Yi.Framework.Core.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using AutoMapper.Internal;
|
using System;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
@@ -42,7 +41,7 @@ namespace Yi.Framework.Core.Helper
|
|||||||
).ToList();
|
).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<Type> GetClassByBaseClassesAndInterfaces(string assemblyFile, Type type)
|
public static List<Type> GetClassByInterfaces(string assemblyFile, Type type)
|
||||||
{
|
{
|
||||||
Assembly assembly = Assembly.Load(assemblyFile);
|
Assembly assembly = Assembly.Load(assemblyFile);
|
||||||
|
|
||||||
@@ -51,7 +50,7 @@ namespace Yi.Framework.Core.Helper
|
|||||||
List<Type> typeList = assembly.GetTypes().Where(m => m.IsClass).ToList();
|
List<Type> typeList = assembly.GetTypes().Where(m => m.IsClass).ToList();
|
||||||
foreach (var t in typeList)
|
foreach (var t in typeList)
|
||||||
{
|
{
|
||||||
var data = t.BaseClassesAndInterfaces();
|
var data = t.GetInterfaces();
|
||||||
if (data.Contains(type))
|
if (data.Contains(type))
|
||||||
{
|
{
|
||||||
resList.Add(t);
|
resList.Add(t);
|
||||||
|
|||||||
@@ -11,8 +11,6 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<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="SqlSugarCoreNoDrive" Version="5.1.3.43" />
|
||||||
<PackageReference Include="StartupModules" Version="4.0.0" />
|
<PackageReference Include="StartupModules" Version="4.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ using Yi.Framework.Domain.Shared;
|
|||||||
using Yi.Framework.Sqlsugar;
|
using Yi.Framework.Sqlsugar;
|
||||||
using Yi.Framework.Web;
|
using Yi.Framework.Web;
|
||||||
|
|
||||||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD>еĵط<C4B5>
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
builder.WebHost.UseUrls(builder.Configuration.GetValue<string>("StartUrl"));
|
builder.WebHost.UseUrls(builder.Configuration.GetValue<string>("StartUrl"));
|
||||||
@@ -31,40 +32,17 @@ builder.UseYiModules(
|
|||||||
typeof(YiFrameworkDomainSharedModule).Assembly,
|
typeof(YiFrameworkDomainSharedModule).Assembly,
|
||||||
typeof(YiFrameworkDomainModule).Assembly,
|
typeof(YiFrameworkDomainModule).Assembly,
|
||||||
typeof(YiFrameworkApplicationContractsModule).Assembly,
|
typeof(YiFrameworkApplicationContractsModule).Assembly,
|
||||||
typeof(YiFrameworkApplicationModule).Assembly
|
typeof(YiFrameworkApplicationModule).Assembly,
|
||||||
|
typeof(YiFrameworkWebModule).Assembly
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
//ʹ<><CAB9>autofac
|
//ʹ<><CAB9>autofac
|
||||||
builder.Host.UseAutoFacServerProviderFactory();
|
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();
|
var app = builder.Build();
|
||||||
|
|
||||||
app.Services.GetRequiredService<IRepository<TestEntity>>();
|
|
||||||
//if (app.Environment.IsDevelopment())
|
|
||||||
{
|
|
||||||
app.UseSwaggerServer();
|
|
||||||
}
|
|
||||||
|
|
||||||
app.UseHttpsRedirection();
|
|
||||||
|
|
||||||
app.UseAuthorization();
|
|
||||||
|
|
||||||
app.UseRouting();
|
|
||||||
|
|
||||||
//ʹ<>ö<EFBFBD>̬api
|
//ʹ<>ö<EFBFBD>̬api
|
||||||
app.UseAutoApiService();
|
app.UseAutoApiService();
|
||||||
app.MapControllers();
|
app.MapControllers();
|
||||||
|
|
||||||
app.Run();
|
app.Run();
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Yi.Framework.Application\Yi.Framework.Application.csproj" />
|
<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.Core.Autofac\Yi.Framework.Core.Autofac.csproj" />
|
||||||
<ProjectReference Include="..\Yi.Framework.Sqlsugar\Yi.Framework.Sqlsugar.csproj" />
|
<ProjectReference Include="..\Yi.Framework.Sqlsugar\Yi.Framework.Sqlsugar.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
@@ -1,16 +1,40 @@
|
|||||||
using StartupModules;
|
using AspNetCore.Microsoft.AspNetCore.Builder;
|
||||||
|
using StartupModules;
|
||||||
|
using Yi.Framework.Application;
|
||||||
|
|
||||||
namespace Yi.Framework.Web
|
namespace Yi.Framework.Web
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 这里是最后执行的模块
|
||||||
|
/// </summary>
|
||||||
public class YiFrameworkWebModule : IStartupModule
|
public class YiFrameworkWebModule : IStartupModule
|
||||||
{
|
{
|
||||||
public void ConfigureServices(IServiceCollection services, ConfigureServicesContext context)
|
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)
|
public void Configure(IApplicationBuilder app, ConfigureMiddlewareContext context)
|
||||||
{
|
{
|
||||||
Console.WriteLine("还有谁");
|
//if (app.Environment.IsDevelopment())
|
||||||
|
{
|
||||||
|
app.UseSwaggerServer();
|
||||||
|
}
|
||||||
|
|
||||||
|
app.UseHttpsRedirection();
|
||||||
|
|
||||||
|
app.UseAuthorization();
|
||||||
|
|
||||||
|
app.UseRouting();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user