mirror of
https://gitee.com/ccnetcore/Yi
synced 2026-04-21 08:56:36 +08:00
配置文件开关,数据库读写分离
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace Yi.Framework.ApiMicroservice
|
||||
#region
|
||||
//ApolloÅäÖÃ
|
||||
#endregion
|
||||
//configurationBuilder.AddApolloService("Yi");
|
||||
configurationBuilder.AddApolloService("Yi");
|
||||
})
|
||||
.ConfigureLogging(loggingBuilder =>
|
||||
{
|
||||
@@ -38,7 +38,7 @@ namespace Yi.Framework.ApiMicroservice
|
||||
})
|
||||
.ConfigureWebHostDefaults(webBuilder =>
|
||||
{
|
||||
webBuilder.UseStartup<Startup>().UseUrls("https://*:44329");
|
||||
webBuilder.UseStartup<Startup>();
|
||||
}).UseServiceProviderFactory(new AutofacServiceProviderFactory());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Yi.Framework.Model.ModelFactory;
|
||||
using Yi.Framework.WebCore.MiddlewareExtend;
|
||||
using Yi.Framework.WebCore.Utility;
|
||||
|
||||
@@ -49,24 +50,19 @@ namespace Yi.Framework.ApiMicroservice
|
||||
services.AddJwtService();
|
||||
|
||||
#region
|
||||
//Sqlite服务配置
|
||||
//数据库配置
|
||||
#endregion
|
||||
services.AddSqliteService();
|
||||
|
||||
#region
|
||||
//MySql服务配置
|
||||
#endregion
|
||||
services.AddMysqlService();
|
||||
services.AddDbService();
|
||||
|
||||
#region
|
||||
//Redis服务配置
|
||||
#endregion
|
||||
//services.AddRedisService();
|
||||
services.AddRedisService();
|
||||
|
||||
#region
|
||||
//RabbitMQ服务配置
|
||||
#endregion
|
||||
//services.AddRabbitMQService();
|
||||
services.AddRabbitMQService();
|
||||
|
||||
|
||||
}
|
||||
@@ -82,7 +78,7 @@ namespace Yi.Framework.ApiMicroservice
|
||||
#endregion
|
||||
|
||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env,DbContext _Db)
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env,IDbContextFactory _DbFactory)
|
||||
{
|
||||
//if (env.IsDevelopment())
|
||||
{
|
||||
@@ -119,7 +115,7 @@ namespace Yi.Framework.ApiMicroservice
|
||||
#region
|
||||
//健康检查注入
|
||||
#endregion
|
||||
//app.UseHealthCheckMiddleware();
|
||||
app.UseHealthCheckMiddleware();
|
||||
|
||||
#region
|
||||
//鉴权注入
|
||||
@@ -134,12 +130,12 @@ namespace Yi.Framework.ApiMicroservice
|
||||
#region
|
||||
//Consul服务注入
|
||||
#endregion
|
||||
//app.UseConsulService();
|
||||
app.UseConsulService();
|
||||
|
||||
#region
|
||||
//数据库种子注入
|
||||
#endregion
|
||||
app.UseDbSeedInitService(_Db);
|
||||
app.UseDbSeedInitService(_DbFactory);
|
||||
|
||||
#region
|
||||
//Endpoints注入
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
{
|
||||
"urls": "http://*:19000",
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
@@ -7,19 +8,33 @@
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
|
||||
"Consul_Enabled": false,
|
||||
"DbSeed_Enabled": true,
|
||||
"Apollo_Enabled": false,
|
||||
"HealthCheck_Enabled": false,
|
||||
"Cors_Enabled": true,
|
||||
"RabbitMQ_Enabled": false,
|
||||
"Redis_Enabled": false,
|
||||
"Kafka_Enabled": false,
|
||||
"MutiDB_Enabled": true,
|
||||
"DbList": [ "Sqlite", "Mysql", "Sqlserver","Oracle"],
|
||||
"DbSelect": "Mysql",
|
||||
|
||||
"DbConn": {
|
||||
"WriteUrl": "server=118.195.191.41;port=3306;database=YIDB;user id=root;password=Qz52013142020.",
|
||||
"ReadUrl": [
|
||||
"server=118.195.191.41;port=3306;database=YIDB;user id=root;password=Qz52013142020.",
|
||||
"server=118.195.191.41;port=3306;database=YIDB;user id=root;password=Qz52013142020.",
|
||||
"server=118.195.191.41;port=3306;database=YIDB;user id=root;password=Qz52013142020."
|
||||
]
|
||||
},
|
||||
"Apollo": {
|
||||
"AppId": "Yi.Framework.ApiMicroservice",
|
||||
"Env": "DEV",
|
||||
"MetaServer": "http://192.168.2.168:8080",
|
||||
"ConfigServer": [ "http://192.168.2.168:8080" ]
|
||||
},
|
||||
"SqliteConn": {
|
||||
"Url": "Filename=YIDB.db"
|
||||
},
|
||||
"MysqlConn": {
|
||||
"Url": "server=118.195.191.41;port=3306;database=YIDB;user id=root;password=Qz52013142020."
|
||||
},
|
||||
|
||||
"JWTTokenOptions": {
|
||||
"Audience": "http://localhost:7000",
|
||||
"Issuer": "http://localhost:7000",
|
||||
|
||||
Reference in New Issue
Block a user