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.
 
 
 
 
 
 

167 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.Text;
  8. namespace Learun.Application.TwoDevelopment.PersonnelManagement
  9. {
  10. /// <summary>
  11. /// 版 本 Learun-ADMS V7.0.6 力软敏捷开发框架
  12. /// Copyright (c) 2013-2020 力软信息技术(苏州)有限公司
  13. /// 创 建:超级管理员
  14. /// 日 期:2022-08-16 17:42
  15. /// 描 述:任教管理
  16. /// </summary>
  17. public class TeachManagementService : 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<TeachManagementEntity> GetPageList(Pagination pagination, string queryJson)
  27. {
  28. try
  29. {
  30. var strSql = new StringBuilder();
  31. strSql.Append("SELECT t.*");
  32. strSql.Append(" FROM TeachManagement t ");
  33. strSql.Append(" WHERE 1=1 ");
  34. var queryParam = queryJson.ToJObject();
  35. // 虚拟参数
  36. var dp = new DynamicParameters(new { });
  37. if (!queryParam["EmpNo"].IsEmpty())
  38. {
  39. dp.Add("EmpNo",queryParam["EmpNo"].ToString(), DbType.String);
  40. strSql.Append(" AND t.EmpNo = @EmpNo ");
  41. }
  42. if (!queryParam["AcademicYearNo"].IsEmpty())
  43. {
  44. dp.Add("AcademicYearNo", "%" + queryParam["AcademicYearNo"].ToString() + "%", DbType.String);
  45. strSql.Append(" AND t.AcademicYearNo Like @AcademicYearNo ");
  46. }
  47. if (!queryParam["Semester"].IsEmpty())
  48. {
  49. dp.Add("Semester", "%" + queryParam["Semester"].ToString() + "%", DbType.String);
  50. strSql.Append(" AND t.Semester Like @Semester ");
  51. }
  52. if (!queryParam["ClassNo"].IsEmpty())
  53. {
  54. dp.Add("ClassNo",queryParam["ClassNo"].ToString(), DbType.String);
  55. strSql.Append(" AND t.ClassNo = @ClassNo ");
  56. }
  57. if (!queryParam["LessonNo"].IsEmpty())
  58. {
  59. dp.Add("LessonNo",queryParam["LessonNo"].ToString(), DbType.String);
  60. strSql.Append(" AND t.LessonNo = @LessonNo ");
  61. }
  62. return this.BaseRepository("CollegeMIS").FindList<TeachManagementEntity>(strSql.ToString(),dp, pagination);
  63. }
  64. catch (Exception ex)
  65. {
  66. if (ex is ExceptionEx)
  67. {
  68. throw;
  69. }
  70. else
  71. {
  72. throw ExceptionEx.ThrowServiceException(ex);
  73. }
  74. }
  75. }
  76. /// <summary>
  77. /// 获取TeachManagement表实体数据
  78. /// </summary>
  79. /// <param name="keyValue">主键</param>
  80. /// <returns></returns>
  81. public TeachManagementEntity GetTeachManagementEntity(string keyValue)
  82. {
  83. try
  84. {
  85. return this.BaseRepository("CollegeMIS").FindEntity<TeachManagementEntity>(keyValue);
  86. }
  87. catch (Exception ex)
  88. {
  89. if (ex is ExceptionEx)
  90. {
  91. throw;
  92. }
  93. else
  94. {
  95. throw ExceptionEx.ThrowServiceException(ex);
  96. }
  97. }
  98. }
  99. #endregion
  100. #region 提交数据
  101. /// <summary>
  102. /// 删除实体数据
  103. /// </summary>
  104. /// <param name="keyValue">主键</param>
  105. public void DeleteEntity(string keyValue)
  106. {
  107. try
  108. {
  109. this.BaseRepository("CollegeMIS").Delete<TeachManagementEntity>(t=>t.Id == keyValue);
  110. }
  111. catch (Exception ex)
  112. {
  113. if (ex is ExceptionEx)
  114. {
  115. throw;
  116. }
  117. else
  118. {
  119. throw ExceptionEx.ThrowServiceException(ex);
  120. }
  121. }
  122. }
  123. /// <summary>
  124. /// 保存实体数据(新增、修改)
  125. /// </summary>
  126. /// <param name="keyValue">主键</param>
  127. /// <param name="entity">实体</param>
  128. public void SaveEntity(string keyValue, TeachManagementEntity entity)
  129. {
  130. try
  131. {
  132. if (!string.IsNullOrEmpty(keyValue))
  133. {
  134. entity.Modify(keyValue);
  135. this.BaseRepository("CollegeMIS").Update(entity);
  136. }
  137. else
  138. {
  139. entity.Create();
  140. this.BaseRepository("CollegeMIS").Insert(entity);
  141. }
  142. }
  143. catch (Exception ex)
  144. {
  145. if (ex is ExceptionEx)
  146. {
  147. throw;
  148. }
  149. else
  150. {
  151. throw ExceptionEx.ThrowServiceException(ex);
  152. }
  153. }
  154. }
  155. #endregion
  156. }
  157. }