Files
Yi.Admin/Yi.Framework.Net6/src/project/Template/Yi.Template.Web/YiTemplateWebModule.cs

53 lines
1.7 KiB
C#
Raw Normal View History

using AspNetCore.Microsoft.AspNetCore.Builder;
using StartupModules;
2023-02-09 19:11:56 +08:00
using Yi.Framework.AspNetCore;
2023-01-19 15:35:50 +08:00
using Yi.Framework.Auth.JwtBearer;
using Yi.Framework.Core;
using Yi.Framework.Core.Attributes;
2023-01-30 14:44:24 +08:00
using Yi.Framework.Core.Autofac;
2023-03-02 09:40:46 +08:00
using Yi.Framework.Core.Module;
2023-02-19 16:49:11 +08:00
using Yi.Framework.Data.Json;
2023-01-24 20:20:32 +08:00
using Yi.Template.Application;
using Yi.Template.Sqlsugar;
2023-01-11 11:10:59 +08:00
2023-01-24 20:20:32 +08:00
namespace Yi.Template.Web
2023-01-11 11:10:59 +08:00
{
[DependsOn(
2023-02-09 19:11:56 +08:00
typeof(YiFrameworkAspNetCoreModule),
2023-01-30 14:44:24 +08:00
typeof(YiFrameworkCoreAutofacModule),
2023-01-24 20:20:32 +08:00
typeof(YiTemplateSqlsugarModule),
typeof(YiTemplateApplicationModule)
)]
2023-01-24 20:20:32 +08:00
public class YiTemplateWebModule : IStartupModule
2023-01-11 11:10:59 +08:00
{
public void ConfigureServices(IServiceCollection services, ConfigureServicesContext context)
2023-01-11 11:10:59 +08:00
{
//添加控制器与动态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"));
});
services.AddAutoApiService(opt =>
{
//NETServiceTest所在程序集添加进动态api配置
2023-03-02 09:40:46 +08:00
opt.CreateConventional(ModuleAssembly.Assemblies, option => option.RootPath = string.Empty);
});
//添加swagger
2023-01-24 20:20:32 +08:00
services.AddSwaggerServer<YiTemplateApplicationModule>();
2023-01-11 11:10:59 +08:00
}
public void Configure(IApplicationBuilder app, ConfigureMiddlewareContext context)
2023-01-11 11:10:59 +08:00
{
//if (app.Environment.IsDevelopment())
{
app.UseSwaggerServer();
}
app.UseHttpsRedirection();
app.UseAuthorization();
app.UseRouting();
2023-01-11 11:10:59 +08:00
}
}
}