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.
 
 
 
 
 
 

184 lines
5.2 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-17 16:22
  15. /// 描 述:移动测试
  16. /// </summary>
  17. public class MobileTestService : 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<MobileTestEntity> GetPageList(Pagination pagination, string queryJson)
  27. {
  28. try
  29. {
  30. var strSql = new StringBuilder();
  31. strSql.Append("SELECT ");
  32. strSql.Append(@"
  33. t.,
  34. t.name,
  35. t.age
  36. ");
  37. strSql.Append(" FROM MobileTest t ");
  38. strSql.Append(" WHERE 1=1 ");
  39. var queryParam = queryJson.ToJObject();
  40. // 虚拟参数
  41. var dp = new DynamicParameters(new { });
  42. return this.BaseRepository().FindList<MobileTestEntity>(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. /// 获取页面显示列表数据
  58. /// <summary>
  59. /// <param name="queryJson">查询参数</param>
  60. /// <returns></returns>
  61. public IEnumerable<MobileTestEntity> GetList(string queryJson)
  62. {
  63. try
  64. {
  65. var strSql = new StringBuilder();
  66. strSql.Append("SELECT ");
  67. strSql.Append(@"
  68. t.,
  69. t.name,
  70. t.age
  71. ");
  72. strSql.Append(" FROM MobileTest t ");
  73. strSql.Append(" WHERE 1=1 ");
  74. var queryParam = queryJson.ToJObject();
  75. // 虚拟参数
  76. var dp = new DynamicParameters(new { });
  77. return this.BaseRepository().FindList<MobileTestEntity>(strSql.ToString(),dp);
  78. }
  79. catch (Exception ex)
  80. {
  81. if (ex is ExceptionEx)
  82. {
  83. throw;
  84. }
  85. else
  86. {
  87. throw ExceptionEx.ThrowServiceException(ex);
  88. }
  89. }
  90. }
  91. /// <summary>
  92. /// 获取MobileTest表实体数据
  93. /// <param name="keyValue">主键</param>
  94. /// <summary>
  95. /// <returns></returns>
  96. public MobileTestEntity GetMobileTestEntity(string keyValue)
  97. {
  98. try
  99. {
  100. return this.BaseRepository().FindEntity<MobileTestEntity>(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. #endregion
  115. #region 提交数据
  116. /// <summary>
  117. /// 删除实体数据
  118. /// <param name="keyValue">主键</param>
  119. /// <summary>
  120. /// <returns></returns>
  121. public void DeleteEntity(string keyValue)
  122. {
  123. try
  124. {
  125. this.BaseRepository().Delete<MobileTestEntity>(t=>t.ID == keyValue);
  126. }
  127. catch (Exception ex)
  128. {
  129. if (ex is ExceptionEx)
  130. {
  131. throw;
  132. }
  133. else
  134. {
  135. throw ExceptionEx.ThrowServiceException(ex);
  136. }
  137. }
  138. }
  139. /// <summary>
  140. /// 保存实体数据(新增、修改)
  141. /// <param name="keyValue">主键</param>
  142. /// <summary>
  143. /// <returns></returns>
  144. public void SaveEntity( UserInfo userInfo, string keyValue, MobileTestEntity entity)
  145. {
  146. try
  147. {
  148. if (!string.IsNullOrEmpty(keyValue))
  149. {
  150. entity.Modify(keyValue,userInfo);
  151. this.BaseRepository().Update(entity);
  152. }
  153. else
  154. {
  155. entity.Create(userInfo);
  156. this.BaseRepository().Insert(entity);
  157. }
  158. }
  159. catch (Exception ex)
  160. {
  161. if (ex is ExceptionEx)
  162. {
  163. throw;
  164. }
  165. else
  166. {
  167. throw ExceptionEx.ThrowServiceException(ex);
  168. }
  169. }
  170. }
  171. #endregion
  172. }
  173. }