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.

InternShipLogService.cs 4.8 KiB

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