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.
 
 
 
 
 
 

168 lines
5.1 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-05-08 18:08
  15. /// 描 述:教科研人员管理
  16. /// </summary>
  17. public class ResearchMentService : 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<ResearchMentEntity> GetPageList(Pagination pagination, string queryJson)
  27. {
  28. try
  29. {
  30. var strSql = new StringBuilder();
  31. strSql.Append("SELECT ");
  32. strSql.Append(@"
  33. t.MentID,
  34. t.MentName,
  35. t.IfSchool,
  36. t.TheTitle,
  37. t.MentSex,
  38. t.MentBirth,
  39. t.iphone,
  40. t.Learn,
  41. t.IdNumber
  42. ");
  43. strSql.Append(" FROM ResearchMent t ");
  44. strSql.Append(" WHERE 1=1 ");
  45. var queryParam = queryJson.ToJObject();
  46. // 虚拟参数
  47. var dp = new DynamicParameters(new { });
  48. if (!queryParam["MentName"].IsEmpty())
  49. {
  50. dp.Add("MentName", "%" + queryParam["MentName"].ToString() + "%", DbType.String);
  51. strSql.Append(" AND t.MentName Like @MentName ");
  52. }
  53. if (!queryParam["TheTitle"].IsEmpty())
  54. {
  55. dp.Add("TheTitle",queryParam["TheTitle"].ToString(), DbType.String);
  56. strSql.Append(" AND t.TheTitle = @TheTitle ");
  57. }
  58. if (!queryParam["IdNumber"].IsEmpty())
  59. {
  60. dp.Add("IdNumber", "%" + queryParam["IdNumber"].ToString() + "%", DbType.String);
  61. strSql.Append(" AND t.IdNumber Like @IdNumber ");
  62. }
  63. return this.BaseRepository("CollegeMIS").FindList<ResearchMentEntity>(strSql.ToString(),dp, pagination);
  64. }
  65. catch (Exception ex)
  66. {
  67. if (ex is ExceptionEx)
  68. {
  69. throw;
  70. }
  71. else
  72. {
  73. throw ExceptionEx.ThrowServiceException(ex);
  74. }
  75. }
  76. }
  77. /// <summary>
  78. /// 获取ResearchMent表实体数据
  79. /// </summary>
  80. /// <param name="keyValue">主键</param>
  81. /// <returns></returns>
  82. public ResearchMentEntity GetResearchMentEntity(string keyValue)
  83. {
  84. try
  85. {
  86. return this.BaseRepository("CollegeMIS").FindEntity<ResearchMentEntity>(keyValue);
  87. }
  88. catch (Exception ex)
  89. {
  90. if (ex is ExceptionEx)
  91. {
  92. throw;
  93. }
  94. else
  95. {
  96. throw ExceptionEx.ThrowServiceException(ex);
  97. }
  98. }
  99. }
  100. #endregion
  101. #region 提交数据
  102. /// <summary>
  103. /// 删除实体数据
  104. /// </summary>
  105. /// <param name="keyValue">主键</param>
  106. public void DeleteEntity(string keyValue)
  107. {
  108. try
  109. {
  110. this.BaseRepository("CollegeMIS").Delete<ResearchMentEntity>(t=>t.MentID == keyValue);
  111. }
  112. catch (Exception ex)
  113. {
  114. if (ex is ExceptionEx)
  115. {
  116. throw;
  117. }
  118. else
  119. {
  120. throw ExceptionEx.ThrowServiceException(ex);
  121. }
  122. }
  123. }
  124. /// <summary>
  125. /// 保存实体数据(新增、修改)
  126. /// </summary>
  127. /// <param name="keyValue">主键</param>
  128. /// <param name="entity">实体</param>
  129. public void SaveEntity(string keyValue, ResearchMentEntity entity)
  130. {
  131. try
  132. {
  133. if (!string.IsNullOrEmpty(keyValue))
  134. {
  135. entity.Modify(keyValue);
  136. this.BaseRepository("CollegeMIS").Update(entity);
  137. }
  138. else
  139. {
  140. entity.Create();
  141. this.BaseRepository("CollegeMIS").Insert(entity);
  142. }
  143. }
  144. catch (Exception ex)
  145. {
  146. if (ex is ExceptionEx)
  147. {
  148. throw;
  149. }
  150. else
  151. {
  152. throw ExceptionEx.ThrowServiceException(ex);
  153. }
  154. }
  155. }
  156. #endregion
  157. }
  158. }