From e78f5936fee9ab4fff600515bb20a41a28f329c4 Mon Sep 17 00:00:00 2001
From: ningshuxia <ningshuxia0927@outlook.com>
Date: 星期一, 12 十二月 2022 10:20:46 +0800
Subject: [PATCH] 更改报表测试接口 文件utf 8

---
 DAL/IStation.DAL.Basic/property/SpecialPropertyMapping.cs |  124 +++++++++++++++++++++++++++++++++++++++++
 1 files changed, 123 insertions(+), 1 deletions(-)

diff --git a/DAL/IStation.DAL.Basic/property/SpecialPropertyMapping.cs b/DAL/IStation.DAL.Basic/property/SpecialPropertyMapping.cs
index 5cbd684..4233dab 100644
--- a/DAL/IStation.DAL.Basic/property/SpecialPropertyMapping.cs
+++ b/DAL/IStation.DAL.Basic/property/SpecialPropertyMapping.cs
@@ -7,7 +7,7 @@
 namespace IStation.DAL
 {
     /// <summary>
-    ///  
+    ///  闄勫姞灞炴�ф槧灏�
     /// </summary>
     public partial class SpecialPropertyMapping : CorpDAL<Entity.SpecialPropertyMapping>
     {
@@ -20,7 +20,129 @@
 
         }
 
+        /// <summary>
+        ///  閫氳繃 CatalogID 鑾峰彇 
+        /// </summary>
+        public List<Entity.SpecialPropertyMapping> GetByCatalogID(long CorpID, long CatalogID)
+        {
+            using (var db = new SqlSugarClient(ConnectionConfig))
+            {
+                return db.Queryable<Entity.SpecialPropertyMapping>()
+                    .Where(x => x.CorpID == CorpID && x.CatalogID == CatalogID).ToList();
+            }
+        }
 
+        /// <summary>
+        ///  閫氳繃 CatalogIds 鑾峰彇 
+        /// </summary>
+        public List<Entity.SpecialPropertyMapping> GetByCatalogIds(long CorpID, List<long> CatalogIds)
+        {
+            if (CatalogIds == null || CatalogIds.Count() < 1)
+                return default;
+            using (var db = new SqlSugarClient(ConnectionConfig))
+            {
+                return db.Queryable<Entity.SpecialPropertyMapping>()
+                    .Where(x => x.CorpID == CorpID && CatalogIds.Contains(x.CatalogID)).ToList();
+            }
+        }
+
+        /// <summary>
+        ///  閫氳繃 PropertyID 鑾峰彇 
+        /// </summary>
+        public List<Entity.SpecialPropertyMapping> GetByPropertyID(long CorpID, long PropertyID)
+        {
+            using (var db = new SqlSugarClient(ConnectionConfig))
+            {
+                return db.Queryable<Entity.SpecialPropertyMapping>()
+                    .Where(x => x.CorpID == CorpID && x.PropertyID == PropertyID).ToList();
+            }
+        }
+
+        /// <summary>
+        ///  閫氳繃 PropertyIds 鑾峰彇 
+        /// </summary>
+        public List<Entity.SpecialPropertyMapping> GetByPropertyIds(long CorpID, List<long> PropertyIds)
+        {
+            if (PropertyIds == null || PropertyIds.Count() < 1)
+                return default;
+            using (var db = new SqlSugarClient(ConnectionConfig))
+            {
+                return db.Queryable<Entity.SpecialPropertyMapping>()
+                    .Where(x => x.CorpID == CorpID && PropertyIds.Contains(x.PropertyID)).ToList();
+            }
+        }
+
+        /// <summary>
+        /// 閫氳繃 CatalogID 鍜� PropertyID 鑾峰彇 
+        /// </summary>
+        public Entity.SpecialPropertyMapping GetByCatalogIDAndPropertyID(long CorpID, long CatalogID, long PropertyID)
+        {
+            using (var db = new SqlSugarClient(ConnectionConfig))
+            {
+                return db.Queryable<Entity.SpecialPropertyMapping>()
+                    .First(x => x.CorpID == CorpID && x.CatalogID == CatalogID && x.PropertyID == PropertyID);
+            }
+        }
+
+        /// <summary>
+        /// 璁剧疆
+        /// </summary>
+        public bool Set(List<Entity.SpecialPropertyMappingSelected> list)
+        {
+            if (list == null || list.Count() < 1)
+                return false;
+            var corpIds = list.Select(x => x.CorpID).Distinct().ToList();
+            if (corpIds.Count != 1)
+                return false;
+            using (var db = new SqlSugarClient(ConnectionConfig))
+            {
+                try
+                {
+                    db.BeginTran();
+                    foreach (var item in list)
+                    {
+                        var bol = db.Queryable<Entity.SpecialPropertyMapping>()
+                            .Where(x => x.CorpID == item.CorpID && x.CatalogID == item.CatalogID && x.PropertyID == item.PropertyID).Count() > 0;
+                        if (bol)//宸插瓨鍦�
+                        {
+                            if (!item.Selected)//鏈�夋嫨
+                            {
+                                var result = db.Deleteable<Entity.SpecialPropertyMapping>()
+                                    .Where(x => x.CorpID == item.CorpID && x.CatalogID == item.CatalogID && x.PropertyID == item.PropertyID).ExecuteCommandHasChange();
+                                if (!result)
+                                {
+                                    db.RollbackTran();
+                                    return false;
+                                }
+                            }
+                        }
+                        else//涓嶅瓨鍦�
+                        {
+                            if (item.Selected)//閫夋嫨
+                            {
+                                var entity = new Entity.SpecialPropertyMapping();
+                                entity.CorpID = item.CorpID;
+                                entity.CatalogID = item.CatalogID;
+                                entity.PropertyID = item.PropertyID;
+                                var id = db.Insertable(entity).ExecuteReturnSnowflakeId();
+                                if (id < 1)
+                                {
+                                    db.RollbackTran();
+                                    return false;
+                                }
+                            }
+                        }
+                    }
+                    db.CommitTran();
+                    return true;
+                }
+                catch
+                {
+                    db.RollbackTran();
+                    throw;
+                }
+            }
+        }
 
 
     }

--
Gitblit v1.9.3