Files
Yi.Admin/Yi.Framework.Net6/src/project/BBS/Yi.BBS.Web/YiBBSWebModule.cs

57 lines
1.8 KiB
C#
Raw Normal View History

2023-01-24 20:28:33 +08:00
using AspNetCore.Microsoft.AspNetCore.Builder;
using StartupModules;
using Yi.Framework.Auth.JwtBearer;
using Yi.Framework.Core;
using Yi.Framework.Core.Attributes;
using Yi.BBS.Application;
using Yi.BBS.Sqlsugar;
2023-01-25 22:27:19 +08:00
using Yi.Framework.AspNetCore.Microsoft.Extensions.DependencyInjection;
2023-01-26 21:00:01 +08:00
using Yi.Framework.Core.Autofac;
2023-01-29 21:13:20 +08:00
using Yi.RBAC.Application;
2023-02-09 19:11:56 +08:00
using Yi.Framework.AspNetCore;
2023-02-19 16:49:11 +08:00
using Yi.Framework.Data.Json;
using Yi.Framework.OperLogManager;
2023-03-02 09:40:46 +08:00
using Yi.Framework.Core.Module;
2023-01-24 20:28:33 +08:00
namespace Yi.BBS.Web
{
[DependsOn(
2023-02-09 19:11:56 +08:00
typeof(YiFrameworkAspNetCoreModule),
2023-01-26 21:00:01 +08:00
typeof(YiFrameworkCoreAutofacModule),
2023-01-24 20:28:33 +08:00
typeof(YiBBSSqlsugarModule),
typeof(YiBBSApplicationModule)
)]
public class YiBBSWebModule : IStartupModule
{
public void ConfigureServices(IServiceCollection services, ConfigureServicesContext context)
{
//添加控制器与动态api
2023-02-19 16:49:11 +08:00
services.AddControllers().AddJsonOptions(opt => {
opt.JsonSerializerOptions.Converters.Add(new DateTimeJsonConverter("yyyy-MM-dd HH:mm:ss"));
});
2023-03-02 09:40:46 +08:00
2023-01-24 20:28:33 +08:00
services.AddAutoApiService(opt =>
{
//NETServiceTest所在程序集添加进动态api配置
2023-03-02 09:40:46 +08:00
opt.CreateConventional(ModuleAssembly.Assemblies, option => option.RootPath = string.Empty);
2023-01-24 20:28:33 +08:00
});
//添加swagger
services.AddSwaggerServer<YiBBSApplicationModule>();
}
public void Configure(IApplicationBuilder app, ConfigureMiddlewareContext context)
{
//if (app.Environment.IsDevelopment())
{
app.UseSwaggerServer();
}
app.UseHttpsRedirection();
app.UseAuthorization();
app.UseRouting();
}
}
}