From c5cae80b64b4c56601835f4d40e204a462563094 Mon Sep 17 00:00:00 2001
From: liaoxujun@qq.com <liaoxujun@qq.com>
Date: 星期二, 29 八月 2023 16:56:38 +0800
Subject: [PATCH] 修正登录逻辑 取消租户登录选项,修正消息租户会自动创建一个员工账号,一企业账号

---
 DocumentServiceAPI.Core/DbContext.cs |   28 ++++++++++++++++++++++++++--
 1 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/DocumentServiceAPI.Core/DbContext.cs b/DocumentServiceAPI.Core/DbContext.cs
index 2aaa3fd..9c98cfa 100644
--- a/DocumentServiceAPI.Core/DbContext.cs
+++ b/DocumentServiceAPI.Core/DbContext.cs
@@ -45,7 +45,7 @@
                db.CurrentConnectionConfig.ConfigureExternalServices = new ConfigureExternalServices()
                {
                    //鍒ゆ柇鏄惁寮�鍚痳edis璁剧疆浜岀骇缂撳瓨鏂瑰紡
-                 //  DataInfoCacheService = new SqlSugarRedisCache(),
+                   DataInfoCacheService = new SqlSugarRedisCache(),
                    //妯″瀷瀹氫箟涓� int?鍙锋椂鑷姩涓哄彲绌�
                    EntityService = (c, p) =>
                    {
@@ -57,6 +57,19 @@
                            p.IsNullable = true;
                        }
                    }
+
+               };
+               db.Aop.OnLogExecuting = (sql, pars) =>
+               {
+                   Console.WriteLine(sql);//杈撳嚭sql,鏌ョ湅鎵цsql聽鎬ц兘鏃犲奖鍝�
+
+
+                   //鑾峰彇鍘熺敓SQL鎺ㄨ崘聽5.1.4.63聽聽鎬ц兘OK
+                   //UtilMethods.GetNativeSql(sql,pars)
+
+                   //鑾峰彇鏃犲弬鏁板寲SQL聽瀵规�ц兘鏈夊奖鍝嶏紝鐗瑰埆澶х殑SQL鍙傛暟澶氱殑锛岃皟璇曚娇鐢�
+                   //UtilMethods.GetSqlString(DbType.SqlServer,sql,pars)
+
 
                };
                db.CurrentConnectionConfig.MoreSettings = new ConnMoreSettings()
@@ -92,11 +105,12 @@
     /// <param name="ModeProjectName"></param>
     public static void DbCodeFirst(this IApplicationBuilder app, string ModeProjectName, string? Modenamespace = null, string? ConfigId = null)
     {
-       var ddb= App.GetService<ISqlSugarClient>();
+      
         var _db = app.ApplicationServices.GetService<ISqlSugarClient>();
         //鍒囨崲鏁版嵁搴�
         if (!string.IsNullOrEmpty(ConfigId))
             _db.AsTenant().ChangeDatabase(ConfigId);
+
         //寤哄簱
         _db.DbMaintenance.CreateDatabase();
         Type[]? types = UtilityFun.GetAllAssembly().Where(x => x.FullName.Contains(ModeProjectName + ",")).FirstOrDefault()?.GetTypes().WhereIF(!string.IsNullOrEmpty(Modenamespace), name => name.FullName.Contains(Modenamespace + ".")).ToArray().Where(x => x.IsSubclassOf(typeof(BaseModel))).ToArray();
@@ -104,4 +118,14 @@
         _db.CodeFirst.InitTables(types);//鏍规嵁types鍒涘缓琛�
 
     }
+    public static void DbCodeFirst(this IApplicationBuilder app, Type Obj,  string? ConfigId = null)
+    {
+        var _db = app.ApplicationServices.GetService<ISqlSugarClient>();
+        //鍒囨崲鏁版嵁搴�
+        if (!string.IsNullOrEmpty(ConfigId))
+            _db.AsTenant().ChangeDatabase(ConfigId);
+        //寤哄簱
+        _db.DbMaintenance.CreateDatabase();
+        _db.CodeFirst.InitTables(Obj);//鏍规嵁types鍒涘缓琛�
+    }
 }

--
Gitblit v1.9.1