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.

DepartmentReleasePermissionsService.cs 5.0 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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. return this.BaseRepository().FindList<DepartmentReleasePermissionsEntity>(strSql.ToString(),dp, pagination);
  48. }
  49. catch (Exception ex)
  50. {
  51. if (ex is ExceptionEx)
  52. {
  53. throw;
  54. }
  55. else
  56. {
  57. throw ExceptionEx.ThrowServiceException(ex);
  58. }
  59. }
  60. }
  61. /// <summary>
  62. /// 获取DepartmentReleasePermissions表实体数据
  63. /// </summary>
  64. /// <param name="keyValue">主键</param>
  65. /// <returns></returns>
  66. public DepartmentReleasePermissionsEntity GetDepartmentReleasePermissionsEntity(string keyValue)
  67. {
  68. try
  69. {
  70. return this.BaseRepository().FindEntity<DepartmentReleasePermissionsEntity>(keyValue);
  71. }
  72. catch (Exception ex)
  73. {
  74. if (ex is ExceptionEx)
  75. {
  76. throw;
  77. }
  78. else
  79. {
  80. throw ExceptionEx.ThrowServiceException(ex);
  81. }
  82. }
  83. }
  84. #endregion
  85. #region 提交数据
  86. /// <summary>
  87. /// 删除实体数据
  88. /// </summary>
  89. /// <param name="keyValue">主键</param>
  90. public void DeleteEntity(string keyValue)
  91. {
  92. try
  93. {
  94. this.BaseRepository().Delete<DepartmentReleasePermissionsEntity>(t=>t.ID == keyValue);
  95. }
  96. catch (Exception ex)
  97. {
  98. if (ex is ExceptionEx)
  99. {
  100. throw;
  101. }
  102. else
  103. {
  104. throw ExceptionEx.ThrowServiceException(ex);
  105. }
  106. }
  107. }
  108. /// <summary>
  109. /// 保存实体数据(新增、修改)
  110. /// </summary>
  111. /// <param name="keyValue">主键</param>
  112. /// <param name="entity">实体</param>
  113. public void SaveEntity(string keyValue, DepartmentReleasePermissionsEntity entity)
  114. {
  115. try
  116. {
  117. if (!string.IsNullOrEmpty(keyValue))
  118. {
  119. entity.Modify(keyValue);
  120. this.BaseRepository().Update(entity);
  121. }
  122. else
  123. {
  124. entity.Create();
  125. this.BaseRepository().Insert(entity);
  126. }
  127. }
  128. catch (Exception ex)
  129. {
  130. if (ex is ExceptionEx)
  131. {
  132. throw;
  133. }
  134. else
  135. {
  136. throw ExceptionEx.ThrowServiceException(ex);
  137. }
  138. }
  139. }
  140. #endregion
  141. public DepartmentReleasePermissionsEntity GetTypesByUserId(string userId)
  142. {
  143. try
  144. {
  145. return this.BaseRepository().FindEntity<DepartmentReleasePermissionsEntity>(a=>a.UserID==userId);
  146. }
  147. catch (Exception ex)
  148. {
  149. if (ex is ExceptionEx)
  150. {
  151. throw;
  152. }
  153. else
  154. {
  155. throw ExceptionEx.ThrowServiceException(ex);
  156. }
  157. }
  158. }
  159. }
  160. }