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.
 
 
 
 
 
 

148 lines
4.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-Ultimate V7.0.0 数字化智慧校园
  12. /// Copyright (c) 2013-2018 北京泉江科技有限公司
  13. /// 创 建:超级管理员
  14. /// 日 期:2019-11-18 16:04
  15. /// 描 述:教材出库
  16. /// </summary>
  17. public class TMOutService : RepositoryFactory
  18. {
  19. #region 获取数据
  20. /// <summary>
  21. /// 获取页面显示列表数据
  22. /// <summary>
  23. /// <param name="queryJson">查询参数</param>
  24. /// <returns></returns>
  25. public IEnumerable<TMOutEntity> GetPageList(Pagination pagination, string queryJson)
  26. {
  27. try
  28. {
  29. var strSql = new StringBuilder();
  30. strSql.Append("SELECT ");
  31. strSql.Append(@"
  32. t.TMOID,
  33. t.TMOCode,
  34. t.TMOPrice,
  35. t.TMOTime
  36. ");
  37. strSql.Append(" FROM TMOut t ");
  38. strSql.Append(" WHERE 1=1 ");
  39. var queryParam = queryJson.ToJObject();
  40. // 虚拟参数
  41. var dp = new DynamicParameters(new { });
  42. return this.BaseRepository("CollegeMIS").FindList<TMOutEntity>(strSql.ToString(),dp, pagination);
  43. }
  44. catch (Exception ex)
  45. {
  46. if (ex is ExceptionEx)
  47. {
  48. throw;
  49. }
  50. else
  51. {
  52. throw ExceptionEx.ThrowServiceException(ex);
  53. }
  54. }
  55. }
  56. /// <summary>
  57. /// 获取TMOut表实体数据
  58. /// <param name="keyValue">主键</param>
  59. /// <summary>
  60. /// <returns></returns>
  61. public TMOutEntity GetTMOutEntity(string keyValue)
  62. {
  63. try
  64. {
  65. return this.BaseRepository("CollegeMIS").FindEntity<TMOutEntity>(keyValue);
  66. }
  67. catch (Exception ex)
  68. {
  69. if (ex is ExceptionEx)
  70. {
  71. throw;
  72. }
  73. else
  74. {
  75. throw ExceptionEx.ThrowServiceException(ex);
  76. }
  77. }
  78. }
  79. #endregion
  80. #region 提交数据
  81. /// <summary>
  82. /// 删除实体数据
  83. /// <param name="keyValue">主键</param>
  84. /// <summary>
  85. /// <returns></returns>
  86. public void DeleteEntity(string keyValue)
  87. {
  88. try
  89. {
  90. this.BaseRepository("CollegeMIS").Delete<TMOutEntity>(t=>t.TMOID == keyValue);
  91. }
  92. catch (Exception ex)
  93. {
  94. if (ex is ExceptionEx)
  95. {
  96. throw;
  97. }
  98. else
  99. {
  100. throw ExceptionEx.ThrowServiceException(ex);
  101. }
  102. }
  103. }
  104. /// <summary>
  105. /// 保存实体数据(新增、修改)
  106. /// <param name="keyValue">主键</param>
  107. /// <summary>
  108. /// <returns></returns>
  109. public void SaveEntity(string keyValue, TMOutEntity entity)
  110. {
  111. try
  112. {
  113. if (!string.IsNullOrEmpty(keyValue))
  114. {
  115. entity.Modify(keyValue);
  116. this.BaseRepository("CollegeMIS").Update(entity);
  117. }
  118. else
  119. {
  120. entity.Create();
  121. this.BaseRepository("CollegeMIS").Insert(entity);
  122. }
  123. }
  124. catch (Exception ex)
  125. {
  126. if (ex is ExceptionEx)
  127. {
  128. throw;
  129. }
  130. else
  131. {
  132. throw ExceptionEx.ThrowServiceException(ex);
  133. }
  134. }
  135. }
  136. #endregion
  137. }
  138. }