Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 
 
 

182 lignes
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-Ultimate V7.0.0 数字化智慧校园
  12. /// Copyright (c) 2013-2018 北京泉江科技有限公司
  13. /// 创 建:超级管理员
  14. /// 日 期:2020-02-10 12:10
  15. /// 描 述:人事异动管理
  16. /// </summary>
  17. public class TeacherChangeService : RepositoryFactory
  18. {
  19. #region 获取数据
  20. /// <summary>
  21. /// 获取页面显示列表数据
  22. /// <summary>
  23. /// <param name="queryJson">查询参数</param>
  24. /// <returns></returns>
  25. public IEnumerable<TeacherChangeEntity> 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.EmpId,
  34. t.ChangeTime,
  35. t.ChangeType
  36. ");
  37. strSql.Append(" FROM TeacherChange t ");
  38. strSql.Append(" WHERE 1=1 ");
  39. var queryParam = queryJson.ToJObject();
  40. // 虚拟参数
  41. var dp = new DynamicParameters(new { });
  42. if (!queryParam["EmpId"].IsEmpty())
  43. {
  44. dp.Add("EmpId", queryParam["EmpId"].ToString(), DbType.String);
  45. strSql.Append(" AND t.EmpId = @EmpId ");
  46. }
  47. if (!queryParam["ChangeType"].IsEmpty())
  48. {
  49. dp.Add("ChangeType", queryParam["ChangeType"].ToString(), DbType.String);
  50. strSql.Append(" AND t.ChangeType = @ChangeType ");
  51. }
  52. return this.BaseRepository().FindList<TeacherChangeEntity>(strSql.ToString(), dp, pagination);
  53. }
  54. catch (Exception ex)
  55. {
  56. if (ex is ExceptionEx)
  57. {
  58. throw;
  59. }
  60. else
  61. {
  62. throw ExceptionEx.ThrowServiceException(ex);
  63. }
  64. }
  65. }
  66. /// <summary>
  67. /// 获取TeacherChange表实体数据
  68. /// <param name="keyValue">主键</param>
  69. /// <summary>
  70. /// <returns></returns>
  71. public TeacherChangeEntity GetTeacherChangeEntity(string keyValue)
  72. {
  73. try
  74. {
  75. return this.BaseRepository().FindEntity<TeacherChangeEntity>(keyValue);
  76. }
  77. catch (Exception ex)
  78. {
  79. if (ex is ExceptionEx)
  80. {
  81. throw;
  82. }
  83. else
  84. {
  85. throw ExceptionEx.ThrowServiceException(ex);
  86. }
  87. }
  88. }
  89. /// <summary>
  90. /// 获取TeacherChange表实体数据
  91. /// <param name="keyValue">主键</param>
  92. /// <summary>
  93. /// <returns></returns>
  94. public TeacherChangeEntity GetTeacherChangeEntityByEmpIdAndType(string empId, string type)
  95. {
  96. try
  97. {
  98. return this.BaseRepository().FindEntity<TeacherChangeEntity>(x => x.EmpId == empId && x.ChangeType == type);
  99. }
  100. catch (Exception ex)
  101. {
  102. if (ex is ExceptionEx)
  103. {
  104. throw;
  105. }
  106. else
  107. {
  108. throw ExceptionEx.ThrowServiceException(ex);
  109. }
  110. }
  111. }
  112. #endregion
  113. #region 提交数据
  114. /// <summary>
  115. /// 删除实体数据
  116. /// <param name="keyValue">主键</param>
  117. /// <summary>
  118. /// <returns></returns>
  119. public void DeleteEntity(string keyValue)
  120. {
  121. try
  122. {
  123. this.BaseRepository().Delete<TeacherChangeEntity>(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. /// <param name="keyValue">主键</param>
  140. /// <summary>
  141. /// <returns></returns>
  142. public void SaveEntity(string keyValue, TeacherChangeEntity entity)
  143. {
  144. try
  145. {
  146. if (!string.IsNullOrEmpty(keyValue))
  147. {
  148. entity.Modify(keyValue);
  149. this.BaseRepository().Update(entity);
  150. }
  151. else
  152. {
  153. entity.Create();
  154. this.BaseRepository().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. }