添加网关与静态化服务

This commit is contained in:
橙子
2021-10-20 18:03:43 +08:00
parent 1bf37a2590
commit ce501c5665
48 changed files with 2030 additions and 9 deletions

View File

@@ -8,7 +8,7 @@
},
"AllowedHosts": "*",
"Apollo": {
"AppId": "Yi-ApiMicroservice",
"AppId": "Yi.Framework.ApiMicroservice",
"Env": "DEV",
"MetaServer": "http://192.168.2.168:8080",
"ConfigServer": [ "http://192.168.2.168:8080" ]

View File

@@ -0,0 +1,39 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Yi.Framework.AuthenticationCenter.Controllers
{
[ApiController]
[Route("[controller]")]
public class WeatherForecastController : ControllerBase
{
private static readonly string[] Summaries = new[]
{
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
};
private readonly ILogger<WeatherForecastController> _logger;
public WeatherForecastController(ILogger<WeatherForecastController> logger)
{
_logger = logger;
}
[HttpGet]
public IEnumerable<WeatherForecast> Get()
{
var rng = new Random();
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
{
Date = DateTime.Now.AddDays(index),
TemperatureC = rng.Next(-20, 55),
Summary = Summaries[rng.Next(Summaries.Length)]
})
.ToArray();
}
}
}

View File

@@ -0,0 +1,26 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Yi.Framework.AuthenticationCenter
{
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
}
}

View File

@@ -0,0 +1,31 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:55249",
"sslPort": 44360
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Yi.Framework.AuthenticationCenter": {
"commandName": "Project",
"dotnetRunMessages": "true",
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "https://localhost:5001;http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

View File

@@ -0,0 +1,59 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.HttpsPolicy;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.OpenApi.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Yi.Framework.AuthenticationCenter
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo { Title = "Yi.Framework.AuthenticationCenter", Version = "v1" });
});
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseSwagger();
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "Yi.Framework.AuthenticationCenter v1"));
}
app.UseHttpsRedirection();
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
}
}
}

View File

@@ -0,0 +1,15 @@
using System;
namespace Yi.Framework.AuthenticationCenter
{
public class WeatherForecast
{
public DateTime Date { get; set; }
public int TemperatureC { get; set; }
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
public string Summary { get; set; }
}
}

View File

@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}

View File

@@ -0,0 +1,10 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*"
}

View File

@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Yi.Framework.Common.Models
{
public class SwaggerModel
{
public SwaggerModel(string url, string name)
{
this.url = url;
this.name = name;
}
public string url { get; set; }
public string name { get; set; }
}
}

View File

@@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Yi.Framework.Common.QueueModel
{
/// <summary>
/// 下单成功后的实体
/// </summary>
public class OrderCreateQueueModel
{
/// <summary>
/// 用户Id
/// </summary>
public long UserId { get; set; }
/// <summary>
/// 订单Id
/// </summary>
public long OrderId { get; set; }
/// <summary>
/// sku ID 集合
/// </summary>
public List<long> SkuIdList { get; set; }
/// <summary>
/// 尝试次数
/// </summary>
public int TryTime { get; set; }
public OrderTypeEnum OrderType { get; set; }
public enum OrderTypeEnum
{
Normal,
Seckill
}
}
}

View File

@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Yi.Framework.Common.QueueModel
{
public class SKUWarmupQueueModel
{
public bool Warmup { get; set; }
}
}

View File

@@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Yi.Framework.Common.QueueModel
{
/// <summary>
/// 以SPU为单位
/// </summary>
public class SPUCQRSQueueModel
{
public long SpuId { get; set; }
/// <summary>
/// enum SPUCQRSQueueModelType
/// </summary>
public int CQRSType { get; set; }
}
/// <summary>
/// 操作类型
/// </summary>
public enum SPUCQRSQueueModelType
{
Insert = 0,
Update = 1,
Delete = 2,
Search = 3
}
}

View File

@@ -4,8 +4,4 @@
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Folder Include="QueueModel\" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,8 @@
using System;
namespace Yi.Framework.ElasticSearchProcessor
{
public class Class1
{
}
}

View File

@@ -0,0 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,13 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Yi.Framework.MSUnitTest
{
[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestMethod1()
{
}
}
}

View File

@@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
<PackageReference Include="MSTest.TestAdapter" Version="2.1.1" />
<PackageReference Include="MSTest.TestFramework" Version="2.1.1" />
<PackageReference Include="coverlet.collector" Version="1.3.0" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,65 @@
<?xml version="1.0" encoding="utf-8"?>
<log4net>
<!-- 将日志以回滚文件的形式写到文件中 -->
<!-- 按日期切分日志文件,并将日期作为日志文件的名字 -->
<!--Error-->
<appender name="ErrorLog" type="log4net.Appender.RollingFileAppender">
<!--不加utf-8编码格式中文字符将显示成乱码-->
<param name="Encoding" value="utf-8" />
<file value="log/"/>
<appendToFile value="true" />
<rollingStyle value="Date" />
<!--日期的格式,每天换一个文件记录,如不设置则永远只记录一天的日志,需设置-->
<datePattern value="&quot;GlobalExceptionLogs_&quot;yyyyMMdd&quot;.log&quot;" />
<!--日志文件名是否为静态-->
<StaticLogFileName value="false"/>
<!--多线程时采用最小锁定-->
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
<!--布局(向用户显示最后经过格式化的输出信息)-->
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date| %-5level %newline%message%newline--------------------------------%newline" />
</layout>
<filter type="log4net.Filter.LevelRangeFilter">
<levelMin value="ERROR" />
<levelMax value="FATAL" />
</filter>
</appender>
<!--Error-->
<!--Info-->
<appender name="InfoLog" type="log4net.Appender.RollingFileAppender">
<!--不加utf-8编码格式中文字符将显示成乱码-->
<param name="Encoding" value="utf-8" />
<!--定义文件存放位置-->
<file value="log/"/>
<appendToFile value="true" />
<rollingStyle value="Date" />
<!--日志文件名是否为静态-->
<StaticLogFileName value="false"/>
<!--日期的格式,每天换一个文件记录,如不设置则永远只记录一天的日志,需设置-->
<datePattern value="&quot;GlobalInfoLogs_&quot;yyyyMMdd&quot;.log&quot;" />
<!--多线程时采用最小锁定-->
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
<!--布局(向用户显示最后经过格式化的输出信息)-->
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date| %-5level%c %newline%message%newline--------------------------------%newline" />
</layout>
<filter type="log4net.Filter.LevelRangeFilter">
<levelMin value="DEBUG" />
<levelMax value="WARN" />
</filter>
</appender>
<!--Info-->
<root>
<!-- 控制级别由低到高ALL|DEBUG|INFO|WARN|ERROR|FATAL|OFF -->
<!-- 比如定义级别为INFO则INFO级别向下的级别比如DEBUG日志将不会被记录 -->
<!-- 如果没有定义LEVEL的值则缺省为DEBUG -->
<level value="ALL" />
<!-- 按日期切分日志文件,并将日期作为日志文件的名字 -->
<appender-ref ref="ErrorLog" />
<appender-ref ref="InfoLog" />
</root>
</log4net>

View File

@@ -0,0 +1,42 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Yi.Framework.OcelotGateway
{
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureAppConfiguration((hostBuilderContext, configurationBuilder) =>
{
configurationBuilder.AddCommandLine(args);
configurationBuilder.AddJsonFile("appsettings.json", optional: true, reloadOnChange: false);
configurationBuilder.AddJsonFile("configuration.json", optional: false, reloadOnChange: true);
#region
//Apollo<6C><6F><EFBFBD><EFBFBD>
#endregion
//configurationBuilder.AddApolloService("Yi");
})
.ConfigureLogging(loggingBuilder =>
{
loggingBuilder.AddFilter("System", Microsoft.Extensions.Logging.LogLevel.Warning);
loggingBuilder.AddFilter("Microsoft", Microsoft.Extensions.Logging.LogLevel.Warning);
loggingBuilder.AddLog4Net();
})
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>().UseUrls("http://*:7200");
});
}
}

View File

@@ -0,0 +1,31 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:54400",
"sslPort": 44373
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Yi.Framework.OcelotGateway": {
"commandName": "Project",
"dotnetRunMessages": "true",
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "https://localhost:5001;http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

View File

@@ -0,0 +1,80 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.HttpsPolicy;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.OpenApi.Models;
using Ocelot.DependencyInjection;
using Ocelot.Middleware;
using Ocelot.Provider.Consul;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Yi.Framework.Common.Models;
using Ocelot.Cache.CacheManager;
using Yi.Framework.WebCore.MiddlewareExtend;
using Ocelot.Provider.Polly;
namespace Yi.Framework.OcelotGateway
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
#region
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#endregion
services.AddCorsService();
#region
//<2F><><EFBFBD>ط<EFBFBD><D8B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#endregion
services.AddOcelot().AddConsul().AddCacheManager(x =>{x.WithDictionaryHandle();}).AddPolly();
#region
//Swagger<65><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#endregion
services.AddSwaggerService<Program>("Yi.Framework.OcelotGateway");
#region
//Jwt<77><74>Ȩ<EFBFBD><C8A8><EFBFBD><EFBFBD>
#endregion
services.AddJwtService();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
//if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
#region
//Swagger<65><72><EFBFBD><EFBFBD>ע<EFBFBD><D7A2>
#endregion
app.UseSwaggerService(new SwaggerModel("api/api/swagger/v1/swagger.json","API<50><49><EFBFBD><EFBFBD>"), new SwaggerModel("api/item/swagger/v1/swagger.json", "<22><>̬ҳ<CCAC><D2B3><EFBFBD><EFBFBD>"));
}
#region
//<2F><><EFBFBD>ط<EFBFBD><D8B7><EFBFBD>ע<EFBFBD><D7A2>
#endregion
app.UseOcelot();
#region
//<2F><>Ȩע<C8A8><D7A2>
#endregion
app.UseAuthentication();
}
}
}

View File

@@ -0,0 +1,8 @@
<?xml version="1.0"?>
<doc>
<assembly>
<name>Yi.Framework.OcelotGateway</name>
</assembly>
<members>
</members>
</doc>

View File

@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DocumentationFile>D:\CC.Yi\CC.Yi\Yi.Framework\Yi.Framework.OcelotGateway\SwaggerDoc.xml</DocumentationFile>
<NoWarn>1701;1702;CS1591</NoWarn>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Ocelot" Version="17.0.0" />
<PackageReference Include="Ocelot.Cache.CacheManager" Version="17.0.0" />
<PackageReference Include="Ocelot.Provider.Consul" Version="17.0.0" />
<PackageReference Include="Ocelot.Provider.Polly" Version="17.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Yi.Framework.WebCore\Yi.Framework.WebCore.csproj" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}

View File

@@ -0,0 +1,21 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*",
"Apollo": {
"AppId": "Yi.Framework.OcelotGateway",
"Env": "DEV",
"MetaServer": "http://192.168.2.168:8080",
"ConfigServer": [ "http://192.168.2.168:8080" ]
},
"JWTTokenOptions": {
"Audience": "http://localhost:7000",
"Issuer": "http://localhost:7000",
"SecurityKey": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDI2a2EJ7m872v0afyoSDJT2o1+SitIeJSWtLJU8/Wz2m7gStexajkeD+Lka6DSTy8gt9UwfgVQo6uKjVLG5Ex7PiGOODVqAEghBuS7JzIYU5RvI543nNDAPfnJsas96mSA7L/mD7RTE2drj6hf3oZjJpMPZUQI/B1Qjb5H3K3PNwIDAQAB"
}
}

View File

@@ -0,0 +1,432 @@
////*****************************<2A><><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD>ؾ<EFBFBD><D8BE><EFBFBD>+Consul********************************
//{
// "Routes": [
// {
// "DownstreamPathTemplate": "/api/{url}", //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ--url<72><6C><EFBFBD><EFBFBD>
// "DownstreamScheme": "http",
// "UpstreamPathTemplate": "/T/{url}", //<2F><><EFBFBD>ص<EFBFBD>ַ--url<72><6C><EFBFBD><EFBFBD>
// "UpstreamHttpMethod": [ "Get", "Post" ],
// "UseServiceDiscovery": true,
// "ServiceName": "ZhaoxiService", //consul<75><6C><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// "LoadBalancerOptions": {
// "Type": "RoundRobin" //<2F><>ѯ LeastConnection-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ķ<EFBFBD><C4B7><EFBFBD><EFBFBD><EFBFBD> NoLoadBalance<63><65><EFBFBD><EFBFBD><EFBFBD>ؾ<EFBFBD><D8BE><EFBFBD>
// }
// }
// ],
// "GlobalConfiguration": {
// "BaseUrl": "http://127.0.0.1:6299", //<2F><><EFBFBD>ض<EFBFBD><D8B6><EFBFBD><EFBFBD><EFBFBD>ַ
// "ServiceDiscoveryProvider": {
// "Host": "47.95.2.2",
// "Port": 8089,
// "Type": "Consul" //<2F><>Consul<75><EFBFBD><E1B9A9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, ÿ<><C3BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȥconsul
// } //Ocelotû<74><C3BB>֧<EFBFBD><D6A7><EFBFBD><EFBFBD><EFBFBD>ö<EFBFBD><C3B6><EFBFBD>Consul
// //,"ServiceDiscoveryProvider": {
// // "Host": "localhost",
// // "Port": 8500,
// // "Type": "PollConsul", //<2F><>Consul<75><EFBFBD><E1B9A9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,
// // "PollingInterval": 1000 //<2F><>ѯconsul,Ƶ<>ʺ<EFBFBD><CABA><EFBFBD>--down<77><6E><EFBFBD>Dz<EFBFBD>֪<EFBFBD><D6AA><EFBFBD><EFBFBD>
// // //"Token": "footoken"//<2F><>ҪACL<43>Ļ<EFBFBD>
// //}
// }
//}
//*****************************Ocelot+Consul********************************
{
"Routes": [
{
"UpstreamPathTemplate": "api/api/{url}", //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ--<2D><><EFBFBD><EFBFBD>
"UpstreamHttpMethod": [ "Get", "Post", "Put", "PATCH", "Delete", "Options" ],
"UseServiceDiscovery": true,
"ServiceName": "ApiMicroservice",
"LoadBalancerOptions": {
"Type": "RoundRobin" //<2F><>ѯ LeastConnection-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ķ<EFBFBD><C4B7><EFBFBD><EFBFBD><EFBFBD> NoLoadBalance<63><65><EFBFBD><EFBFBD><EFBFBD>ؾ<EFBFBD><D8BE><EFBFBD>
},
"DownstreamPathTemplate": "api/api/{url}", //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ--url<72><6C><EFBFBD><EFBFBD>
"DownstreamScheme": "https",
"DownstreamHeaderTransform": {
"Access-Control-Allow-Origin": "*", //<2F><><EFBFBD><EFBFBD><EFBFBD>ھ<EFBFBD><DABE><EFBFBD><EFBFBD><EFBFBD>
"Access-Control-Allow-Methods": "*",
"Access-Control-Allow-Headers": "*"
}
},
{
"UpstreamPathTemplate": "api/item/{url}", //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ--<2D><><EFBFBD><EFBFBD>
"UpstreamHttpMethod": [ "Get", "Post", "Put", "PATCH", "Delete", "Options" ],
"UseServiceDiscovery": true,
"ServiceName": "PageDetail",
"LoadBalancerOptions": {
"Type": "RoundRobin" //<2F><>ѯ LeastConnection-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ķ<EFBFBD><C4B7><EFBFBD><EFBFBD><EFBFBD> NoLoadBalance<63><65><EFBFBD><EFBFBD><EFBFBD>ؾ<EFBFBD><D8BE><EFBFBD>
},
"DownstreamPathTemplate": "api/item/{url}", //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ--url<72><6C><EFBFBD><EFBFBD>
"DownstreamScheme": "https",
"DownstreamHeaderTransform": {
"Access-Control-Allow-Origin": "*", //<2F><><EFBFBD><EFBFBD><EFBFBD>ھ<EFBFBD><DABE><EFBFBD><EFBFBD><EFBFBD>
"Access-Control-Allow-Methods": "*",
"Access-Control-Allow-Headers": "*"
}
}
],
"GlobalConfiguration": {
"BaseUrl": "http://127.0.0.1:7200", //<2F><><EFBFBD>ض<EFBFBD><D8B6><EFBFBD><EFBFBD><EFBFBD>ַ
"ServiceDiscoveryProvider": {
"Host": "192.168.2.128",
"Port": 8500,
"Type": "Consul" //<2F><>Consul<75><EFBFBD><E1B9A9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, ÿ<><C3BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȥconsul
},
"RateLimitOptions": {
"QuotaExceededMessage": "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ժ<EFBFBD><D4BA><EFBFBD><EFBFBD>ԣ<EFBFBD>", // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD><D8B1>ض<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>ص<EFBFBD><D8B5><EFBFBD>Ϣ
"HttpStatusCode": 666 // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD><D8B1>ض<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>ص<EFBFBD>http status
//"ClientIdHeader": "client_id" // <20><><EFBFBD><EFBFBD>ʶ<EFBFBD><CAB6><EFBFBD>ͻ<EFBFBD><CDBB>˵<EFBFBD><CBB5><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7>Ĭ<EFBFBD><C4AC><EFBFBD><EFBFBD> ClientId
}
//,"ServiceDiscoveryProvider": {
// "Host": "localhost",
// "Port": 8500,
// "Type": "PollConsul", //<2F><>Consul<75><EFBFBD><E1B9A9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,
// "PollingInterval": 1000 //<2F><>ѯconsul,Ƶ<>ʺ<EFBFBD><CABA><EFBFBD>--down<77><6E><EFBFBD>Dz<EFBFBD>֪<EFBFBD><D6AA><EFBFBD><EFBFBD>
// //"Token": "footoken"//<2F><>ҪACL<43>Ļ<EFBFBD>
//}
}
}
////*****************************<2A><><EFBFBD><EFBFBD>ַ--<2D><>Consul********************************
//{
// "Routes": [
// {
// "UpstreamPathTemplate": "/api/auth/{url}", //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ--<2D><><EFBFBD><EFBFBD>
// "UpstreamHttpMethod": [ "Get", "Post", "Put", "PATCH", "Delete", "Options" ],
// "DownstreamHostAndPorts": [
// {
// "Host": "localhost",
// "Port": 7200 //<2F><><EFBFBD><EFBFBD>api <20>˿<EFBFBD>
// }
// ],
// "DownstreamPathTemplate": "/api/{url}", //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ--url<72><6C><EFBFBD><EFBFBD>
// "DownstreamScheme": "http",
// "DownstreamHeaderTransform": {
// "Access-Control-Allow-Origin": "*", //<2F><><EFBFBD><EFBFBD><EFBFBD>ھ<EFBFBD><DABE><EFBFBD><EFBFBD><EFBFBD>
// "Access-Control-Allow-Methods": "*",
// "Access-Control-Allow-Headers": "*"
// }
// }
// ]
//}
////*****************************<2A><><EFBFBD><EFBFBD>ַȫƥ<C8AB><C6A5>********************************
//{
// "Routes": [
// {
// "DownstreamPathTemplate": "/{url}", //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ--url<72><6C><EFBFBD><EFBFBD>
// "DownstreamScheme": "http",
// "DownstreamHostAndPorts": [
// {
// "Host": "localhost",
// "Port": 5726 //<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
// }
// ],
// "UpstreamPathTemplate": "/{url}", //<2F><><EFBFBD>ص<EFBFBD>ַ--url<72><6C><EFBFBD><EFBFBD> //<2F><>ͻ<EFBFBD>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD>Լ<EFBFBD>Ȩ<EFBFBD><C8A8>Priority
// "UpstreamHttpMethod": [ "Get", "Post" ]
// }
// ]
//}
////*****************************<2A><><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7>ʵ<EFBFBD><CAB5>********************************
//{
// "Routes": [
// {
// "DownstreamPathTemplate": "/api/{url}", //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ--url<72><6C><EFBFBD><EFBFBD>
// "DownstreamScheme": "http",
// "DownstreamHostAndPorts": [
// {
// "Host": "localhost",
// "Port": 5726 //<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
// }
// ],
// "UpstreamPathTemplate": "/T5726/{url}", //<2F><><EFBFBD>ص<EFBFBD>ַ--url<72><6C><EFBFBD><EFBFBD>
// "UpstreamHttpMethod": [ "Get", "Post" ]
// },
// {
// "DownstreamPathTemplate": "/api/{url}", //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ--url<72><6C><EFBFBD><EFBFBD>
// "DownstreamScheme": "http",
// "DownstreamHostAndPorts": [
// {
// "Host": "localhost",
// "Port": 5727 //<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
// }
// ],
// "UpstreamPathTemplate": "/T5727/{url}", //<2F><><EFBFBD>ص<EFBFBD>ַ--url<72><6C><EFBFBD><EFBFBD>
// "UpstreamHttpMethod": [ "Get", "Post" ]
// },
// {
// "DownstreamPathTemplate": "/api/{url}", //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ--url<72><6C><EFBFBD><EFBFBD>
// "DownstreamScheme": "http",
// "DownstreamHostAndPorts": [
// {
// "Host": "localhost",
// "Port": 5728 //<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
// }
// ],
// "UpstreamPathTemplate": "/T5728/{url}", //<2F><><EFBFBD>ص<EFBFBD>ַ--url<72><6C><EFBFBD><EFBFBD>
// "UpstreamHttpMethod": [ "Get", "Post" ]
// }
// ]
//}
//////MVC<56><43>·<EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD>ǽ<EFBFBD>ˮ¥̨<C2A5>ȵ<EFBFBD><C8B5><EFBFBD>--
////*****************************·<>ɳ<EFBFBD>ͻ+<2B><>Ȩƥ<C8A8><C6A5>********************************
//{
// "Routes": [
// {
// "DownstreamPathTemplate": "/{url}", //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ--url<72><6C><EFBFBD><EFBFBD>
// "DownstreamScheme": "http",
// "DownstreamHostAndPorts": [
// {
// "Host": "localhost",
// "Port": 5726 //<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
// }
// ],
// "UpstreamPathTemplate": "/{url}", //<2F><><EFBFBD>ص<EFBFBD>ַ--url<72><6C><EFBFBD><EFBFBD> //<2F><>ͻ<EFBFBD>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD>Լ<EFBFBD>Ȩ<EFBFBD><C8A8>Priority
// "UpstreamHttpMethod": [ "Get", "Post" ],
// "Priority": 0 //Ĭ<><C4AC><EFBFBD><EFBFBD>0 <20>Ӹ<EFBFBD>1
// },
// {
// "DownstreamPathTemplate": "/api/users/get?id={id}", //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ--url<72><6C><EFBFBD><EFBFBD>
// "DownstreamScheme": "http",
// "DownstreamHostAndPorts": [
// {
// "Host": "localhost",
// "Port": 5727 //<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
// }
// ],
// "UpstreamPathTemplate": "/api/users/get/{id}", //<2F><><EFBFBD>ص<EFBFBD>ַ--url<72><6C><EFBFBD><EFBFBD> //<2F><>ͻ<EFBFBD>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD>Լ<EFBFBD>Ȩ<EFBFBD><C8A8>Priority
// "UpstreamHttpMethod": [ "Get", "Post" ],
// "Priority": 1 //Ĭ<><C4AC><EFBFBD><EFBFBD>0 <20>Ӹ<EFBFBD>1
// },
// {
// "DownstreamPathTemplate": "/api/users/{url}?id={id}", //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ--url<72><6C><EFBFBD><EFBFBD>
// "DownstreamScheme": "http",
// "DownstreamHostAndPorts": [
// {
// "Host": "localhost",
// "Port": 5728 //<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
// }
// ],
// "UpstreamPathTemplate": "/api/users/{url}/{id}", //<2F><><EFBFBD>ص<EFBFBD>ַ--url<72><6C><EFBFBD><EFBFBD> //<2F><>ͻ<EFBFBD>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD>Լ<EFBFBD>Ȩ<EFBFBD><C8A8>Priority
// "UpstreamHttpMethod": [ "Get", "Post" ],
// "Priority": 2 //Ĭ<><C4AC><EFBFBD><EFBFBD>0 <20>Ӹ<EFBFBD>1
// }
// ]
//}
////*****************************<2A><><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD>ؾ<EFBFBD><D8BE><EFBFBD>********************************
//{
// "Routes": [
// {
// "DownstreamPathTemplate": "/api/{url}", //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ--url<72><6C><EFBFBD><EFBFBD>
// "DownstreamScheme": "http",
// "DownstreamHostAndPorts": [
// {
// "Host": "47.95.2.2",
// "Port": 5726
// }, //Ocelot<6F><74><EFBFBD>ؾ<EFBFBD><D8BE><EFBFBD>
// {
// "Host": "47.95.2.2",
// "Port": 5727
// },
// {
// "Host": "47.95.2.2",
// "Port": 5728
// }
// ],
// "UpstreamPathTemplate": "/T/{url}", //<2F><><EFBFBD>ص<EFBFBD>ַ--url<72><6C><EFBFBD><EFBFBD> //<2F><>ͻ<EFBFBD>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD>Լ<EFBFBD>Ȩ<EFBFBD><C8A8>Priority
// "UpstreamHttpMethod": [ "Get", "Post" ],
// "LoadBalancerOptions": {
// "Type": "RoundRobin" //<2F><>ѯ //"LeastConnection" //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ķ<EFBFBD><C4B7><EFBFBD><EFBFBD><EFBFBD> "NoLoadBalance" //<2F><><EFBFBD><EFBFBD><EFBFBD>ؾ<EFBFBD><D8BE><EFBFBD> //"CookieStickySessions" //<2F>Ựճ<E1BBB0><D5B3> //
// }
// //"LoadBalancerOptions": {
// // "Type": "CookieStickySessions",
// // "Key": "ASP.NET_SessionId",
// // "Expiry": 1800000
// //}
// }
// ]
//}
////*****************************<2A><><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD>ؾ<EFBFBD><D8BE><EFBFBD>+Consul********************************
//{
// "Routes": [
// {
// "DownstreamPathTemplate": "/api/{url}", //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ--url<72><6C><EFBFBD><EFBFBD>
// "DownstreamScheme": "http",
// "UpstreamPathTemplate": "/T/{url}", //<2F><><EFBFBD>ص<EFBFBD>ַ--url<72><6C><EFBFBD><EFBFBD>
// "UpstreamHttpMethod": [ "Get", "Post" ],
// "UseServiceDiscovery": true,
// "ServiceName": "ZhaoxiService", //consul<75><6C><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// "LoadBalancerOptions": {
// "Type": "RoundRobin" //<2F><>ѯ LeastConnection-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ķ<EFBFBD><C4B7><EFBFBD><EFBFBD><EFBFBD> NoLoadBalance<63><65><EFBFBD><EFBFBD><EFBFBD>ؾ<EFBFBD><D8BE><EFBFBD>
// }
// }
// ],
// "GlobalConfiguration": {
// "BaseUrl": "http://127.0.0.1:6299", //<2F><><EFBFBD>ض<EFBFBD><D8B6><EFBFBD><EFBFBD><EFBFBD>ַ
// "ServiceDiscoveryProvider": {
// "Host": "47.95.2.2",
// "Port": 8089,
// "Type": "Consul" //<2F><>Consul<75><EFBFBD><E1B9A9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, ÿ<><C3BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȥconsul
// } //Ocelotû<74><C3BB>֧<EFBFBD><D6A7><EFBFBD><EFBFBD><EFBFBD>ö<EFBFBD><C3B6><EFBFBD>Consul
// //,"ServiceDiscoveryProvider": {
// // "Host": "localhost",
// // "Port": 8500,
// // "Type": "PollConsul", //<2F><>Consul<75><EFBFBD><E1B9A9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,
// // "PollingInterval": 1000 //<2F><>ѯconsul,Ƶ<>ʺ<EFBFBD><CABA><EFBFBD>--down<77><6E><EFBFBD>Dz<EFBFBD>֪<EFBFBD><D6AA><EFBFBD><EFBFBD>
// // //"Token": "footoken"//<2F><>ҪACL<43>Ļ<EFBFBD>
// //}
// }
//}
////*****************************Consul+<2B><><EFBFBD><EFBFBD>Cache********************************
//{
// "Routes": [
// {
// "DownstreamPathTemplate": "/api/{url}", //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ--url<72><6C><EFBFBD><EFBFBD>
// "DownstreamScheme": "http",
// "UpstreamPathTemplate": "/T/{url}", //<2F><><EFBFBD>ص<EFBFBD>ַ--url<72><6C><EFBFBD><EFBFBD>
// "UpstreamHttpMethod": [ "Get", "Post" ],
// "UseServiceDiscovery": true,
// "ServiceName": "ZhaoxiService", //consul<75><6C><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// "LoadBalancerOptions": {
// "Type": "RoundRobin" //<2F><>ѯ LeastConnection-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ķ<EFBFBD><C4B7><EFBFBD><EFBFBD><EFBFBD> NoLoadBalance<63><65><EFBFBD><EFBFBD><EFBFBD>ؾ<EFBFBD><D8BE><EFBFBD>
// },
// "FileCacheOptions": {
// "TtlSeconds": 15, //Second
// "Region": "UserCache" //<2F><><EFBFBD>Ե<EFBFBD><D4B5><EFBFBD>Api<70><69><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// }
// }
// ],
// "GlobalConfiguration": {
// "BaseUrl": "http://127.0.0.1:6299", //<2F><><EFBFBD>ض<EFBFBD><D8B6><EFBFBD><EFBFBD><EFBFBD>ַ
// "ServiceDiscoveryProvider": {
// "Host": "47.95.2.2",
// "Port": 8089,
// "Type": "Consul" //<2F><>Consul<75><EFBFBD><E1B9A9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, ÿ<><C3BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȥconsul
// }
// //"ServiceDiscoveryProvider": {
// // "Host": "localhost",
// // "Port": 8500,
// // "Type": "PollConsul", //<2F><>Consul<75><EFBFBD><E1B9A9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,
// // "PollingInterval": 1000 //<2F><>ѯconsul,Ƶ<>ʺ<EFBFBD><CABA><EFBFBD>--down<77><6E><EFBFBD>Dz<EFBFBD>֪<EFBFBD><D6AA><EFBFBD><EFBFBD>
// // //"Token": "footoken"//<2F><>ҪACL<43>Ļ<EFBFBD>
// //}
// }
//}
////*****************************<2A><>ʱ+<2B><><EFBFBD><EFBFBD>+<2B>۶<EFBFBD>+<2B><><EFBFBD><EFBFBD>+Consul+Polly********************************
//{
// "Routes": [
// {
// "DownstreamPathTemplate": "/api/{url}", //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ--url<72><6C><EFBFBD><EFBFBD>
// "DownstreamScheme": "http",
// "UpstreamPathTemplate": "/T/{url}", //<2F><><EFBFBD>ص<EFBFBD>ַ--url<72><6C><EFBFBD><EFBFBD>
// "UpstreamHttpMethod": [ "Get", "Post" ],
// "UseServiceDiscovery": true,
// "ServiceName": "ZhaoxiService", //consul<75><6C><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// "LoadBalancerOptions": {
// "Type": "RoundRobin" //<2F><>ѯ LeastConnection-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ķ<EFBFBD><C4B7><EFBFBD><EFBFBD><EFBFBD> NoLoadBalance<63><65><EFBFBD><EFBFBD><EFBFBD>ؾ<EFBFBD><D8BE><EFBFBD>
// },
// "RateLimitOptions": {
// "ClientWhitelist": [ "eleven", "seven" ], //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ClientId <20><><EFBFBD>ִ<EFBFBD>Сд
// "EnableRateLimiting": true,
// "Period": "5m", //1s, 5m, 1h, 1d
// "PeriodTimespan": 30, //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֮<EFBFBD><D6AE><EFBFBD>ͻ<EFBFBD><CDBB>˿<EFBFBD><CBBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// "Limit": 5 //ͳ<><CDB3>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// },
// "AuthenticationOptions": {
// "AuthenticationProviderKey": "UserGatewayKey",
// "AllowedScopes": []
// },
// "QoSOptions": {
// "ExceptionsAllowedBeforeBreaking": 3, //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٸ<EFBFBD><D9B8><EFBFBD><ECB3A3><EFBFBD><EFBFBD>
// "DurationOfBreak": 10000, // <20>۶ϵ<DBB6>ʱ<EFBFBD><EFBFBD><E4A3AC>λΪms
// "TimeoutValue": 2000 //<2F><>λms <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD>ʱ<EFBFBD><EFBFBD><E4B3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E7BDAB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>ʱ Ĭ<><C4AC>90<39><30>
// }
// //"FileCacheOptions": {
// // "TtlSeconds": 15,
// // "Region": "UserCache" //<2F><><EFBFBD>Ե<EFBFBD><D4B5><EFBFBD>Api<70><69><EFBFBD><EFBFBD>
// //}
// }
// ],
// "GlobalConfiguration": {
// "BaseUrl": "http://127.0.0.1:6299", //<2F><><EFBFBD>ض<EFBFBD><D8B6><EFBFBD><EFBFBD><EFBFBD>ַ
// "ServiceDiscoveryProvider": {
// "Host": "47.95.2.2",
// "Port": 8089,
// "Type": "Consul" //<2F><>Consul<75><EFBFBD><E1B9A9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// },
// "RateLimitOptions": {
// "QuotaExceededMessage": "Too many requests, maybe later? 11", // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD><D8B1>ض<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>ص<EFBFBD><D8B5><EFBFBD>Ϣ
// "HttpStatusCode": 666, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD><D8B1>ض<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>ص<EFBFBD>http status
// //"ClientIdHeader": "client_id" // <20><><EFBFBD><EFBFBD>ʶ<EFBFBD><CAB6><EFBFBD>ͻ<EFBFBD><CDBB>˵<EFBFBD><CBB5><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7>Ĭ<EFBFBD><C4AC><EFBFBD><EFBFBD> ClientId
// }
// }
//}
////*****************************<2A><><EFBFBD><EFBFBD><EFBFBD>ۺ<EFBFBD>Aggregator********************************
//{
// "Routes": [
// {
// "DownstreamPathTemplate": "/api/users/all",
// "DownstreamScheme": "http",
// "DownstreamHostAndPorts": [
// {
// "Host": "localhost",
// "Port": 5726 //<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
// } //<2F><><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>и<EFBFBD><D0B8>ؾ<EFBFBD><D8BE><EFBFBD>
// ],
// "UpstreamPathTemplate": "/T5726/users/all",
// "UpstreamHttpMethod": [ "Get", "Post" ],
// "key": "T5726"
// },
// {
// "DownstreamPathTemplate": "/api/users/all",
// "DownstreamScheme": "http",
// "DownstreamHostAndPorts": [
// {
// "Host": "localhost",
// "Port": 5727 //<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
// }
// ],
// "UpstreamPathTemplate": "/T5727/users/all",
// "UpstreamHttpMethod": [ "Get", "Post" ],
// "key": "T5727"
// },
// {
// "DownstreamPathTemplate": "/api/users/all",
// "DownstreamScheme": "http",
// "DownstreamHostAndPorts": [
// {
// "Host": "localhost",
// "Port": 5728 //<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
// }
// ],
// "UpstreamPathTemplate": "/T5728/users/all",
// "UpstreamHttpMethod": [ "Get", "Post" ],
// "key": "T5728"
// }
// ],
// "Aggregates": [
// {
// "RouteKeys": [
// "T5726",
// "T5727",
// "T5728"
// ],
// "UpstreamPathTemplate": "/UserAggregator", //<2F><><EFBFBD><EFBFBD>ij<EFBFBD><C4B3>404 <20>Dz<EFBFBD>Ӱ<EFBFBD><EFBFBD>أ<EFBFBD><D8A3><EFBFBD><EFBFBD><EFBFBD>null
// "Aggregator": "CustomUserAggregator" //<2F>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD>ۺ<EFBFBD><DBBA><EFBFBD>
// }
// ]
//}

View File

@@ -0,0 +1,25 @@
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Yi.Framework.Interface;
using Yi.Framework.Model.Models;
namespace Yi.Framework.PageDetail.Controllers
{
public class PageDetaiController : Controller
{
private IUserService _IUserService;
public PageDetaiController(IUserService IUserService)
{
_IUserService = IUserService;
}
[Route("/item/{id}.html")]
public IActionResult Index(int id)
{
var htmlmodel = _IUserService.GetEntityById(id);
return View(htmlmodel);
}
}
}

View File

@@ -0,0 +1,65 @@
<?xml version="1.0" encoding="utf-8"?>
<log4net>
<!-- 将日志以回滚文件的形式写到文件中 -->
<!-- 按日期切分日志文件,并将日期作为日志文件的名字 -->
<!--Error-->
<appender name="ErrorLog" type="log4net.Appender.RollingFileAppender">
<!--不加utf-8编码格式中文字符将显示成乱码-->
<param name="Encoding" value="utf-8" />
<file value="log/"/>
<appendToFile value="true" />
<rollingStyle value="Date" />
<!--日期的格式,每天换一个文件记录,如不设置则永远只记录一天的日志,需设置-->
<datePattern value="&quot;GlobalExceptionLogs_&quot;yyyyMMdd&quot;.log&quot;" />
<!--日志文件名是否为静态-->
<StaticLogFileName value="false"/>
<!--多线程时采用最小锁定-->
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
<!--布局(向用户显示最后经过格式化的输出信息)-->
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date| %-5level %newline%message%newline--------------------------------%newline" />
</layout>
<filter type="log4net.Filter.LevelRangeFilter">
<levelMin value="ERROR" />
<levelMax value="FATAL" />
</filter>
</appender>
<!--Error-->
<!--Info-->
<appender name="InfoLog" type="log4net.Appender.RollingFileAppender">
<!--不加utf-8编码格式中文字符将显示成乱码-->
<param name="Encoding" value="utf-8" />
<!--定义文件存放位置-->
<file value="log/"/>
<appendToFile value="true" />
<rollingStyle value="Date" />
<!--日志文件名是否为静态-->
<StaticLogFileName value="false"/>
<!--日期的格式,每天换一个文件记录,如不设置则永远只记录一天的日志,需设置-->
<datePattern value="&quot;GlobalInfoLogs_&quot;yyyyMMdd&quot;.log&quot;" />
<!--多线程时采用最小锁定-->
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
<!--布局(向用户显示最后经过格式化的输出信息)-->
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date| %-5level%c %newline%message%newline--------------------------------%newline" />
</layout>
<filter type="log4net.Filter.LevelRangeFilter">
<levelMin value="DEBUG" />
<levelMax value="WARN" />
</filter>
</appender>
<!--Info-->
<root>
<!-- 控制级别由低到高ALL|DEBUG|INFO|WARN|ERROR|FATAL|OFF -->
<!-- 比如定义级别为INFO则INFO级别向下的级别比如DEBUG日志将不会被记录 -->
<!-- 如果没有定义LEVEL的值则缺省为DEBUG -->
<level value="ALL" />
<!-- 按日期切分日志文件,并将日期作为日志文件的名字 -->
<appender-ref ref="ErrorLog" />
<appender-ref ref="InfoLog" />
</root>
</log4net>

View File

@@ -0,0 +1,42 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Yi.Framework.PageDetail
{
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureAppConfiguration((hostBuilderContext, configurationBuilder) =>
{
configurationBuilder.AddCommandLine(args);
configurationBuilder.AddJsonFile("appsettings.json", optional: true, reloadOnChange: false);
configurationBuilder.AddJsonFile("configuration.json", optional: false, reloadOnChange: true);
#region
//Apollo<6C><6F><EFBFBD><EFBFBD>
#endregion
//configurationBuilder.AddApolloService("Yi");
})
.ConfigureLogging(loggingBuilder =>
{
loggingBuilder.AddFilter("System", Microsoft.Extensions.Logging.LogLevel.Warning);
loggingBuilder.AddFilter("Microsoft", Microsoft.Extensions.Logging.LogLevel.Warning);
loggingBuilder.AddLog4Net();
})
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>().UseUrls("http://*:7007");
});
}
}

View File

@@ -0,0 +1,31 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:55468",
"sslPort": 44333
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Yi.Framework.PageDetail": {
"commandName": "Project",
"dotnetRunMessages": "true",
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "https://localhost:5001;http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

View File

@@ -0,0 +1,67 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.HttpsPolicy;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.OpenApi.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Yi.Framework.Interface;
using Yi.Framework.Service;
using Yi.Framework.WebCore.MiddlewareExtend;
namespace Yi.Framework.PageDetail
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddIocService(Configuration);
services.AddControllers();
#region
//Swagger<65><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#endregion
services.AddSwaggerService<Program>("Yi.Framework.OcelotGateway.PageDetail");
services.AddScoped<IUserService,UserService>();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
//if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
#region
//Swagger<65><72><EFBFBD><EFBFBD>ע<EFBFBD><D7A2>
#endregion
app.UseSwaggerService();
}
app.UseHttpsRedirection();
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
}
}
}

View File

@@ -0,0 +1,8 @@
<?xml version="1.0"?>
<doc>
<assembly>
<name>Yi.Framework.PageDetail</name>
</assembly>
<members>
</members>
</doc>

View File

@@ -0,0 +1,90 @@
@model Yi.Framework.Model.Models.user
@{
ViewData["Title"] = "Index";
}
<h1>Index</h1>
<div>
<h4>user</h4>
<hr />
<dl class="row">
<dt class = "col-sm-2">
@Html.DisplayNameFor(model => model.username)
</dt>
<dd class = "col-sm-10">
@Html.DisplayFor(model => model.username)
</dd>
<dt class = "col-sm-2">
@Html.DisplayNameFor(model => model.password)
</dt>
<dd class = "col-sm-10">
@Html.DisplayFor(model => model.password)
</dd>
<dt class = "col-sm-2">
@Html.DisplayNameFor(model => model.icon)
</dt>
<dd class = "col-sm-10">
@Html.DisplayFor(model => model.icon)
</dd>
<dt class = "col-sm-2">
@Html.DisplayNameFor(model => model.nick)
</dt>
<dd class = "col-sm-10">
@Html.DisplayFor(model => model.nick)
</dd>
<dt class = "col-sm-2">
@Html.DisplayNameFor(model => model.email)
</dt>
<dd class = "col-sm-10">
@Html.DisplayFor(model => model.email)
</dd>
<dt class = "col-sm-2">
@Html.DisplayNameFor(model => model.ip)
</dt>
<dd class = "col-sm-10">
@Html.DisplayFor(model => model.ip)
</dd>
<dt class = "col-sm-2">
@Html.DisplayNameFor(model => model.age)
</dt>
<dd class = "col-sm-10">
@Html.DisplayFor(model => model.age)
</dd>
<dt class = "col-sm-2">
@Html.DisplayNameFor(model => model.introduction)
</dt>
<dd class = "col-sm-10">
@Html.DisplayFor(model => model.introduction)
</dd>
<dt class = "col-sm-2">
@Html.DisplayNameFor(model => model.address)
</dt>
<dd class = "col-sm-10">
@Html.DisplayFor(model => model.address)
</dd>
<dt class = "col-sm-2">
@Html.DisplayNameFor(model => model.phone)
</dt>
<dd class = "col-sm-10">
@Html.DisplayFor(model => model.phone)
</dd>
<dt class = "col-sm-2">
@Html.DisplayNameFor(model => model.id)
</dt>
<dd class = "col-sm-10">
@Html.DisplayFor(model => model.id)
</dd>
<dt class = "col-sm-2">
@Html.DisplayNameFor(model => model.is_delete)
</dt>
<dd class = "col-sm-10">
@Html.DisplayFor(model => model.is_delete)
</dd>
</dl>
</div>
<div>
@Html.ActionLink("Edit", "Edit", new { /* id = Model.PrimaryKey */ }) |
<a asp-action="Index">Back to List</a>
</div>

View File

@@ -0,0 +1,18 @@
<environment names="Development">
<script src="~/lib/jquery-validation/dist/jquery.validate.js"></script>
<script src="~/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.js"></script>
</environment>
<environment names="Staging,Production">
<script src="https://ajax.aspnetcdn.com/ajax/jquery.validate/1.17.0/jquery.validate.min.js"
asp-fallback-src="~/lib/jquery-validation/dist/jquery.validate.min.js"
asp-fallback-test="window.jQuery && window.jQuery.validator"
crossorigin="anonymous"
integrity="sha384-rZfj/ogBloos6wzLGpPkkOr/gpkBNLZ6b6yLy4o+ok+t/SAKlL5mvXLr0OXNi1Hp">
</script>
<script src="https://ajax.aspnetcdn.com/ajax/jquery.validation.unobtrusive/3.2.9/jquery.validate.unobtrusive.min.js"
asp-fallback-src="~/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js"
asp-fallback-test="window.jQuery && window.jQuery.validator && window.jQuery.validator.unobtrusive"
crossorigin="anonymous"
integrity="sha384-ifv0TYDWxBHzvAk2Z0n8R434FL1Rlv/Av18DXE43N/1rvHyOG4izKst0f2iSLdds">
</script>
</environment>

View File

@@ -0,0 +1,43 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DocumentationFile>D:\CC.Yi\CC.Yi\Yi.Framework\Yi.Framework.PageDetail\SwaggerDoc.xml</DocumentationFile>
<WarningsAsErrors>;NU1605</WarningsAsErrors>
<NoWarn>1701;1702;CS1591</NoWarn>
</PropertyGroup>
<ItemGroup>
<Content Remove="appsettings.Development.json" />
<Content Remove="appsettings.json" />
</ItemGroup>
<ItemGroup>
<None Include="appsettings.Development.json" />
<None Include="appsettings.json" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="5.0.2" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Yi.Framework.Interface\Yi.Framework.Interface.csproj" />
<ProjectReference Include="..\Yi.Framework.Model\Yi.Framework.Model.csproj" />
<ProjectReference Include="..\Yi.Framework.Service\Yi.Framework.Service.csproj" />
<ProjectReference Include="..\Yi.Framework.WebCore\Yi.Framework.WebCore.csproj" />
</ItemGroup>
<ItemGroup>
<Content Update="Log4net.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}

View File

@@ -0,0 +1,43 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*",
"MysqlConn": {
"Url": ""
},
"RedisConn": {
"Host": "192.168.2.128",
"Prot": 6379,
"DB": 0,
"Password": "123456"
},
"StaticDirectory": "D:/cc-app/",
//"StaticDirectory": "/app/temp/staticfile/",
"IsSaveHtml": true,
"ConsulClientOption": {
"IP": "192.168.2.128",
"Port": "8500",
"Datacenter": "dc1"
},
"ConsulRegisterOption": {
"IP": "192.168.0.103",
"Port": "7007",
"GroupName": "PageDetail",
"HealthCheckUrl": "/Health",
"Interval": 10,
"Timeout": 5,
"DeregisterCriticalServiceAfter": 60,
"Tag": "13"
},
"Apollo": {
"AppId": "Yi.Framework.PageDetail",
"Env": "DEV",
"MetaServer": "http://192.168.2.168:8080",
"ConfigServer": [ "http://192.168.2.168:8080" ]
}
}

View File

@@ -0,0 +1,100 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Yi.Framework.Common.IOCOptions;
using Yi.Framework.Common.Models;
using Yi.Framework.Common.QueueModel;
using Yi.Framework.Core;
using Yi.Framework.Core.ConsulExtend;
namespace Yi.Framework.StaticPageProcessor
{
public class InitPageWorker : BackgroundService
{
private readonly IConfiguration _configuration;
private readonly ILogger<InitPageWorker> _logger;
private readonly RabbitMQInvoker _RabbitMQInvoker;
private readonly AbstractConsulDispatcher _AbstractConsulDispatcher = null;
public InitPageWorker(ILogger<InitPageWorker> logger, RabbitMQInvoker rabbitMQInvoker, IConfiguration configuration, AbstractConsulDispatcher abstractConsulDispatcher)
{
this._logger = logger;
this._RabbitMQInvoker = rabbitMQInvoker;
this._configuration = configuration;
this._AbstractConsulDispatcher = abstractConsulDispatcher;
}
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
RabbitMQConsumerModel rabbitMQConsumerModel = new RabbitMQConsumerModel()
{
ExchangeName = RabbitMQExchangeQueueName.SKUCQRS_Exchange,
QueueName = RabbitMQExchangeQueueName.SKUCQRS_Queue_StaticPage
};
HttpClient _HttpClient = new HttpClient();
this._RabbitMQInvoker.RegistReciveAction(rabbitMQConsumerModel, message =>
{
SPUCQRSQueueModel skuCQRSQueueModel = JsonConvert.DeserializeObject<SPUCQRSQueueModel>(message);
string detailUrl = this._AbstractConsulDispatcher.GetAddress(this._configuration["DetailPageUrl"]);
string totalUrl = null;
switch (skuCQRSQueueModel.CQRSType)
{
case (int)SPUCQRSQueueModelType.Insert:
totalUrl = $"{detailUrl}{skuCQRSQueueModel.SpuId}.html";
break;
case (int)SPUCQRSQueueModelType.Update:
totalUrl = $"{detailUrl}{skuCQRSQueueModel.SpuId}.html";
break;
case (int)SPUCQRSQueueModelType.Delete:
totalUrl = $"{detailUrl}{skuCQRSQueueModel.SpuId}.html?ActionHeader=Delete";
break;
default:
break;
}
try
{
var result = _HttpClient.GetAsync(totalUrl).Result;
if (result.StatusCode == HttpStatusCode.OK)
{
this._logger.LogInformation($"{nameof(WarmupPageWorker)}.Init succeed {totalUrl}");
return true;
}
else
{
this._logger.LogWarning($"{nameof(WarmupPageWorker)}.Init succeed {totalUrl}");
return false;
}
}
catch (Exception ex)
{
var logModel = new LogModel()
{
OriginalClassName = this.GetType().FullName,
OriginalMethodName = nameof(ExecuteAsync),
Remark = "<22><>ʱ<EFBFBD><CAB1>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־"
};
this._logger.LogError(ex, $"{nameof(WarmupPageWorker)}.Init failed {totalUrl}, Exception:{ex.Message}", JsonConvert.SerializeObject(logModel));
return false;
}
});
await Task.CompletedTask;
//while (!stoppingToken.IsCancellationRequested)
//{
// _logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now);
// await Task.Delay(1000, stoppingToken);
//}
}
}
}

View File

@@ -0,0 +1,65 @@
<?xml version="1.0" encoding="utf-8"?>
<log4net>
<!-- 将日志以回滚文件的形式写到文件中 -->
<!-- 按日期切分日志文件,并将日期作为日志文件的名字 -->
<!--Error-->
<appender name="ErrorLog" type="log4net.Appender.RollingFileAppender">
<!--不加utf-8编码格式中文字符将显示成乱码-->
<param name="Encoding" value="utf-8" />
<file value="log/"/>
<appendToFile value="true" />
<rollingStyle value="Date" />
<!--日期的格式,每天换一个文件记录,如不设置则永远只记录一天的日志,需设置-->
<datePattern value="&quot;GlobalExceptionLogs_&quot;yyyyMMdd&quot;.log&quot;" />
<!--日志文件名是否为静态-->
<StaticLogFileName value="false"/>
<!--多线程时采用最小锁定-->
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
<!--布局(向用户显示最后经过格式化的输出信息)-->
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date| %-5level %newline%message%newline--------------------------------%newline" />
</layout>
<filter type="log4net.Filter.LevelRangeFilter">
<levelMin value="ERROR" />
<levelMax value="FATAL" />
</filter>
</appender>
<!--Error-->
<!--Info-->
<appender name="InfoLog" type="log4net.Appender.RollingFileAppender">
<!--不加utf-8编码格式中文字符将显示成乱码-->
<param name="Encoding" value="utf-8" />
<!--定义文件存放位置-->
<file value="log/"/>
<appendToFile value="true" />
<rollingStyle value="Date" />
<!--日志文件名是否为静态-->
<StaticLogFileName value="false"/>
<!--日期的格式,每天换一个文件记录,如不设置则永远只记录一天的日志,需设置-->
<datePattern value="&quot;GlobalInfoLogs_&quot;yyyyMMdd&quot;.log&quot;" />
<!--多线程时采用最小锁定-->
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
<!--布局(向用户显示最后经过格式化的输出信息)-->
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date| %-5level%c %newline%message%newline--------------------------------%newline" />
</layout>
<filter type="log4net.Filter.LevelRangeFilter">
<levelMin value="DEBUG" />
<levelMax value="WARN" />
</filter>
</appender>
<!--Info-->
<root>
<!-- 控制级别由低到高ALL|DEBUG|INFO|WARN|ERROR|FATAL|OFF -->
<!-- 比如定义级别为INFO则INFO级别向下的级别比如DEBUG日志将不会被记录 -->
<!-- 如果没有定义LEVEL的值则缺省为DEBUG -->
<level value="ALL" />
<!-- 按日期切分日志文件,并将日期作为日志文件的名字 -->
<appender-ref ref="ErrorLog" />
<appender-ref ref="InfoLog" />
</root>
</log4net>

View File

@@ -0,0 +1,67 @@
using Com.Ctrip.Framework.Apollo;
using Com.Ctrip.Framework.Apollo.Core;
using Com.Ctrip.Framework.Apollo.Enums;
using Com.Ctrip.Framework.Apollo.Logging;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using System;
using Yi.Framework.Common.IOCOptions;
using Yi.Framework.Core;
using Yi.Framework.Core.ConsulExtend;
namespace Yi.Framework.StaticPageProcessor
{
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureAppConfiguration((hostBuilderContext, configurationBuilder) =>
{
configurationBuilder.AddCommandLine(args);
configurationBuilder.AddJsonFile("appsettings.json", optional: true, reloadOnChange: false);
configurationBuilder.AddJsonFile("configuration.json", optional: false, reloadOnChange: true);
#region
//Apollo配置
#endregion
//configurationBuilder.AddApolloService("Yi");
})
.ConfigureLogging(loggingBuilder =>
{
loggingBuilder.AddFilter("System", Microsoft.Extensions.Logging.LogLevel.Warning);
loggingBuilder.AddFilter("Microsoft", Microsoft.Extensions.Logging.LogLevel.Warning);
loggingBuilder.AddLog4Net();
})
.ConfigureServices((hostContext, services) =>
{
IConfiguration configuration = services.BuildServiceProvider().GetRequiredService<IConfiguration>();
services.AddHostedService<Worker>();
services.AddHostedService<InitPageWorker>();
#region
services.Configure<MySqlConnOptions>(configuration.GetSection("MysqlConn"));
services.AddTransient<CacheClientDB, CacheClientDB>();
services.Configure<RedisConnOptions>(configuration.GetSection("RedisConn"));
services.AddSingleton<RabbitMQInvoker>();
services.Configure<RabbitMQOptions>(configuration.GetSection("RabbitMQOptions"));
#endregion
#region Consul
services.Configure<ConsulClientOption>(configuration.GetSection("ConsulClientOption"));
services.AddTransient<AbstractConsulDispatcher, PollingDispatcher>();
#endregion
services.AddHostedService<WarmupPageWorker>();
});
}
}

View File

@@ -0,0 +1,133 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Yi.Framework.Common.IOCOptions;
using Yi.Framework.Common.Models;
using Yi.Framework.Common.QueueModel;
using Yi.Framework.Core;
using Yi.Framework.Core.ConsulExtend;
namespace Yi.Framework.StaticPageProcessor
{
public class WarmupPageWorker : BackgroundService
{
private readonly IConfiguration _configuration;
private readonly ILogger<WarmupPageWorker> _logger;
private readonly RabbitMQInvoker _RabbitMQInvoker;
private readonly AbstractConsulDispatcher _IConsulDispatcher = null;
public WarmupPageWorker(ILogger<WarmupPageWorker> logger, RabbitMQInvoker rabbitMQInvoker, IConfiguration configuration, AbstractConsulDispatcher consulDispatcher)
{
this._logger = logger;
this._RabbitMQInvoker = rabbitMQInvoker;
this._configuration = configuration;
this._IConsulDispatcher = consulDispatcher;
}
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
RabbitMQConsumerModel rabbitMQConsumerModel = new RabbitMQConsumerModel()
{
ExchangeName = RabbitMQExchangeQueueName.SKUWarmup_Exchange,
QueueName = RabbitMQExchangeQueueName.SKUWarmup_Queue_StaticPage
};
HttpClient _HttpClient = new HttpClient();
this._RabbitMQInvoker.RegistReciveAction(rabbitMQConsumerModel, message =>
{
string realUrl= this._IConsulDispatcher.GetAddress(this._configuration["DetailPageUrl"]);
SKUWarmupQueueModel skuWarmupQueueModel = JsonConvert.DeserializeObject<SKUWarmupQueueModel>(message);
#region <EFBFBD><EFBFBD>ClearAll
{
string totalUrl = $"{realUrl}{0}.html?ActionHeader=ClearAll";
try
{
var result = _HttpClient.GetAsync(totalUrl).Result;
if (result.StatusCode == HttpStatusCode.OK)
{
this._logger.LogInformation($"{nameof(WarmupPageWorker)}.ClearAll succeed {totalUrl}");
//return true;
}
else
{
this._logger.LogWarning($"{nameof(WarmupPageWorker)}.ClearAll failed {totalUrl}");
return false;
}
}
catch (Exception ex)
{
this._logger.LogError($"{nameof(WarmupPageWorker)}.ClearAll failed {totalUrl}, Exception:{ex.Message}");
return false;
}
}
#endregion
#region Ȼ<EFBFBD><EFBFBD>ȫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Warmup
{
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>----<2D><><EFBFBD><EFBFBD>---<2D><>¼<EFBFBD><C2BC><EFBFBD>µ<EFBFBD>
int count = 100;//<2F><><EFBFBD>β<EFBFBD>ѯ
int pageIndex = 1;//<2F><>ҳ<EFBFBD><D2B3>ҳ<EFBFBD><D2B3><EFBFBD>ߵ<EFBFBD>
while (count == 100)
{
// -------------------> <20>˴<EFBFBD><CBB4><EFBFBD><EFBFBD>ɾ<EFBFBD>̬ҳ<CCAC><D2B3><EFBFBD>ƣ<EFBFBD>ͨ<EFBFBD><CDA8>ʹ<EFBFBD><CAB9>id<69><64>ʶ,<2C><><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>service<63>IJ<EFBFBD>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD>id
List<long> ids = new List<long>{ 1,2,3,4,5,6,7,8,9};
// -------------------> <20>˴<EFBFBD><CBB4><EFBFBD><EFBFBD>ɾ<EFBFBD>̬ҳ<CCAC><D2B3><EFBFBD>ƣ<EFBFBD>ͨ<EFBFBD><CDA8>ʹ<EFBFBD><CAB9>id<69><64>ʶ,<2C><><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>service<63>IJ<EFBFBD>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD>id
foreach (var id in ids)
{
string totalUrl = $"{realUrl}{id}.html";
try
{
var result = _HttpClient.GetAsync(totalUrl).Result;
if (result.StatusCode == HttpStatusCode.OK)
{
this._logger.LogInformation($"{nameof(WarmupPageWorker)}.Warmup succeed {totalUrl}");
//return true;
}
else
{
this._logger.LogWarning($"{nameof(WarmupPageWorker)}.Warmup failed {totalUrl}");
return false;
}
}
catch (Exception ex)
{
var logModel = new LogModel()
{
OriginalClassName = this.GetType().FullName,
OriginalMethodName = nameof(ExecuteAsync),
Remark = "<22><>ʱ<EFBFBD><CAB1>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־"
};
this._logger.LogError(ex, $"{nameof(WarmupPageWorker)}.Warmup failed {totalUrl}, Exception:{ex.Message}", JsonConvert.SerializeObject(logModel));
return false;
}
}
pageIndex++;
count = ids.Count;
}
}
#endregion
return true;
});
await Task.CompletedTask;
//while (!stoppingToken.IsCancellationRequested)
//{
// _logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now);
// await Task.Delay(1000, stoppingToken);
//}
}
}
}

View File

@@ -0,0 +1,32 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
namespace Yi.Framework.StaticPageProcessor
{
public class Worker : BackgroundService
{
private readonly ILogger<Worker> _logger;
private readonly IConfiguration _IConfiguration;
public Worker(ILogger<Worker> logger, IConfiguration configuration)
{
this._logger = logger;
this._IConfiguration = configuration;
}
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
while (!stoppingToken.IsCancellationRequested)
{
_logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now);
_logger.LogInformation($"Worker appsetting ConsulClientOption:Ip={this._IConfiguration["ConsulClientOption:Ip"]}");
await Task.Delay(1000, stoppingToken);
}
}
}
}

View File

@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<None Remove="Log4net.config" />
</ItemGroup>
<ItemGroup>
<Content Include="Log4net.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Yi.Framework.WebCore\Yi.Framework.WebCore.csproj" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}

View File

@@ -0,0 +1,36 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"RedisConn": {
"Host": "192.168.2.128",
"Prot": 6379,
"DB": 0,
"Password": "123456"
},
"RabbitMQOptions": {
"HostName": "192.168.2.128",
"UserName": "cc",
"Password": "cc"
},
//"DetailPageUrl": "http://localhost:5728/item/",
"DetailPageUrl": "http://PageDetail/item/",
"ConsulClientOption": {
"IP": "192.168.2.128",
"Port": "8500",
"Datacenter": "dc1"
},
"MysqlConn": {
"Url": "server=192.168.2.128;port=3306;database=ECDB;user id=root;password=123456"
},
"Apollo": {
"AppId": "Yi.Framework.StaticPageProcessor",
"Env": "DEV",
"MetaServer": "http://192.168.2.168:8080",
"ConfigServer": [ "http://192.168.2.168:8080" ]
}
}

View File

@@ -3,6 +3,7 @@ using Microsoft.Extensions.DependencyInjection;
using Microsoft.OpenApi.Models;
using System;
using System.IO;
using Yi.Framework.Common.Models;
namespace Yi.Framework.WebCore.MiddlewareExtend
{
@@ -11,11 +12,11 @@ namespace Yi.Framework.WebCore.MiddlewareExtend
/// </summary>
public static class SwaggerExtension
{
public static IServiceCollection AddSwaggerService<Program>(this IServiceCollection services)
public static IServiceCollection AddSwaggerService<Program>(this IServiceCollection services, string title = "Yi意框架-API接口")
{
var apiInfo = new OpenApiInfo
{
Title = "Yi意框架-API接口",
Title = title,
Version = "v1",
Contact = new OpenApiContact { Name = "橙子", Email = "454313500@qq.com", Url = new System.Uri("https://ccnetcore.com") }
};
@@ -64,12 +65,28 @@ namespace Yi.Framework.WebCore.MiddlewareExtend
return services;
}
public static void UseSwaggerService(this IApplicationBuilder app)
public static void UseSwaggerService(this IApplicationBuilder app, params SwaggerModel[] swaggerModels)
{
//在 Startup.Configure 方法中,启用中间件为生成的 JSON 文档和 Swagger UI 提供服务:
// Enable middleware to serve generated Swagger as a JSON endpoint.
app.UseSwagger();
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "Yi.Framework"));
app.UseSwaggerUI(c =>
{
if (swaggerModels.Length == 0)
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "Yi.Framework");
}
else
{
foreach (var k in swaggerModels)
{
c.SwaggerEndpoint(k.url, k.name);
}
}
}
);
}
}

View File

@@ -29,6 +29,18 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Yi.Framework.WebCore", "Yi.
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Yi.Framework.ApiMicroservice", "Yi.Framework.ApiMicroservice\Yi.Framework.ApiMicroservice.csproj", "{A95157D2-907F-411E-BA1D-A17F48C54A0E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Yi.Framework.OcelotGateway", "Yi.Framework.OcelotGateway\Yi.Framework.OcelotGateway.csproj", "{671E38D8-ECAF-484B-A2AE-63DDC469C315}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Yi.Framework.AuthenticationCenter", "Yi.Framework.AuthenticationCenter\Yi.Framework.AuthenticationCenter.csproj", "{694C0EC0-ED32-4E5D-8EA1-FB82E1303EAB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Yi.Framework.StaticPageProcessor", "Yi.Framework.StaticPageProcessor\Yi.Framework.StaticPageProcessor.csproj", "{D2BC3EBE-7F08-476E-9BB5-58A6F27AB31A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Yi.Framework.ElasticSearchProcessor", "Yi.Framework.ElasticSearchProcessor\Yi.Framework.ElasticSearchProcessor.csproj", "{EEF89893-A6A9-4C02-818C-D116C8EAE0EF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Yi.Framework.MSUnitTest", "Yi.Framework.MSUnitTest\Yi.Framework.MSUnitTest.csproj", "{531255B3-9669-4BC1-B4E5-A0C6E0540F0D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Yi.Framework.PageDetail", "Yi.Framework.PageDetail\Yi.Framework.PageDetail.csproj", "{637501E2-A32E-485C-8680-ED863D1793C2}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -67,6 +79,30 @@ Global
{A95157D2-907F-411E-BA1D-A17F48C54A0E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A95157D2-907F-411E-BA1D-A17F48C54A0E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A95157D2-907F-411E-BA1D-A17F48C54A0E}.Release|Any CPU.Build.0 = Release|Any CPU
{671E38D8-ECAF-484B-A2AE-63DDC469C315}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{671E38D8-ECAF-484B-A2AE-63DDC469C315}.Debug|Any CPU.Build.0 = Debug|Any CPU
{671E38D8-ECAF-484B-A2AE-63DDC469C315}.Release|Any CPU.ActiveCfg = Release|Any CPU
{671E38D8-ECAF-484B-A2AE-63DDC469C315}.Release|Any CPU.Build.0 = Release|Any CPU
{694C0EC0-ED32-4E5D-8EA1-FB82E1303EAB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{694C0EC0-ED32-4E5D-8EA1-FB82E1303EAB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{694C0EC0-ED32-4E5D-8EA1-FB82E1303EAB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{694C0EC0-ED32-4E5D-8EA1-FB82E1303EAB}.Release|Any CPU.Build.0 = Release|Any CPU
{D2BC3EBE-7F08-476E-9BB5-58A6F27AB31A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D2BC3EBE-7F08-476E-9BB5-58A6F27AB31A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D2BC3EBE-7F08-476E-9BB5-58A6F27AB31A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D2BC3EBE-7F08-476E-9BB5-58A6F27AB31A}.Release|Any CPU.Build.0 = Release|Any CPU
{EEF89893-A6A9-4C02-818C-D116C8EAE0EF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EEF89893-A6A9-4C02-818C-D116C8EAE0EF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EEF89893-A6A9-4C02-818C-D116C8EAE0EF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EEF89893-A6A9-4C02-818C-D116C8EAE0EF}.Release|Any CPU.Build.0 = Release|Any CPU
{531255B3-9669-4BC1-B4E5-A0C6E0540F0D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{531255B3-9669-4BC1-B4E5-A0C6E0540F0D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{531255B3-9669-4BC1-B4E5-A0C6E0540F0D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{531255B3-9669-4BC1-B4E5-A0C6E0540F0D}.Release|Any CPU.Build.0 = Release|Any CPU
{637501E2-A32E-485C-8680-ED863D1793C2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{637501E2-A32E-485C-8680-ED863D1793C2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{637501E2-A32E-485C-8680-ED863D1793C2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{637501E2-A32E-485C-8680-ED863D1793C2}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -80,6 +116,12 @@ Global
{07A80C17-E03E-475D-9BBF-98E3B1393652} = {9ABAF6B1-6C02-498A-90A2-ABC1140CF89A}
{E4734315-158C-4D35-AF01-1122C22F2955} = {9ABAF6B1-6C02-498A-90A2-ABC1140CF89A}
{A95157D2-907F-411E-BA1D-A17F48C54A0E} = {026D2797-07D1-4BA5-8070-50CDE0258C59}
{671E38D8-ECAF-484B-A2AE-63DDC469C315} = {D6B44435-EAFA-4D55-90D0-3AF80485FB83}
{694C0EC0-ED32-4E5D-8EA1-FB82E1303EAB} = {D6B44435-EAFA-4D55-90D0-3AF80485FB83}
{D2BC3EBE-7F08-476E-9BB5-58A6F27AB31A} = {D6B44435-EAFA-4D55-90D0-3AF80485FB83}
{EEF89893-A6A9-4C02-818C-D116C8EAE0EF} = {D6B44435-EAFA-4D55-90D0-3AF80485FB83}
{531255B3-9669-4BC1-B4E5-A0C6E0540F0D} = {C90E38FB-69EA-4997-8B3A-2C71EFA65B2B}
{637501E2-A32E-485C-8680-ED863D1793C2} = {026D2797-07D1-4BA5-8070-50CDE0258C59}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {1ED77A6E-377F-4EEF-A3D0-D65C94657DAF}