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.
 
 
 
 
 
 

177 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-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 admsdb = this.BaseRepository("CollegeMIS").getDbConnection().Database;
  30. var strSql = new StringBuilder();
  31. strSql.Append("SELECT t.* ");
  32. strSql.Append(" FROM TeacherChange t left join " + admsdb + ".dbo.EmpInfo e on t.EmpId=e.EmpId ");
  33. strSql.Append(" WHERE 1=1 ");
  34. var queryParam = queryJson.ToJObject();
  35. // 虚拟参数
  36. var dp = new DynamicParameters(new { });
  37. if (!queryParam["EName"].IsEmpty())
  38. {
  39. dp.Add("EName", "%" + queryParam["EName"].ToString() + "%", DbType.String);
  40. strSql.Append(" AND e.EmpName like @EName ");
  41. }
  42. if (!queryParam["ChangeType"].IsEmpty())
  43. {
  44. dp.Add("ChangeType", queryParam["ChangeType"].ToString(), DbType.String);
  45. strSql.Append(" AND t.ChangeType = @ChangeType ");
  46. }
  47. return this.BaseRepository().FindList<TeacherChangeEntity>(strSql.ToString(), dp, pagination);
  48. }
  49. catch (Exception ex)
  50. {
  51. if (ex is ExceptionEx)
  52. {
  53. throw;
  54. }
  55. else
  56. {
  57. throw ExceptionEx.ThrowServiceException(ex);
  58. }
  59. }
  60. }
  61. /// <summary>
  62. /// 获取TeacherChange表实体数据
  63. /// <param name="keyValue">主键</param>
  64. /// <summary>
  65. /// <returns></returns>
  66. public TeacherChangeEntity GetTeacherChangeEntity(string keyValue)
  67. {
  68. try
  69. {
  70. return this.BaseRepository().FindEntity<TeacherChangeEntity>(keyValue);
  71. }
  72. catch (Exception ex)
  73. {
  74. if (ex is ExceptionEx)
  75. {
  76. throw;
  77. }
  78. else
  79. {
  80. throw ExceptionEx.ThrowServiceException(ex);
  81. }
  82. }
  83. }
  84. /// <summary>
  85. /// 获取TeacherChange表实体数据
  86. /// <param name="keyValue">主键</param>
  87. /// <summary>
  88. /// <returns></returns>
  89. public TeacherChangeEntity GetTeacherChangeEntityByEmpIdAndType(string empId, string type)
  90. {
  91. try
  92. {
  93. return this.BaseRepository().FindEntity<TeacherChangeEntity>(x => x.EmpId == empId && x.ChangeType == type);
  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. #endregion
  108. #region 提交数据
  109. /// <summary>
  110. /// 删除实体数据
  111. /// <param name="keyValue">主键</param>
  112. /// <summary>
  113. /// <returns></returns>
  114. public void DeleteEntity(string keyValue)
  115. {
  116. try
  117. {
  118. this.BaseRepository().Delete<TeacherChangeEntity>(t => t.Id == keyValue);
  119. }
  120. catch (Exception ex)
  121. {
  122. if (ex is ExceptionEx)
  123. {
  124. throw;
  125. }
  126. else
  127. {
  128. throw ExceptionEx.ThrowServiceException(ex);
  129. }
  130. }
  131. }
  132. /// <summary>
  133. /// 保存实体数据(新增、修改)
  134. /// <param name="keyValue">主键</param>
  135. /// <summary>
  136. /// <returns></returns>
  137. public void SaveEntity(string keyValue, TeacherChangeEntity entity)
  138. {
  139. try
  140. {
  141. if (!string.IsNullOrEmpty(keyValue))
  142. {
  143. entity.Modify(keyValue);
  144. this.BaseRepository().Update(entity);
  145. }
  146. else
  147. {
  148. entity.Create();
  149. this.BaseRepository().Insert(entity);
  150. }
  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. }