mirror of
https://gitee.com/ccnetcore/Yi
synced 2026-04-03 23:56:37 +08:00
优化扩展
This commit is contained in:
@@ -18,6 +18,7 @@ using Yi.Framework.Common.IOCOptions;
|
||||
using Yi.Framework.Interface;
|
||||
using Yi.Framework.Model;
|
||||
using Yi.Framework.Service;
|
||||
using Yi.Framework.WebCore;
|
||||
using Yi.Framework.WebCore.MiddlewareExtend;
|
||||
|
||||
namespace Yi.Framework.ApiMicroservice
|
||||
@@ -34,6 +35,11 @@ namespace Yi.Framework.ApiMicroservice
|
||||
// This method gets called by the runtime. Use this method to add services to the container.
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
#region
|
||||
//Ioc配置
|
||||
#endregion
|
||||
services.AddIocService(Configuration);
|
||||
|
||||
#region
|
||||
//控制器+过滤器配置
|
||||
#endregion
|
||||
@@ -50,25 +56,21 @@ namespace Yi.Framework.ApiMicroservice
|
||||
services.AddCorsService();
|
||||
|
||||
#region
|
||||
//数据库服务配置
|
||||
//Sqlite服务配置
|
||||
#endregion
|
||||
services.AddDataBaseService<SqliteOptions>("SqliteConn");
|
||||
services.AddSqliteService();
|
||||
|
||||
#region
|
||||
//Redis服务配置
|
||||
#endregion
|
||||
services.AddRedisService();
|
||||
//services.AddRedisService();
|
||||
|
||||
#region
|
||||
//RabbitMQ服务配置
|
||||
#endregion
|
||||
services.AddRabbitMQService();
|
||||
|
||||
//下面这些应自动注入
|
||||
services.AddScoped<IUserService, UserService>();
|
||||
services.AddScoped<IRoleService, RoleService>();
|
||||
|
||||
//services.AddRabbitMQService();
|
||||
|
||||
|
||||
}
|
||||
|
||||
#region Autofac容器注入
|
||||
@@ -82,7 +84,7 @@ namespace Yi.Framework.ApiMicroservice
|
||||
#endregion
|
||||
|
||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||
public async void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||
{
|
||||
//if (env.IsDevelopment())
|
||||
{
|
||||
@@ -115,7 +117,7 @@ namespace Yi.Framework.ApiMicroservice
|
||||
#region
|
||||
//健康检查注入
|
||||
#endregion
|
||||
app.UseHealthCheckMiddleware();
|
||||
//app.UseHealthCheckMiddleware();
|
||||
|
||||
#region
|
||||
//鉴权注入
|
||||
@@ -130,7 +132,7 @@ namespace Yi.Framework.ApiMicroservice
|
||||
#region
|
||||
//Consul服务注入
|
||||
#endregion
|
||||
await app.UseConsulService();
|
||||
//await app.UseConsulService();
|
||||
|
||||
#region
|
||||
//Endpoints注入
|
||||
|
||||
43
Yi.Framework/Yi.Framework.ApiMicroservice/SwaggerDoc.xml
Normal file
43
Yi.Framework/Yi.Framework.ApiMicroservice/SwaggerDoc.xml
Normal file
@@ -0,0 +1,43 @@
|
||||
<?xml version="1.0"?>
|
||||
<doc>
|
||||
<assembly>
|
||||
<name>Yi.Framework.ApiMicroservice</name>
|
||||
</assembly>
|
||||
<members>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.UserController.GetUser">
|
||||
<summary>
|
||||
查
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.UserController.UpdateUser(Yi.Framework.Model.Models.user)">
|
||||
<summary>
|
||||
更
|
||||
</summary>
|
||||
<param name="_user"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.UserController.DelListUser(System.Collections.Generic.List{System.Int32})">
|
||||
<summary>
|
||||
删
|
||||
</summary>
|
||||
<param name="_ids"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.UserController.AddUser(Yi.Framework.Model.Models.user)">
|
||||
<summary>
|
||||
增
|
||||
</summary>
|
||||
<param name="_user"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:Yi.Framework.ApiMicroservice.Utility.CustomHostingStartup">
|
||||
<summary>
|
||||
必须实现IHostingStartup接口
|
||||
必须标记HostingStartup特性
|
||||
|
||||
就像木马一样
|
||||
</summary>
|
||||
</member>
|
||||
</members>
|
||||
</doc>
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Castle.DynamicProxy;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@@ -39,9 +39,12 @@ namespace Yi.Framework.ApiMicroservice.Utility
|
||||
//containerBuilder.RegisterType<A>().As<IA>().EnableInterfaceInterceptors();开启Aop
|
||||
|
||||
//将数据库对象注入
|
||||
containerBuilder.RegisterType<DataContext>().As<DbContext>().InstancePerLifetimeScope().EnableInterfaceInterceptors();
|
||||
//containerBuilder.RegisterType<DataContext>().As<DbContext>().InstancePerLifetimeScope().EnableInterfaceInterceptors();
|
||||
|
||||
containerBuilder.RegisterGeneric(typeof(BaseService<>)).As(typeof(IBaseService<>)).EnableInterfaceInterceptors();
|
||||
containerBuilder.RegisterGeneric(typeof(BaseService<>)).As(typeof(IBaseService<>)).InstancePerLifetimeScope().EnableInterfaceInterceptors();
|
||||
|
||||
containerBuilder.RegisterType<UserService>().As< IUserService >().InstancePerLifetimeScope().EnableInterfaceInterceptors();
|
||||
containerBuilder.RegisterType<RoleService>().As<IRoleService>().InstancePerLifetimeScope().EnableInterfaceInterceptors();
|
||||
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
@@ -5,11 +5,14 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<DocumentationFile>D:\CC.Yi\CC.Yi\Yi.Framework\Yi.Framework.ApiMicroservice\Yi.Framework.ApiMicroservice.xml</DocumentationFile>
|
||||
<DocumentationFile>D:\CC.Yi\CC.Yi\Yi.Framework\Yi.Framework.ApiMicroservice\SwaggerDoc.xml</DocumentationFile>
|
||||
<NoWarn>1701;1702;CS1591</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Autofac" Version="6.3.0" />
|
||||
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.1.0" />
|
||||
<PackageReference Include="Autofac.Extras.DynamicProxy" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.10">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
@@ -21,6 +24,7 @@
|
||||
<ProjectReference Include="..\Yi.Framework.Interface\Yi.Framework.Interface.csproj" />
|
||||
<ProjectReference Include="..\Yi.Framework.Model\Yi.Framework.Model.csproj" />
|
||||
<ProjectReference Include="..\Yi.Framework.Service\Yi.Framework.Service.csproj" />
|
||||
<ProjectReference Include="..\Yi.Framework.WebCore\Yi.Framework.WebCore.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
Reference in New Issue
Block a user