PermissionBLL.cs 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. using LeaRun.Application.Busines.BaseManage;
  2. using LeaRun.Application.Code;
  3. using LeaRun.Application.Entity.AuthorizeManage;
  4. using LeaRun.Application.Entity.BaseManage;
  5. using LeaRun.Application.IService.AuthorizeManage;
  6. using LeaRun.Application.Service.BaseManage;
  7. using LeaRun.Util;
  8. using System;
  9. using System.Linq;
  10. using System.Collections.Generic;
  11. using System.Text;
  12. namespace LeaRun.Application.Busines.AuthorizeManage
  13. {
  14. /// <summary>
  15. /// 版 本
  16. /// Copyright (c) 2013-2016 上海力软信息技术有限公司
  17. /// 创建人:佘赐雄
  18. /// 日 期:2015.11.5 22:35
  19. /// 描 述:权限配置管理(角色、岗位、职位、用户组、用户)
  20. /// </summary>
  21. public class PermissionBLL
  22. {
  23. private IPermissionService service = new PermissionService();
  24. private UserBLL userBLL = new UserBLL();
  25. #region 获取数据
  26. /// <summary>
  27. /// 获取成员列表
  28. /// </summary>
  29. /// <param name="objectId">对象Id</param>
  30. /// <returns></returns>
  31. public IEnumerable<UserRelationEntity> GetMemberList(string objectId)
  32. {
  33. return service.GetMemberList(objectId);
  34. }
  35. /// <summary>
  36. /// 获取对象列表
  37. /// </summary>
  38. /// <param name="UserId"></param>
  39. /// <returns></returns>
  40. public IEnumerable<UserRelationEntity> GetObjectList(string userId)
  41. {
  42. return service.GetObjectList(userId);
  43. }
  44. /// <summary>
  45. /// 获取对象列表
  46. /// </summary>
  47. /// <param name="UserId"></param>
  48. /// <returns></returns>
  49. public string GetObjectStr(string userId)
  50. {
  51. StringBuilder sbId = new StringBuilder();
  52. List<UserRelationEntity> list = service.GetObjectList(userId).ToList();
  53. if (list.Count > 0)
  54. {
  55. foreach (UserRelationEntity item in list)
  56. {
  57. sbId.Append(item.ObjectId + ",");
  58. }
  59. sbId.Append(userId);
  60. }
  61. else
  62. {
  63. sbId.Append(userId + ",");
  64. }
  65. return sbId.ToString();
  66. }
  67. /// <summary>
  68. /// 获取功能列表
  69. /// </summary>
  70. /// <param name="objectId">对象Id</param>
  71. /// <returns></returns>
  72. public IEnumerable<AuthorizeEntity> GetModuleList(string objectId)
  73. {
  74. return service.GetModuleList(objectId);
  75. }
  76. /// <summary>
  77. /// 获取功能列表
  78. /// </summary>
  79. /// <param name="objectId">对象Id</param>
  80. /// <returns></returns>
  81. public IEnumerable<AuthorizeEntity> GetModuleListN(string objectId)
  82. {
  83. return service.GetModuleListN(objectId);
  84. }
  85. /// <summary>
  86. /// 获取按钮列表
  87. /// </summary>
  88. /// <param name="objectId">对象Id</param>
  89. /// <returns></returns>
  90. public IEnumerable<AuthorizeEntity> GetModuleButtonList(string objectId)
  91. {
  92. return service.GetModuleButtonList(objectId);
  93. }
  94. /// <summary>
  95. /// 获取视图列表
  96. /// </summary>
  97. /// <param name="objectId">对象Id</param>
  98. /// <returns></returns>
  99. public IEnumerable<AuthorizeEntity> GetModuleColumnList(string objectId)
  100. {
  101. return service.GetModuleColumnList(objectId);
  102. }
  103. /// <summary>
  104. /// 获取数据权限列表
  105. /// </summary>
  106. /// <param name="objectId">对象Id</param>
  107. /// <returns></returns>
  108. public IEnumerable<AuthorizeDataEntity> GetAuthorizeDataList(string objectId)
  109. {
  110. return service.GetAuthorizeDataList(objectId);
  111. }
  112. #endregion
  113. #region 提交数据
  114. /// <summary>
  115. /// 添加成员
  116. /// </summary>
  117. /// <param name="authorizeType">权限分类</param>
  118. /// <param name="objectId">对象Id</param>
  119. /// <param name="userIds">成员Id:1,2,3,4</param>
  120. public void SaveMember(AuthorizeTypeEnum authorizeType, string objectId, string userIds)
  121. {
  122. try
  123. {
  124. string[] arrayUserId = userIds.Split(',');
  125. service.SaveMember(authorizeType, objectId, arrayUserId);
  126. }
  127. catch (Exception)
  128. {
  129. throw;
  130. }
  131. }
  132. /// <summary>
  133. /// 保存授权
  134. /// </summary>
  135. /// <param name="authorizeType">权限分类</param>
  136. /// <param name="objectId">对象Id</param>
  137. /// <param name="moduleIds">功能Id</param>
  138. /// <param name="moduleButtonIds">按钮Id</param>
  139. /// <param name="moduleColumnIds">视图Id</param>
  140. /// <param name="authorizeDataJson">数据权限</param>
  141. /// <returns></returns>
  142. public void SaveAuthorize(AuthorizeTypeEnum authorizeType, string objectId, string moduleIds, string moduleButtonIds, string moduleColumnIds, string authorizeDataJson)
  143. {
  144. try
  145. {
  146. string[] arrayModuleId = moduleIds.Split(',');
  147. string[] arrayModuleButtonId = moduleButtonIds.Split(',');
  148. string[] arrayModuleColumnId = moduleColumnIds.Split(',');
  149. IEnumerable<AuthorizeDataEntity> authorizeDataList = authorizeDataJson.ToList<AuthorizeDataEntity>();
  150. service.SaveAuthorize(authorizeType, objectId, arrayModuleId, arrayModuleButtonId, arrayModuleColumnId, authorizeDataList);
  151. }
  152. catch (Exception)
  153. {
  154. throw;
  155. }
  156. }
  157. #endregion
  158. }
  159. }