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.
 
 
 
 
 
 

178 lines
5.0 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 V7.0.6 力软敏捷开发框架
  12. /// Copyright (c) 2013-2020 力软信息技术(苏州)有限公司
  13. /// 创 建:超级管理员
  14. /// 日 期:2021-06-21 10:33
  15. /// 描 述:考试科目基础信息
  16. /// </summary>
  17. public class ExamSubjectService : RepositoryFactory
  18. {
  19. #region 获取数据
  20. /// <summary>
  21. /// 获取页面显示列表数据
  22. /// </summary>
  23. /// <param name="pagination">查询参数</param>
  24. /// <param name="queryJson">查询参数</param>
  25. /// <returns></returns>
  26. public IEnumerable<ExamSubjectEntity> GetPageList(Pagination pagination, string queryJson)
  27. {
  28. try
  29. {
  30. var strSql = new StringBuilder();
  31. strSql.Append("SELECT ");
  32. strSql.Append(@"
  33. t.Id,
  34. t.SubjectNo,
  35. t.SubjectName,
  36. t.Address,
  37. t.BeginTime,
  38. t.EndTime,
  39. t.IsFlag
  40. ");
  41. strSql.Append(" FROM ExamSubject t ");
  42. strSql.Append(" WHERE 1=1 ");
  43. var queryParam = queryJson.ToJObject();
  44. // 虚拟参数
  45. var dp = new DynamicParameters(new { });
  46. return this.BaseRepository("CollegeMIS").FindList<ExamSubjectEntity>(strSql.ToString(), dp, pagination);
  47. }
  48. catch (Exception ex)
  49. {
  50. if (ex is ExceptionEx)
  51. {
  52. throw;
  53. }
  54. else
  55. {
  56. throw ExceptionEx.ThrowServiceException(ex);
  57. }
  58. }
  59. }
  60. /// <summary>
  61. /// 获取ExamSubject表实体数据
  62. /// </summary>
  63. /// <param name="keyValue">主键</param>
  64. /// <returns></returns>
  65. public ExamSubjectEntity GetExamSubjectEntity(string keyValue)
  66. {
  67. try
  68. {
  69. return this.BaseRepository("CollegeMIS").FindEntity<ExamSubjectEntity>(keyValue);
  70. }
  71. catch (Exception ex)
  72. {
  73. if (ex is ExceptionEx)
  74. {
  75. throw;
  76. }
  77. else
  78. {
  79. throw ExceptionEx.ThrowServiceException(ex);
  80. }
  81. }
  82. }
  83. #endregion
  84. #region 提交数据
  85. /// <summary>
  86. /// 删除实体数据
  87. /// </summary>
  88. /// <param name="keyValue">主键</param>
  89. public void DeleteEntity(string keyValue)
  90. {
  91. try
  92. {
  93. this.BaseRepository("CollegeMIS").Delete<ExamSubjectEntity>(t => t.Id == keyValue);
  94. }
  95. catch (Exception ex)
  96. {
  97. if (ex is ExceptionEx)
  98. {
  99. throw;
  100. }
  101. else
  102. {
  103. throw ExceptionEx.ThrowServiceException(ex);
  104. }
  105. }
  106. }
  107. /// <summary>
  108. /// 保存实体数据(新增、修改)
  109. /// </summary>
  110. /// <param name="keyValue">主键</param>
  111. /// <param name="entity">实体</param>
  112. public void SaveEntity(string keyValue, ExamSubjectEntity entity)
  113. {
  114. try
  115. {
  116. if (!string.IsNullOrEmpty(keyValue))
  117. {
  118. entity.Modify(keyValue);
  119. this.BaseRepository("CollegeMIS").Update(entity);
  120. }
  121. else
  122. {
  123. entity.Create();
  124. this.BaseRepository("CollegeMIS").Insert(entity);
  125. }
  126. }
  127. catch (Exception ex)
  128. {
  129. if (ex is ExceptionEx)
  130. {
  131. throw;
  132. }
  133. else
  134. {
  135. throw ExceptionEx.ThrowServiceException(ex);
  136. }
  137. }
  138. }
  139. #endregion
  140. #region MyRegion
  141. /// <summary>
  142. /// 获取表实体数据
  143. /// <param name="keyValue">主键</param>
  144. /// <summary>
  145. /// <returns></returns>
  146. public ExamSubjectEntity GetExamSubjectBySubjectNo(string SubjectNo)
  147. {
  148. try
  149. {
  150. return this.BaseRepository("CollegeMIS").FindEntity<ExamSubjectEntity>(x => x.SubjectNo == SubjectNo);
  151. }
  152. catch (Exception ex)
  153. {
  154. if (ex is ExceptionEx)
  155. {
  156. throw;
  157. }
  158. else
  159. {
  160. throw ExceptionEx.ThrowServiceException(ex);
  161. }
  162. }
  163. }
  164. #endregion
  165. }
  166. }