12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- 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
- {
- /// <summary>
- /// 缓存
- /// </summary>
- static WMCache cache = WMCache.GetCacheService();
- public static List<Notice> GetNoticeList()
- {
- string key = string.Format(CacheKeys.Notice);
- List<Notice> list = cache.GetObject<List<Notice>>(key);
- if (list == null)
- {
- list = new List<Notice>();
- var dc = new DataConnect();
- string sql = string.Format(" order by addtime asc");
- list = dc.db.Fetch<Notice>(sql);
- cache.AddObject(key, list, (int)CacheTime.System);
- }
- return list;
- }
- public static List<Notice> GetNoticePage(int pageSize, int pageIndex, out int count)
- {
- var list = GetNoticeList();
- count = list.Count;
- return list == null ? new List<Notice>() : 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();
- }
- }
- }
|