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.
 
 
 
 
 
 

181 lines
6.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. /// 日 期:2022-03-01 17:26
  15. /// 描 述:教材征订管理
  16. /// </summary>
  17. public class TextBookSolSubService : 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<TextBookSolSubEntity> GetPageList(Pagination pagination, string queryJson)
  27. {
  28. try
  29. {
  30. var strSql = new StringBuilder();
  31. strSql.Append("SELECT ");
  32. strSql.Append(@"
  33. t.*
  34. ");
  35. strSql.Append(" FROM TextBookSolSub t ");
  36. strSql.Append(" WHERE 1=1 ");
  37. var queryParam = queryJson.ToJObject();
  38. // 虚拟参数
  39. var dp = new DynamicParameters(new { });
  40. if (!queryParam["StartTime"].IsEmpty() && !queryParam["EndTime"].IsEmpty())
  41. {
  42. dp.Add("startTime", queryParam["StartTime"].ToDate(), DbType.DateTime);
  43. dp.Add("endTime", queryParam["EndTime"].ToDate(), DbType.DateTime);
  44. strSql.Append(" AND ( t.CreateTime >= @startTime AND t.CreateTime <= @endTime ) ");
  45. }
  46. if (!queryParam["DeptNo"].IsEmpty())
  47. {
  48. dp.Add("DeptNo", queryParam["DeptNo"].ToString(), DbType.String);
  49. strSql.Append(" AND t.DeptNo = @DeptNo ");
  50. }
  51. if (!queryParam["MajorNo"].IsEmpty())
  52. {
  53. dp.Add("MajorNo", queryParam["MajorNo"].ToString(), DbType.String);
  54. strSql.Append(" AND t.MajorNo = @MajorNo ");
  55. }
  56. if (!queryParam["LessonNo"].IsEmpty())
  57. {
  58. dp.Add("LessonNo", queryParam["LessonNo"].ToString(), DbType.String);
  59. strSql.Append(" AND t.LessonNo = @LessonNo ");
  60. }
  61. if (!queryParam["AcademicYearNo"].IsEmpty())
  62. {
  63. dp.Add("AcademicYearNo", queryParam["AcademicYearNo"].ToString(), DbType.String);
  64. strSql.Append(" AND t.AcademicYearNo = @AcademicYearNo ");
  65. }
  66. if (!queryParam["Semester"].IsEmpty())
  67. {
  68. dp.Add("Semester", queryParam["Semester"].ToString(), DbType.String);
  69. strSql.Append(" AND t.Semester = @Semester ");
  70. }
  71. if (!queryParam["PublishNo"].IsEmpty())
  72. {
  73. dp.Add("PublishNo", "%" + queryParam["PublishNo"].ToString() + "%", DbType.String);
  74. strSql.Append(" AND t.PublishNo Like @PublishNo ");
  75. }
  76. return this.BaseRepository("CollegeMIS").FindList<TextBookSolSubEntity>(strSql.ToString(),dp, pagination);
  77. }
  78. catch (Exception ex)
  79. {
  80. if (ex is ExceptionEx)
  81. {
  82. throw;
  83. }
  84. else
  85. {
  86. throw ExceptionEx.ThrowServiceException(ex);
  87. }
  88. }
  89. }
  90. /// <summary>
  91. /// 获取TextBookSolSub表实体数据
  92. /// </summary>
  93. /// <param name="keyValue">主键</param>
  94. /// <returns></returns>
  95. public TextBookSolSubEntity GetTextBookSolSubEntity(string keyValue)
  96. {
  97. try
  98. {
  99. return this.BaseRepository("CollegeMIS").FindEntity<TextBookSolSubEntity>(keyValue);
  100. }
  101. catch (Exception ex)
  102. {
  103. if (ex is ExceptionEx)
  104. {
  105. throw;
  106. }
  107. else
  108. {
  109. throw ExceptionEx.ThrowServiceException(ex);
  110. }
  111. }
  112. }
  113. #endregion
  114. #region 提交数据
  115. /// <summary>
  116. /// 删除实体数据
  117. /// </summary>
  118. /// <param name="keyValue">主键</param>
  119. public void DeleteEntity(string keyValue)
  120. {
  121. try
  122. {
  123. this.BaseRepository("CollegeMIS").Delete<TextBookSolSubEntity>(t=>t.ID == keyValue);
  124. }
  125. catch (Exception ex)
  126. {
  127. if (ex is ExceptionEx)
  128. {
  129. throw;
  130. }
  131. else
  132. {
  133. throw ExceptionEx.ThrowServiceException(ex);
  134. }
  135. }
  136. }
  137. /// <summary>
  138. /// 保存实体数据(新增、修改)
  139. /// </summary>
  140. /// <param name="keyValue">主键</param>
  141. /// <param name="entity">实体</param>
  142. public void SaveEntity(string keyValue, TextBookSolSubEntity entity)
  143. {
  144. try
  145. {
  146. if (!string.IsNullOrEmpty(keyValue))
  147. {
  148. entity.Modify(keyValue);
  149. this.BaseRepository("CollegeMIS").Update(entity);
  150. }
  151. else
  152. {
  153. entity.Create();
  154. this.BaseRepository("CollegeMIS").Insert(entity);
  155. }
  156. }
  157. catch (Exception ex)
  158. {
  159. if (ex is ExceptionEx)
  160. {
  161. throw;
  162. }
  163. else
  164. {
  165. throw ExceptionEx.ThrowServiceException(ex);
  166. }
  167. }
  168. }
  169. #endregion
  170. }
  171. }