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.
 
 
 
 
 
 

195 lines
6.0 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. t.Id,
  35. t.EmpId,
  36. t.PunishmentName,
  37. t.Reason,
  38. t.StartTime,
  39. t.EndTime
  40. ");
  41. strSql.Append(" FROM TeacherPunishment t ");
  42. strSql.Append(" WHERE 1=1 ");
  43. var queryParam = queryJson.ToJObject();
  44. // 虚拟参数
  45. var dp = new DynamicParameters(new { });
  46. if (!queryParam["EmpId"].IsEmpty())
  47. {
  48. dp.Add("EmpId",queryParam["EmpId"].ToString(), DbType.String);
  49. strSql.Append(" AND t.EmpId = @EmpId ");
  50. }
  51. if (!queryParam["PunishmentName"].IsEmpty())
  52. {
  53. dp.Add("PunishmentName", "%" + queryParam["PunishmentName"].ToString() + "%", DbType.String);
  54. strSql.Append(" AND t.PunishmentName Like @PunishmentName ");
  55. }
  56. return this.BaseRepository().FindList<TeacherPunishmentEntity>(strSql.ToString(),dp, pagination);
  57. }
  58. catch (Exception ex)
  59. {
  60. if (ex is ExceptionEx)
  61. {
  62. throw;
  63. }
  64. else
  65. {
  66. throw ExceptionEx.ThrowServiceException(ex);
  67. }
  68. }
  69. }
  70. /// <summary>
  71. /// 获取TeacherPunishment表实体数据
  72. /// <param name="keyValue">主键</param>
  73. /// <summary>
  74. /// <returns></returns>
  75. public TeacherPunishmentEntity GetTeacherPunishmentEntity(string keyValue)
  76. {
  77. try
  78. {
  79. return this.BaseRepository().FindEntity<TeacherPunishmentEntity>(keyValue);
  80. }
  81. catch (Exception ex)
  82. {
  83. if (ex is ExceptionEx)
  84. {
  85. throw;
  86. }
  87. else
  88. {
  89. throw ExceptionEx.ThrowServiceException(ex);
  90. }
  91. }
  92. }
  93. /// <summary>
  94. /// 获取页面显示列表数据
  95. /// <summary>
  96. /// <param name="queryJson">查询参数</param>
  97. /// <returns></returns>
  98. public IEnumerable<TeacherPunishmentEntity> GetListByEmpId(string empId)
  99. {
  100. try
  101. {
  102. var data = new List<TeacherPunishmentEntity>();
  103. var empInfoEntity = this.BaseRepository("CollegeMIS").FindEntity<EmpInfoEntity>(empId);
  104. if (empInfoEntity != null)
  105. {
  106. var userEntity = this.BaseRepository().FindEntity<UserEntity>(x => x.F_Account == empInfoEntity.EmpNo);
  107. if (userEntity != null)
  108. {
  109. return this.BaseRepository().FindList<TeacherPunishmentEntity>(x => x.EmpId == userEntity.F_UserId);
  110. }
  111. }
  112. return data;
  113. }
  114. catch (Exception ex)
  115. {
  116. if (ex is ExceptionEx)
  117. {
  118. throw;
  119. }
  120. else
  121. {
  122. throw ExceptionEx.ThrowServiceException(ex);
  123. }
  124. }
  125. }
  126. #endregion
  127. #region 提交数据
  128. /// <summary>
  129. /// 删除实体数据
  130. /// <param name="keyValue">主键</param>
  131. /// <summary>
  132. /// <returns></returns>
  133. public void DeleteEntity(string keyValue)
  134. {
  135. try
  136. {
  137. this.BaseRepository().Delete<TeacherPunishmentEntity>(t=>t.Id == keyValue);
  138. }
  139. catch (Exception ex)
  140. {
  141. if (ex is ExceptionEx)
  142. {
  143. throw;
  144. }
  145. else
  146. {
  147. throw ExceptionEx.ThrowServiceException(ex);
  148. }
  149. }
  150. }
  151. /// <summary>
  152. /// 保存实体数据(新增、修改)
  153. /// <param name="keyValue">主键</param>
  154. /// <summary>
  155. /// <returns></returns>
  156. public void SaveEntity(string keyValue, TeacherPunishmentEntity entity)
  157. {
  158. try
  159. {
  160. if (!string.IsNullOrEmpty(keyValue))
  161. {
  162. entity.Modify(keyValue);
  163. this.BaseRepository().Update(entity);
  164. }
  165. else
  166. {
  167. entity.Create();
  168. this.BaseRepository().Insert(entity);
  169. }
  170. }
  171. catch (Exception ex)
  172. {
  173. if (ex is ExceptionEx)
  174. {
  175. throw;
  176. }
  177. else
  178. {
  179. throw ExceptionEx.ThrowServiceException(ex);
  180. }
  181. }
  182. }
  183. #endregion
  184. }
  185. }