林豪 左 2 vuotta sitten
vanhempi
commit
ae226587df

+ 50 - 3
ServiceCenter/SqlSugars/SqlSugarHelper.cs

@@ -7,14 +7,61 @@ namespace ServiceCenter.SqlSugars
     /// </summary>
     public class SqlSugarHelper
     {
-        //如果是固定多库可以传 new SqlSugarScope(List<ConnectionConfig>,db=>{}) 文档:多租户
-        //如果是不固定多库 可以看文档Saas分库
-
         /// <summary>
         /// 数据库连接
         /// </summary>
         private static SqlSugarScope? _Db { get; set; } = null;
 
+        /// <summary>
+        /// 默认数据库连接Key
+        /// </summary>
+        private static string? _Default { get; set; } = null;
+
+        /// <summary>
+        /// Dlog数据库连接Key
+        /// </summary>
+        private static string? _Dlog { get; set; } = null;
+
+        /// <summary>
+        ///  设置数据库连接Key
+        /// </summary>
+        /// <param name="configId">默认多租户ID</param>
+        public static void SetDefault(string configId)
+        {
+            _Default = configId;
+        }
+
+        /// <summary>
+        ///  设置 Dlog数据库连接Key
+        /// </summary>
+        /// <param name="configId">多租户Dlog ID</param>
+        public static void SetDlog(string configId)
+        {
+            _Dlog = configId;
+        }
+
+        /// <summary>
+        /// 默认数据库连接Key
+        /// </summary>
+        public static string Default
+        {
+            get
+            {
+                return _Default ?? throw new Exception("请调用[SqlSugarHelper.SetDefault]方法设置默认数据库连接");
+            }
+        }
+
+        /// <summary>
+        /// Dlog数据库连接Key
+        /// </summary>
+        public static string Dlog
+        {
+            get
+            {
+                return _Dlog ?? throw new Exception("请调用[SqlSugarHelper.SetDlog]方法设置Dlog数据库连接");
+            }
+        }
+
         /// <summary>
         ///  设置数据库连接
         /// </summary>

+ 2 - 2
WCS.Entity/OBJ.cs

@@ -28,13 +28,13 @@ namespace WCS.Entity
         /// 仅记录用户ID
         /// </summary>
         [SugarColumn(ColumnDescription = "更新用户", Length = 50)]
-        public string UPDATEUSER { get; set; }
+        public string EditWho { get; set; } = null!;
 
         /// <summary>
         /// 更新时间
         /// </summary>
         [SugarColumn(ColumnDescription = "更新时间")]
-        public DateTime UPDATETIME { get; set; } = DateTime.Now;
+        public DateTime EditTime { get; set; } = DateTime.Now;
 
         /// <summary>
         /// 版本号

+ 3 - 3
WCS.Service/Worker.cs

@@ -105,9 +105,9 @@ namespace WCS.Service
             //初始化数据库
             SqlSugarHelper.Do(db =>
             {
-                var _db = db.Connect;
                 foreach (var connectionString in ServiceHub.DbConnectionStrings!)
                 {
+                    var _db = db.Connect.GetConnectionScope(connectionString.Key);
                     switch (connectionString.Key)
                     {
                         case "WCSDB"://WCS基本数据库
@@ -135,8 +135,8 @@ namespace WCS.Service
                             //db.Context(WcsDlog).CodeFirst.InitTables(typeof(WCS_RGV520));
                             //db.Context(WcsDlog).CodeFirst.InitTables(typeof(WCS_RGV521));
                             //db.Context(WcsDlog).CodeFirst.InitTables(typeof(WCS_RGV523));
-                            //db.Context(WcsDlog).CodeFirst.InitTables(typeof(WCS_SRM520));
-                            //db.Context(WcsDlog).CodeFirst.InitTables(typeof(WCS_SRM521));
+                            //_db.CodeFirst.InitTables(typeof(WCS_SRM520));
+                            //_db.CodeFirst.InitTables(typeof(WCS_SRM521));
                             //db.Context(WcsDlog).CodeFirst.InitTables(typeof(WCS_SRM537));
                             _db.CodeFirst.InitTables(typeof(WCS_Station520));
                             _db.CodeFirst.InitTables(typeof(WCS_Station521));

+ 1 - 1
WCS.WorkEngineering/WCS.WorkEngineering.csproj

@@ -8,7 +8,7 @@
 
   <ItemGroup>
     <PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="7.0.5" />
-    <PackageReference Include="ServiceCenter" Version="1.0.0.21" />
+    <PackageReference Include="ServiceCenter" Version="1.0.0.22" />
   </ItemGroup>
 
   <ItemGroup>