您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 
 

180 行
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.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. strSql.Append(" FROM ExamSubject t ");
  34. strSql.Append(" WHERE 1=1 ");
  35. var queryParam = queryJson.ToJObject();
  36. var dp = new DynamicParameters(new { });
  37. if (!queryParam["SubjectNo"].IsEmpty())
  38. {
  39. dp.Add("SubjectNo", "%" + queryParam["SubjectNo"].ToString() + "%", DbType.String);
  40. strSql.Append(" AND t.SubjectNo Like @SubjectNo ");
  41. }
  42. if (!queryParam["SubjectName"].IsEmpty())
  43. {
  44. dp.Add("SubjectName", "%" + queryParam["SubjectName"].ToString() + "%", DbType.String);
  45. strSql.Append(" AND t.SubjectName Like @SubjectName ");
  46. }
  47. // 虚拟参数
  48. return this.BaseRepository("CollegeMIS").FindList<ExamSubjectEntity>(strSql.ToString(), dp, pagination);
  49. }
  50. catch (Exception ex)
  51. {
  52. if (ex is ExceptionEx)
  53. {
  54. throw;
  55. }
  56. else
  57. {
  58. throw ExceptionEx.ThrowServiceException(ex);
  59. }
  60. }
  61. }
  62. /// <summary>
  63. /// 获取ExamSubject表实体数据
  64. /// </summary>
  65. /// <param name="keyValue">主键</param>
  66. /// <returns></returns>
  67. public ExamSubjectEntity GetExamSubjectEntity(string keyValue)
  68. {
  69. try
  70. {
  71. return this.BaseRepository("CollegeMIS").FindEntity<ExamSubjectEntity>(keyValue);
  72. }
  73. catch (Exception ex)
  74. {
  75. if (ex is ExceptionEx)
  76. {
  77. throw;
  78. }
  79. else
  80. {
  81. throw ExceptionEx.ThrowServiceException(ex);
  82. }
  83. }
  84. }
  85. #endregion
  86. #region 提交数据
  87. /// <summary>
  88. /// 删除实体数据
  89. /// </summary>
  90. /// <param name="keyValue">主键</param>
  91. public void DeleteEntity(string keyValue)
  92. {
  93. try
  94. {
  95. this.BaseRepository("CollegeMIS").Delete<ExamSubjectEntity>(t => t.Id == keyValue);
  96. }
  97. catch (Exception ex)
  98. {
  99. if (ex is ExceptionEx)
  100. {
  101. throw;
  102. }
  103. else
  104. {
  105. throw ExceptionEx.ThrowServiceException(ex);
  106. }
  107. }
  108. }
  109. /// <summary>
  110. /// 保存实体数据(新增、修改)
  111. /// </summary>
  112. /// <param name="keyValue">主键</param>
  113. /// <param name="entity">实体</param>
  114. public void SaveEntity(string keyValue, ExamSubjectEntity entity)
  115. {
  116. try
  117. {
  118. if (!string.IsNullOrEmpty(keyValue))
  119. {
  120. entity.Modify(keyValue);
  121. this.BaseRepository("CollegeMIS").Update(entity);
  122. }
  123. else
  124. {
  125. entity.Create();
  126. this.BaseRepository("CollegeMIS").Insert(entity);
  127. }
  128. }
  129. catch (Exception ex)
  130. {
  131. if (ex is ExceptionEx)
  132. {
  133. throw;
  134. }
  135. else
  136. {
  137. throw ExceptionEx.ThrowServiceException(ex);
  138. }
  139. }
  140. }
  141. #endregion
  142. #region MyRegion
  143. /// <summary>
  144. /// 获取表实体数据
  145. /// <param name="keyValue">主键</param>
  146. /// <summary>
  147. /// <returns></returns>
  148. public ExamSubjectEntity GetExamSubjectBySubjectNo(string SubjectNo)
  149. {
  150. try
  151. {
  152. return this.BaseRepository("CollegeMIS").FindEntity<ExamSubjectEntity>(x => x.SubjectNo == SubjectNo);
  153. }
  154. catch (Exception ex)
  155. {
  156. if (ex is ExceptionEx)
  157. {
  158. throw;
  159. }
  160. else
  161. {
  162. throw ExceptionEx.ThrowServiceException(ex);
  163. }
  164. }
  165. }
  166. #endregion
  167. }
  168. }