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.
 
 
 
 
 
 

280 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. /// <summary>
  25. /// 获取页面显示列表数据
  26. /// <summary>
  27. /// <param name="queryJson">查询参数</param>
  28. /// <returns></returns>
  29. public IEnumerable<CdDeptEntity> GetPageList(Pagination pagination, string queryJson)
  30. {
  31. try
  32. {
  33. return cdDeptService.GetPageList(pagination, queryJson);
  34. }
  35. catch (Exception ex)
  36. {
  37. if (ex is ExceptionEx)
  38. {
  39. throw;
  40. }
  41. else
  42. {
  43. throw ExceptionEx.ThrowBusinessException(ex);
  44. }
  45. }
  46. }
  47. /// <summary>
  48. /// 获取CdDept表实体数据
  49. /// <param name="keyValue">主键</param>
  50. /// <summary>
  51. /// <returns></returns>
  52. public CdDeptEntity GetCdDeptEntity(string keyValue)
  53. {
  54. try
  55. {
  56. return cdDeptService.GetCdDeptEntity(keyValue);
  57. }
  58. catch (Exception ex)
  59. {
  60. if (ex is ExceptionEx)
  61. {
  62. throw;
  63. }
  64. else
  65. {
  66. throw ExceptionEx.ThrowBusinessException(ex);
  67. }
  68. }
  69. }
  70. /// <summary>
  71. /// 获取CdDept表实体数据
  72. /// <param name="deptNo">系部编号</param>
  73. /// <summary>
  74. /// <returns></returns>
  75. public CdDeptEntity GetCdDeptEntityByNo(string deptNo)
  76. {
  77. try
  78. {
  79. return cdDeptService.GetCdDeptEntityByNo(deptNo);
  80. }
  81. catch (Exception ex)
  82. {
  83. if (ex is ExceptionEx)
  84. {
  85. throw;
  86. }
  87. else
  88. {
  89. throw ExceptionEx.ThrowBusinessException(ex);
  90. }
  91. }
  92. }
  93. public bool GetAny()
  94. {
  95. try
  96. {
  97. return cdDeptService.GetAny();
  98. }
  99. catch (Exception ex)
  100. {
  101. if (ex is ExceptionEx)
  102. {
  103. throw;
  104. }
  105. else
  106. {
  107. throw ExceptionEx.ThrowBusinessException(ex);
  108. }
  109. }
  110. }
  111. #endregion
  112. #region 提交数据
  113. /// <summary>
  114. /// 删除实体数据
  115. /// <param name="keyValue">主键</param>
  116. /// <summary>
  117. /// <returns></returns>
  118. public void DeleteEntity(string keyValue)
  119. {
  120. try
  121. {
  122. cdDeptService.DeleteEntity(keyValue);
  123. }
  124. catch (Exception ex)
  125. {
  126. if (ex is ExceptionEx)
  127. {
  128. throw;
  129. }
  130. else
  131. {
  132. throw ExceptionEx.ThrowBusinessException(ex);
  133. }
  134. }
  135. }
  136. /// <summary>
  137. /// 保存实体数据(新增、修改)
  138. /// <param name="keyValue">主键</param>
  139. /// <summary>
  140. /// <returns></returns>
  141. public void SaveEntity(string keyValue, CdDeptEntity entity)
  142. {
  143. try
  144. {
  145. cdDeptService.SaveEntity(keyValue, entity);
  146. }
  147. catch (Exception ex)
  148. {
  149. if (ex is ExceptionEx)
  150. {
  151. throw;
  152. }
  153. else
  154. {
  155. throw ExceptionEx.ThrowBusinessException(ex);
  156. }
  157. }
  158. }
  159. public IEnumerable<CdDeptEntity> GetListBySchoolId(string schoolId)
  160. {
  161. try
  162. {
  163. return cdDeptService.GetListBySchoolId(schoolId);
  164. }
  165. catch (Exception ex)
  166. {
  167. if (ex is ExceptionEx)
  168. {
  169. throw;
  170. }
  171. else
  172. {
  173. throw ExceptionEx.ThrowBusinessException(ex);
  174. }
  175. }
  176. }
  177. public IEnumerable<CdDeptEntity> GetAllList()
  178. {
  179. try
  180. {
  181. return cdDeptService.GetAllList();
  182. }
  183. catch (Exception ex)
  184. {
  185. if (ex is ExceptionEx)
  186. {
  187. throw;
  188. }
  189. else
  190. {
  191. throw ExceptionEx.ThrowBusinessException(ex);
  192. }
  193. }
  194. }
  195. #endregion
  196. #region 扩展数据
  197. /// <summary>
  198. /// 获取列表数据
  199. /// </summary>
  200. /// <returns></returns>
  201. public List<CdDeptEntity> GetList()
  202. {
  203. try
  204. {
  205. List<CdDeptEntity> list = cache.Read<List<CdDeptEntity>>(cacheKey);
  206. if (list == null)
  207. {
  208. list = (List<CdDeptEntity>)cdDeptService.GetList();
  209. cache.Write<List<CdDeptEntity>>(cacheKey, list, CacheId.company);
  210. }
  211. return list;
  212. }
  213. catch (Exception ex)
  214. {
  215. if (ex is ExceptionEx)
  216. {
  217. throw;
  218. }
  219. else
  220. {
  221. throw ExceptionEx.ThrowBusinessException(ex);
  222. }
  223. }
  224. }
  225. public List<TreeModel> GetTree(string parentId)
  226. {
  227. try
  228. {
  229. List<CdDeptEntity> list = GetList();
  230. List<TreeModel> treeList = new List<TreeModel>();
  231. foreach (var item in list)
  232. {
  233. TreeModel node = new TreeModel
  234. {
  235. id = item.DeptNo,
  236. text = item.DeptName,
  237. value = item.DeptNo,
  238. showcheck = false,
  239. checkstate = 0,
  240. isexpand = true,
  241. parentId = item.DeptId
  242. };
  243. treeList.Add(node);
  244. }
  245. return treeList.ToTree();
  246. }
  247. catch (Exception ex)
  248. {
  249. if (ex is ExceptionEx)
  250. {
  251. throw;
  252. }
  253. else
  254. {
  255. throw ExceptionEx.ThrowBusinessException(ex);
  256. }
  257. }
  258. }
  259. #endregion
  260. }
  261. }