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.
 
 
 
 
 
 

158 line
4.6 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.PersonnelManagement
  9. {
  10. /// <summary>
  11. /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
  12. /// Copyright (c) 2013-2018 北京泉江科技有限公司
  13. /// 创 建:超级管理员
  14. /// 日 期:2020-03-23 14:57
  15. /// 描 述:文档管理
  16. /// </summary>
  17. public class SRDocumentService : RepositoryFactory
  18. {
  19. #region 获取数据
  20. /// <summary>
  21. /// 获取页面显示列表数据
  22. /// <summary>
  23. /// <param name="queryJson">查询参数</param>
  24. /// <returns></returns>
  25. public IEnumerable<SRDocumentEntity> GetPageList(Pagination pagination, string queryJson)
  26. {
  27. try
  28. {
  29. var strSql = new StringBuilder();
  30. strSql.Append("SELECT ");
  31. strSql.Append(@"
  32. t.Id,
  33. t.Name,
  34. t.DocumentName,
  35. t.Content
  36. ");
  37. strSql.Append(" FROM SRDocument t ");
  38. strSql.Append(" WHERE 1=1 ");
  39. var queryParam = queryJson.ToJObject();
  40. // 虚拟参数
  41. var dp = new DynamicParameters(new { });
  42. if (!queryParam["Name"].IsEmpty())
  43. {
  44. dp.Add("Name", "%" + queryParam["Name"].ToString() + "%", DbType.String);
  45. strSql.Append(" AND t.Name Like @Name ");
  46. }
  47. if (!queryParam["DocumentName"].IsEmpty())
  48. {
  49. dp.Add("DocumentName", "%" + queryParam["DocumentName"].ToString() + "%", DbType.String);
  50. strSql.Append(" AND t.DocumentName Like @DocumentName ");
  51. }
  52. return this.BaseRepository("CollegeMIS").FindList<SRDocumentEntity>(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. /// 获取SRDocument表实体数据
  68. /// <param name="keyValue">主键</param>
  69. /// <summary>
  70. /// <returns></returns>
  71. public SRDocumentEntity GetSRDocumentEntity(string keyValue)
  72. {
  73. try
  74. {
  75. return this.BaseRepository("CollegeMIS").FindEntity<SRDocumentEntity>(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. /// <param name="keyValue">主键</param>
  94. /// <summary>
  95. /// <returns></returns>
  96. public void DeleteEntity(string keyValue)
  97. {
  98. try
  99. {
  100. this.BaseRepository("CollegeMIS").Delete<SRDocumentEntity>(t=>t.Id == keyValue);
  101. }
  102. catch (Exception ex)
  103. {
  104. if (ex is ExceptionEx)
  105. {
  106. throw;
  107. }
  108. else
  109. {
  110. throw ExceptionEx.ThrowServiceException(ex);
  111. }
  112. }
  113. }
  114. /// <summary>
  115. /// 保存实体数据(新增、修改)
  116. /// <param name="keyValue">主键</param>
  117. /// <summary>
  118. /// <returns></returns>
  119. public void SaveEntity(string keyValue, SRDocumentEntity entity)
  120. {
  121. try
  122. {
  123. if (!string.IsNullOrEmpty(keyValue))
  124. {
  125. entity.Modify(keyValue);
  126. this.BaseRepository("CollegeMIS").Update(entity);
  127. }
  128. else
  129. {
  130. entity.Create();
  131. this.BaseRepository("CollegeMIS").Insert(entity);
  132. }
  133. }
  134. catch (Exception ex)
  135. {
  136. if (ex is ExceptionEx)
  137. {
  138. throw;
  139. }
  140. else
  141. {
  142. throw ExceptionEx.ThrowServiceException(ex);
  143. }
  144. }
  145. }
  146. #endregion
  147. }
  148. }