ningshuxia
2023-02-24 1e4b358de58e36bfbf692ab2538ff9e7d60fd025
BLL/IStation.BLL.Logic/logic_tree/LogicTree.cs
@@ -21,7 +21,7 @@
        {
            return LogicTreeCacheHelper.GetSet(projectId, () =>
            {
                var entities = _dal.QueryAll(projectId);
                var entities = _dal.GetAll(projectId);
                var models = Entity2Models(entities);
                if (models == null)
                {
@@ -34,7 +34,7 @@
        //根据 Id 更新缓存
        private void UpdateProjectCache(long projectId, long Id)
        {
            var entity_ds = _dal.QueryById(projectId, Id);
            var entity_ds = _dal.GetById(projectId, Id);
            var model_ds = Entity2Model(entity_ds);
            var all = GetProjectCache(projectId);
            var model = all.Find(x => x.Id == Id);
@@ -53,7 +53,7 @@
        {
            if (Ids == null || Ids.Count() < 1)
                return;
            var entities = _dal.QueryByIds(projectId, Ids);
            var entities = _dal.GetByIds(projectId, Ids);
            var models = Entity2Models(entities);
            var all = GetProjectCache(projectId);
            all.RemoveAll(x => Ids.Contains(x.Id));
@@ -72,12 +72,12 @@
        #endregion
        #region Query
        #region Get
        /// <summary>
        /// 查询全部
        /// </summary>
        public List<Model.LogicTree> QueryAll(long projectId)
        public List<Model.LogicTree> GetAll(long projectId)
        {
            var all = GetProjectCache(projectId);
            return all.OrderBy(x => x.SortCode).ToList();
@@ -86,21 +86,31 @@
        /// <summary>
        /// 根据 Id查询
        /// </summary>
        public Model.LogicTree QueryById(long projectId, long Id)
        public Model.LogicTree GetById(long projectId, long Id)
        {
            var all = QueryAll(projectId);
            var all = GetAll(projectId);
            return all.Find(x => x.Id == Id);
        }
        /// <summary>
        /// 根据 Ids 查询
        /// </summary>
        public List<Model.LogicTree> QueryByIds(long projectId, IEnumerable<long> Ids)
        public List<Model.LogicTree> GetByIds(long projectId, IEnumerable<long> Ids)
        {
            if (Ids == null || Ids.Count() < 1)
                return default;
            var all = QueryAll(projectId);
            var all = GetAll(projectId);
            return all.Where(x => Ids.Contains(x.Id)).ToList();
        }
        /// <summary>
        /// 根据 LogicType LogicId 查询
        /// </summary>
        public Model.LogicTree GetByLogicTypeAndLogicId(long projectId, string logicType, long logicId)
        {
            var all = GetAll(projectId);
            return all.Find(x => x.LogicType == logicType&&x.LogicId== logicId);
        }
        #endregion
@@ -196,7 +206,7 @@
        /// </summary>
        public bool IsExistById(long projectId, long Id)
        {
            var all = QueryAll(projectId);
            var all = GetAll(projectId);
            return all.Exists(x => x.Id == Id);
        } 
        #endregion