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.
 
 
 
 
 
 

194 lines
5.4 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-02-10 19:21
  15. /// 描 述:疫情接触外人
  16. /// </summary>
  17. public class EpiPeopleDetailsService : RepositoryFactory
  18. {
  19. #region 构造函数和属性
  20. private string fieldSql;
  21. public EpiPeopleDetailsService()
  22. {
  23. fieldSql=@"
  24. t.ID,
  25. t.Name,
  26. t.Gender,
  27. t.Mobile,
  28. t.QTType,
  29. t.QTAddress,
  30. t.QTTime,
  31. t.QTContactTime,
  32. t.Fever,
  33. t.EID,
  34. t.Province,
  35. t.City,
  36. t.Area
  37. ";
  38. }
  39. #endregion
  40. #region 获取数据
  41. /// <summary>
  42. /// 获取列表数据
  43. /// <summary>
  44. /// <returns></returns>
  45. public IEnumerable<PeopleDetailsEntity> GetList( string queryJson )
  46. {
  47. try
  48. {
  49. //参考写法
  50. //var queryParam = queryJson.ToJObject();
  51. // 虚拟参数
  52. //var dp = new DynamicParameters(new { });
  53. //dp.Add("startTime", queryParam["StartTime"].ToDate(), DbType.DateTime);
  54. var strSql = new StringBuilder();
  55. strSql.Append("SELECT ");
  56. strSql.Append(fieldSql);
  57. strSql.Append(" FROM PeopleDetails t ");
  58. return this.BaseRepository("CollegeMIS").FindList<PeopleDetailsEntity>(strSql.ToString());
  59. }
  60. catch (Exception ex)
  61. {
  62. if (ex is ExceptionEx)
  63. {
  64. throw;
  65. }
  66. else
  67. {
  68. throw ExceptionEx.ThrowServiceException(ex);
  69. }
  70. }
  71. }
  72. /// <summary>
  73. /// 获取列表分页数据
  74. /// <param name="pagination">分页参数</param>
  75. /// <summary>
  76. /// <returns></returns>
  77. public IEnumerable<PeopleDetailsEntity> GetPageList(Pagination pagination, string queryJson)
  78. {
  79. try
  80. {
  81. var strSql = new StringBuilder();
  82. strSql.Append("SELECT ");
  83. strSql.Append(fieldSql);
  84. strSql.Append(" FROM PeopleDetails t ");
  85. return this.BaseRepository("CollegeMIS").FindList<PeopleDetailsEntity>(strSql.ToString(), pagination);
  86. }
  87. catch (Exception ex)
  88. {
  89. if (ex is ExceptionEx)
  90. {
  91. throw;
  92. }
  93. else
  94. {
  95. throw ExceptionEx.ThrowServiceException(ex);
  96. }
  97. }
  98. }
  99. /// <summary>
  100. /// 获取实体数据
  101. /// <param name="keyValue">主键</param>
  102. /// <summary>
  103. /// <returns></returns>
  104. public PeopleDetailsEntity GetEntity(string keyValue)
  105. {
  106. try
  107. {
  108. return this.BaseRepository("CollegeMIS").FindEntity<PeopleDetailsEntity>(keyValue);
  109. }
  110. catch (Exception ex)
  111. {
  112. if (ex is ExceptionEx)
  113. {
  114. throw;
  115. }
  116. else
  117. {
  118. throw ExceptionEx.ThrowServiceException(ex);
  119. }
  120. }
  121. }
  122. #endregion
  123. #region 提交数据
  124. /// <summary>
  125. /// 删除实体数据
  126. /// <param name="keyValue">主键</param>
  127. /// <summary>
  128. /// <returns></returns>
  129. public void DeleteEntity(string keyValue)
  130. {
  131. try
  132. {
  133. this.BaseRepository("CollegeMIS").Delete<PeopleDetailsEntity>(t=>t.ID == keyValue);
  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. /// <summary>
  148. /// 保存实体数据(新增、修改)
  149. /// <param name="keyValue">主键</param>
  150. /// <summary>
  151. /// <returns></returns>
  152. public void SaveEntity(string keyValue, PeopleDetailsEntity entity)
  153. {
  154. try
  155. {
  156. if (!string.IsNullOrEmpty(keyValue))
  157. {
  158. entity.Modify(keyValue);
  159. this.BaseRepository("CollegeMIS").Update(entity);
  160. }
  161. else
  162. {
  163. entity.Create();
  164. this.BaseRepository("CollegeMIS").Insert(entity);
  165. }
  166. }
  167. catch (Exception ex)
  168. {
  169. if (ex is ExceptionEx)
  170. {
  171. throw;
  172. }
  173. else
  174. {
  175. throw ExceptionEx.ThrowServiceException(ex);
  176. }
  177. }
  178. }
  179. #endregion
  180. }
  181. }