From 1c4cce22f78300a8b1a55f328006443ab42623a5 Mon Sep 17 00:00:00 2001 From: lixiaojun <1287241240@qq.com> Date: 星期三, 29 五月 2024 13:36:47 +0800 Subject: [PATCH] 新增复制功能 --- Yw.Service.Bimface.Core/04-dal/03-sqlite/BimfaceFileRelation.cs | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 60 insertions(+), 0 deletions(-) diff --git a/Yw.Service.Bimface.Core/04-dal/03-sqlite/BimfaceFileRelation.cs b/Yw.Service.Bimface.Core/04-dal/03-sqlite/BimfaceFileRelation.cs index 40654aa..e9ace46 100644 --- a/Yw.Service.Bimface.Core/04-dal/03-sqlite/BimfaceFileRelation.cs +++ b/Yw.Service.Bimface.Core/04-dal/03-sqlite/BimfaceFileRelation.cs @@ -15,6 +15,66 @@ } /// <summary> + /// 鎻掑叆鎷撳睍 + /// </summary> + public long InsertEx(Entity.BimfaceFileRelation entity, List<Entity.BimfaceFileRelationLabel> 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.RelationID = 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> /// 鏇存柊 Purpose /// </summary> public bool UpdatePurpose(long ID, string Purpose) -- Gitblit v1.9.3