TermBLL.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using CP.Cache;
  2. using CP.Model;
  3. using CP.Model.other;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. namespace CP.Business
  10. {
  11. public class TermBLL : DataConnect
  12. {
  13. /// 缓存
  14. /// </summary>
  15. static WMCache cache = WMCache.GetCacheService();
  16. public List<Term> GetList()
  17. {
  18. string key = string.Format(CacheKeys.TermList);
  19. var list = cache.GetObject<List<Term>>(key);
  20. if (list == null)
  21. {
  22. DataConnect dc = new DataConnect();
  23. list= dc.db.Fetch<Term>($" ORDER BY id asc");
  24. cache.AddObject(CacheKeys.TermList, list, (int)CacheTime.System);
  25. }
  26. return list;
  27. }
  28. /// <summary>
  29. /// 获取单个实体类
  30. /// </summary>
  31. /// <param name="id"></param>
  32. /// <returns></returns>
  33. public Term GetTerm(int id) {
  34. string key = string.Format(CacheKeys.TermList);
  35. var list = cache.GetObject<List<Term>>(key);
  36. if (list == null)
  37. {
  38. DataConnect dc = new DataConnect();
  39. list = dc.db.Fetch<Term>($" ORDER BY id asc");
  40. cache.AddObject(CacheKeys.TermList, list, (int)CacheTime.System);
  41. }
  42. return list.Where(p=>p.id==id).ToList()[0];
  43. }
  44. }
  45. }