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.
 
 
 
 
 
 

194 lines
6.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-Ultimate V7.0.0 数字化智慧校园
  12. /// Copyright (c) 2013-2018 北京泉江科技有限公司
  13. /// 创 建:超级管理员
  14. /// 日 期:2019-12-26 16:33
  15. /// 描 述:掌上报修
  16. /// </summary>
  17. public class EmpRepairService : 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<EmpRepairEntity> GetPageList(Pagination pagination, string queryJson)
  27. {
  28. try
  29. {
  30. var strSql = new StringBuilder();
  31. strSql.Append("SELECT t.* ");
  32. strSql.Append(" FROM EmpRepair t ");
  33. strSql.Append(" WHERE 1=1 ");
  34. var queryParam = queryJson.ToJObject();
  35. // 虚拟参数
  36. var dp = new DynamicParameters(new { });
  37. if (!queryParam["ApplyCode"].IsEmpty())
  38. {
  39. dp.Add("ApplyCode", "%" + queryParam["ApplyCode"].ToString() + "%", DbType.String);
  40. strSql.Append(" AND t.ApplyCode Like @ApplyCode ");
  41. }
  42. if (!queryParam["ApplyContent"].IsEmpty())
  43. {
  44. dp.Add("ApplyContent", "%" + queryParam["ApplyContent"].ToString() + "%", DbType.String);
  45. strSql.Append(" AND t.ApplyContent Like @ApplyContent ");
  46. }
  47. return this.BaseRepository("CollegeMIS").FindList<EmpRepairEntity>(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. /// 获取页面显示列表数据
  63. /// <summary>
  64. /// <param name="queryJson">查询参数</param>
  65. /// <returns></returns>
  66. public IEnumerable<EmpRepairEntity> GetList(string queryJson)
  67. {
  68. try
  69. {
  70. var strSql = new StringBuilder();
  71. strSql.Append("SELECT t.* ");
  72. strSql.Append(" FROM EmpRepair t ");
  73. strSql.Append(" WHERE 1=1 ");
  74. var queryParam = queryJson.ToJObject();
  75. // 虚拟参数
  76. var dp = new DynamicParameters(new { });
  77. if (!queryParam["ApplyCode"].IsEmpty())
  78. {
  79. dp.Add("ApplyCode", "%" + queryParam["ApplyCode"].ToString() + "%", DbType.String);
  80. strSql.Append(" AND t.ApplyCode Like @ApplyCode ");
  81. }
  82. if (!queryParam["ApplyContent"].IsEmpty())
  83. {
  84. dp.Add("ApplyContent", "%" + queryParam["ApplyContent"].ToString() + "%", DbType.String);
  85. strSql.Append(" AND t.ApplyContent Like @ApplyContent ");
  86. }
  87. return this.BaseRepository("CollegeMIS").FindList<EmpRepairEntity>(strSql.ToString(),dp);
  88. }
  89. catch (Exception ex)
  90. {
  91. if (ex is ExceptionEx)
  92. {
  93. throw;
  94. }
  95. else
  96. {
  97. throw ExceptionEx.ThrowServiceException(ex);
  98. }
  99. }
  100. }
  101. /// <summary>
  102. /// 获取EmpRepair表实体数据
  103. /// <param name="keyValue">主键</param>
  104. /// <summary>
  105. /// <returns></returns>
  106. public EmpRepairEntity GetEmpRepairEntity(string keyValue)
  107. {
  108. try
  109. {
  110. return this.BaseRepository("CollegeMIS").FindEntity<EmpRepairEntity>(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. #endregion
  125. #region 提交数据
  126. /// <summary>
  127. /// 删除实体数据
  128. /// <param name="keyValue">主键</param>
  129. /// <summary>
  130. /// <returns></returns>
  131. public void DeleteEntity(string keyValue)
  132. {
  133. try
  134. {
  135. this.BaseRepository("CollegeMIS").Delete<EmpRepairEntity>(t=>t.Id == keyValue);
  136. }
  137. catch (Exception ex)
  138. {
  139. if (ex is ExceptionEx)
  140. {
  141. throw;
  142. }
  143. else
  144. {
  145. throw ExceptionEx.ThrowServiceException(ex);
  146. }
  147. }
  148. }
  149. /// <summary>
  150. /// 保存实体数据(新增、修改)
  151. /// <param name="keyValue">主键</param>
  152. /// <summary>
  153. /// <returns></returns>
  154. public void SaveEntity( UserInfo userInfo, string keyValue, EmpRepairEntity entity)
  155. {
  156. try
  157. {
  158. if (!string.IsNullOrEmpty(keyValue))
  159. {
  160. entity.Modify(keyValue,userInfo);
  161. this.BaseRepository("CollegeMIS").Update(entity);
  162. }
  163. else
  164. {
  165. entity.Create(userInfo);
  166. this.BaseRepository("CollegeMIS").Insert(entity);
  167. }
  168. }
  169. catch (Exception ex)
  170. {
  171. if (ex is ExceptionEx)
  172. {
  173. throw;
  174. }
  175. else
  176. {
  177. throw ExceptionEx.ThrowServiceException(ex);
  178. }
  179. }
  180. }
  181. #endregion
  182. }
  183. }