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.
 
 
 
 
 
 

160 lines
4.7 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-03-23 14:49
  15. /// 描 述:获奖管理
  16. /// </summary>
  17. public class SRWinningService : RepositoryFactory
  18. {
  19. #region 获取数据
  20. /// <summary>
  21. /// 获取页面显示列表数据
  22. /// <summary>
  23. /// <param name="queryJson">查询参数</param>
  24. /// <returns></returns>
  25. public IEnumerable<SRWinningEntity> 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.Name,
  34. t.WinningName,
  35. t.Content,
  36. t.Time,
  37. t.Files
  38. ");
  39. strSql.Append(" FROM SRWinning t ");
  40. strSql.Append(" WHERE 1=1 ");
  41. var queryParam = queryJson.ToJObject();
  42. // 虚拟参数
  43. var dp = new DynamicParameters(new { });
  44. if (!queryParam["Name"].IsEmpty())
  45. {
  46. dp.Add("Name", "%" + queryParam["Name"].ToString() + "%", DbType.String);
  47. strSql.Append(" AND t.Name Like @Name ");
  48. }
  49. if (!queryParam["WinningName"].IsEmpty())
  50. {
  51. dp.Add("WinningName", "%" + queryParam["WinningName"].ToString() + "%", DbType.String);
  52. strSql.Append(" AND t.WinningName Like @WinningName ");
  53. }
  54. return this.BaseRepository("CollegeMIS").FindList<SRWinningEntity>(strSql.ToString(),dp, pagination);
  55. }
  56. catch (Exception ex)
  57. {
  58. if (ex is ExceptionEx)
  59. {
  60. throw;
  61. }
  62. else
  63. {
  64. throw ExceptionEx.ThrowServiceException(ex);
  65. }
  66. }
  67. }
  68. /// <summary>
  69. /// 获取SRWinning表实体数据
  70. /// <param name="keyValue">主键</param>
  71. /// <summary>
  72. /// <returns></returns>
  73. public SRWinningEntity GetSRWinningEntity(string keyValue)
  74. {
  75. try
  76. {
  77. return this.BaseRepository("CollegeMIS").FindEntity<SRWinningEntity>(keyValue);
  78. }
  79. catch (Exception ex)
  80. {
  81. if (ex is ExceptionEx)
  82. {
  83. throw;
  84. }
  85. else
  86. {
  87. throw ExceptionEx.ThrowServiceException(ex);
  88. }
  89. }
  90. }
  91. #endregion
  92. #region 提交数据
  93. /// <summary>
  94. /// 删除实体数据
  95. /// <param name="keyValue">主键</param>
  96. /// <summary>
  97. /// <returns></returns>
  98. public void DeleteEntity(string keyValue)
  99. {
  100. try
  101. {
  102. this.BaseRepository("CollegeMIS").Delete<SRWinningEntity>(t=>t.Id == keyValue);
  103. }
  104. catch (Exception ex)
  105. {
  106. if (ex is ExceptionEx)
  107. {
  108. throw;
  109. }
  110. else
  111. {
  112. throw ExceptionEx.ThrowServiceException(ex);
  113. }
  114. }
  115. }
  116. /// <summary>
  117. /// 保存实体数据(新增、修改)
  118. /// <param name="keyValue">主键</param>
  119. /// <summary>
  120. /// <returns></returns>
  121. public void SaveEntity(string keyValue, SRWinningEntity entity)
  122. {
  123. try
  124. {
  125. if (!string.IsNullOrEmpty(keyValue))
  126. {
  127. entity.Modify(keyValue);
  128. this.BaseRepository("CollegeMIS").Update(entity);
  129. }
  130. else
  131. {
  132. entity.Create();
  133. this.BaseRepository("CollegeMIS").Insert(entity);
  134. }
  135. }
  136. catch (Exception ex)
  137. {
  138. if (ex is ExceptionEx)
  139. {
  140. throw;
  141. }
  142. else
  143. {
  144. throw ExceptionEx.ThrowServiceException(ex);
  145. }
  146. }
  147. }
  148. #endregion
  149. }
  150. }