|
|
|
@ -33,9 +33,11 @@ namespace djyweb_djyPaasApi
|
|
|
|
|
|
|
|
|
|
public void ConfigureServices(IServiceCollection services)
|
|
|
|
|
{
|
|
|
|
|
services.AddControllers().ConfigureApiBehaviorOptions(options=> {
|
|
|
|
|
services.AddControllers().ConfigureApiBehaviorOptions(options =>
|
|
|
|
|
{
|
|
|
|
|
options.InvalidModelStateResponseFactory = context =>
|
|
|
|
|
{var result = new BadRequestObjectResult(context.HttpContext);
|
|
|
|
|
{
|
|
|
|
|
var result = new BadRequestObjectResult(context.HttpContext);
|
|
|
|
|
return result;
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
@ -46,7 +48,8 @@ namespace djyweb_djyPaasApi
|
|
|
|
|
Configuration.Bind("WebConfig", sysOptionConfig.YsWebconfig);
|
|
|
|
|
sysOptionConfig._Configuration = Configuration;
|
|
|
|
|
|
|
|
|
|
services.AddAuthentication("Bearer").AddJwtBearer("Bearer",option=> {
|
|
|
|
|
services.AddAuthentication("Bearer").AddJwtBearer("Bearer", option =>
|
|
|
|
|
{
|
|
|
|
|
option.Authority = sysOptionConfig.YsWebconfig.IdentServerUrl;//授权服务的URl地址
|
|
|
|
|
option.RequireHttpsMetadata = false;//是否使用了https
|
|
|
|
|
option.TokenValidationParameters = new Microsoft.IdentityModel.Tokens.TokenValidationParameters
|
|
|
|
@ -73,8 +76,9 @@ namespace djyweb_djyPaasApi
|
|
|
|
|
services.AddAutoMapper(typeof(AutoMapperConfig));
|
|
|
|
|
|
|
|
|
|
//任务配置
|
|
|
|
|
services.AddHangfire(config => {
|
|
|
|
|
config.UseRedisStorage(sysOptionConfig.YsWebconfig.Redis, new Hangfire.Redis.RedisStorageOptions { Prefix = "hf_"+sysOptionConfig.YsWebconfig.WebName,InvisibilityTimeout=TimeSpan.FromHours(1) });
|
|
|
|
|
services.AddHangfire(config =>
|
|
|
|
|
{
|
|
|
|
|
config.UseRedisStorage(sysOptionConfig.YsWebconfig.Redis, new Hangfire.Redis.RedisStorageOptions { Prefix = "hf_" + sysOptionConfig.YsWebconfig.WebName, InvisibilityTimeout = TimeSpan.FromHours(1), Db = 3 });
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
services.AddHangfireServer();
|
|
|
|
@ -127,7 +131,8 @@ namespace djyweb_djyPaasApi
|
|
|
|
|
{
|
|
|
|
|
app.UseDeveloperExceptionPage();
|
|
|
|
|
app.UseSwagger();
|
|
|
|
|
app.UseSwaggerUI(c => {
|
|
|
|
|
app.UseSwaggerUI(c =>
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
c.SwaggerEndpoint("/swagger/v1/swagger.json", "web_djyuserapi v1");
|
|
|
|
|
// c.RoutePrefix = "apidoc";
|
|
|
|
@ -145,7 +150,8 @@ namespace djyweb_djyPaasApi
|
|
|
|
|
app.UseDefaultFiles(defaultFiles);
|
|
|
|
|
|
|
|
|
|
app.UseStaticFiles();
|
|
|
|
|
app.UseCors(builder => {
|
|
|
|
|
app.UseCors(builder =>
|
|
|
|
|
{
|
|
|
|
|
builder.AllowAnyHeader();
|
|
|
|
|
builder.AllowAnyMethod();
|
|
|
|
|
//builder.WithOrigins("http://www.baidu.com");//跨域配置
|
|
|
|
@ -170,7 +176,8 @@ namespace djyweb_djyPaasApi
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 启动任务请求
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void _Job(IWebHostEnvironment env) {
|
|
|
|
|
private void _Job(IWebHostEnvironment env)
|
|
|
|
|
{
|
|
|
|
|
//初始化数据字典
|
|
|
|
|
var _itool = IOC.AddServer<IToolsService>();
|
|
|
|
|
|
|
|
|
|