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.
 
 
 
 
 
 

291 lines
8.8 KiB

  1. using Learun.Application.Base.AuthorizeModule;
  2. using Learun.Application.Base.SystemModule;
  3. using Learun.Util;
  4. using System;
  5. using System.Collections.Generic;
  6. using Learun.Application.AppMagager.Function;
  7. namespace Learun.Application.AppMagager
  8. {
  9. /// <summary>
  10. /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
  11. /// Copyright (c) 2013-2018 北京泉江科技有限公司
  12. /// 创建人:陈彬彬
  13. /// 日 期:2018.03.16
  14. /// 描 述:移动端功能管理
  15. /// </summary>
  16. public class FunctionBLL: FunctionIBLL
  17. {
  18. private FunctionSerivce functionSerivce = new FunctionSerivce();
  19. private DataItemIBLL dataItemIBLL = new DataItemBLL();
  20. private AuthorizeIBLL authorizeIBLL = new AuthorizeBLL();
  21. #region 获取数据
  22. public IEnumerable<DesktopEntity> GetDesktopList(string type)
  23. {
  24. try
  25. {
  26. return functionSerivce.GetDesktopList(type);
  27. }
  28. catch (Exception ex)
  29. {
  30. if (ex is ExceptionEx)
  31. {
  32. throw;
  33. }
  34. else
  35. {
  36. throw ExceptionEx.ThrowBusinessException(ex);
  37. }
  38. }
  39. }
  40. /// <summary>
  41. /// 获取分页列表
  42. /// </summary>
  43. /// <param name="pagination">分页参数</param>
  44. /// <param name="keyword">关键字</param>
  45. /// <param name="type">分类</param>
  46. /// <returns></returns>
  47. public IEnumerable<FunctionEntity> GetPageList(Pagination pagination, string keyword, string type)
  48. {
  49. try
  50. {
  51. return functionSerivce.GetPageList(pagination, keyword, type);
  52. }
  53. catch (Exception ex)
  54. {
  55. if (ex is ExceptionEx)
  56. {
  57. throw;
  58. }
  59. else
  60. {
  61. throw ExceptionEx.ThrowBusinessException(ex);
  62. }
  63. }
  64. }
  65. /// <summary>
  66. /// 获取列表数据
  67. /// </summary>
  68. /// <returns></returns>
  69. public IEnumerable<FunctionEntity> GetList(UserInfo userInfo)
  70. {
  71. try
  72. {
  73. List<FunctionEntity> list = (List<FunctionEntity>)functionSerivce.GetList();
  74. /*关联权限*/
  75. if (!userInfo.isSystem)
  76. {
  77. string objectIds = userInfo.userId + (string.IsNullOrEmpty(userInfo.roleIds) ? "" : ("," + userInfo.roleIds));
  78. List<string> itemIdList = authorizeIBLL.GetItemIdListByobjectIds(objectIds, 5);
  79. list = list.FindAll(t => itemIdList.IndexOf(t.F_Id) >= 0);
  80. }
  81. return list;
  82. }
  83. catch (Exception ex)
  84. {
  85. if (ex is ExceptionEx)
  86. {
  87. throw;
  88. }
  89. else
  90. {
  91. throw ExceptionEx.ThrowBusinessException(ex);
  92. }
  93. }
  94. }
  95. /// <summary>
  96. /// 获取实体对象
  97. /// </summary>
  98. /// <param name="keyValue">主键</param>
  99. /// <returns></returns>
  100. public FunctionEntity GetEntity(string keyValue)
  101. {
  102. try
  103. {
  104. return functionSerivce.GetEntity(keyValue);
  105. }
  106. catch (Exception ex)
  107. {
  108. if (ex is ExceptionEx)
  109. {
  110. throw;
  111. }
  112. else
  113. {
  114. throw ExceptionEx.ThrowBusinessException(ex);
  115. }
  116. }
  117. }
  118. /// <summary>
  119. /// 获取移动功能模板
  120. /// </summary>
  121. /// <param name="keyValue">主键</param>
  122. /// <returns></returns>
  123. public FunctionSchemeEntity GetScheme(string keyValue)
  124. {
  125. try
  126. {
  127. return functionSerivce.GetScheme(keyValue);
  128. }
  129. catch (Exception ex)
  130. {
  131. if (ex is ExceptionEx)
  132. {
  133. throw;
  134. }
  135. else
  136. {
  137. throw ExceptionEx.ThrowBusinessException(ex);
  138. }
  139. }
  140. }
  141. /// <summary>
  142. /// 获取树形移动功能列表
  143. /// </summary>
  144. /// <returns></returns>
  145. public List<TreeModel> GetCheckTree()
  146. {
  147. try
  148. {
  149. List<TreeModel> treeList = new List<TreeModel>();
  150. var dataItemList = dataItemIBLL.GetDetailList("function");
  151. UserInfo userInfo = LoginUserInfo.Get();
  152. var list = GetList(userInfo);
  153. Dictionary<string, List<TreeModel>> map = new Dictionary<string, List<TreeModel>>();
  154. foreach (var item in list)
  155. {
  156. if (!map.ContainsKey(item.F_Type))
  157. {
  158. map[item.F_Type] = new List<TreeModel>();
  159. }
  160. TreeModel treeItem = new TreeModel();
  161. treeItem.id = item.F_Id;
  162. treeItem.text = item.F_Name;
  163. treeItem.value = item.F_Id;
  164. treeItem.showcheck = true;
  165. treeItem.checkstate = 0;
  166. treeItem.parentId = item.F_Type + "_MKDataItem";
  167. map[item.F_Type].Add(treeItem);
  168. treeItem.complete = true;
  169. }
  170. foreach (var item in dataItemList)
  171. {
  172. if (map.ContainsKey(item.F_ItemValue))
  173. {
  174. TreeModel treeItem = new TreeModel();
  175. treeItem.id = item.F_ItemValue + "_MKDataItem";
  176. treeItem.text = item.F_ItemName;
  177. treeItem.value = item.F_ItemValue + "_MKDataItem";
  178. treeItem.showcheck = true;
  179. treeItem.checkstate = 0;
  180. treeItem.parentId = "0";
  181. treeItem.hasChildren = true;
  182. treeItem.complete = true;
  183. treeItem.isexpand = true;
  184. treeItem.ChildNodes = map[item.F_ItemValue];
  185. treeList.Add(treeItem);
  186. }
  187. }
  188. return treeList;
  189. }
  190. catch (Exception ex)
  191. {
  192. if (ex is ExceptionEx)
  193. {
  194. throw;
  195. }
  196. else
  197. {
  198. throw ExceptionEx.ThrowBusinessException(ex);
  199. }
  200. }
  201. }
  202. #endregion
  203. #region 提交数据
  204. /// <summary>
  205. /// 删除
  206. /// </summary>
  207. /// <param name="keyValue">主键</param>
  208. public void Delete(string keyValue)
  209. {
  210. try
  211. {
  212. functionSerivce.Delete(keyValue);
  213. }
  214. catch (Exception ex)
  215. {
  216. if (ex is ExceptionEx)
  217. {
  218. throw;
  219. }
  220. else
  221. {
  222. throw ExceptionEx.ThrowBusinessException(ex);
  223. }
  224. }
  225. }
  226. /// <summary>
  227. /// 保存
  228. /// </summary>
  229. /// <param name="keyValue">主键</param>
  230. /// <param name="functionEntity">功能信息</param>
  231. /// <param name="functionSchemeEntity">功能模板信息</param>
  232. public void SaveEntity(string keyValue, FunctionEntity functionEntity, FunctionSchemeEntity functionSchemeEntity)
  233. {
  234. try
  235. {
  236. functionSerivce.SaveEntity(keyValue, functionEntity, functionSchemeEntity);
  237. }
  238. catch (Exception ex)
  239. {
  240. if (ex is ExceptionEx)
  241. {
  242. throw;
  243. }
  244. else
  245. {
  246. throw ExceptionEx.ThrowBusinessException(ex);
  247. }
  248. }
  249. }
  250. /// <summary>
  251. /// 更新状态
  252. /// </summary>
  253. /// <param name="keyValue">模板信息主键</param>
  254. /// <param name="state">状态1启用0禁用</param>
  255. public void UpdateState(string keyValue, int state)
  256. {
  257. try
  258. {
  259. functionSerivce.UpdateState(keyValue, state);
  260. }
  261. catch (Exception ex)
  262. {
  263. if (ex is ExceptionEx)
  264. {
  265. throw;
  266. }
  267. else
  268. {
  269. throw ExceptionEx.ThrowBusinessException(ex);
  270. }
  271. }
  272. }
  273. #endregion
  274. }
  275. }