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.
 
 
 
 
 
 

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