From a60f3ee45a6b86de936d19a122acdfb30570a867 Mon Sep 17 00:00:00 2001 From: lixiaojun <1287241240@qq.com> Date: 星期三, 17 七月 2024 12:30:49 +0800 Subject: [PATCH] bug修复,优化 --- Yw.Service.Run.Core/07-service/01-configure/RunAnalyConfigure.cs | 64 ++++++++++++++++++++++++++++---- 1 files changed, 56 insertions(+), 8 deletions(-) diff --git a/Yw.Service.Run.Core/07-service/01-configure/RunAnalyConfigure.cs b/Yw.Service.Run.Core/07-service/01-configure/RunAnalyConfigure.cs index db4efaf..738bfa1 100644 --- a/Yw.Service.Run.Core/07-service/01-configure/RunAnalyConfigure.cs +++ b/Yw.Service.Run.Core/07-service/01-configure/RunAnalyConfigure.cs @@ -69,6 +69,14 @@ } //绉婚櫎缂撳瓨 + private static void RemoveCacheByObjectTypeAndObjectID(string ObjectType, long ObjectID) + { + var all = GetCache(); + all.RemoveAll(x => x.ObjectType == ObjectType && x.ObjectID == ObjectID); + RunAnalyConfigureCacheHelper.Trigger(); + } + + //绉婚櫎缂撳瓨 private static void RemoveCache() { RunAnalyConfigureCacheHelper.Remove(); @@ -168,6 +176,26 @@ return false; } + /// <summary> + /// 鎻掑叆鎴栨洿鏂� + /// </summary> + public long InsertOrUpdate(Model.RunAnalyConfigurePure pure) + { + if (pure == null) + { + return default; + } + + var dal = DALCreateHelper.CreateDAL<Yw.DAL.IRunAnalyConfigure>(); + var entity = pure.ToEntity(); + var id = dal.InsertOrUpdate(entity); + if (id > 0) + { + UpdateCache(id); + } + return id; + } + #endregion #region Update @@ -179,11 +207,11 @@ { if (model == null) { - return default; + return false; } if (model.ID < 1) { - return default; + return false; } var dal = DALCreateHelper.CreateDAL<Yw.DAL.IRunAnalyConfigure>(); var entity = Model2Entity(model); @@ -202,14 +230,14 @@ { if (list == null || list.Count < 1) { - return default; + return false; } - if (list.ToList().Exists(x => x.ID < 1)) + if (list.Exists(x => x.ID < 1)) { - return default; + return false; } var dal = DALCreateHelper.CreateDAL<Yw.DAL.IRunAnalyConfigure>(); - var entity_list = Model2Entities(list.ToList()); + var entity_list = Model2Entities(list); var bol = dal.Updates(entity_list); if (bol) { @@ -250,6 +278,21 @@ return bol; } + /// <summary> + /// 閫氳繃 ObjectType 鍜� ObjectID 鍒犻櫎 + /// </summary> + public bool DeleteByObjectTypeAndObjectID(string ObjectType, long ObjectID, out string Msg) + { + Msg = string.Empty; + var dal = DALCreateHelper.CreateDAL<Yw.DAL.IRunAnalyConfigure>(); + var bol = dal.DeleteByObjectTypeAndObjectID(ObjectType, ObjectID); + if (bol) + { + RemoveCacheByObjectTypeAndObjectID(ObjectType, ObjectID); + } + return bol; + } + #endregion #region Set @@ -257,9 +300,14 @@ /// <summary> /// 璁剧疆 /// </summary> - public bool Set(List<Model.RunAnalyConfigure> list) + public bool Set(List<Model.RunAnalyConfigurePure> list, out string Msg) { - var entityList = Model2Entities(list); + Msg = string.Empty; + if (list == null || list.Count < 1) + { + return false; + } + var entityList = list.ToEntityList(); var dal = DALCreateHelper.CreateDAL<Yw.DAL.IRunAnalyConfigure>(); var bol = dal.Set(entityList); if (bol) -- Gitblit v1.9.3