wangzelong
2022-11-30 44e4286e0384f8daf9b89e8f551f0f743b60ebb3
Service/IStation.Service.Basic/property/special_property_value/SpecialPropertyValue.cs
@@ -66,6 +66,22 @@
            }
        }
        //通过 PropertyIds 更新缓存
        private void UpdateCorpCacheByPropertyIds(long CorpID, List<long> PropertyIds)
        {
            if (PropertyIds == null || PropertyIds.Count() < 1)
                return;
            var dal = new DAL.SpecialPropertyValue();
            var entity_list = dal.GetByPropertyIds(CorpID, PropertyIds);
            var model_list = Entity2Models(entity_list);
            var all = GetCorpCache(CorpID);
            all.RemoveAll(x => PropertyIds.Contains(x.PropertyID));
            if (model_list != null && model_list.Count > 0)
            {
                all.AddRange(model_list);
            }
        }
        //通过 ID 移除缓存
        private void RemoveCorpCache(long CorpID, long ID)
        {
@@ -250,6 +266,29 @@
        #endregion
        #region Set
        /// <summary>
        /// 设置
        /// </summary>
        public bool Set(List<Model.SpecialPropertyValueSetter> list)
        {
            if (list == null || list.Count() < 1)
                return false;
            var corpIds = list.Select(x => x.CorpID).Distinct().ToList();
            if (corpIds.Count != 1 || corpIds[0] < 1)
                return false;
            var dal = new DAL.SpecialPropertyValue();
            var bol = dal.Set(list.ToEntityList());
            if (bol)
            {
                UpdateCorpCacheByPropertyIds(corpIds[0], list.Select(x => x.PropertyID).ToList());
            }
            return bol;
        }
        #endregion
    }
}