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.
 
 
 
 
 
 

175 lines
5.3 KiB

  1. using Dapper;
  2. using Learun.DataBase.Repository;
  3. using Learun.Util;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Data;
  7. using System.Text;
  8. namespace Learun.Application.TwoDevelopment.Permission
  9. {
  10. /// <summary>
  11. /// 版 本 Learun-ADMS V7.0.6 力软敏捷开发框架
  12. /// Copyright (c) 2013-2020 力软信息技术(苏州)有限公司
  13. /// 创 建:超级管理员
  14. /// 日 期:2020-12-22 11:35
  15. /// 描 述:公告发布权限设置
  16. /// </summary>
  17. public class DepartmentReleasePermissionsService : RepositoryFactory
  18. {
  19. #region 获取数据
  20. /// <summary>
  21. /// 获取页面显示列表数据
  22. /// </summary>
  23. /// <param name="pagination">查询参数</param>
  24. /// <param name="queryJson">查询参数</param>
  25. /// <returns></returns>
  26. public IEnumerable<DepartmentReleasePermissionsEntity> GetPageList(Pagination pagination, string queryJson)
  27. {
  28. try
  29. {
  30. var strSql = new StringBuilder();
  31. strSql.Append("SELECT ");
  32. strSql.Append(@"
  33. t.ID,
  34. t.UserID,
  35. t.Permission
  36. ");
  37. strSql.Append(" FROM DepartmentReleasePermissions t ");
  38. strSql.Append(" WHERE 1=1 ");
  39. var queryParam = queryJson.ToJObject();
  40. // 虚拟参数
  41. var dp = new DynamicParameters(new { });
  42. if (!queryParam["DepartmentID"].IsEmpty())
  43. {
  44. dp.Add("DepartmentID",queryParam["DepartmentID"].ToString(), DbType.String);
  45. strSql.Append(" AND t.DepartmentID = @DepartmentID ");
  46. }
  47. if (!queryParam["UserID"].IsEmpty())
  48. {
  49. dp.Add("UserID", queryParam["UserID"].ToString(), DbType.String);
  50. strSql.Append(" AND t.UserID = @UserID ");
  51. }
  52. return this.BaseRepository().FindList<DepartmentReleasePermissionsEntity>(strSql.ToString(),dp, pagination);
  53. }
  54. catch (Exception ex)
  55. {
  56. if (ex is ExceptionEx)
  57. {
  58. throw;
  59. }
  60. else
  61. {
  62. throw ExceptionEx.ThrowServiceException(ex);
  63. }
  64. }
  65. }
  66. /// <summary>
  67. /// 获取DepartmentReleasePermissions表实体数据
  68. /// </summary>
  69. /// <param name="keyValue">主键</param>
  70. /// <returns></returns>
  71. public DepartmentReleasePermissionsEntity GetDepartmentReleasePermissionsEntity(string keyValue)
  72. {
  73. try
  74. {
  75. return this.BaseRepository().FindEntity<DepartmentReleasePermissionsEntity>(keyValue);
  76. }
  77. catch (Exception ex)
  78. {
  79. if (ex is ExceptionEx)
  80. {
  81. throw;
  82. }
  83. else
  84. {
  85. throw ExceptionEx.ThrowServiceException(ex);
  86. }
  87. }
  88. }
  89. #endregion
  90. #region 提交数据
  91. /// <summary>
  92. /// 删除实体数据
  93. /// </summary>
  94. /// <param name="keyValue">主键</param>
  95. public void DeleteEntity(string keyValue)
  96. {
  97. try
  98. {
  99. this.BaseRepository().Delete<DepartmentReleasePermissionsEntity>(t=>t.ID == keyValue);
  100. }
  101. catch (Exception ex)
  102. {
  103. if (ex is ExceptionEx)
  104. {
  105. throw;
  106. }
  107. else
  108. {
  109. throw ExceptionEx.ThrowServiceException(ex);
  110. }
  111. }
  112. }
  113. /// <summary>
  114. /// 保存实体数据(新增、修改)
  115. /// </summary>
  116. /// <param name="keyValue">主键</param>
  117. /// <param name="entity">实体</param>
  118. public void SaveEntity(string keyValue, DepartmentReleasePermissionsEntity entity)
  119. {
  120. try
  121. {
  122. if (!string.IsNullOrEmpty(keyValue))
  123. {
  124. entity.Modify(keyValue);
  125. this.BaseRepository().Update(entity);
  126. }
  127. else
  128. {
  129. entity.Create();
  130. this.BaseRepository().Insert(entity);
  131. }
  132. }
  133. catch (Exception ex)
  134. {
  135. if (ex is ExceptionEx)
  136. {
  137. throw;
  138. }
  139. else
  140. {
  141. throw ExceptionEx.ThrowServiceException(ex);
  142. }
  143. }
  144. }
  145. #endregion
  146. public DepartmentReleasePermissionsEntity GetTypesByUserId(string userId)
  147. {
  148. try
  149. {
  150. return this.BaseRepository().FindEntity<DepartmentReleasePermissionsEntity>(a=>a.UserID==userId);
  151. }
  152. catch (Exception ex)
  153. {
  154. if (ex is ExceptionEx)
  155. {
  156. throw;
  157. }
  158. else
  159. {
  160. throw ExceptionEx.ThrowServiceException(ex);
  161. }
  162. }
  163. }
  164. }
  165. }