From bce72e28513fface09c5a777e26b010afb17ac28 Mon Sep 17 00:00:00 2001
From: lixiaojun <1287241240@qq.com>
Date: 星期三, 04 十二月 2024 20:00:42 +0800
Subject: [PATCH] 增加删除方法

---
 Yw.Service.Bimface.Core/04-dal/02-postgresql/BimfaceFile.cs |   67 ++++++++++++++++++++++++++++++---
 1 files changed, 60 insertions(+), 7 deletions(-)

diff --git a/Yw.Service.Bimface.Core/04-dal/02-postgresql/BimfaceFile.cs b/Yw.Service.Bimface.Core/04-dal/02-postgresql/BimfaceFile.cs
index fe041e6..1016106 100644
--- a/Yw.Service.Bimface.Core/04-dal/02-postgresql/BimfaceFile.cs
+++ b/Yw.Service.Bimface.Core/04-dal/02-postgresql/BimfaceFile.cs
@@ -3,7 +3,7 @@
     /// <summary>
     /// 
     /// </summary>
-    public partial class BimfaceFile : BaseTraceDAL_Paras_Flags_TagName_Sorter<Entity.BimfaceFile>, IBimfaceFile
+    public partial class BimfaceFile : BaseDAL_Paras_Flags_TagName_Sorter<Entity.BimfaceFile>, IBimfaceFile
     {
         /// <summary>
         /// 
@@ -11,7 +11,66 @@
         public override ConnectionConfig ConnectionConfig
         {
             get { return ConfigHelper.PostgreSqlConnectionConfig; }
+        }
 
+        /// <summary>
+        /// 鎻掑叆鎷撳睍
+        /// </summary>
+        public long InsertEx(Entity.BimfaceFile entity, List<Entity.BimfaceFileLabel> entityLabelList)
+        {
+            if (entity == null)
+            {
+                return default;
+            }
+            using (var db = new SqlSugarClient(ConnectionConfig))
+            {
+                try
+                {
+                    db.BeginTran();
+                    if (entity.ID > 0)
+                    {
+                        var bol = db.Insertable(entity).ExecuteCommand() > 0;
+                        if (!bol)
+                        {
+                            db.RollbackTran();
+                            return default;
+                        }
+                    }
+                    else
+                    {
+                        entity.ID = db.Insertable(entity).ExecuteReturnSnowflakeId();
+                    }
+                    if (entity.ID < 1)
+                    {
+                        db.RollbackTran();
+                        return default;
+                    }
+                    if (entityLabelList != null && entityLabelList.Count > 0)
+                    {
+                        entityLabelList.ForEach(x =>
+                        {
+                            x.BimfaceFileID = entity.ID;
+                            if (x.ID < 1)
+                            {
+                                x.ID = SnowFlakeSingle.instance.NextId();
+                            }
+                        });
+                        var bol = db.Insertable(entityLabelList).ExecuteCommand() > 0;
+                        if (!bol)
+                        {
+                            db.RollbackTran();
+                            return default;
+                        }
+                    }
+                    db.CommitTran();
+                    return entity.ID;
+                }
+                catch
+                {
+                    db.RollbackTran();
+                    throw;
+                }
+            }
         }
 
         /// <summary>
@@ -23,9 +82,6 @@
             {
                 return db.Updateable<Entity.BimfaceFile>()
                     .SetColumns(x => x.FileStatus == FileStatus)
-                    .SetColumns(x => x.UpdateUserID == UserRegister.UserID)
-                    .SetColumns(x => x.UpdateTime == DateTime.Now)
-                    .SetColumns(x => x.UpdateUserName == UserRegister.UserName)
                     .Where(x => x.ID == ID)
                     .ExecuteCommandHasChange();
             }
@@ -40,9 +96,6 @@
             {
                 return db.Updateable<Entity.BimfaceFile>()
                     .SetColumns(x => x.Content == Content)
-                    .SetColumns(x => x.UpdateUserID == UserRegister.UserID)
-                    .SetColumns(x => x.UpdateTime == DateTime.Now)
-                    .SetColumns(x => x.UpdateUserName == UserRegister.UserName)
                     .Where(x => x.ID == ID)
                     .ExecuteCommandHasChange();
             }

--
Gitblit v1.9.3