AreaBLL.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. using LeaRun.Application.Entity.SystemManage;
  2. using LeaRun.Application.IService.SystemManage;
  3. using LeaRun.Application.Service.SystemManage;
  4. using LeaRun.Cache.Factory;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Linq;
  8. namespace LeaRun.Application.Busines.SystemManage
  9. {
  10. /// <summary>
  11. /// 版 本 6.1
  12. /// Copyright (c) 2013-2016 上海力软信息技术有限公司
  13. /// 创建人:佘赐雄
  14. /// 日 期:2015.11.12 16:40
  15. /// 描 述:区域管理
  16. /// </summary>
  17. public class AreaBLL
  18. {
  19. private IAreaService service = new AreaService();
  20. /// <summary>
  21. /// 缓存key
  22. /// </summary>
  23. private string cacheKey = "areaCache";
  24. #region 获取数据
  25. /// <summary>
  26. /// 区域列表
  27. /// </summary>
  28. /// <returns></returns>
  29. public IEnumerable<AreaEntity> GetList()
  30. {
  31. var cacheList = CacheFactory.Cache().GetCache<IEnumerable<AreaEntity>>(cacheKey);
  32. if (cacheList == null)
  33. {
  34. var data = service.GetList();
  35. CacheFactory.Cache().WriteCache(data, cacheKey);
  36. return data;
  37. }
  38. else
  39. {
  40. return cacheList;
  41. }
  42. }
  43. /// <summary>
  44. /// 区域列表
  45. /// </summary>
  46. /// <param name="parentId">节点Id</param>
  47. /// <param name="keyword">关键字查询</param>
  48. /// <returns></returns>
  49. public IEnumerable<AreaEntity> GetList(string parentId, string keyword = "")
  50. {
  51. return service.GetList(parentId, keyword);
  52. }
  53. /// <summary>
  54. /// 区域列表(主要是给绑定数据源提供的)
  55. /// </summary>
  56. /// <param name="parentId">节点Id</param>
  57. /// <returns></returns>
  58. public IEnumerable<AreaEntity> GetAreaList(string parentId)
  59. {
  60. return this.GetList().Where(t => t.EnabledMark == 1 && t.ParentId == parentId);
  61. }
  62. /// <summary>
  63. /// 区域实体
  64. /// </summary>
  65. /// <param name="keyValue">主键值</param>
  66. /// <returns></returns>
  67. public AreaEntity GetEntity(string keyValue)
  68. {
  69. return service.GetEntity(keyValue);
  70. }
  71. #endregion
  72. #region 提交数据
  73. /// <summary>
  74. /// 删除区域
  75. /// </summary>
  76. /// <param name="keyValue">主键</param>
  77. public void RemoveForm(string keyValue)
  78. {
  79. try
  80. {
  81. service.RemoveForm(keyValue);
  82. CacheFactory.Cache().RemoveCache(cacheKey);
  83. }
  84. catch (Exception)
  85. {
  86. throw;
  87. }
  88. }
  89. /// <summary>
  90. /// 保存区域表单(新增、修改)
  91. /// </summary>
  92. /// <param name="keyValue">主键值</param>
  93. /// <param name="{">区域实体</param>
  94. /// <returns></returns>
  95. public void SaveForm(string keyValue, AreaEntity areaEntity)
  96. {
  97. try
  98. {
  99. service.SaveForm(keyValue, areaEntity);
  100. CacheFactory.Cache().RemoveCache(cacheKey);
  101. }
  102. catch (Exception)
  103. {
  104. throw;
  105. }
  106. }
  107. #endregion
  108. }
  109. }