TemplateCache.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using CB.Cache;
  5. using CB.Entity;
  6. namespace CB.Data
  7. {
  8. public partial class Caches
  9. {
  10. /// <summary>
  11. /// 获取模板列表
  12. /// </summary>
  13. /// <returns></returns>
  14. public static IList<TemplateInfo> GetTemplateList()
  15. {
  16. var cache = CBCache.GetCacheService();
  17. IList<TemplateInfo> list = cache.GetObject(CacheKeys.TemplateList) as IList<TemplateInfo>;
  18. if (null == list)
  19. {
  20. list = TemplateService.ToList();
  21. cache.AddObject(CacheKeys.TemplateList, list);
  22. }
  23. return list;
  24. }
  25. /// <summary>
  26. /// 获取模板详情
  27. /// </summary>
  28. /// <param name="tid"></param>
  29. /// <returns></returns>
  30. public static TemplateInfo GetTemplateInfo(int tid)
  31. {
  32. var list = GetTemplateList();
  33. if (null == list || 0 >= list.Count)
  34. return null;
  35. return list.FirstOrDefault(item => tid == item.Id);
  36. }
  37. }
  38. }