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.
 
 
 
 
 
 

159 lines
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. /// 日 期:2019-12-31 10:40
  15. /// 描 述:党组织生活管理
  16. /// </summary>
  17. public class PMLifeService : RepositoryFactory
  18. {
  19. #region 获取数据
  20. /// <summary>
  21. /// 获取页面显示列表数据
  22. /// <summary>
  23. /// <param name="queryJson">查询参数</param>
  24. /// <returns></returns>
  25. public IEnumerable<PMLifeEntity> 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.Title,
  34. t.Content,
  35. t.Time,
  36. t.Remark
  37. ");
  38. strSql.Append(" FROM PMLife t ");
  39. strSql.Append(" WHERE 1=1 ");
  40. var queryParam = queryJson.ToJObject();
  41. // 虚拟参数
  42. var dp = new DynamicParameters(new { });
  43. if (!queryParam["Title"].IsEmpty())
  44. {
  45. dp.Add("Title", "%" + queryParam["Title"].ToString() + "%", DbType.String);
  46. strSql.Append(" AND t.Title Like @Title ");
  47. }
  48. if (!queryParam["Time"].IsEmpty())
  49. {
  50. dp.Add("Time",queryParam["Time"].ToString(), DbType.String);
  51. strSql.Append(" AND t.Time = @Time ");
  52. }
  53. return this.BaseRepository("CollegeMIS").FindList<PMLifeEntity>(strSql.ToString(),dp, pagination);
  54. }
  55. catch (Exception ex)
  56. {
  57. if (ex is ExceptionEx)
  58. {
  59. throw;
  60. }
  61. else
  62. {
  63. throw ExceptionEx.ThrowServiceException(ex);
  64. }
  65. }
  66. }
  67. /// <summary>
  68. /// 获取PMLife表实体数据
  69. /// <param name="keyValue">主键</param>
  70. /// <summary>
  71. /// <returns></returns>
  72. public PMLifeEntity GetPMLifeEntity(string keyValue)
  73. {
  74. try
  75. {
  76. return this.BaseRepository("CollegeMIS").FindEntity<PMLifeEntity>(keyValue);
  77. }
  78. catch (Exception ex)
  79. {
  80. if (ex is ExceptionEx)
  81. {
  82. throw;
  83. }
  84. else
  85. {
  86. throw ExceptionEx.ThrowServiceException(ex);
  87. }
  88. }
  89. }
  90. #endregion
  91. #region 提交数据
  92. /// <summary>
  93. /// 删除实体数据
  94. /// <param name="keyValue">主键</param>
  95. /// <summary>
  96. /// <returns></returns>
  97. public void DeleteEntity(string keyValue)
  98. {
  99. try
  100. {
  101. this.BaseRepository("CollegeMIS").Delete<PMLifeEntity>(t=>t.ID == keyValue);
  102. }
  103. catch (Exception ex)
  104. {
  105. if (ex is ExceptionEx)
  106. {
  107. throw;
  108. }
  109. else
  110. {
  111. throw ExceptionEx.ThrowServiceException(ex);
  112. }
  113. }
  114. }
  115. /// <summary>
  116. /// 保存实体数据(新增、修改)
  117. /// <param name="keyValue">主键</param>
  118. /// <summary>
  119. /// <returns></returns>
  120. public void SaveEntity(string keyValue, PMLifeEntity entity)
  121. {
  122. try
  123. {
  124. if (!string.IsNullOrEmpty(keyValue))
  125. {
  126. entity.Modify(keyValue);
  127. this.BaseRepository("CollegeMIS").Update(entity);
  128. }
  129. else
  130. {
  131. entity.Create();
  132. this.BaseRepository("CollegeMIS").Insert(entity);
  133. }
  134. }
  135. catch (Exception ex)
  136. {
  137. if (ex is ExceptionEx)
  138. {
  139. throw;
  140. }
  141. else
  142. {
  143. throw ExceptionEx.ThrowServiceException(ex);
  144. }
  145. }
  146. }
  147. #endregion
  148. }
  149. }