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.
 
 
 
 
 
 

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