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.
 
 
 
 
 
 

161 lines
4.8 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.EducationalAdministration
  9. {
  10. /// <summary>
  11. /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
  12. /// Copyright (c) 2013-2018 北京泉江科技有限公司
  13. /// 创 建:超级管理员
  14. /// 日 期:2019-11-19 10:31
  15. /// 描 述:实习总结管理
  16. /// </summary>
  17. public class InternShipSummaryService : RepositoryFactory
  18. {
  19. #region 获取数据
  20. /// <summary>
  21. /// 获取页面显示列表数据
  22. /// <summary>
  23. /// <param name="queryJson">查询参数</param>
  24. /// <returns></returns>
  25. public IEnumerable<InternShipSummaryEntity> 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.Student,
  34. t.SummaryName,
  35. t.AddTime,
  36. t.Mobile,
  37. t.Remark,
  38. t.SummaryContent
  39. ");
  40. strSql.Append(" FROM InternShipSummary t ");
  41. strSql.Append(" WHERE 1=1 ");
  42. var queryParam = queryJson.ToJObject();
  43. // 虚拟参数
  44. var dp = new DynamicParameters(new { });
  45. if (!queryParam["Student"].IsEmpty())
  46. {
  47. dp.Add("Student", "%" + queryParam["Student"].ToString() + "%", DbType.String);
  48. strSql.Append(" AND t.Student Like @Student ");
  49. }
  50. if (!queryParam["Mobile"].IsEmpty())
  51. {
  52. dp.Add("Mobile", "%" + queryParam["Mobile"].ToString() + "%", DbType.String);
  53. strSql.Append(" AND t.Mobile Like @Mobile ");
  54. }
  55. return this.BaseRepository("CollegeMIS").FindList<InternShipSummaryEntity>(strSql.ToString(),dp, pagination);
  56. }
  57. catch (Exception ex)
  58. {
  59. if (ex is ExceptionEx)
  60. {
  61. throw;
  62. }
  63. else
  64. {
  65. throw ExceptionEx.ThrowServiceException(ex);
  66. }
  67. }
  68. }
  69. /// <summary>
  70. /// 获取InternShipSummary表实体数据
  71. /// <param name="keyValue">主键</param>
  72. /// <summary>
  73. /// <returns></returns>
  74. public InternShipSummaryEntity GetInternShipSummaryEntity(string keyValue)
  75. {
  76. try
  77. {
  78. return this.BaseRepository("CollegeMIS").FindEntity<InternShipSummaryEntity>(keyValue);
  79. }
  80. catch (Exception ex)
  81. {
  82. if (ex is ExceptionEx)
  83. {
  84. throw;
  85. }
  86. else
  87. {
  88. throw ExceptionEx.ThrowServiceException(ex);
  89. }
  90. }
  91. }
  92. #endregion
  93. #region 提交数据
  94. /// <summary>
  95. /// 删除实体数据
  96. /// <param name="keyValue">主键</param>
  97. /// <summary>
  98. /// <returns></returns>
  99. public void DeleteEntity(string keyValue)
  100. {
  101. try
  102. {
  103. this.BaseRepository("CollegeMIS").Delete<InternShipSummaryEntity>(t=>t.ID == keyValue);
  104. }
  105. catch (Exception ex)
  106. {
  107. if (ex is ExceptionEx)
  108. {
  109. throw;
  110. }
  111. else
  112. {
  113. throw ExceptionEx.ThrowServiceException(ex);
  114. }
  115. }
  116. }
  117. /// <summary>
  118. /// 保存实体数据(新增、修改)
  119. /// <param name="keyValue">主键</param>
  120. /// <summary>
  121. /// <returns></returns>
  122. public void SaveEntity(string keyValue, InternShipSummaryEntity entity)
  123. {
  124. try
  125. {
  126. if (!string.IsNullOrEmpty(keyValue))
  127. {
  128. entity.Modify(keyValue);
  129. this.BaseRepository("CollegeMIS").Update(entity);
  130. }
  131. else
  132. {
  133. entity.Create();
  134. this.BaseRepository("CollegeMIS").Insert(entity);
  135. }
  136. }
  137. catch (Exception ex)
  138. {
  139. if (ex is ExceptionEx)
  140. {
  141. throw;
  142. }
  143. else
  144. {
  145. throw ExceptionEx.ThrowServiceException(ex);
  146. }
  147. }
  148. }
  149. #endregion
  150. }
  151. }