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.
 
 
 
 
 
 

240 lines
6.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.Linq;
  8. using System.Text;
  9. namespace Learun.Application.TwoDevelopment.EducationalAdministration
  10. {
  11. /// <summary>
  12. /// 版 本 Learun-ADMS V7.0.6 力软敏捷开发框架
  13. /// Copyright (c) 2013-2020 力软信息技术(苏州)有限公司
  14. /// 创 建:超级管理员
  15. /// 日 期:2021-07-06 12:05
  16. /// 描 述:收文阅读
  17. /// </summary>
  18. public class DispatchAuditService : RepositoryFactory
  19. {
  20. #region 构造函数和属性
  21. private string fieldSql;
  22. /// <summary>
  23. /// 构造方法
  24. /// </summary>
  25. public DispatchAuditService()
  26. {
  27. fieldSql = @"
  28. t.Id,
  29. t.DisId,
  30. t.AuditTime,
  31. t.AuditUser,
  32. t.AuditName
  33. ";
  34. }
  35. #endregion
  36. #region 获取数据
  37. /// <summary>
  38. /// 获取列表数据
  39. /// </summary>
  40. /// <param name="queryJson">条件参数</param>
  41. /// <returns></returns>
  42. public IEnumerable<DispatchAuditEntity> GetList(string queryJson)
  43. {
  44. try
  45. {
  46. //参考写法
  47. //var queryParam = queryJson.ToJObject();
  48. // 虚拟参数
  49. //var dp = new DynamicParameters(new { });
  50. //dp.Add("startTime", queryParam["StartTime"].ToDate(), DbType.DateTime);
  51. var strSql = new StringBuilder();
  52. strSql.Append("SELECT ");
  53. strSql.Append(fieldSql);
  54. strSql.Append(" FROM DispatchAudit t ");
  55. return this.BaseRepository("CollegeMIS").FindList<DispatchAuditEntity>(strSql.ToString());
  56. }
  57. catch (Exception ex)
  58. {
  59. if (ex is ExceptionEx)
  60. {
  61. throw;
  62. }
  63. else
  64. {
  65. throw ExceptionEx.ThrowServiceException(ex);
  66. }
  67. }
  68. }
  69. /// <summary>
  70. /// 获取列表分页数据
  71. /// </summary>
  72. /// <param name="pagination">分页参数</param>
  73. /// <param name="queryJson">条件参数</param>
  74. /// <returns></returns>
  75. public IEnumerable<DispatchAuditEntity> GetPageList(Pagination pagination, string queryJson)
  76. {
  77. try
  78. {
  79. var strSql = new StringBuilder();
  80. strSql.Append("SELECT ");
  81. strSql.Append(fieldSql);
  82. strSql.Append(" FROM DispatchAudit t ");
  83. return this.BaseRepository("CollegeMIS").FindList<DispatchAuditEntity>(strSql.ToString(), pagination);
  84. }
  85. catch (Exception ex)
  86. {
  87. if (ex is ExceptionEx)
  88. {
  89. throw;
  90. }
  91. else
  92. {
  93. throw ExceptionEx.ThrowServiceException(ex);
  94. }
  95. }
  96. }
  97. /// <summary>
  98. /// 获取实体数据
  99. /// </summary>
  100. /// <param name="keyValue">主键</param>
  101. /// <returns></returns>
  102. public DispatchAuditEntity GetEntity(string keyValue)
  103. {
  104. try
  105. {
  106. return this.BaseRepository("CollegeMIS").FindEntity<DispatchAuditEntity>(keyValue);
  107. }
  108. catch (Exception ex)
  109. {
  110. if (ex is ExceptionEx)
  111. {
  112. throw;
  113. }
  114. else
  115. {
  116. throw ExceptionEx.ThrowServiceException(ex);
  117. }
  118. }
  119. }
  120. #endregion
  121. #region 提交数据
  122. /// <summary>
  123. /// 删除实体数据
  124. /// </summary>
  125. /// <param name="keyValue">主键</param>
  126. public void DeleteEntity(string keyValue)
  127. {
  128. try
  129. {
  130. this.BaseRepository("CollegeMIS").Delete<DispatchAuditEntity>(t => t.Id == keyValue);
  131. }
  132. catch (Exception ex)
  133. {
  134. if (ex is ExceptionEx)
  135. {
  136. throw;
  137. }
  138. else
  139. {
  140. throw ExceptionEx.ThrowServiceException(ex);
  141. }
  142. }
  143. }
  144. /// <summary>
  145. /// 保存实体数据(新增、修改)
  146. /// <param name="keyValue">主键</param>
  147. /// <param name="entity">实体</param>
  148. /// </summary>
  149. public void SaveEntity(string keyValue, DispatchAuditEntity entity)
  150. {
  151. try
  152. {
  153. if (!string.IsNullOrEmpty(keyValue))
  154. {
  155. entity.Modify(keyValue);
  156. this.BaseRepository("CollegeMIS").Update(entity);
  157. }
  158. else
  159. {
  160. entity.Create();
  161. this.BaseRepository("CollegeMIS").Insert(entity);
  162. }
  163. }
  164. catch (Exception ex)
  165. {
  166. if (ex is ExceptionEx)
  167. {
  168. throw;
  169. }
  170. else
  171. {
  172. throw ExceptionEx.ThrowServiceException(ex);
  173. }
  174. }
  175. }
  176. #endregion
  177. #region 扩展数据
  178. /// <summary>
  179. /// 查阅数据
  180. /// </summary>
  181. /// <param name="DisId"></param>
  182. /// <param name="Name"></param>
  183. public DispatchAuditEntity Repetition(string DisId, string Name)
  184. {
  185. try
  186. {
  187. return this.BaseRepository("CollegeMIS").FindEntity<DispatchAuditEntity>(x => x.DisId == DisId && x.AuditName == Name);
  188. }
  189. catch (Exception ex)
  190. {
  191. if (ex is ExceptionEx)
  192. {
  193. throw;
  194. }
  195. else
  196. {
  197. throw ExceptionEx.ThrowServiceException(ex);
  198. }
  199. }
  200. }
  201. /// <summary>
  202. /// 获取查阅数据
  203. /// </summary>
  204. /// <param name="DisId"></param>
  205. public List<DispatchAuditEntity> ReadList(string DisId)
  206. {
  207. try
  208. {
  209. return this.BaseRepository("CollegeMIS").FindList<DispatchAuditEntity>(x => x.DisId == DisId).ToList();
  210. }
  211. catch (Exception ex)
  212. {
  213. if (ex is ExceptionEx)
  214. {
  215. throw;
  216. }
  217. else
  218. {
  219. throw ExceptionEx.ThrowServiceException(ex);
  220. }
  221. }
  222. }
  223. #endregion
  224. }
  225. }