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.
 
 
 
 
 
 

275 lines
7.3 KiB

  1. using Learun.Util;
  2. using System;
  3. using System.Data;
  4. using System.Collections.Generic;
  5. using Learun.Cache.Base;
  6. using Learun.Cache.Factory;
  7. namespace Learun.Application.TwoDevelopment.EducationalAdministration
  8. {
  9. /// <summary>
  10. /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
  11. /// Copyright (c) 2013-2018 北京泉江科技有限公司
  12. /// 创 建:超级管理员
  13. /// 日 期:2019-01-22 10:53
  14. /// 描 述:系部信息管理
  15. /// </summary>
  16. public class CdDeptBLL : CdDeptIBLL
  17. {
  18. private CdDeptService cdDeptService = new CdDeptService();
  19. #region 缓存定义
  20. private ICache cache = CacheFactory.CaChe();
  21. private string cacheKey = "Learun_adms_cddept";
  22. #endregion
  23. #region 获取数据
  24. public List<TreeModel> GetTree(string parentId)
  25. {
  26. try
  27. {
  28. List<CdDeptEntity> list = GetList();
  29. List<TreeModel> treeList = new List<TreeModel>();
  30. foreach (var item in list)
  31. {
  32. TreeModel node = new TreeModel
  33. {
  34. id = item.DeptNo,
  35. text = item.DeptName,
  36. value = item.DeptNo,
  37. showcheck = false,
  38. checkstate = 0,
  39. isexpand = true,
  40. parentId = item.DeptId
  41. };
  42. treeList.Add(node);
  43. }
  44. return treeList.ToTree();
  45. }
  46. catch (Exception ex)
  47. {
  48. if (ex is ExceptionEx)
  49. {
  50. throw;
  51. }
  52. else
  53. {
  54. throw ExceptionEx.ThrowBusinessException(ex);
  55. }
  56. }
  57. }
  58. /// <summary>
  59. /// 获取列表数据
  60. /// </summary>
  61. /// <returns></returns>
  62. public List<CdDeptEntity> GetList()
  63. {
  64. try
  65. {
  66. List<CdDeptEntity> list = cache.Read<List<CdDeptEntity>>(cacheKey);
  67. if (list == null)
  68. {
  69. list = (List<CdDeptEntity>)cdDeptService.GetList();
  70. cache.Write<List<CdDeptEntity>>(cacheKey, list, CacheId.company);
  71. }
  72. return list;
  73. }
  74. catch (Exception ex)
  75. {
  76. if (ex is ExceptionEx)
  77. {
  78. throw;
  79. }
  80. else
  81. {
  82. throw ExceptionEx.ThrowBusinessException(ex);
  83. }
  84. }
  85. }
  86. /// <summary>
  87. /// 获取页面显示列表数据
  88. /// <summary>
  89. /// <param name="queryJson">查询参数</param>
  90. /// <returns></returns>
  91. public IEnumerable<CdDeptEntity> GetPageList(Pagination pagination, string queryJson)
  92. {
  93. try
  94. {
  95. return cdDeptService.GetPageList(pagination, queryJson);
  96. }
  97. catch (Exception ex)
  98. {
  99. if (ex is ExceptionEx)
  100. {
  101. throw;
  102. }
  103. else
  104. {
  105. throw ExceptionEx.ThrowBusinessException(ex);
  106. }
  107. }
  108. }
  109. /// <summary>
  110. /// 获取CdDept表实体数据
  111. /// <param name="keyValue">主键</param>
  112. /// <summary>
  113. /// <returns></returns>
  114. public CdDeptEntity GetCdDeptEntity(string keyValue)
  115. {
  116. try
  117. {
  118. return cdDeptService.GetCdDeptEntity(keyValue);
  119. }
  120. catch (Exception ex)
  121. {
  122. if (ex is ExceptionEx)
  123. {
  124. throw;
  125. }
  126. else
  127. {
  128. throw ExceptionEx.ThrowBusinessException(ex);
  129. }
  130. }
  131. }
  132. /// <summary>
  133. /// 获取CdDept表实体数据
  134. /// <param name="deptNo">系部编号</param>
  135. /// <summary>
  136. /// <returns></returns>
  137. public CdDeptEntity GetCdDeptEntityByNo(string deptNo)
  138. {
  139. try
  140. {
  141. return cdDeptService.GetCdDeptEntityByNo(deptNo);
  142. }
  143. catch (Exception ex)
  144. {
  145. if (ex is ExceptionEx)
  146. {
  147. throw;
  148. }
  149. else
  150. {
  151. throw ExceptionEx.ThrowBusinessException(ex);
  152. }
  153. }
  154. }
  155. public bool GetAny()
  156. {
  157. try
  158. {
  159. return cdDeptService.GetAny();
  160. }
  161. catch (Exception ex)
  162. {
  163. if (ex is ExceptionEx)
  164. {
  165. throw;
  166. }
  167. else
  168. {
  169. throw ExceptionEx.ThrowBusinessException(ex);
  170. }
  171. }
  172. }
  173. #endregion
  174. #region 提交数据
  175. /// <summary>
  176. /// 删除实体数据
  177. /// <param name="keyValue">主键</param>
  178. /// <summary>
  179. /// <returns></returns>
  180. public void DeleteEntity(string keyValue)
  181. {
  182. try
  183. {
  184. cdDeptService.DeleteEntity(keyValue);
  185. }
  186. catch (Exception ex)
  187. {
  188. if (ex is ExceptionEx)
  189. {
  190. throw;
  191. }
  192. else
  193. {
  194. throw ExceptionEx.ThrowBusinessException(ex);
  195. }
  196. }
  197. }
  198. /// <summary>
  199. /// 保存实体数据(新增、修改)
  200. /// <param name="keyValue">主键</param>
  201. /// <summary>
  202. /// <returns></returns>
  203. public void SaveEntity(string keyValue, CdDeptEntity entity)
  204. {
  205. try
  206. {
  207. cdDeptService.SaveEntity(keyValue, entity);
  208. }
  209. catch (Exception ex)
  210. {
  211. if (ex is ExceptionEx)
  212. {
  213. throw;
  214. }
  215. else
  216. {
  217. throw ExceptionEx.ThrowBusinessException(ex);
  218. }
  219. }
  220. }
  221. public IEnumerable<CdDeptEntity> GetListBySchoolId(string schoolId)
  222. {
  223. try
  224. {
  225. return cdDeptService.GetListBySchoolId(schoolId);
  226. }
  227. catch (Exception ex)
  228. {
  229. if (ex is ExceptionEx)
  230. {
  231. throw;
  232. }
  233. else
  234. {
  235. throw ExceptionEx.ThrowBusinessException(ex);
  236. }
  237. }
  238. }
  239. public IEnumerable<CdDeptEntity> GetAllList()
  240. {
  241. try
  242. {
  243. return cdDeptService.GetAllList();
  244. }
  245. catch (Exception ex)
  246. {
  247. if (ex is ExceptionEx)
  248. {
  249. throw;
  250. }
  251. else
  252. {
  253. throw ExceptionEx.ThrowBusinessException(ex);
  254. }
  255. }
  256. }
  257. #endregion
  258. }
  259. }