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.
 
 
 
 
 
 

158 lines
4.5 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-06-12 10:13
  15. /// 描 述:丢失书籍
  16. /// </summary>
  17. public class BookLoseService : RepositoryFactory
  18. {
  19. #region 获取数据
  20. /// <summary>
  21. /// 获取页面显示列表数据
  22. /// <summary>
  23. /// <param name="queryJson">查询参数</param>
  24. /// <returns></returns>
  25. public IEnumerable<Book_loseEntity> GetPageList(Pagination pagination, string queryJson)
  26. {
  27. try
  28. {
  29. var strSql = new StringBuilder();
  30. strSql.Append("SELECT ");
  31. strSql.Append(@"
  32. t.ID,
  33. t.BookID,
  34. t.BookName,
  35. t.LosePeopleName,
  36. t.LoseTime,
  37. t.LosePeopleType,
  38. t.LosePeopleID,
  39. t.BookPrice,
  40. t.CheckMark
  41. ");
  42. strSql.Append(" FROM Book_lose t ");
  43. strSql.Append(" WHERE 1=1 ");
  44. var queryParam = queryJson.ToJObject();
  45. // 虚拟参数
  46. var dp = new DynamicParameters(new { });
  47. if (!queryParam["BookName"].IsEmpty())
  48. {
  49. dp.Add("BookName", "%" + queryParam["BookName"].ToString() + "%", DbType.String);
  50. strSql.Append(" AND t.BookName Like @BookName ");
  51. }
  52. return this.BaseRepository().FindList<Book_loseEntity>(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. /// 获取Book_lose表实体数据
  68. /// <param name="keyValue">主键</param>
  69. /// <summary>
  70. /// <returns></returns>
  71. public Book_loseEntity GetBook_loseEntity(string keyValue)
  72. {
  73. try
  74. {
  75. return this.BaseRepository().FindEntity<Book_loseEntity>(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. /// <param name="keyValue">主键</param>
  94. /// <summary>
  95. /// <returns></returns>
  96. public void DeleteEntity(string keyValue)
  97. {
  98. try
  99. {
  100. this.BaseRepository().Delete<Book_loseEntity>(t=>t.ID == keyValue);
  101. }
  102. catch (Exception ex)
  103. {
  104. if (ex is ExceptionEx)
  105. {
  106. throw;
  107. }
  108. else
  109. {
  110. throw ExceptionEx.ThrowServiceException(ex);
  111. }
  112. }
  113. }
  114. /// <summary>
  115. /// 保存实体数据(新增、修改)
  116. /// <param name="keyValue">主键</param>
  117. /// <summary>
  118. /// <returns></returns>
  119. public void SaveEntity(string keyValue, Book_loseEntity entity)
  120. {
  121. try
  122. {
  123. if (!string.IsNullOrEmpty(keyValue))
  124. {
  125. entity.Modify(keyValue);
  126. this.BaseRepository().Update(entity);
  127. }
  128. else
  129. {
  130. entity.Create();
  131. this.BaseRepository().Insert(entity);
  132. }
  133. }
  134. catch (Exception ex)
  135. {
  136. if (ex is ExceptionEx)
  137. {
  138. throw;
  139. }
  140. else
  141. {
  142. throw ExceptionEx.ThrowServiceException(ex);
  143. }
  144. }
  145. }
  146. #endregion
  147. }
  148. }