TbHelpBll.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using CP.Cache;
  2. using CP.Dapper;
  3. using CP.Model;
  4. using MC.ORM;
  5. using MySql.Data.MySqlClient;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Configuration;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Threading.Tasks;
  12. namespace CP.Business
  13. {
  14. public class TbHelpBll : BaseBll
  15. {
  16. /// <summary>
  17. /// 缓存
  18. /// </summary>
  19. static WMCache cache = WMCache.GetCacheService();
  20. public static List<TbHelp> GetHelpList()
  21. {
  22. string key = string.Format(CacheKeys.Help);
  23. List<TbHelp> list = cache.GetObject<List<TbHelp>>(key);
  24. if (list == null)
  25. {
  26. list = new List<TbHelp>();
  27. var dc = new DataConnect();
  28. string sql = string.Format(" order by seq asc");
  29. list = dc.db.Fetch<TbHelp>(sql);
  30. cache.AddObject(key, list, (int)CacheTime.System);
  31. }
  32. return list;
  33. }
  34. public static List<TbHelp> GetHelpPage(int pageSize, int pageIndex,out int count)
  35. {
  36. var list = GetHelpList();
  37. count = list.Count;
  38. return list == null ? new List<TbHelp>() : list.Skip(pageSize * (pageIndex - 1)).Take(pageSize).ToList();
  39. }
  40. public static List<TbHelp> GetCzHelp(int cid)
  41. {
  42. var list = GetHelpList();
  43. return list == null ? new List<TbHelp>() : list.Where(a=>a.cid == cid).ToList();
  44. }
  45. }
  46. }