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.0 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-11-12 17:45
  15. /// 描 述:赛项管理
  16. /// </summary>
  17. public class CompetitionManagementService : 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<CompetitionManagementEntity> GetPageList(Pagination pagination, string queryJson)
  27. {
  28. try
  29. {
  30. var strSql = new StringBuilder();
  31. strSql.Append("SELECT ");
  32. strSql.Append(@"
  33. t.Id,
  34. t.Name,
  35. t.Levels,
  36. t.Type,
  37. t.Url,
  38. t.Remark
  39. ");
  40. strSql.Append(" FROM CompetitionManagement t ");
  41. strSql.Append(" WHERE 1=1 ");
  42. var queryParam = queryJson.ToJObject();
  43. // 虚拟参数
  44. var dp = new DynamicParameters(new { });
  45. if (!queryParam["Name"].IsEmpty())
  46. {
  47. dp.Add("Name", "%" + queryParam["Name"].ToString() + "%", DbType.String);
  48. strSql.Append(" AND t.Name Like @Name ");
  49. }
  50. if (!queryParam["Levels"].IsEmpty())
  51. {
  52. dp.Add("Levels",queryParam["Levels"].ToString(), DbType.String);
  53. strSql.Append(" AND t.Levels = @Levels ");
  54. }
  55. if (!queryParam["Type"].IsEmpty())
  56. {
  57. dp.Add("Type", "%" + queryParam["Type"].ToString() + "%", DbType.String);
  58. strSql.Append(" AND t.Type Like @Type ");
  59. }
  60. return this.BaseRepository("CollegeMIS").FindList<CompetitionManagementEntity>(strSql.ToString(),dp, pagination);
  61. }
  62. catch (Exception ex)
  63. {
  64. if (ex is ExceptionEx)
  65. {
  66. throw;
  67. }
  68. else
  69. {
  70. throw ExceptionEx.ThrowServiceException(ex);
  71. }
  72. }
  73. }
  74. /// <summary>
  75. /// 获取CompetitionManagement表实体数据
  76. /// </summary>
  77. /// <param name="keyValue">主键</param>
  78. /// <returns></returns>
  79. public CompetitionManagementEntity GetCompetitionManagementEntity(string keyValue)
  80. {
  81. try
  82. {
  83. return this.BaseRepository("CollegeMIS").FindEntity<CompetitionManagementEntity>(keyValue);
  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. #endregion
  98. #region 提交数据
  99. /// <summary>
  100. /// 删除实体数据
  101. /// </summary>
  102. /// <param name="keyValue">主键</param>
  103. public void DeleteEntity(string keyValue)
  104. {
  105. try
  106. {
  107. this.BaseRepository("CollegeMIS").Delete<CompetitionManagementEntity>(t=>t.Id == keyValue);
  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, CompetitionManagementEntity 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. }