|
|
@ -33,9 +33,11 @@ namespace djyweb_djyPaasApi
|
|
|
|
|
|
|
|
|
|
|
|
public void ConfigureServices(IServiceCollection services)
|
|
|
|
public void ConfigureServices(IServiceCollection services)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
services.AddControllers().ConfigureApiBehaviorOptions(options=> {
|
|
|
|
services.AddControllers().ConfigureApiBehaviorOptions(options =>
|
|
|
|
|
|
|
|
{
|
|
|
|
options.InvalidModelStateResponseFactory = context =>
|
|
|
|
options.InvalidModelStateResponseFactory = context =>
|
|
|
|
{var result = new BadRequestObjectResult(context.HttpContext);
|
|
|
|
{
|
|
|
|
|
|
|
|
var result = new BadRequestObjectResult(context.HttpContext);
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -46,7 +48,8 @@ namespace djyweb_djyPaasApi
|
|
|
|
Configuration.Bind("WebConfig", sysOptionConfig.YsWebconfig);
|
|
|
|
Configuration.Bind("WebConfig", sysOptionConfig.YsWebconfig);
|
|
|
|
sysOptionConfig._Configuration = Configuration;
|
|
|
|
sysOptionConfig._Configuration = Configuration;
|
|
|
|
|
|
|
|
|
|
|
|
services.AddAuthentication("Bearer").AddJwtBearer("Bearer",option=> {
|
|
|
|
services.AddAuthentication("Bearer").AddJwtBearer("Bearer", option =>
|
|
|
|
|
|
|
|
{
|
|
|
|
option.Authority = sysOptionConfig.YsWebconfig.IdentServerUrl;//授权服务的URl地址
|
|
|
|
option.Authority = sysOptionConfig.YsWebconfig.IdentServerUrl;//授权服务的URl地址
|
|
|
|
option.RequireHttpsMetadata = false;//是否使用了https
|
|
|
|
option.RequireHttpsMetadata = false;//是否使用了https
|
|
|
|
option.TokenValidationParameters = new Microsoft.IdentityModel.Tokens.TokenValidationParameters
|
|
|
|
option.TokenValidationParameters = new Microsoft.IdentityModel.Tokens.TokenValidationParameters
|
|
|
@ -73,8 +76,9 @@ namespace djyweb_djyPaasApi
|
|
|
|
services.AddAutoMapper(typeof(AutoMapperConfig));
|
|
|
|
services.AddAutoMapper(typeof(AutoMapperConfig));
|
|
|
|
|
|
|
|
|
|
|
|
//任务配置
|
|
|
|
//任务配置
|
|
|
|
services.AddHangfire(config => {
|
|
|
|
services.AddHangfire(config =>
|
|
|
|
config.UseRedisStorage(sysOptionConfig.YsWebconfig.Redis, new Hangfire.Redis.RedisStorageOptions { Prefix = "hf_"+sysOptionConfig.YsWebconfig.WebName,InvisibilityTimeout=TimeSpan.FromHours(1) });
|
|
|
|
{
|
|
|
|
|
|
|
|
config.UseRedisStorage(sysOptionConfig.YsWebconfig.Redis, new Hangfire.Redis.RedisStorageOptions { Prefix = "hf_" + sysOptionConfig.YsWebconfig.WebName, InvisibilityTimeout = TimeSpan.FromHours(1), Db = 3 });
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
services.AddHangfireServer();
|
|
|
|
services.AddHangfireServer();
|
|
|
@ -105,7 +109,7 @@ namespace djyweb_djyPaasApi
|
|
|
|
c.SwaggerDoc("v1", new OpenApiInfo { Title = "web_djyPaasapi", Version = "v1" });
|
|
|
|
c.SwaggerDoc("v1", new OpenApiInfo { Title = "web_djyPaasapi", Version = "v1" });
|
|
|
|
var basePath = Path.GetDirectoryName(typeof(Program).Assembly.Location);
|
|
|
|
var basePath = Path.GetDirectoryName(typeof(Program).Assembly.Location);
|
|
|
|
var xmlPath = Path.Combine(basePath, "AppServer.xml");
|
|
|
|
var xmlPath = Path.Combine(basePath, "AppServer.xml");
|
|
|
|
// c.IncludeXmlComments(Path.Combine(basePath, "djyweb_djyPaasApi.xml"));
|
|
|
|
// c.IncludeXmlComments(Path.Combine(basePath, "djyweb_djyPaasApi.xml"));
|
|
|
|
//c.IncludeXmlComments(Path.Combine(basePath, "djy.Model.xml"));
|
|
|
|
//c.IncludeXmlComments(Path.Combine(basePath, "djy.Model.xml"));
|
|
|
|
//c.IncludeXmlComments(Path.Combine(basePath, "Ys.Core.Common.xml"));
|
|
|
|
//c.IncludeXmlComments(Path.Combine(basePath, "Ys.Core.Common.xml"));
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -127,10 +131,11 @@ namespace djyweb_djyPaasApi
|
|
|
|
{
|
|
|
|
{
|
|
|
|
app.UseDeveloperExceptionPage();
|
|
|
|
app.UseDeveloperExceptionPage();
|
|
|
|
app.UseSwagger();
|
|
|
|
app.UseSwagger();
|
|
|
|
app.UseSwaggerUI(c => {
|
|
|
|
app.UseSwaggerUI(c =>
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
c.SwaggerEndpoint("/swagger/v1/swagger.json", "web_djyuserapi v1");
|
|
|
|
c.SwaggerEndpoint("/swagger/v1/swagger.json", "web_djyuserapi v1");
|
|
|
|
// c.RoutePrefix = "apidoc";
|
|
|
|
// c.RoutePrefix = "apidoc";
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -145,7 +150,8 @@ namespace djyweb_djyPaasApi
|
|
|
|
app.UseDefaultFiles(defaultFiles);
|
|
|
|
app.UseDefaultFiles(defaultFiles);
|
|
|
|
|
|
|
|
|
|
|
|
app.UseStaticFiles();
|
|
|
|
app.UseStaticFiles();
|
|
|
|
app.UseCors(builder => {
|
|
|
|
app.UseCors(builder =>
|
|
|
|
|
|
|
|
{
|
|
|
|
builder.AllowAnyHeader();
|
|
|
|
builder.AllowAnyHeader();
|
|
|
|
builder.AllowAnyMethod();
|
|
|
|
builder.AllowAnyMethod();
|
|
|
|
//builder.WithOrigins("http://www.baidu.com");//跨域配置
|
|
|
|
//builder.WithOrigins("http://www.baidu.com");//跨域配置
|
|
|
@ -155,13 +161,13 @@ namespace djyweb_djyPaasApi
|
|
|
|
app.UseAuthorization();//授权
|
|
|
|
app.UseAuthorization();//授权
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app.UseHangfireDashboard("/job", new DashboardOptions() { Authorization = new[] { new HangFireAuthorizeFilter() } });
|
|
|
|
app.UseHangfireDashboard("/job", new DashboardOptions() { Authorization = new[] { new HangFireAuthorizeFilter() } });
|
|
|
|
|
|
|
|
|
|
|
|
app.UseEndpoints(endpoints =>
|
|
|
|
app.UseEndpoints(endpoints =>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
endpoints.MapControllers();
|
|
|
|
endpoints.MapControllers();
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
//启动运行启动
|
|
|
|
//启动运行启动
|
|
|
|
_Job(env);
|
|
|
|
_Job(env);
|
|
|
@ -170,14 +176,15 @@ namespace djyweb_djyPaasApi
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 启动任务请求
|
|
|
|
/// 启动任务请求
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
private void _Job(IWebHostEnvironment env) {
|
|
|
|
private void _Job(IWebHostEnvironment env)
|
|
|
|
|
|
|
|
{
|
|
|
|
//初始化数据字典
|
|
|
|
//初始化数据字典
|
|
|
|
var _itool = IOC.AddServer<IToolsService>();
|
|
|
|
var _itool = IOC.AddServer<IToolsService>();
|
|
|
|
|
|
|
|
|
|
|
|
_itool.bindConfigDict(true, 5);
|
|
|
|
_itool.bindConfigDict(true, 5);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_itool.AutoJob();
|
|
|
|
_itool.AutoJob();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|