PermissionBLL.cs 5.4 KB

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