From b278a1ec101f9bc8649e48fe074f8b736eb10e58 Mon Sep 17 00:00:00 2001
From: yubaolee <yubaolee@163.com>
Date: Wed, 21 Apr 2021 18:02:01 +0800
Subject: [PATCH] fix issue
 https://gitee.com/yubaolee/OpenAuth.Core/issues/I383XZ

---
 Infrastructure/AppSetting.cs                  |  7 ++--
 Infrastructure/Utilities/HttpContext.cs       | 13 ------
 Infrastructure/Utilities/HttpContextUtil.cs   | 40 +++++++++++++++++++
 OpenAuth.App/BuilderTable/BuilderTableApp.cs  |  5 ---
 OpenAuth.App/DbExtension.cs                   |  9 ++++-
 OpenAuth.App/Form/FormApp.cs                  | 13 ++++--
 OpenAuth.App/Test/TestBase.cs                 | 11 ++++-
 OpenAuth.App/Test/TestBuilder.cs              |  1 -
 OpenAuth.Identity/Startup.cs                  |  7 +++-
 OpenAuth.Identity/appsettings.Production.json |  4 +-
 OpenAuth.Identity/appsettings.json            |  4 +-
 OpenAuth.Mvc/Startup.cs                       |  6 ++-
 OpenAuth.Mvc/appsettings.Production.json      |  6 ++-
 OpenAuth.Mvc/appsettings.json                 |  4 +-
 OpenAuth.Repository/OpenAuthDBContext.cs      | 29 +++++---------
 OpenAuth.Repository/Test/TestBase.cs          | 11 ++++-
 OpenAuth.WebApi/Startup.cs                    |  5 ++-
 OpenAuth.WebApi/appsettings.Production.json   |  4 +-
 OpenAuth.WebApi/appsettings.json              | 10 +++--
 19 files changed, 124 insertions(+), 65 deletions(-)
 delete mode 100644 Infrastructure/Utilities/HttpContext.cs
 create mode 100644 Infrastructure/Utilities/HttpContextUtil.cs

diff --git a/Infrastructure/AppSetting.cs b/Infrastructure/AppSetting.cs
index b695e52f..fdfefa22 100644
--- a/Infrastructure/AppSetting.cs
+++ b/Infrastructure/AppSetting.cs
@@ -1,4 +1,6 @@
-namespace Infrastructure
+using System.Collections.Generic;
+
+namespace Infrastructure
 {
     /// <summary>
     /// 配置项
@@ -12,7 +14,6 @@
             Version = "";
             UploadPath = "";
             IdentityServerUrl = "";
-            DbType = Define.DBTYPE_SQLSERVER;
         }
         /// <summary>
         /// SSO地址
@@ -28,7 +29,7 @@
         /// <summary>
         /// 数据库类型 SqlServer、MySql
         /// </summary>
-        public string DbType { get; set; }
+        public Dictionary<string, string> DbTypes { get; set; }
 
         /// <summary> 附件上传路径</summary>
         public string UploadPath { get; set; }
diff --git a/Infrastructure/Utilities/HttpContext.cs b/Infrastructure/Utilities/HttpContext.cs
deleted file mode 100644
index 4d49563c..00000000
--- a/Infrastructure/Utilities/HttpContext.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-using Infrastructure.Extensions.AutofacManager;
-using Microsoft.AspNetCore.Http;
-
-namespace Infrastructure.Utilities
-{
-    public static class HttpContext
-    {
-        private static IHttpContextAccessor _accessor=AutofacContainerModule.GetService<IHttpContextAccessor>();
-
-        public static Microsoft.AspNetCore.Http.HttpContext Current => _accessor.HttpContext;
-        
-    }
-}
diff --git a/Infrastructure/Utilities/HttpContextUtil.cs b/Infrastructure/Utilities/HttpContextUtil.cs
new file mode 100644
index 00000000..ef988655
--- /dev/null
+++ b/Infrastructure/Utilities/HttpContextUtil.cs
@@ -0,0 +1,40 @@
+using Infrastructure.Extensions.AutofacManager;
+using Microsoft.AspNetCore.Http;
+
+namespace Infrastructure.Utilities
+{
+    public static class HttpContextUtil
+    {
+        private static IHttpContextAccessor _accessor=AutofacContainerModule.GetService<IHttpContextAccessor>();
+
+        public static Microsoft.AspNetCore.Http.HttpContext Current => _accessor.HttpContext;
+        
+        /// <summary>
+        /// 获取租户ID
+        /// </summary>
+        /// <returns></returns>
+        public static string GetTenantId(this IHttpContextAccessor accessor)
+        {
+            string tenantId = "OpenAuthDBContext";
+            
+            if (accessor != null && accessor.HttpContext != null)
+            {
+                //读取多租户ID
+                var httpTenantId = accessor.HttpContext.Request.Query[Define.TENANT_ID];
+                if (string.IsNullOrEmpty(httpTenantId))
+                {
+                    httpTenantId = accessor.HttpContext.Request.Headers[Define.TENANT_ID];
+                }
+                
+                //如果没有租户id,或租户用的是默认的OpenAuthDBContext,则不做任何调整
+                if (!string.IsNullOrEmpty(httpTenantId))
+                {
+                    tenantId = httpTenantId;
+                }
+            }
+
+            return tenantId;
+        }
+        
+    }
+}
diff --git a/OpenAuth.App/BuilderTable/BuilderTableApp.cs b/OpenAuth.App/BuilderTable/BuilderTableApp.cs
index 9fde3eb7..256b1c6d 100644
--- a/OpenAuth.App/BuilderTable/BuilderTableApp.cs
+++ b/OpenAuth.App/BuilderTable/BuilderTableApp.cs
@@ -499,11 +499,6 @@ namespace OpenAuth.App
             FileHelper.RegxAddContentByParenthesis(openAuthDBContextPath, "public virtual DbSet<" + tableInfo.ClassName + "> " + tableInfo.TableName + "s { get; set; }");
         }
 
-        private bool IsMysql()
-        {
-            return (_appConfiguration.Value.DbType == Define.DBTYPE_MYSQL);
-        }
-
         Dictionary<string, Type> PrimitiveTypes = new Dictionary<string, Type>()
         {
             {"int", typeof(int)}
diff --git a/OpenAuth.App/DbExtension.cs b/OpenAuth.App/DbExtension.cs
index 9ad05f5d..46392a79 100644
--- a/OpenAuth.App/DbExtension.cs
+++ b/OpenAuth.App/DbExtension.cs
@@ -5,6 +5,8 @@ using System.Data;
 using System.Linq;
 using Autofac.Extensions.DependencyInjection;
 using Infrastructure;
+using Infrastructure.Utilities;
+using Microsoft.AspNetCore.Http;
 using Microsoft.EntityFrameworkCore;
 using Microsoft.EntityFrameworkCore.Infrastructure;
 using Microsoft.EntityFrameworkCore.Internal;
@@ -22,10 +24,12 @@ namespace OpenAuth.App
         private List<DbContext> _contexts = new List<DbContext>();
         
         private IOptions<AppSetting> _appConfiguration;
+        private IHttpContextAccessor _httpContextAccessor;
 
-        public DbExtension(IOptions<AppSetting> appConfiguration, OpenAuthDBContext openAuthDbContext)
+        public DbExtension(IOptions<AppSetting> appConfiguration, OpenAuthDBContext openAuthDbContext, IHttpContextAccessor httpContextAccessor)
         {
             _appConfiguration = appConfiguration;
+            _httpContextAccessor = httpContextAccessor;
             _contexts.Add(openAuthDbContext);  //如果有多个DBContext,可以按OpenAuthDBContext同样的方式添加到_contexts中
         }
 
@@ -105,7 +109,8 @@ namespace OpenAuth.App
         /// <returns></returns>
         public IList<SysTableColumn> GetDbTableStructure(string tableName)
         {
-            if (_appConfiguration.Value.DbType == Define.DBTYPE_MYSQL)
+            var dbtype = _appConfiguration.Value.DbTypes[_httpContextAccessor.GetTenantId()];
+            if (dbtype == Define.DBTYPE_MYSQL)
             {
                 return GetMySqlStructure(tableName);
             }
diff --git a/OpenAuth.App/Form/FormApp.cs b/OpenAuth.App/Form/FormApp.cs
index 76da85da..6679dafa 100644
--- a/OpenAuth.App/Form/FormApp.cs
+++ b/OpenAuth.App/Form/FormApp.cs
@@ -2,6 +2,8 @@ using System;
 using System.Linq;
 using System.Threading.Tasks;
 using Infrastructure;
+using Infrastructure.Utilities;
+using Microsoft.AspNetCore.Http;
 using Microsoft.Extensions.Options;
 using OpenAuth.App.Interface;
 using OpenAuth.App.Request;
@@ -17,6 +19,7 @@ namespace OpenAuth.App
     {
         private IAuth _auth;
         private IOptions<AppSetting> _appConfiguration;
+        private IHttpContextAccessor _httpContextAccessor;
         /// <summary>
         /// 加载列表
         /// </summary>
@@ -44,7 +47,9 @@ namespace OpenAuth.App
             UnitWork.Add(obj);
             if (!string.IsNullOrEmpty(obj.DbName))
             {
-                UnitWork.ExecuteSql(FormUtil.GetSql(obj, _appConfiguration.Value.DbType));
+                var dbtype = _appConfiguration.Value.DbTypes[_httpContextAccessor.GetTenantId()];
+                
+                UnitWork.ExecuteSql(FormUtil.GetSql(obj, dbtype));
             }
             UnitWork.Save();
         }
@@ -67,7 +72,8 @@ namespace OpenAuth.App
 
             if (!string.IsNullOrEmpty(obj.DbName))
             {
-                UnitWork.ExecuteSql(FormUtil.GetSql(obj, _appConfiguration.Value.DbType));
+                var dbtype = _appConfiguration.Value.DbTypes[_httpContextAccessor.GetTenantId()];
+                UnitWork.ExecuteSql(FormUtil.GetSql(obj, dbtype));
             }
         }
 
@@ -78,10 +84,11 @@ namespace OpenAuth.App
         }
 
         public FormApp(IUnitWork<OpenAuthDBContext> unitWork, IRepository<Form,OpenAuthDBContext> repository,
-            IAuth auth, IOptions<AppSetting> appConfiguration) : base(unitWork, repository, auth)
+            IAuth auth, IOptions<AppSetting> appConfiguration, IHttpContextAccessor httpContextAccessor) : base(unitWork, repository, auth)
         {
             _auth = auth;
             _appConfiguration = appConfiguration;
+            _httpContextAccessor = httpContextAccessor;
         }
     }
 }
\ No newline at end of file
diff --git a/OpenAuth.App/Test/TestBase.cs b/OpenAuth.App/Test/TestBase.cs
index bbba6f75..24fa7779 100644
--- a/OpenAuth.App/Test/TestBase.cs
+++ b/OpenAuth.App/Test/TestBase.cs
@@ -1,8 +1,10 @@
 using System;
 using System.IO;
+using System.Linq;
 using Autofac.Extensions.DependencyInjection;
 using Infrastructure;
 using Infrastructure.Extensions.AutofacManager;
+using Infrastructure.Utilities;
 using Microsoft.AspNetCore.Http;
 using Microsoft.Extensions.Configuration;
 using Microsoft.Extensions.DependencyInjection;
@@ -33,8 +35,7 @@ namespace OpenAuth.App.Test
                 .AddJsonFile("appsettings.Development.json", optional: true)
                 .AddEnvironmentVariables()
                 .Build();
-            Console.WriteLine($"单元测试数据库信息:{config.GetSection("AppSetting")["DbType"]}/{config.GetSection("ConnectionStrings")["OpenAuthDBContext"]}");
-
+           
             serviceCollection.Configure<AppSetting>(config.GetSection("AppSetting"));
             //添加log4net
             serviceCollection.AddLogging(builder =>
@@ -57,6 +58,12 @@ namespace OpenAuth.App.Test
             var container = AutofacExt.InitForTest(serviceCollection);
             _autofacServiceProvider = new AutofacServiceProvider(container);
             AutofacContainerModule.ConfigServiceProvider(_autofacServiceProvider);
+            
+            var dbtypes = config.GetSection("AppSetting:DbTypes").GetChildren()
+                .ToDictionary(x => x.Key, x => x.Value);
+            
+            Console.WriteLine($"单元测试数据库信息:{dbtypes[httpContextAccessorMock.Object.GetTenantId()]}/{config.GetSection("ConnectionStrings")["OpenAuthDBContext"]}");
+
         }
 
         /// <summary>
diff --git a/OpenAuth.App/Test/TestBuilder.cs b/OpenAuth.App/Test/TestBuilder.cs
index 7fcf251f..b4a7a2f4 100644
--- a/OpenAuth.App/Test/TestBuilder.cs
+++ b/OpenAuth.App/Test/TestBuilder.cs
@@ -12,7 +12,6 @@ using Microsoft.Extensions.Hosting;
 using Moq;
 using OpenAuth.App.Request;
 using OpenAuth.App.SSO;
-using HttpContext = Infrastructure.Utilities.HttpContext;
 
 namespace OpenAuth.App.Test
 {
diff --git a/OpenAuth.Identity/Startup.cs b/OpenAuth.Identity/Startup.cs
index 53302c6c..bc75cec8 100644
--- a/OpenAuth.Identity/Startup.cs
+++ b/OpenAuth.Identity/Startup.cs
@@ -2,6 +2,7 @@
 // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
 
 
+using System.Linq;
 using Autofac;
 using Infrastructure;
 using Microsoft.AspNetCore.Builder;
@@ -69,9 +70,11 @@ namespace OpenAuth.IdentityServer
             
             //映射配置文件
             services.Configure<AppSetting>(Configuration.GetSection("AppSetting"));
-
+            
             //在startup里面只能通过这种方式获取到appsettings里面的值,不能用IOptions😰
-            var dbType = ((ConfigurationSection) Configuration.GetSection("AppSetting:DbType")).Value;
+            var dbtypes = ((ConfigurationSection)Configuration.GetSection("AppSetting:DbTypes")).GetChildren()
+                .ToDictionary(x => x.Key, x => x.Value);
+            var dbType = dbtypes["OpenAuthDBContext"];
             if (dbType == Define.DBTYPE_SQLSERVER)
             {
                 services.AddDbContext<OpenAuthDBContext>(options =>
diff --git a/OpenAuth.Identity/appsettings.Production.json b/OpenAuth.Identity/appsettings.Production.json
index 4817d665..b28e46b5 100644
--- a/OpenAuth.Identity/appsettings.Production.json
+++ b/OpenAuth.Identity/appsettings.Production.json
@@ -9,6 +9,8 @@
     "OpenAuthDBContext": "server=127.0.0.1;user id=root;database=openauthdb;password=000000" //my sql
   },
   "AppSetting": {
-    "DbType": "MySql" //数据库类型:SqlServer/MySql
+    "DbTypes": {
+      "OpenAuthDBContext":"MySql" //数据库类型:SqlServer、MySql、Oracle
+    }
   }
 }
diff --git a/OpenAuth.Identity/appsettings.json b/OpenAuth.Identity/appsettings.json
index 9eceb8e5..dd34451f 100644
--- a/OpenAuth.Identity/appsettings.json
+++ b/OpenAuth.Identity/appsettings.json
@@ -10,6 +10,8 @@
     //"OpenAuthDBContext": "server=127.0.0.1;user id=root;database=openauthdb;password=000000" //my sql
   },
   "AppSetting": {
-    "DbType": "SqlServer" //数据库类型:SqlServer/MySql
+    "DbTypes": {
+      "OpenAuthDBContext":"SqlServer" //数据库类型:SqlServer、MySql、Oracle
+    }
   }
 }
diff --git a/OpenAuth.Mvc/Startup.cs b/OpenAuth.Mvc/Startup.cs
index 6f7b84f8..47409f2d 100644
--- a/OpenAuth.Mvc/Startup.cs
+++ b/OpenAuth.Mvc/Startup.cs
@@ -1,4 +1,5 @@
 using System.IO;
+using System.Linq;
 using Autofac;
 using Infrastructure;
 using Infrastructure.Extensions.AutofacManager;
@@ -88,9 +89,10 @@ namespace OpenAuth.Mvc
             services.Configure<AppSetting>(Configuration.GetSection("AppSetting"));
 
             //在startup里面只能通过这种方式获取到appsettings里面的值,不能用IOptions😰
-            var dbType = ((ConfigurationSection)Configuration.GetSection("AppSetting:DbType")).Value;
+            var dbtypes = ((ConfigurationSection)Configuration.GetSection("AppSetting:DbTypes")).GetChildren()
+                .ToDictionary(x => x.Key, x => x.Value);
             var connectionString = Configuration.GetConnectionString("OpenAuthDBContext");
-            logger.LogInformation($"当前数据库类型:{dbType},连接字符串:{connectionString}");
+            logger.LogInformation($"系统配置的数据库类型:{JsonHelper.Instance.Serialize(dbtypes)},连接字符串:{connectionString}");
 
             services.AddDbContext<OpenAuthDBContext>();
 
diff --git a/OpenAuth.Mvc/appsettings.Production.json b/OpenAuth.Mvc/appsettings.Production.json
index 2bd28a74..ac3b39bd 100644
--- a/OpenAuth.Mvc/appsettings.Production.json
+++ b/OpenAuth.Mvc/appsettings.Production.json
@@ -13,7 +13,9 @@
     "IdentityServerUrl": "http://demo.openauth.me:12796", //IdentityServer服务器地址。如果为空,则不启用OAuth认证
    // "IdentityServerUrl": "", //IdentityServer服务器地址。如果为空,则不启用OAuth认证
     "SSOPassport": "http://localhost:52789",
-    "Version": "demo", 
-    "DbType": "MySql" //数据库类型 SqlServer/MySql
+    "Version": "demo",
+    "DbTypes": {
+      "OpenAuthDBContext":"MySql" //数据库类型:SqlServer、MySql、Oracle
+    }
   }
 }
diff --git a/OpenAuth.Mvc/appsettings.json b/OpenAuth.Mvc/appsettings.json
index 2cf53ee7..4ea00c35 100644
--- a/OpenAuth.Mvc/appsettings.json
+++ b/OpenAuth.Mvc/appsettings.json
@@ -15,6 +15,8 @@
     "IdentityServerUrl": "", //IdentityServer服务器地址。如果为空,则不启用OAuth认证
     "SSOPassport": "http://localhost:52789",
     "Version": "1.0", //如果为demo,则可以防止post提交
-    "DbType": "SqlServer" //数据库类型:SqlServer、MySql
+    "DbTypes": {
+      "OpenAuthDBContext":"SqlServer" //数据库类型:SqlServer、MySql、Oracle
+    }
   }
 }
diff --git a/OpenAuth.Repository/OpenAuthDBContext.cs b/OpenAuth.Repository/OpenAuthDBContext.cs
index db8d01b6..959c188f 100644
--- a/OpenAuth.Repository/OpenAuthDBContext.cs
+++ b/OpenAuth.Repository/OpenAuthDBContext.cs
@@ -1,5 +1,9 @@
 using System;
+using System.Collections.Generic;
+using System.Linq;
 using Infrastructure;
+using Infrastructure.Extensions;
+using Infrastructure.Utilities;
 using Microsoft.AspNetCore.Http;
 using Microsoft.EntityFrameworkCore;
 using Microsoft.Extensions.Configuration;
@@ -40,24 +44,8 @@ namespace OpenAuth.Repository
         //初始化多租户信息,根据租户id调整数据库
         private void InitTenant(DbContextOptionsBuilder optionsBuilder)
         {
-            string tenantId = "OpenAuthDBContext";
-            
-            if (_httpContextAccessor != null && _httpContextAccessor.HttpContext != null)
-            {
-                //读取多租户ID
-                var httpTenantId = _httpContextAccessor.HttpContext.Request.Query[Define.TENANT_ID];
-                if (string.IsNullOrEmpty(httpTenantId))
-                {
-                    httpTenantId = _httpContextAccessor.HttpContext.Request.Headers[Define.TENANT_ID];
-                }
-                
-                //如果没有租户id,或租户用的是默认的OpenAuthDBContext,则不做任何调整
-                if (!string.IsNullOrEmpty(httpTenantId))
-                {
-                    tenantId = httpTenantId;
-                }
-            }
-            
+
+            var tenantId = _httpContextAccessor.GetTenantId();
             string connect = _configuration.GetConnectionString(tenantId);
             if (string.IsNullOrEmpty(connect))
             {
@@ -65,7 +53,10 @@ namespace OpenAuth.Repository
             }
 
             //这个地方如果用IOption,在单元测试的时候会获取不到AppSetting的值😅
-           var dbType = _configuration.GetSection("AppSetting")["DbType"];
+            var dbtypes = _configuration.GetSection("AppSetting:DbTypes").GetChildren()
+                .ToDictionary(x => x.Key, x => x.Value);
+            
+           var dbType = dbtypes[tenantId];
            if (dbType == Define.DBTYPE_SQLSERVER)
            {
                optionsBuilder.UseSqlServer(connect);
diff --git a/OpenAuth.Repository/Test/TestBase.cs b/OpenAuth.Repository/Test/TestBase.cs
index d45defb7..dfd369e8 100644
--- a/OpenAuth.Repository/Test/TestBase.cs
+++ b/OpenAuth.Repository/Test/TestBase.cs
@@ -1,9 +1,11 @@
 using System;
 using System.IO;
+using System.Linq;
 using System.Reflection;
 using Autofac;
 using Autofac.Extensions.DependencyInjection;
 using Infrastructure;
+using Infrastructure.Utilities;
 using Microsoft.AspNetCore.Http;
 using Microsoft.EntityFrameworkCore;
 using Microsoft.Extensions.Configuration;
@@ -45,8 +47,7 @@ namespace OpenAuth.Repository.Test
                 .AddJsonFile("appsettings.Development.json", optional: true)
                 .AddEnvironmentVariables()
                 .Build();
-            Console.WriteLine($"单元测试数据库信息:{config.GetSection("AppSetting")["DbType"]}/{config.GetSection("ConnectionStrings")["OpenAuthDBContext"]}");
-
+         
             //添加log4net
             serviceCollection.AddLogging(builder =>
             {
@@ -74,6 +75,12 @@ namespace OpenAuth.Repository.Test
           
             var _container = builder.Build();
             _autofacServiceProvider = new AutofacServiceProvider(_container);
+            
+            var dbtypes = config.GetSection("AppSetting:DbTypes").GetChildren()
+                .ToDictionary(x => x.Key, x => x.Value);
+            
+            Console.WriteLine($"单元测试数据库信息:{dbtypes[httpContextAccessorMock.Object.GetTenantId()]}/{config.GetSection("ConnectionStrings")["OpenAuthDBContext"]}");
+
 
         }
 
diff --git a/OpenAuth.WebApi/Startup.cs b/OpenAuth.WebApi/Startup.cs
index ecfa692c..623ff968 100644
--- a/OpenAuth.WebApi/Startup.cs
+++ b/OpenAuth.WebApi/Startup.cs
@@ -140,9 +140,10 @@ namespace OpenAuth.WebApi
 //                policy.AllowAnyHeader().AllowAnyMethod().AllowCredentials().WithOrigins(origins)));
 
             //在startup里面只能通过这种方式获取到appsettings里面的值,不能用IOptions😰
-            var dbType = ((ConfigurationSection)Configuration.GetSection("AppSetting:DbType")).Value;
+            var dbtypes = ((ConfigurationSection)Configuration.GetSection("AppSetting:DbTypes")).GetChildren()
+                .ToDictionary(x => x.Key, x => x.Value);
             var connectionString = Configuration.GetConnectionString("OpenAuthDBContext");
-            logger.LogInformation($"当前数据库类型:{dbType},连接字符串:{connectionString}");
+            logger.LogInformation($"系统配置的数据库类型:{JsonHelper.Instance.Serialize(dbtypes)},连接字符串:{connectionString}");
             services.AddDbContext<OpenAuthDBContext>();
 
             services.AddHttpClient();
diff --git a/OpenAuth.WebApi/appsettings.Production.json b/OpenAuth.WebApi/appsettings.Production.json
index 7bfa8fc4..7c754715 100644
--- a/OpenAuth.WebApi/appsettings.Production.json
+++ b/OpenAuth.WebApi/appsettings.Production.json
@@ -14,7 +14,9 @@
   "AppSetting": {
     "IdentityServerUrl": "", //IdentityServer服务器地址。如果为空,则不启用OAuth认证
     //"IdentityServerUrl": "http://demo.openauth.me:12796", //IdentityServer服务器地址。如果为空,则不启用OAuth认证
-    "DbType": "MySql", //数据库类型:SqlServer、MySql、Oracle
+    "DbTypes": {
+      "OpenAuthDBContext":"MySql" //数据库类型:SqlServer、MySql、Oracle
+    },
     "UploadPath": "", //附件上传的路径,如果为空则保存在站点根目录
     "RedisConf": "your_redis_server:6379,password=your_redis_password"  //redis配置信息
   }
diff --git a/OpenAuth.WebApi/appsettings.json b/OpenAuth.WebApi/appsettings.json
index de96ba35..3395c267 100644
--- a/OpenAuth.WebApi/appsettings.json
+++ b/OpenAuth.WebApi/appsettings.json
@@ -8,13 +8,17 @@
   "DataProtection": "temp-keys/",
   "ConnectionStrings": {
     "OpenAuthDBContext": "Data Source=.;Initial Catalog=OpenAuthDB;User=sa;Password=000000"
-    //"OpenAuthDBContext": "DATA SOURCE=192.168.0.118:1521/YUBAO;PASSWORD=000000;Validate Connection=true;PERSIST SECURITY INFO=True;USER ID=yubaolee;" //Oracle
-    //"OpenAuthDBContext": "server=127.0.0.1;user id=root;database=openauthdb;password=000000" //my sql
+    //"OpenAuthDBContext2": "DATA SOURCE=192.168.0.118:1521/YUBAO;PASSWORD=000000;Validate Connection=true;PERSIST SECURITY INFO=True;USER ID=yubaolee;" //Oracle
+    //"OpenAuthDBContext3": "server=127.0.0.1;user id=root;database=openauthpro;password=000000" //my sql
   },
   "AppSetting": {
     "IdentityServerUrl": "", //IdentityServer服务器地址。如果为空,则不启用OAuth认证
    // "IdentityServerUrl": "http://localhost:12796", //IdentityServer服务器地址。如果为空,则不启用OAuth认证
-    "DbType": "SqlServer", //数据库类型:SqlServer、MySql、Oracle
+    "DbTypes": {
+        "OpenAuthDBContext":"SqlServer" //数据库类型:SqlServer、MySql、Oracle
+//        ,"OpenAuthDBContext2":"Oracle"
+//        ,"OpenAuthDBContext3":"MySql"
+    }, 
     "UploadPath": "", //附件上传的路径,如果为空则保存在站点根目录
     "RedisConf": "redistest.cq-p.com.cn:8001,password=share_redis@123"
   }