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.
 
 
 
 
 
 

198 lines
6.1 KiB

  1. using Learun.Util;
  2. using System;
  3. using System.Collections.Generic;
  4. namespace Learun.Application.Base.Files
  5. {
  6. /// <summary>
  7. /// 版 本 Learun-ADMS V7.0.3 力软敏捷开发框架
  8. /// Copyright (c) 2013-2018 上海力软信息技术有限公司
  9. /// 创 建:超级管理员
  10. /// 日 期:2019-11-28 09:23
  11. /// 描 述:文件夹管理
  12. /// </summary>
  13. public class FolderBLL : FolderIBLL
  14. {
  15. private FolderService folderService = new FolderService();
  16. #region 获取数据
  17. /// <summary>
  18. /// 获取页面显示列表数据
  19. /// </summary>
  20. /// <param name="keyWord">关键字</param>
  21. /// <param name="pId">父级id</param>
  22. /// <returns></returns>
  23. public IEnumerable<FolderEntity> GetList(string keyWord, string pId)
  24. {
  25. try
  26. {
  27. return folderService.GetList(keyWord, pId);
  28. }
  29. catch (Exception ex)
  30. {
  31. if (ex is ExceptionEx)
  32. {
  33. throw;
  34. }
  35. else
  36. {
  37. throw ExceptionEx.ThrowBusinessException(ex);
  38. }
  39. }
  40. }
  41. /// <summary>
  42. /// 获取树形数据
  43. /// </summary>
  44. /// <returns></returns>
  45. public List<TreeModel> GetTree() {
  46. var list = (List<FolderEntity>)GetList("","");
  47. list.Add(new FolderEntity()
  48. {
  49. F_Id = "0",
  50. F_PId = "00000",
  51. F_Name = "主目录"
  52. });
  53. UserInfo userInfo = LoginUserInfo.Get();
  54. if (!userInfo.isSystem)
  55. {
  56. string roleIds = userInfo.roleIds;
  57. if (string.IsNullOrEmpty(roleIds))
  58. {
  59. return new List<TreeModel>();
  60. }
  61. else
  62. {
  63. roleIds = "('" + roleIds.Replace(",", "','") + "')";
  64. var authList = (List<FileAuthEntity>)folderService.BaseRepository().FindList<FileAuthEntity>(" select * from lr_base_fileauth where F_ObjId in " + roleIds + " AND F_Time >= @ftime ORDER BY F_Type,F_Level ", new { ftime = DateTime.Now });
  65. List<FolderEntity> list2 = new List<FolderEntity>();
  66. foreach (var item in list)
  67. {
  68. item.F_AuthType = "1";
  69. var roleIdList = userInfo.roleIds.Split(',');
  70. foreach (var roleIdItem in roleIdList)
  71. {
  72. var authList2 = authList.FindAll(t => t.F_FileInfoId == item.F_Id && t.F_ObjId == roleIdItem);
  73. if (authList2.Count > 0)
  74. {
  75. if (authList2[0].F_Type != 2 && authList2[0].F_AuthType.IndexOf("2") != -1)
  76. {
  77. item.F_AuthType = "2";
  78. break;
  79. }
  80. }
  81. }
  82. }
  83. }
  84. }
  85. List<TreeModel> treeList = new List<TreeModel>();
  86. foreach (var item in list)
  87. {
  88. TreeModel node = new TreeModel();
  89. node.id = item.F_Id;
  90. node.text = item.F_Name;
  91. node.value = item.F_Id;
  92. node.showcheck = false;
  93. node.checkstate = 0;
  94. node.isexpand = true;
  95. node.parentId = item.F_PId;
  96. node.checkstate = 2; //1表示没有权限,2表示有权限
  97. if (!userInfo.isSystem) {
  98. if (item.F_AuthType == "2")
  99. {
  100. node.checkstate = 2;
  101. }
  102. else {
  103. node.checkstate = 1;
  104. node.text += "【无权限】";
  105. }
  106. }
  107. treeList.Add(node);
  108. }
  109. return treeList.ToTree();
  110. }
  111. /// <summary>
  112. /// 获取lr_base_folder表实体数据
  113. /// </summary>
  114. /// <param name="keyValue">主键</param>
  115. /// <returns></returns>
  116. public FolderEntity GetEntity(string keyValue)
  117. {
  118. try
  119. {
  120. return folderService.GetEntity(keyValue);
  121. }
  122. catch (Exception ex)
  123. {
  124. if (ex is ExceptionEx)
  125. {
  126. throw;
  127. }
  128. else
  129. {
  130. throw ExceptionEx.ThrowBusinessException(ex);
  131. }
  132. }
  133. }
  134. #endregion
  135. #region 提交数据
  136. /// <summary>
  137. /// 删除实体数据
  138. /// </summary>
  139. /// <param name="keyValue">主键</param>
  140. public bool DeleteEntity(string keyValue)
  141. {
  142. try
  143. {
  144. return folderService.DeleteEntity(keyValue);
  145. }
  146. catch (Exception ex)
  147. {
  148. if (ex is ExceptionEx)
  149. {
  150. throw;
  151. }
  152. else
  153. {
  154. throw ExceptionEx.ThrowBusinessException(ex);
  155. }
  156. }
  157. }
  158. /// <summary>
  159. /// 保存实体数据(新增、修改)
  160. /// </summary>
  161. /// <param name="keyValue">主键</param>
  162. /// <param name="entity">实体</param>
  163. public void SaveEntity(string keyValue, FolderEntity entity)
  164. {
  165. try
  166. {
  167. folderService.SaveEntity(keyValue, entity);
  168. }
  169. catch (Exception ex)
  170. {
  171. if (ex is ExceptionEx)
  172. {
  173. throw;
  174. }
  175. else
  176. {
  177. throw ExceptionEx.ThrowBusinessException(ex);
  178. }
  179. }
  180. }
  181. #endregion
  182. }
  183. }