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.
 
 
 
 
 
 

223 lines
7.0 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. /// 日 期:2021-03-04 14:21
  15. /// 描 述:教师销假管理
  16. /// </summary>
  17. public class TeacherCancelLeaveManagementService : 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<TeacherCancelLeaveManagementEntity> GetPageList(Pagination pagination, string queryJson)
  27. {
  28. try
  29. {
  30. var strSql = new StringBuilder();
  31. strSql.Append("SELECT t.* ");
  32. strSql.Append(" FROM TeacherCancelLeaveManagement t ");
  33. strSql.Append(" WHERE 1=1 ");
  34. var queryParam = queryJson.ToJObject();
  35. // 虚拟参数
  36. var dp = new DynamicParameters(new { });
  37. if (!queryParam["CancelLeaveType"].IsEmpty())
  38. {
  39. dp.Add("CancelLeaveType",queryParam["CancelLeaveType"].ToString(), DbType.String);
  40. strSql.Append(" AND t.CancelLeaveType = @CancelLeaveType ");
  41. }
  42. if (!queryParam["CreateUserId"].IsEmpty())
  43. {
  44. dp.Add("CreateUserId",queryParam["CreateUserId"].ToString(), DbType.String);
  45. strSql.Append(" AND t.CreateUserId = @CreateUserId ");
  46. }
  47. return this.BaseRepository("CollegeMIS").FindList<TeacherCancelLeaveManagementEntity>(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. /// 获取TeacherCancelLeaveManagement表实体数据
  63. /// </summary>
  64. /// <param name="keyValue">主键</param>
  65. /// <returns></returns>
  66. public TeacherCancelLeaveManagementEntity GetTeacherCancelLeaveManagementEntity(string keyValue)
  67. {
  68. try
  69. {
  70. return this.BaseRepository("CollegeMIS").FindEntity<TeacherCancelLeaveManagementEntity>(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. /// 获取主表实体数据
  86. /// </summary>
  87. /// <param name="processId">流程实例ID</param>
  88. /// <returns></returns>
  89. public TeacherCancelLeaveManagementEntity GetEntityByProcessId(string processId)
  90. {
  91. try
  92. {
  93. return this.BaseRepository("CollegeMIS").FindEntity<TeacherCancelLeaveManagementEntity>(t=>t.ProcessId == processId);
  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. /// </summary>
  112. /// <param name="keyValue">主键</param>
  113. public void DeleteEntity(string keyValue)
  114. {
  115. try
  116. {
  117. this.BaseRepository("CollegeMIS").Delete<TeacherCancelLeaveManagementEntity>(t=>t.Id == keyValue);
  118. }
  119. catch (Exception ex)
  120. {
  121. if (ex is ExceptionEx)
  122. {
  123. throw;
  124. }
  125. else
  126. {
  127. throw ExceptionEx.ThrowServiceException(ex);
  128. }
  129. }
  130. }
  131. /// <summary>
  132. /// 保存实体数据(新增、修改)
  133. /// </summary>
  134. /// <param name="keyValue">主键</param>
  135. /// <param name="entity">实体</param>
  136. /// <returns></returns>
  137. public void SaveEntity(string keyValue, TeacherCancelLeaveManagementEntity entity)
  138. {
  139. try
  140. {
  141. if (!string.IsNullOrEmpty(keyValue))
  142. {
  143. entity.Modify(keyValue);
  144. this.BaseRepository("CollegeMIS").Update(entity);
  145. }
  146. else
  147. {
  148. entity.Create();
  149. this.BaseRepository("CollegeMIS").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. /// <summary>
  165. /// 提交实体数据
  166. /// </summary>
  167. /// <param name="keyValue">主键</param>
  168. public void DoSubmit(string keyValue, string status, string processId)
  169. {
  170. try
  171. {
  172. this.BaseRepository("CollegeMIS").ExecuteBySql("update TeacherCancelLeaveManagement set CheckStatus='" + status + "',ProcessId='" + processId + "' where Id='" + keyValue + "' ");
  173. }
  174. catch (Exception ex)
  175. {
  176. if (ex is ExceptionEx)
  177. {
  178. throw;
  179. }
  180. else
  181. {
  182. throw ExceptionEx.ThrowServiceException(ex);
  183. }
  184. }
  185. }
  186. /// <summary>
  187. /// 审核实体数据
  188. /// </summary>
  189. /// <param name="keyValue">主键</param>
  190. public void ChangeStatusByProcessId(string status, string processId, string userId)
  191. {
  192. try
  193. {
  194. this.BaseRepository("CollegeMIS").ExecuteBySql("update TeacherCancelLeaveManagement set CheckStatus='" + status + "',CheckUserId='" + userId + "',CheckTime='" + DateTime.Now + "' where ProcessId='" + processId + "' ");
  195. }
  196. catch (Exception ex)
  197. {
  198. if (ex is ExceptionEx)
  199. {
  200. throw;
  201. }
  202. else
  203. {
  204. throw ExceptionEx.ThrowServiceException(ex);
  205. }
  206. }
  207. }
  208. #endregion
  209. }
  210. }