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.
 
 
 
 
 
 

188 lines
5.8 KiB

  1. using Dapper;
  2. using Learun.Application.Organization;
  3. using Learun.Application.TwoDevelopment.EducationalAdministration;
  4. using Learun.DataBase.Repository;
  5. using Learun.Util;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Data;
  9. using System.Text;
  10. namespace Learun.Application.TwoDevelopment.PersonnelManagement
  11. {
  12. /// <summary>
  13. /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
  14. /// Copyright (c) 2013-2018 北京泉江科技有限公司
  15. /// 创 建:超级管理员
  16. /// 日 期:2020-04-29 16:13
  17. /// 描 述:教师处分管理
  18. /// </summary>
  19. public class TeacherPunishmentService : RepositoryFactory
  20. {
  21. #region 获取数据
  22. /// <summary>
  23. /// 获取页面显示列表数据
  24. /// <summary>
  25. /// <param name="queryJson">查询参数</param>
  26. /// <returns></returns>
  27. public IEnumerable<TeacherPunishmentEntity> GetPageList(Pagination pagination, string queryJson)
  28. {
  29. try
  30. {
  31. var strSql = new StringBuilder();
  32. strSql.Append("SELECT ");
  33. strSql.Append(@" * ");
  34. strSql.Append(" FROM TeacherPunishment t ");
  35. strSql.Append(" WHERE 1=1 ");
  36. var queryParam = queryJson.ToJObject();
  37. // 虚拟参数
  38. var dp = new DynamicParameters(new { });
  39. if (!queryParam["EmpId"].IsEmpty())
  40. {
  41. dp.Add("EmpId",queryParam["EmpId"].ToString(), DbType.String);
  42. strSql.Append(" AND t.EmpId = @EmpId ");
  43. }
  44. if (!queryParam["PunishmentName"].IsEmpty())
  45. {
  46. dp.Add("PunishmentName", "%" + queryParam["PunishmentName"].ToString() + "%", DbType.String);
  47. strSql.Append(" AND t.PunishmentName Like @PunishmentName ");
  48. }
  49. return this.BaseRepository().FindList<TeacherPunishmentEntity>(strSql.ToString(),dp, pagination);
  50. }
  51. catch (Exception ex)
  52. {
  53. if (ex is ExceptionEx)
  54. {
  55. throw;
  56. }
  57. else
  58. {
  59. throw ExceptionEx.ThrowServiceException(ex);
  60. }
  61. }
  62. }
  63. /// <summary>
  64. /// 获取TeacherPunishment表实体数据
  65. /// <param name="keyValue">主键</param>
  66. /// <summary>
  67. /// <returns></returns>
  68. public TeacherPunishmentEntity GetTeacherPunishmentEntity(string keyValue)
  69. {
  70. try
  71. {
  72. return this.BaseRepository().FindEntity<TeacherPunishmentEntity>(keyValue);
  73. }
  74. catch (Exception ex)
  75. {
  76. if (ex is ExceptionEx)
  77. {
  78. throw;
  79. }
  80. else
  81. {
  82. throw ExceptionEx.ThrowServiceException(ex);
  83. }
  84. }
  85. }
  86. /// <summary>
  87. /// 获取页面显示列表数据
  88. /// <summary>
  89. /// <param name="queryJson">查询参数</param>
  90. /// <returns></returns>
  91. public IEnumerable<TeacherPunishmentEntity> GetListByEmpId(string empId)
  92. {
  93. try
  94. {
  95. var data = new List<TeacherPunishmentEntity>();
  96. var empInfoEntity = this.BaseRepository("CollegeMIS").FindEntity<EmpInfoEntity>(empId);
  97. if (empInfoEntity != null)
  98. {
  99. var userEntity = this.BaseRepository().FindEntity<UserEntity>(x => x.F_Account == empInfoEntity.EmpNo);
  100. if (userEntity != null)
  101. {
  102. return this.BaseRepository().FindList<TeacherPunishmentEntity>(x => x.EmpId == userEntity.F_UserId);
  103. }
  104. }
  105. return data;
  106. }
  107. catch (Exception ex)
  108. {
  109. if (ex is ExceptionEx)
  110. {
  111. throw;
  112. }
  113. else
  114. {
  115. throw ExceptionEx.ThrowServiceException(ex);
  116. }
  117. }
  118. }
  119. #endregion
  120. #region 提交数据
  121. /// <summary>
  122. /// 删除实体数据
  123. /// <param name="keyValue">主键</param>
  124. /// <summary>
  125. /// <returns></returns>
  126. public void DeleteEntity(string keyValue)
  127. {
  128. try
  129. {
  130. this.BaseRepository().Delete<TeacherPunishmentEntity>(t=>t.Id == keyValue);
  131. }
  132. catch (Exception ex)
  133. {
  134. if (ex is ExceptionEx)
  135. {
  136. throw;
  137. }
  138. else
  139. {
  140. throw ExceptionEx.ThrowServiceException(ex);
  141. }
  142. }
  143. }
  144. /// <summary>
  145. /// 保存实体数据(新增、修改)
  146. /// <param name="keyValue">主键</param>
  147. /// <summary>
  148. /// <returns></returns>
  149. public void SaveEntity(string keyValue, TeacherPunishmentEntity entity)
  150. {
  151. try
  152. {
  153. if (!string.IsNullOrEmpty(keyValue))
  154. {
  155. entity.Modify(keyValue);
  156. this.BaseRepository().Update(entity);
  157. }
  158. else
  159. {
  160. entity.Create();
  161. this.BaseRepository().Insert(entity);
  162. }
  163. }
  164. catch (Exception ex)
  165. {
  166. if (ex is ExceptionEx)
  167. {
  168. throw;
  169. }
  170. else
  171. {
  172. throw ExceptionEx.ThrowServiceException(ex);
  173. }
  174. }
  175. }
  176. #endregion
  177. }
  178. }