using CP.Cache; using CP.Model; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace CP.Business { public class NoticeBll : BaseBll { /// /// 缓存 /// static WMCache cache = WMCache.GetCacheService(); public static List GetNoticeList() { string key = string.Format(CacheKeys.Notice); List list = cache.GetObject>(key); if (list == null) { list = new List(); var dc = new DataConnect(); string sql = string.Format(" order by addtime asc"); list = dc.db.Fetch(sql); cache.AddObject(key, list, (int)CacheTime.System); } return list; } public static List GetNoticePage(int pageSize, int pageIndex, out int count) { var list = GetNoticeList(); count = list.Count; return list == null ? new List() : list.Skip(pageSize * (pageIndex - 1)).Take(pageSize).ToList(); } public static Notice GetNotice(int id) { var list = GetNoticeList(); return list == null ? new Notice() : list.Where(a => a.id == id).FirstOrDefault(); } } }