You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

224 lines
6.6 KiB

  1. using Learun.Cache.Base;
  2. using Learun.Cache.Factory;
  3. using Learun.Util;
  4. using System;
  5. using System.Collections.Generic;
  6. namespace Learun.Application.Base.SystemModule
  7. {
  8. /// <summary>
  9. /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
  10. /// Copyright (c) 2013-2018 北京泉江科技有限公司
  11. /// 创建人:陈彬彬
  12. /// 日 期:2017.04.01
  13. /// 描 述:接口管理
  14. /// </summary>
  15. public class InterfaceBLL : InterfaceIBLL
  16. {
  17. private InterfaceService interfaceService = new InterfaceService();
  18. private ICache cache = CacheFactory.CaChe();
  19. private string cacheKey = "Learun_adms_interface";
  20. #region 获取数据
  21. /// <summary>
  22. /// 获取列表数据
  23. /// </summary>
  24. /// <returns></returns>
  25. public List<InterfaceEntity> GetList()
  26. {
  27. try
  28. {
  29. List<InterfaceEntity> list = cache.Read<List<InterfaceEntity>>(cacheKey, CacheId.Interface);
  30. if (list == null)
  31. {
  32. list = (List<InterfaceEntity>)interfaceService.GetList();
  33. cache.Write<List<InterfaceEntity>>(cacheKey, list, CacheId.Interface);
  34. }
  35. return list;
  36. }
  37. catch (Exception ex)
  38. {
  39. if (ex is ExceptionEx)
  40. {
  41. throw;
  42. }
  43. else
  44. {
  45. throw ExceptionEx.ThrowBusinessException(ex);
  46. }
  47. }
  48. }
  49. /// <summary>
  50. /// 获取树形数据列表
  51. /// </summary>
  52. /// <returns></returns>
  53. public List<TreeModel> GetTree()
  54. {
  55. try
  56. {
  57. List<InterfaceEntity> list = GetList();
  58. List<TreeModel> treeList = new List<TreeModel>();
  59. foreach (var item in list)
  60. {
  61. TreeModel node = new TreeModel();
  62. node.id = item.F_Id;
  63. node.text = item.F_Name;
  64. node.value = item.F_Name;
  65. node.showcheck = false;
  66. node.checkstate = 0;
  67. node.isexpand = true;
  68. node.parentId = "0";
  69. treeList.Add(node);
  70. }
  71. return treeList.ToTree();
  72. }
  73. catch (Exception ex)
  74. {
  75. if (ex is ExceptionEx)
  76. {
  77. throw;
  78. }
  79. else
  80. {
  81. throw ExceptionEx.ThrowBusinessException(ex);
  82. }
  83. }
  84. }
  85. /// <summary>
  86. /// 获取分页列表
  87. /// </summary>
  88. /// <param name="pagination">分页参数</param>
  89. /// <param name="keyword">关键词</param>
  90. /// <returns></returns>
  91. public List<InterfaceEntity> GetPageList(Pagination pagination, string keyword)
  92. {
  93. try
  94. {
  95. List<InterfaceEntity> list = GetList();
  96. if (!string.IsNullOrEmpty(keyword))
  97. {
  98. list = list.FindAll(t => t.F_Name.ContainsEx(keyword) || t.F_Address.ContainsEx(keyword));
  99. }
  100. return list;
  101. }
  102. catch (Exception ex)
  103. {
  104. if (ex is ExceptionEx)
  105. {
  106. throw;
  107. }
  108. else
  109. {
  110. throw ExceptionEx.ThrowBusinessException(ex);
  111. }
  112. }
  113. }
  114. /// <summary>
  115. /// 获取实体数据
  116. /// </summary>
  117. /// <param name="keyValue">主键</param>
  118. /// <returns></returns>
  119. public InterfaceEntity GetEntity(string keyValue)
  120. {
  121. try
  122. {
  123. List<InterfaceEntity> list = GetList();
  124. return list.Find(t => t.F_Id == keyValue);
  125. }
  126. catch (Exception ex)
  127. {
  128. if (ex is ExceptionEx)
  129. {
  130. throw;
  131. }
  132. else
  133. {
  134. throw ExceptionEx.ThrowBusinessException(ex);
  135. }
  136. }
  137. }
  138. /// <summary>
  139. /// 获取实体数据
  140. /// </summary>
  141. /// <param name="url">接口地址</param>
  142. /// <returns></returns>
  143. public InterfaceEntity GetEntityByUrl(string url)
  144. {
  145. try
  146. {
  147. if (url.Contains("?"))
  148. {
  149. if (!url.Contains("/LR_FormModule/FormRelation/PreviewIndex"))
  150. {
  151. url = url.Substring(0, url.IndexOf('?'));
  152. }
  153. }
  154. List<InterfaceEntity> list = GetList();
  155. return list.Find(t => t.F_Address == url);
  156. }
  157. catch (Exception ex)
  158. {
  159. if (ex is ExceptionEx)
  160. {
  161. throw;
  162. }
  163. else
  164. {
  165. throw ExceptionEx.ThrowBusinessException(ex);
  166. }
  167. }
  168. }
  169. #endregion
  170. #region 提交数据
  171. /// <summary>
  172. /// 虚拟删除分类数据
  173. /// </summary>
  174. /// <param name="keyValue">主键</param>
  175. public void DeleteEntity(string keyValue)
  176. {
  177. try
  178. {
  179. cache.Remove(cacheKey, CacheId.Interface);
  180. interfaceService.DeleteEntity(keyValue);
  181. }
  182. catch (Exception ex)
  183. {
  184. if (ex is ExceptionEx)
  185. {
  186. throw;
  187. }
  188. else
  189. {
  190. throw ExceptionEx.ThrowBusinessException(ex);
  191. }
  192. }
  193. }
  194. /// <summary>
  195. /// 保存分类数据实体
  196. /// </summary>
  197. /// <param name="keyValue">主键</param>
  198. /// <param name="entity">实体</param>
  199. public void SaveEntity(string keyValue, InterfaceEntity entity)
  200. {
  201. try
  202. {
  203. cache.Remove(cacheKey, CacheId.Interface);
  204. interfaceService.SaveEntity(keyValue, entity);
  205. }
  206. catch (Exception ex)
  207. {
  208. if (ex is ExceptionEx)
  209. {
  210. throw;
  211. }
  212. else
  213. {
  214. throw ExceptionEx.ThrowBusinessException(ex);
  215. }
  216. }
  217. }
  218. #endregion
  219. }
  220. }