From 6eb4d5574aee7042b1883e043d5798865e84d1d1 Mon Sep 17 00:00:00 2001
From: ningshuxia <ningshuxia0927@outlook.com>
Date: 星期一, 29 四月 2024 14:44:23 +0800
Subject: [PATCH] 1.分析组合 2.分析组合结论

---
 Schedule/IStation.Algorithm _v1/DAL/Base/BaseDAL.cs |   87 +++++++++++++++----------------------------
 1 files changed, 30 insertions(+), 57 deletions(-)

diff --git a/Schedule/IStation.Algorithm/DAL/BaseDAL.cs b/Schedule/IStation.Algorithm _v1/DAL/Base/BaseDAL.cs
similarity index 71%
rename from Schedule/IStation.Algorithm/DAL/BaseDAL.cs
rename to Schedule/IStation.Algorithm _v1/DAL/Base/BaseDAL.cs
index ac0550b..6930379 100644
--- a/Schedule/IStation.Algorithm/DAL/BaseDAL.cs
+++ b/Schedule/IStation.Algorithm _v1/DAL/Base/BaseDAL.cs
@@ -5,13 +5,11 @@
     /// </summary>
     /// <typeparam name="T">瀹炰綋绫荤被鍨�</typeparam>
     public partial class BaseDAL<T>
-        where T : Model.BaseModel, new()
+        where T : Entity.BaseEntity, new()
     {
         /// <summary>
         /// 鑾峰彇琛ㄥ悕绉�
-        /// </summary>
-        /// <typeparam name="T"></typeparam>
-        /// <returns></returns>
+        /// </summary> 
         public string TableName
         {
             get
@@ -22,27 +20,16 @@
                     return (att[0] as SugarTable).TableName;
                 return objType.Name;
             }
-
         }
 
         /// <summary>
-        /// 杩炴帴閰嶇疆
+        /// 榛樿杩炴帴瀵硅薄
         /// </summary>
-        public virtual ConnectionConfig ConnectionConfig
+        public virtual SqlSugarClient Connection
         {
             get
             {
                 return default;
-            }
-        }
-        /// <summary>
-        /// 榛樿杩炴帴瀵硅薄
-        /// </summary>
-        public ISqlSugarClient Connection
-        {
-            get
-            {
-                return new SqlSugarClient(ConnectionConfig);
             }
         }
 
@@ -51,13 +38,13 @@
         /// <summary>
         /// 鎻掑叆鎸囧畾瀵硅薄鍒版暟鎹簱涓�
         /// </summary>
-        public virtual long Insert(T entity)
+        public virtual int Insert(T entity)
         {
             if (entity == null)
                 return default;
-            using (SqlSugarClient db = new SqlSugarClient(ConnectionConfig))
+            using (SqlSugarClient db = Connection)
             {
-                return db.Insertable(entity).ExecuteReturnSnowflakeId();
+                return db.Insertable(entity).ExecuteReturnIdentity();
             }
         }
 
@@ -68,22 +55,9 @@
         {
             if (list == null || list.Count < 1)
                 return default;
-            using (SqlSugarClient db = new SqlSugarClient(ConnectionConfig))
+            using (SqlSugarClient db = Connection)
             {
-                return db.Insertable(list).ExecuteReturnSnowflakeIdList().Count() > 0;
-            }
-        }
-
-        /// <summary>
-        /// 鎻掑叆骞惰繑鍥�
-        /// </summary>
-        public virtual List<long> InsertsR(List<T> list)
-        {
-            if (list == null || list.Count < 1)
-                return default;
-            using (SqlSugarClient db = new SqlSugarClient(ConnectionConfig))
-            {
-                return db.Insertable(list).ExecuteReturnSnowflakeIdList();
+                return db.Insertable(list).ExecuteReturnIdentity() > 0;
             }
         }
 
@@ -94,8 +68,7 @@
         {
             if (list == null || list.Count < 1)
                 return default;
-            list.ForEach(x => x.ID = SnowFlakeSingle.instance.NextId());
-            using (SqlSugarClient db = new SqlSugarClient(ConnectionConfig))
+            using (SqlSugarClient db = Connection)
             {
                 return db.Fastest<T>().BulkCopy(list) > 0;
             }
@@ -112,7 +85,7 @@
         {
             if (entity == null)
                 return default;
-            using (SqlSugarClient db = new SqlSugarClient(ConnectionConfig))
+            using (SqlSugarClient db = Connection)
             {
                 return db.Updateable(entity).ExecuteCommand() > 0;
             }
@@ -127,7 +100,7 @@
                 return default;
             if (pros == null || pros.Count < 1)
                 return default;
-            using (SqlSugarClient db = new SqlSugarClient(ConnectionConfig))
+            using (SqlSugarClient db = Connection)
             {
                 return db.Updateable(entity).UpdateColumns(pros.ToArray()).ExecuteCommand() > 0;
             }
@@ -140,7 +113,7 @@
         {
             if (list == null || list.Count < 1)
                 return default;
-            using (SqlSugarClient db = new SqlSugarClient(ConnectionConfig))
+            using (SqlSugarClient db = Connection)
             {
                 return db.Updateable(list).ExecuteCommand() > 0;
             }
@@ -155,7 +128,7 @@
                 return default;
             if (pros == null || pros.Count < 1)
                 return default;
-            using (SqlSugarClient db = new SqlSugarClient(ConnectionConfig))
+            using (SqlSugarClient db = Connection)
             {
                 return db.Updateable(list).UpdateColumns(pros.ToArray()).ExecuteCommand() > 0;
             }
@@ -168,7 +141,7 @@
         {
             if (list == null || list.Count < 1)
                 return default;
-            using (SqlSugarClient db = new SqlSugarClient(ConnectionConfig))
+            using (SqlSugarClient db = Connection)
             {
                 return db.Fastest<T>().BulkUpdate(list) > 0;
             }
@@ -187,7 +160,7 @@
                 return default;
             if (entity.ID < 1)
                 return default;
-            using (SqlSugarClient db = new SqlSugarClient(ConnectionConfig))
+            using (SqlSugarClient db = Connection)
             {
                 return db.Deleteable<T>().Where(entity).ExecuteCommand() > 0;
             }
@@ -202,7 +175,7 @@
                 return default;
             if (list.Exists(x => x.ID < 1))
                 return default;
-            using (SqlSugarClient db = new SqlSugarClient(ConnectionConfig))
+            using (SqlSugarClient db = Connection)
             {
                 return db.Deleteable<T>().Where(list).ExecuteCommand() > 0;
             }
@@ -211,12 +184,12 @@
         /// <summary>
         /// 鏍规嵁鎸囧畾瀵硅薄鐨処D,浠庢暟鎹簱涓垹闄ゆ寚瀹氬璞�
         /// </summary>
-        public virtual bool DeleteByID(long ID)
+        public virtual bool DeleteByID(int ID)
         {
             if (ID < 1)
                 return default;
 
-            using (SqlSugarClient db = new SqlSugarClient(ConnectionConfig))
+            using (SqlSugarClient db = Connection)
             {
                 return db.Deleteable<T>().Where(x => x.ID == ID).ExecuteCommand() > 0;
             }
@@ -225,11 +198,11 @@
         /// <summary>
         /// 閫氳繃id鍒楄〃鍒犻櫎
         /// </summary>
-        public virtual bool DeleteByIds(List<long> ids)
+        public virtual bool DeleteByIds(List<int> ids)
         {
             if (ids == null || ids.Count < 1)
                 return default;
-            using (SqlSugarClient db = new SqlSugarClient(ConnectionConfig))
+            using (SqlSugarClient db = Connection)
             {
                 return db.Deleteable<T>().Where(x => ids.Contains(x.ID)).ExecuteCommand() > 0;
             }
@@ -240,7 +213,7 @@
         /// </summary>
         public virtual bool DeleteAll()
         {
-            using (SqlSugarClient db = new SqlSugarClient(ConnectionConfig))
+            using (SqlSugarClient db = Connection)
             {
                 return db.DbMaintenance.TruncateTable<T>();
             }
@@ -255,7 +228,7 @@
         /// </summary>
         public virtual List<T> GetAll()
         {
-            using (SqlSugarClient db = new SqlSugarClient(ConnectionConfig))
+            using (SqlSugarClient db = Connection)
             {
                 return db.Queryable<T>().ToList();
             }
@@ -264,11 +237,11 @@
         /// <summary>
         /// 鏌ヨ鏁版嵁搴�,杩斿洖鎸囧畾ID鐨勫璞�
         /// </summary>
-        public virtual T GetByID(long id)
+        public virtual T GetByID(int id)
         {
             if (id < 1)
                 return default;
-            using (SqlSugarClient db = new SqlSugarClient(ConnectionConfig))
+            using (SqlSugarClient db = Connection)
             {
                 return db.Queryable<T>().First(x => x.ID == id);
             }
@@ -278,11 +251,11 @@
         /// 閫氭嫇id鍒楄〃鑾峰彇
         /// </summary>
         /// <returns></returns>
-        public virtual List<T> GetByIds(List<long> ids)
+        public virtual List<T> GetByIds(List<int> ids)
         {
             if (ids == null || ids.Count < 1)
                 return default;
-            using (SqlSugarClient db = new SqlSugarClient(ConnectionConfig))
+            using (SqlSugarClient db = Connection)
             {
                 return db.Queryable<T>().OrderBy(x => x.ID).Where(x => ids.Contains(x.ID)).ToList();
             }
@@ -295,9 +268,9 @@
         /// <summary>
         /// 鍒ゆ柇鏁版嵁搴撴槸鍚﹀瓨鍦ㄥ璞�
         /// </summary>
-        public virtual bool Exist(long id)
+        public virtual bool Exist(int id)
         {
-            using (SqlSugarClient db = new SqlSugarClient(ConnectionConfig))
+            using (SqlSugarClient db = Connection)
             {
                 return db.Queryable<T>().Where(x => x.ID == id).Any();
             }
@@ -315,7 +288,7 @@
             if (list == null || list.Count < 1)
                 return default;
 
-            using (SqlSugarClient db = new SqlSugarClient(ConnectionConfig))
+            using (SqlSugarClient db = Connection)
             {
                 db.Ado.BeginTran();
                 db.Deleteable<T>().ExecuteCommand();

--
Gitblit v1.9.3