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.

TMOrderService.cs 4.8 KiB

4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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 15:56
  15. /// 描 述:教材订单
  16. /// </summary>
  17. public class TMOrderService : RepositoryFactory
  18. {
  19. #region 获取数据
  20. /// <summary>
  21. /// 获取页面显示列表数据
  22. /// <summary>
  23. /// <param name="queryJson">查询参数</param>
  24. /// <returns></returns>
  25. public IEnumerable<TMOrderEntity> 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.TMYear,
  34. t.TMMajor,
  35. t.TMLesson,
  36. t.TMBookName,
  37. t.TMPress,
  38. t.TMChiefEditor,
  39. t.TMBookNumber,
  40. t.TMPrice,
  41. t.TMNumber,
  42. t.TMOPrice
  43. ");
  44. strSql.Append(" FROM TMOrder t ");
  45. strSql.Append(" WHERE 1=1 ");
  46. var queryParam = queryJson.ToJObject();
  47. // 虚拟参数
  48. var dp = new DynamicParameters(new { });
  49. if (!queryParam["TMYear"].IsEmpty())
  50. {
  51. dp.Add("TMYear", "%" + queryParam["TMYear"].ToString() + "%", DbType.String);
  52. strSql.Append(" AND t.TMYear Like @TMYear ");
  53. }
  54. if (!queryParam["TMMajor"].IsEmpty())
  55. {
  56. dp.Add("TMMajor", "%" + queryParam["TMMajor"].ToString() + "%", DbType.String);
  57. strSql.Append(" AND t.TMMajor Like @TMMajor ");
  58. }
  59. return this.BaseRepository("CollegeMIS").FindList<TMOrderEntity>(strSql.ToString(),dp, pagination);
  60. }
  61. catch (Exception ex)
  62. {
  63. if (ex is ExceptionEx)
  64. {
  65. throw;
  66. }
  67. else
  68. {
  69. throw ExceptionEx.ThrowServiceException(ex);
  70. }
  71. }
  72. }
  73. /// <summary>
  74. /// 获取TMOrder表实体数据
  75. /// <param name="keyValue">主键</param>
  76. /// <summary>
  77. /// <returns></returns>
  78. public TMOrderEntity GetTMOrderEntity(string keyValue)
  79. {
  80. try
  81. {
  82. return this.BaseRepository("CollegeMIS").FindEntity<TMOrderEntity>(keyValue);
  83. }
  84. catch (Exception ex)
  85. {
  86. if (ex is ExceptionEx)
  87. {
  88. throw;
  89. }
  90. else
  91. {
  92. throw ExceptionEx.ThrowServiceException(ex);
  93. }
  94. }
  95. }
  96. #endregion
  97. #region 提交数据
  98. /// <summary>
  99. /// 删除实体数据
  100. /// <param name="keyValue">主键</param>
  101. /// <summary>
  102. /// <returns></returns>
  103. public void DeleteEntity(string keyValue)
  104. {
  105. try
  106. {
  107. this.BaseRepository("CollegeMIS").Delete<TMOrderEntity>(t=>t.TMOID == 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. /// <param name="keyValue">主键</param>
  124. /// <summary>
  125. /// <returns></returns>
  126. public void SaveEntity(string keyValue, TMOrderEntity 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. }