|
|
@ -1,6 +1,7 @@
|
|
|
|
using System.Text;
|
|
|
|
using System.Text;
|
|
|
|
using Autofac;
|
|
|
|
using Autofac;
|
|
|
|
using Autofac.Extensions.DependencyInjection;
|
|
|
|
using Autofac.Extensions.DependencyInjection;
|
|
|
|
|
|
|
|
using Common.Util;
|
|
|
|
using Entity.Dto.Resp;
|
|
|
|
using Entity.Dto.Resp;
|
|
|
|
using HybirdFrameworkCore.Autofac;
|
|
|
|
using HybirdFrameworkCore.Autofac;
|
|
|
|
using HybirdFrameworkCore.AutoTask;
|
|
|
|
using HybirdFrameworkCore.AutoTask;
|
|
|
@ -25,7 +26,6 @@ builder.Host.ConfigureContainer<ContainerBuilder>(cb =>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
cb.Register(c =>
|
|
|
|
cb.Register(c =>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
var db = new SqlSugarScope(new ConnectionConfig
|
|
|
|
var db = new SqlSugarScope(new ConnectionConfig
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ConfigId = AppSettingsConstVars.ConfigId,
|
|
|
|
ConfigId = AppSettingsConstVars.ConfigId,
|
|
|
@ -34,13 +34,11 @@ builder.Host.ConfigureContainer<ContainerBuilder>(cb =>
|
|
|
|
IsAutoCloseConnection = true,
|
|
|
|
IsAutoCloseConnection = true,
|
|
|
|
|
|
|
|
|
|
|
|
InitKeyType = InitKeyType.Attribute // 如果使用实体类的属性进行主键标识,请设置为 InitKeyType.Attr
|
|
|
|
InitKeyType = InitKeyType.Attribute // 如果使用实体类的属性进行主键标识,请设置为 InitKeyType.Attr
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
return db;
|
|
|
|
return db;
|
|
|
|
}).As<ISqlSugarClient>().SingleInstance();
|
|
|
|
}).As<ISqlSugarClient>().SingleInstance();
|
|
|
|
|
|
|
|
|
|
|
|
cb.RegisterModule(new AutofacModuleRegister());
|
|
|
|
cb.RegisterModule(new AutofacModuleRegister());
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// 注册自定义映射
|
|
|
|
// 注册自定义映射
|
|
|
@ -67,7 +65,7 @@ builder.Services.AddCors(options =>
|
|
|
|
|
|
|
|
|
|
|
|
//redis
|
|
|
|
//redis
|
|
|
|
var redisConnectionString = AppSettingsHelper.GetContent("Redis", "Connection");
|
|
|
|
var redisConnectionString = AppSettingsHelper.GetContent("Redis", "Connection");
|
|
|
|
var instanceName = AppSettingsHelper.GetContent("Redis", "InstanceName");//默认数据库
|
|
|
|
var instanceName = AppSettingsHelper.GetContent("Redis", "InstanceName"); //默认数据库
|
|
|
|
var defaultDb = int.Parse(AppSettingsHelper.GetContent("Redis", "DefaultDB") ?? "0");
|
|
|
|
var defaultDb = int.Parse(AppSettingsHelper.GetContent("Redis", "DefaultDB") ?? "0");
|
|
|
|
if (redisConnectionString != null && instanceName != null)
|
|
|
|
if (redisConnectionString != null && instanceName != null)
|
|
|
|
builder.Services.AddSingleton(new RedisHelper(redisConnectionString, instanceName, defaultDb));
|
|
|
|
builder.Services.AddSingleton(new RedisHelper(redisConnectionString, instanceName, defaultDb));
|
|
|
@ -75,6 +73,7 @@ if (redisConnectionString != null && instanceName != null)
|
|
|
|
builder.Services.AddControllers().AddJsonOptions(configure =>
|
|
|
|
builder.Services.AddControllers().AddJsonOptions(configure =>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
configure.JsonSerializerOptions.Converters.Add(new DatetimeJsonConverter());
|
|
|
|
configure.JsonSerializerOptions.Converters.Add(new DatetimeJsonConverter());
|
|
|
|
|
|
|
|
configure.JsonSerializerOptions.Converters.Add(new LongJsonConverter());
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
builder.Services.AddControllers();
|
|
|
|
builder.Services.AddControllers();
|
|
|
@ -89,8 +88,6 @@ builder.Services.AddSwaggerGen(c =>
|
|
|
|
c.IncludeXmlComments(Path.Combine(basePath, "WebStarter.xml"), true);
|
|
|
|
c.IncludeXmlComments(Path.Combine(basePath, "WebStarter.xml"), true);
|
|
|
|
c.IncludeXmlComments(Path.Combine(basePath, "Entity.xml"), true);
|
|
|
|
c.IncludeXmlComments(Path.Combine(basePath, "Entity.xml"), true);
|
|
|
|
c.IncludeXmlComments(Path.Combine(basePath, "HybirdFrameworkCore.xml"), true);
|
|
|
|
c.IncludeXmlComments(Path.Combine(basePath, "HybirdFrameworkCore.xml"), true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
builder.Services.AddControllers().AddJsonOptions(configure =>
|
|
|
|
builder.Services.AddControllers().AddJsonOptions(configure =>
|
|
|
@ -120,9 +117,6 @@ builder.Services.AddAuthentication(options =>
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var app = builder.Build();
|
|
|
|
var app = builder.Build();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -164,7 +158,6 @@ if (AppSettingsHelper.GetBool("swap", "enable"))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TaskInit.Init();
|
|
|
|
TaskInit.Init();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|