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.
 
 
 
 
 
 

161 lines
4.9 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-04 16:17
  15. /// 描 述:奖学金管理
  16. /// </summary>
  17. public class ScholarshipManagementService : RepositoryFactory
  18. {
  19. #region 获取数据
  20. /// <summary>
  21. /// 获取页面显示列表数据
  22. /// <summary>
  23. /// <param name="queryJson">查询参数</param>
  24. /// <returns></returns>
  25. public IEnumerable<ScholarshipManagementEntity> 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.ScholarshipType,
  34. t.ScholarshipDegree,
  35. t.Money,
  36. t.Count,
  37. t.Condition,
  38. t.Remark
  39. ");
  40. strSql.Append(" FROM ScholarshipManagement t ");
  41. strSql.Append(" WHERE 1=1 ");
  42. var queryParam = queryJson.ToJObject();
  43. // 虚拟参数
  44. var dp = new DynamicParameters(new { });
  45. if (!queryParam["ScholarshipType"].IsEmpty())
  46. {
  47. dp.Add("ScholarshipType",queryParam["ScholarshipType"].ToString(), DbType.String);
  48. strSql.Append(" AND t.ScholarshipType = @ScholarshipType ");
  49. }
  50. if (!queryParam["ScholarshipDegree"].IsEmpty())
  51. {
  52. dp.Add("ScholarshipDegree",queryParam["ScholarshipDegree"].ToString(), DbType.String);
  53. strSql.Append(" AND t.ScholarshipDegree = @ScholarshipDegree ");
  54. }
  55. return this.BaseRepository("CollegeMIS").FindList<ScholarshipManagementEntity>(strSql.ToString(),dp, pagination);
  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. /// 获取ScholarshipManagement表实体数据
  71. /// <param name="keyValue">主键</param>
  72. /// <summary>
  73. /// <returns></returns>
  74. public ScholarshipManagementEntity GetScholarshipManagementEntity(string keyValue)
  75. {
  76. try
  77. {
  78. return this.BaseRepository("CollegeMIS").FindEntity<ScholarshipManagementEntity>(keyValue);
  79. }
  80. catch (Exception ex)
  81. {
  82. if (ex is ExceptionEx)
  83. {
  84. throw;
  85. }
  86. else
  87. {
  88. throw ExceptionEx.ThrowServiceException(ex);
  89. }
  90. }
  91. }
  92. #endregion
  93. #region 提交数据
  94. /// <summary>
  95. /// 删除实体数据
  96. /// <param name="keyValue">主键</param>
  97. /// <summary>
  98. /// <returns></returns>
  99. public void DeleteEntity(string keyValue)
  100. {
  101. try
  102. {
  103. this.BaseRepository("CollegeMIS").Delete<ScholarshipManagementEntity>(t=>t.Id == keyValue);
  104. }
  105. catch (Exception ex)
  106. {
  107. if (ex is ExceptionEx)
  108. {
  109. throw;
  110. }
  111. else
  112. {
  113. throw ExceptionEx.ThrowServiceException(ex);
  114. }
  115. }
  116. }
  117. /// <summary>
  118. /// 保存实体数据(新增、修改)
  119. /// <param name="keyValue">主键</param>
  120. /// <summary>
  121. /// <returns></returns>
  122. public void SaveEntity(string keyValue, ScholarshipManagementEntity entity)
  123. {
  124. try
  125. {
  126. if (!string.IsNullOrEmpty(keyValue))
  127. {
  128. entity.Modify(keyValue);
  129. this.BaseRepository("CollegeMIS").Update(entity);
  130. }
  131. else
  132. {
  133. entity.Create();
  134. this.BaseRepository("CollegeMIS").Insert(entity);
  135. }
  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. #endregion
  150. }
  151. }