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.
 
 
 
 
 
 

210 lines
6.3 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.PersonnelManagement
  9. {
  10. /// <summary>
  11. /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
  12. /// Copyright (c) 2013-2018 北京泉江科技有限公司
  13. /// 创 建:超级管理员
  14. /// 日 期:2019-11-19 16:03
  15. /// 描 述:会议室管理
  16. /// </summary>
  17. public class ConferenceRoomService : RepositoryFactory
  18. {
  19. #region 获取数据
  20. /// <summary>
  21. /// 获取页面显示列表数据
  22. /// <summary>
  23. /// <param name="queryJson">查询参数</param>
  24. /// <returns></returns>
  25. public IEnumerable<ConferenceRoomEntity> GetPageList(Pagination pagination, string queryJson)
  26. {
  27. try
  28. {
  29. var strSql = new StringBuilder();
  30. strSql.Append("SELECT t.* ");
  31. strSql.Append(" FROM ConferenceRoom t ");
  32. strSql.Append(" WHERE 1=1 ");
  33. var queryParam = queryJson.ToJObject();
  34. // 虚拟参数
  35. var dp = new DynamicParameters(new { });
  36. if (!queryParam["Name"].IsEmpty())
  37. {
  38. dp.Add("Name", "%" + queryParam["Name"].ToString() + "%", DbType.String);
  39. strSql.Append(" AND t.Name Like @Name ");
  40. }
  41. if (!queryParam["Status"].IsEmpty())
  42. {
  43. if (queryParam["Status"].ToString() == "1")
  44. {
  45. dp.Add("Status", queryParam["Status"].ToString(), DbType.String);
  46. strSql.Append(" AND t.Status = @Status ");
  47. }
  48. else
  49. {
  50. strSql.Append(" AND t.Status != '1' ");
  51. }
  52. }
  53. return this.BaseRepository("CollegeMIS").FindList<ConferenceRoomEntity>(strSql.ToString(), dp, pagination);
  54. }
  55. catch (Exception ex)
  56. {
  57. if (ex is ExceptionEx)
  58. {
  59. throw;
  60. }
  61. else
  62. {
  63. throw ExceptionEx.ThrowServiceException(ex);
  64. }
  65. }
  66. }
  67. /// <summary>
  68. /// 获取页面显示列表数据
  69. /// <summary>
  70. /// <param name="queryJson">查询参数</param>
  71. /// <returns></returns>
  72. public IEnumerable<ConferenceRoomEntity> GetList()
  73. {
  74. try
  75. {
  76. var strSql = new StringBuilder();
  77. strSql.Append("SELECT t.* ");
  78. strSql.Append(" FROM ConferenceRoom t ");
  79. strSql.Append(" WHERE 1=1 and t.Status = '1' ");
  80. return this.BaseRepository("CollegeMIS").FindList<ConferenceRoomEntity>(strSql.ToString());
  81. }
  82. catch (Exception ex)
  83. {
  84. if (ex is ExceptionEx)
  85. {
  86. throw;
  87. }
  88. else
  89. {
  90. throw ExceptionEx.ThrowServiceException(ex);
  91. }
  92. }
  93. }
  94. /// <summary>
  95. /// 获取ConferenceRoom表实体数据
  96. /// <param name="keyValue">主键</param>
  97. /// <summary>
  98. /// <returns></returns>
  99. public ConferenceRoomEntity GetConferenceRoomEntity(string keyValue)
  100. {
  101. try
  102. {
  103. return this.BaseRepository("CollegeMIS").FindEntity<ConferenceRoomEntity>(keyValue);
  104. }
  105. catch (Exception ex)
  106. {
  107. if (ex is ExceptionEx)
  108. {
  109. throw;
  110. }
  111. else
  112. {
  113. throw ExceptionEx.ThrowServiceException(ex);
  114. }
  115. }
  116. }
  117. #endregion
  118. #region 提交数据
  119. /// <summary>
  120. /// 删除实体数据
  121. /// <param name="keyValue">主键</param>
  122. /// <summary>
  123. /// <returns></returns>
  124. public void DeleteEntity(string keyValue)
  125. {
  126. try
  127. {
  128. this.BaseRepository("CollegeMIS").Delete<ConferenceRoomEntity>(t => t.ID == keyValue);
  129. }
  130. catch (Exception ex)
  131. {
  132. if (ex is ExceptionEx)
  133. {
  134. throw;
  135. }
  136. else
  137. {
  138. throw ExceptionEx.ThrowServiceException(ex);
  139. }
  140. }
  141. }
  142. /// <summary>
  143. /// 保存实体数据(新增、修改)
  144. /// <param name="keyValue">主键</param>
  145. /// <summary>
  146. /// <returns></returns>
  147. public void SaveEntity(string keyValue, ConferenceRoomEntity entity)
  148. {
  149. try
  150. {
  151. if (!string.IsNullOrEmpty(keyValue))
  152. {
  153. entity.Modify(keyValue);
  154. this.BaseRepository("CollegeMIS").Update(entity);
  155. }
  156. else
  157. {
  158. entity.Create();
  159. this.BaseRepository("CollegeMIS").Insert(entity);
  160. }
  161. }
  162. catch (Exception ex)
  163. {
  164. if (ex is ExceptionEx)
  165. {
  166. throw;
  167. }
  168. else
  169. {
  170. throw ExceptionEx.ThrowServiceException(ex);
  171. }
  172. }
  173. }
  174. /// <summary>
  175. /// 启用禁用实体数据
  176. /// <param name="keyValue">主键</param>
  177. /// <summary>
  178. /// <returns></returns>
  179. public void DoEnable(string keyValue, string status)
  180. {
  181. try
  182. {
  183. this.BaseRepository("CollegeMIS").ExecuteBySql("update ConferenceRoom set Status='" + status + "' where ID='" + keyValue + "' ");
  184. }
  185. catch (Exception ex)
  186. {
  187. if (ex is ExceptionEx)
  188. {
  189. throw;
  190. }
  191. else
  192. {
  193. throw ExceptionEx.ThrowServiceException(ex);
  194. }
  195. }
  196. }
  197. #endregion
  198. }
  199. }