using System; using System.Collections.Generic; using CB.Cache; using CB.Entity; namespace CB.Data { public partial class Caches { /// /// 获取文章分类列表 /// /// public static IList GetTopicClassList() { var cache = CBCache.GetCacheService(); IList list = cache.GetObject(CacheKeys.TopicClasList) as IList; if (null == list) { list = TopicClassService.ToList(); cache.AddObject(CacheKeys.TopicClasList, list); } return list; } /// /// 获取所有子文章分类 /// /// /// public static IList GetTopicClassList(int parendId) { var list = GetTopicClassList(); if (null == list || 0 >= list.Count) return null; IList r = new List(); foreach (var item in list) { if (parendId == item.ParentId) r.Add(item); } return r; } /// /// 获取文章分类详细 /// /// /// public static TopicClassInfo GetTopicClassInfo(int cid) { var list = GetTopicClassList(); if (null == list || 0 >= list.Count) return null; TopicClassInfo entity = null; foreach (var item in list) { if (cid == item.Cid) { entity = item; break; } } return entity; } } }