1234567891011121314151617181920212223242526272829303132333435363738394041 |
- 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 ZtPageBll
- {
- /// <summary>
- /// 缓存
- /// </summary>
- static WMCache cache = WMCache.GetCacheService();
- public static List<ZtPage> GetList()
- {
- string key = string.Format(CacheKeys.Zt_Page);
- List<ZtPage> list = cache.GetObject<List<ZtPage>>(key) as List<ZtPage>;
- if (list == null)
- {
- var dc = new DataConnect();
- list = dc.db.Fetch<ZtPage>("where id>0");
- cache.AddObject(key, list, (int)CacheTime.System);
- }
- return list;
- }
- public static ZtPage GetById(int id)
- {
- string key = string.Format(CacheKeys.Zt_Page);
- List<ZtPage> list = GetList();
- if (list == null)
- return new ZtPage();
- return list.SingleOrDefault(m => m.Id == id) ?? new ZtPage();
- }
- }
- }
|