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.
 
 
 
 
 
 

176 lines
5.3 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. /// 日 期:2022-08-05 09:35
  15. /// 描 述:毕业条件模板管理
  16. /// </summary>
  17. public class StuGraduateConditionService : 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<StuGraduateConditionEntity> GetPageList(Pagination pagination, string queryJson)
  27. {
  28. try
  29. {
  30. var strSql = new StringBuilder();
  31. strSql.Append("SELECT t.* ");
  32. strSql.Append(" FROM StuGraduateCondition t ");
  33. strSql.Append(" WHERE 1=1 ");
  34. var queryParam = queryJson.ToJObject();
  35. // 虚拟参数
  36. var dp = new DynamicParameters(new { });
  37. if (!queryParam["Name"].IsEmpty())
  38. {
  39. dp.Add("Name",queryParam["Name"].ToString(), DbType.String);
  40. strSql.Append(" AND t.Name = @Name ");
  41. }
  42. if (!queryParam["EnabledMark"].IsEmpty())
  43. {
  44. dp.Add("EnabledMark",queryParam["EnabledMark"].ToString(), DbType.String);
  45. strSql.Append(" AND t.EnabledMark = @EnabledMark ");
  46. }
  47. return this.BaseRepository("CollegeMIS").FindList<StuGraduateConditionEntity>(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. /// 获取StuGraduateCondition表实体数据
  63. /// </summary>
  64. /// <param name="keyValue">主键</param>
  65. /// <returns></returns>
  66. public StuGraduateConditionEntity GetStuGraduateConditionEntity(string keyValue)
  67. {
  68. try
  69. {
  70. return this.BaseRepository("CollegeMIS").FindEntity<StuGraduateConditionEntity>(keyValue);
  71. }
  72. catch (Exception ex)
  73. {
  74. if (ex is ExceptionEx)
  75. {
  76. throw;
  77. }
  78. else
  79. {
  80. throw ExceptionEx.ThrowServiceException(ex);
  81. }
  82. }
  83. }
  84. /// <summary>
  85. /// 获取StuGraduateCondition表实体数据
  86. /// </summary>
  87. /// <param name="name">条件</param>
  88. /// <returns></returns>
  89. public StuGraduateConditionEntity GetStuGraduateConditionEntityByName(string name)
  90. {
  91. try
  92. {
  93. return this.BaseRepository("CollegeMIS").FindEntity<StuGraduateConditionEntity>(x=>x.Name==name);
  94. }
  95. catch (Exception ex)
  96. {
  97. if (ex is ExceptionEx)
  98. {
  99. throw;
  100. }
  101. else
  102. {
  103. throw ExceptionEx.ThrowServiceException(ex);
  104. }
  105. }
  106. }
  107. #endregion
  108. #region 提交数据
  109. /// <summary>
  110. /// 删除实体数据
  111. /// </summary>
  112. /// <param name="keyValue">主键</param>
  113. public void DeleteEntity(string keyValue)
  114. {
  115. try
  116. {
  117. this.BaseRepository("CollegeMIS").Delete<StuGraduateConditionEntity>(t=>t.Id == keyValue);
  118. }
  119. catch (Exception ex)
  120. {
  121. if (ex is ExceptionEx)
  122. {
  123. throw;
  124. }
  125. else
  126. {
  127. throw ExceptionEx.ThrowServiceException(ex);
  128. }
  129. }
  130. }
  131. /// <summary>
  132. /// 保存实体数据(新增、修改)
  133. /// </summary>
  134. /// <param name="keyValue">主键</param>
  135. /// <param name="entity">实体</param>
  136. public void SaveEntity(string keyValue, StuGraduateConditionEntity entity)
  137. {
  138. try
  139. {
  140. if (!string.IsNullOrEmpty(keyValue))
  141. {
  142. entity.Modify(keyValue);
  143. this.BaseRepository("CollegeMIS").Update(entity);
  144. }
  145. else
  146. {
  147. entity.Create();
  148. this.BaseRepository("CollegeMIS").Insert(entity);
  149. }
  150. }
  151. catch (Exception ex)
  152. {
  153. if (ex is ExceptionEx)
  154. {
  155. throw;
  156. }
  157. else
  158. {
  159. throw ExceptionEx.ThrowServiceException(ex);
  160. }
  161. }
  162. }
  163. #endregion
  164. }
  165. }