ZtPageBll.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using CP.Cache;
  2. using CP.Model;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. namespace CP.Business
  9. {
  10. public class ZtPageBll
  11. {
  12. /// <summary>
  13. /// 缓存
  14. /// </summary>
  15. static WMCache cache = WMCache.GetCacheService();
  16. public static List<ZtPage> GetList()
  17. {
  18. string key = string.Format(CacheKeys.Zt_Page);
  19. List<ZtPage> list = cache.GetObject<List<ZtPage>>(key) as List<ZtPage>;
  20. if (list == null)
  21. {
  22. var dc = new DataConnect();
  23. list = dc.db.Fetch<ZtPage>("where id>0");
  24. cache.AddObject(key, list, (int)CacheTime.System);
  25. }
  26. return list;
  27. }
  28. public static ZtPage GetById(int id)
  29. {
  30. string key = string.Format(CacheKeys.Zt_Page);
  31. List<ZtPage> list = GetList();
  32. if (list == null)
  33. return new ZtPage();
  34. return list.SingleOrDefault(m => m.Id == id) ?? new ZtPage();
  35. }
  36. }
  37. }