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.
 
 
 
 
 
 

165 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.EducationalAdministration
  9. {
  10. /// <summary>
  11. /// 版 本 Learun-ADMS V7.0.6 力软敏捷开发框架
  12. /// Copyright (c) 2013-2020 力软信息技术(苏州)有限公司
  13. /// 创 建:超级管理员
  14. /// 日 期:2021-09-24 17:38
  15. /// 描 述:奖励惩罚管理
  16. /// </summary>
  17. public class AwardPunishInfoService : 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<AwardPunishInfoEntity> GetPageList(Pagination pagination, string queryJson)
  27. {
  28. try
  29. {
  30. var strSql = new StringBuilder();
  31. strSql.Append("SELECT ");
  32. strSql.Append(@" * ");
  33. strSql.Append(" FROM AwardPunishInfo t ");
  34. strSql.Append(" WHERE 1=1 ");
  35. var queryParam = queryJson.ToJObject();
  36. // 虚拟参数
  37. var dp = new DynamicParameters(new { });
  38. if (!queryParam["NatureType"].IsEmpty())
  39. {
  40. dp.Add("NatureType",queryParam["NatureType"].ToString(), DbType.String);
  41. strSql.Append(" AND t.NatureType = @NatureType ");
  42. }
  43. if (!queryParam["StuName"].IsEmpty())
  44. {
  45. dp.Add("StuName", queryParam["StuName"].ToString(), DbType.String);
  46. strSql.Append(" AND t.StuName = @StuName ");
  47. }
  48. if (!queryParam["IsVaild"].IsEmpty())
  49. {
  50. dp.Add("IsVaild", queryParam["IsVaild"].ToString(), DbType.String);
  51. strSql.Append(" AND t.IsVaild = @IsVaild ");
  52. }
  53. return this.BaseRepository("CollegeMIS").FindList<AwardPunishInfoEntity>(strSql.ToString(),dp, pagination);
  54. }
  55. catch (Exception ex)
  56. {
  57. if (ex is ExceptionEx)
  58. {
  59. throw;
  60. }
  61. else
  62. {
  63. throw ExceptionEx.ThrowServiceException(ex);
  64. }
  65. }
  66. }
  67. /// <summary>
  68. /// 获取AwardPunishInfo表实体数据
  69. /// </summary>
  70. /// <param name="keyValue">主键</param>
  71. /// <returns></returns>
  72. public AwardPunishInfoEntity GetAwardPunishInfoEntity(string keyValue)
  73. {
  74. try
  75. {
  76. return this.BaseRepository("CollegeMIS").FindEntity<AwardPunishInfoEntity>(keyValue);
  77. }
  78. catch (Exception ex)
  79. {
  80. if (ex is ExceptionEx)
  81. {
  82. throw;
  83. }
  84. else
  85. {
  86. throw ExceptionEx.ThrowServiceException(ex);
  87. }
  88. }
  89. }
  90. #endregion
  91. #region 提交数据
  92. /// <summary>
  93. /// 删除实体数据
  94. /// </summary>
  95. /// <param name="keyValue">主键</param>
  96. public void DeleteEntity(string keyValue)
  97. {
  98. var db = this.BaseRepository("CollegeMIS").BeginTrans();
  99. try
  100. {
  101. //多个删除
  102. var keyValueArr = keyValue.Split(',');
  103. foreach (var item in keyValueArr)
  104. {
  105. db.Delete<AwardPunishInfoEntity>(t => t.Id == item);
  106. }
  107. db.Commit();
  108. }
  109. catch (Exception ex)
  110. {
  111. if (ex is ExceptionEx)
  112. {
  113. throw;
  114. }
  115. else
  116. {
  117. throw ExceptionEx.ThrowServiceException(ex);
  118. }
  119. }
  120. }
  121. /// <summary>
  122. /// 保存实体数据(新增、修改)
  123. /// </summary>
  124. /// <param name="keyValue">主键</param>
  125. /// <param name="entity">实体</param>
  126. public void SaveEntity(string keyValue, AwardPunishInfoEntity entity)
  127. {
  128. try
  129. {
  130. if (!string.IsNullOrEmpty(keyValue))
  131. {
  132. entity.Modify(keyValue);
  133. this.BaseRepository("CollegeMIS").Update(entity);
  134. }
  135. else
  136. {
  137. entity.Create();
  138. this.BaseRepository("CollegeMIS").Insert(entity);
  139. }
  140. }
  141. catch (Exception ex)
  142. {
  143. if (ex is ExceptionEx)
  144. {
  145. throw;
  146. }
  147. else
  148. {
  149. throw ExceptionEx.ThrowServiceException(ex);
  150. }
  151. }
  152. }
  153. #endregion
  154. }
  155. }