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.

VenhicleManageService.cs 4.5 KiB

4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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.PersonnelManagement
  9. {
  10. /// <summary>
  11. /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
  12. /// Copyright (c) 2013-2018 北京泉江科技有限公司
  13. /// 创 建:超级管理员
  14. /// 日 期:2019-11-19 16:07
  15. /// 描 述:车辆信息管理
  16. /// </summary>
  17. public class VenhicleManageService : RepositoryFactory
  18. {
  19. #region 获取数据
  20. /// <summary>
  21. /// 获取页面显示列表数据
  22. /// <summary>
  23. /// <param name="queryJson">查询参数</param>
  24. /// <returns></returns>
  25. public IEnumerable<VenhicleManageEntity> 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.Model,
  34. t.Price,
  35. t.AddTime,
  36. t.Status,
  37. t.SeatNum,
  38. t.Remark
  39. ");
  40. strSql.Append(" FROM VenhicleManage t ");
  41. strSql.Append(" WHERE 1=1 ");
  42. var queryParam = queryJson.ToJObject();
  43. // 虚拟参数
  44. var dp = new DynamicParameters(new { });
  45. if (!queryParam["Model"].IsEmpty())
  46. {
  47. dp.Add("Model", "%" + queryParam["Model"].ToString() + "%", DbType.String);
  48. strSql.Append(" AND t.Model Like @Model ");
  49. }
  50. return this.BaseRepository("CollegeMIS").FindList<VenhicleManageEntity>(strSql.ToString(),dp, pagination);
  51. }
  52. catch (Exception ex)
  53. {
  54. if (ex is ExceptionEx)
  55. {
  56. throw;
  57. }
  58. else
  59. {
  60. throw ExceptionEx.ThrowServiceException(ex);
  61. }
  62. }
  63. }
  64. /// <summary>
  65. /// 获取VenhicleManage表实体数据
  66. /// <param name="keyValue">主键</param>
  67. /// <summary>
  68. /// <returns></returns>
  69. public VenhicleManageEntity GetVenhicleManageEntity(string keyValue)
  70. {
  71. try
  72. {
  73. return this.BaseRepository("CollegeMIS").FindEntity<VenhicleManageEntity>(keyValue);
  74. }
  75. catch (Exception ex)
  76. {
  77. if (ex is ExceptionEx)
  78. {
  79. throw;
  80. }
  81. else
  82. {
  83. throw ExceptionEx.ThrowServiceException(ex);
  84. }
  85. }
  86. }
  87. #endregion
  88. #region 提交数据
  89. /// <summary>
  90. /// 删除实体数据
  91. /// <param name="keyValue">主键</param>
  92. /// <summary>
  93. /// <returns></returns>
  94. public void DeleteEntity(string keyValue)
  95. {
  96. try
  97. {
  98. this.BaseRepository("CollegeMIS").Delete<VenhicleManageEntity>(t=>t.ID == keyValue);
  99. }
  100. catch (Exception ex)
  101. {
  102. if (ex is ExceptionEx)
  103. {
  104. throw;
  105. }
  106. else
  107. {
  108. throw ExceptionEx.ThrowServiceException(ex);
  109. }
  110. }
  111. }
  112. /// <summary>
  113. /// 保存实体数据(新增、修改)
  114. /// <param name="keyValue">主键</param>
  115. /// <summary>
  116. /// <returns></returns>
  117. public void SaveEntity(string keyValue, VenhicleManageEntity entity)
  118. {
  119. try
  120. {
  121. if (!string.IsNullOrEmpty(keyValue))
  122. {
  123. entity.Modify(keyValue);
  124. this.BaseRepository("CollegeMIS").Update(entity);
  125. }
  126. else
  127. {
  128. entity.Create();
  129. this.BaseRepository("CollegeMIS").Insert(entity);
  130. }
  131. }
  132. catch (Exception ex)
  133. {
  134. if (ex is ExceptionEx)
  135. {
  136. throw;
  137. }
  138. else
  139. {
  140. throw ExceptionEx.ThrowServiceException(ex);
  141. }
  142. }
  143. }
  144. #endregion
  145. }
  146. }