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.
 
 
 
 
 
 

163 lines
4.8 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 11:53
  15. /// 描 述:在职教职工校外兼职管理
  16. /// </summary>
  17. public class TeacherPartTimeJobService : RepositoryFactory
  18. {
  19. #region 获取数据
  20. /// <summary>
  21. /// 获取页面显示列表数据
  22. /// <summary>
  23. /// <param name="queryJson">查询参数</param>
  24. /// <returns></returns>
  25. public IEnumerable<TeacherPartTimeJobEntity> 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.School,
  35. t.Department,
  36. t.Post,
  37. t.Certificate,
  38. t.CertificateNo,
  39. t.StartTime,
  40. t.EndTime
  41. ");
  42. strSql.Append(" FROM TeacherPartTimeJob t ");
  43. strSql.Append(" WHERE 1=1 ");
  44. var queryParam = queryJson.ToJObject();
  45. // 虚拟参数
  46. var dp = new DynamicParameters(new { });
  47. if (!queryParam["EmpId"].IsEmpty())
  48. {
  49. dp.Add("EmpId",queryParam["EmpId"].ToString(), DbType.String);
  50. strSql.Append(" AND t.EmpId = @EmpId ");
  51. }
  52. if (!queryParam["CertificateNo"].IsEmpty())
  53. {
  54. dp.Add("CertificateNo", "%" + queryParam["CertificateNo"].ToString() + "%", DbType.String);
  55. strSql.Append(" AND t.CertificateNo Like @CertificateNo ");
  56. }
  57. return this.BaseRepository().FindList<TeacherPartTimeJobEntity>(strSql.ToString(),dp, pagination);
  58. }
  59. catch (Exception ex)
  60. {
  61. if (ex is ExceptionEx)
  62. {
  63. throw;
  64. }
  65. else
  66. {
  67. throw ExceptionEx.ThrowServiceException(ex);
  68. }
  69. }
  70. }
  71. /// <summary>
  72. /// 获取TeacherPartTimeJob表实体数据
  73. /// <param name="keyValue">主键</param>
  74. /// <summary>
  75. /// <returns></returns>
  76. public TeacherPartTimeJobEntity GetTeacherPartTimeJobEntity(string keyValue)
  77. {
  78. try
  79. {
  80. return this.BaseRepository().FindEntity<TeacherPartTimeJobEntity>(keyValue);
  81. }
  82. catch (Exception ex)
  83. {
  84. if (ex is ExceptionEx)
  85. {
  86. throw;
  87. }
  88. else
  89. {
  90. throw ExceptionEx.ThrowServiceException(ex);
  91. }
  92. }
  93. }
  94. #endregion
  95. #region 提交数据
  96. /// <summary>
  97. /// 删除实体数据
  98. /// <param name="keyValue">主键</param>
  99. /// <summary>
  100. /// <returns></returns>
  101. public void DeleteEntity(string keyValue)
  102. {
  103. try
  104. {
  105. this.BaseRepository().Delete<TeacherPartTimeJobEntity>(t=>t.Id == keyValue);
  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. /// <summary>
  120. /// 保存实体数据(新增、修改)
  121. /// <param name="keyValue">主键</param>
  122. /// <summary>
  123. /// <returns></returns>
  124. public void SaveEntity(string keyValue, TeacherPartTimeJobEntity entity)
  125. {
  126. try
  127. {
  128. if (!string.IsNullOrEmpty(keyValue))
  129. {
  130. entity.Modify(keyValue);
  131. this.BaseRepository().Update(entity);
  132. }
  133. else
  134. {
  135. entity.Create();
  136. this.BaseRepository().Insert(entity);
  137. }
  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. #endregion
  152. }
  153. }