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.6 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-07-03 14:31
  15. /// 描 述:校历管理
  16. /// </summary>
  17. public class SchoolCalendarService : 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<SchoolCalendarEntity> GetPageList(Pagination pagination, string queryJson)
  27. {
  28. try
  29. {
  30. var strSql = new StringBuilder();
  31. strSql.Append("SELECT ");
  32. strSql.Append(@"
  33. t.ID,
  34. t.AcademicYearNo,
  35. t.Semester,
  36. t.StartTime,
  37. t.EndTime,
  38. t.Content
  39. ");
  40. strSql.Append(" FROM SchoolCalendar t ");
  41. strSql.Append(" WHERE 1=1 ");
  42. var queryParam = queryJson.ToJObject();
  43. // 虚拟参数
  44. var dp = new DynamicParameters(new { });
  45. if (!queryParam["AcademicYearNo"].IsEmpty())
  46. {
  47. dp.Add("AcademicYearNo", "%" + queryParam["AcademicYearNo"].ToString() + "%", DbType.String);
  48. strSql.Append(" AND t.AcademicYearNo Like @AcademicYearNo ");
  49. }
  50. if (!queryParam["Semester"].IsEmpty())
  51. {
  52. dp.Add("Semester", "%" + queryParam["Semester"].ToString() + "%", DbType.String);
  53. strSql.Append(" AND t.Semester Like @Semester ");
  54. }
  55. return this.BaseRepository().FindList<SchoolCalendarEntity>(strSql.ToString(),dp, pagination);
  56. }
  57. catch (Exception ex)
  58. {
  59. if (ex is ExceptionEx)
  60. {
  61. throw;
  62. }
  63. else
  64. {
  65. throw ExceptionEx.ThrowServiceException(ex);
  66. }
  67. }
  68. }
  69. /// <summary>
  70. /// 获取页面显示列表数据
  71. /// <summary>
  72. /// <param name="queryJson">查询参数</param>
  73. /// <returns></returns>
  74. public IEnumerable<SchoolCalendarEntity> GetList(string queryJson)
  75. {
  76. try
  77. {
  78. var strSql = new StringBuilder();
  79. strSql.Append("SELECT ");
  80. strSql.Append(@"
  81. t.ID,
  82. t.AcademicYearNo,
  83. t.Semester,
  84. t.StartTime,
  85. t.EndTime,
  86. t.Content
  87. ");
  88. strSql.Append(" FROM SchoolCalendar t ");
  89. strSql.Append(" WHERE 1=1 ");
  90. var queryParam = queryJson.ToJObject();
  91. // 虚拟参数
  92. var dp = new DynamicParameters(new { });
  93. if (!queryParam["AcademicYearNo"].IsEmpty())
  94. {
  95. dp.Add("AcademicYearNo", "%" + queryParam["AcademicYearNo"].ToString() + "%", DbType.String);
  96. strSql.Append(" AND t.AcademicYearNo Like @AcademicYearNo ");
  97. }
  98. if (!queryParam["Semester"].IsEmpty())
  99. {
  100. dp.Add("Semester", "%" + queryParam["Semester"].ToString() + "%", DbType.String);
  101. strSql.Append(" AND t.Semester Like @Semester ");
  102. }
  103. return this.BaseRepository().FindList<SchoolCalendarEntity>(strSql.ToString(),dp);
  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. /// <summary>
  118. /// 获取SchoolCalendar表实体数据
  119. /// <param name="keyValue">主键</param>
  120. /// <summary>
  121. /// <returns></returns>
  122. public SchoolCalendarEntity GetSchoolCalendarEntity(string keyValue)
  123. {
  124. try
  125. {
  126. return this.BaseRepository().FindEntity<SchoolCalendarEntity>(keyValue);
  127. }
  128. catch (Exception ex)
  129. {
  130. if (ex is ExceptionEx)
  131. {
  132. throw;
  133. }
  134. else
  135. {
  136. throw ExceptionEx.ThrowServiceException(ex);
  137. }
  138. }
  139. }
  140. #endregion
  141. #region 提交数据
  142. /// <summary>
  143. /// 删除实体数据
  144. /// <param name="keyValue">主键</param>
  145. /// <summary>
  146. /// <returns></returns>
  147. public void DeleteEntity(string keyValue)
  148. {
  149. try
  150. {
  151. this.BaseRepository().Delete<SchoolCalendarEntity>(t=>t.ID == keyValue);
  152. }
  153. catch (Exception ex)
  154. {
  155. if (ex is ExceptionEx)
  156. {
  157. throw;
  158. }
  159. else
  160. {
  161. throw ExceptionEx.ThrowServiceException(ex);
  162. }
  163. }
  164. }
  165. /// <summary>
  166. /// 保存实体数据(新增、修改)
  167. /// <param name="keyValue">主键</param>
  168. /// <summary>
  169. /// <returns></returns>
  170. public void SaveEntity( UserInfo userInfo, string keyValue, SchoolCalendarEntity entity)
  171. {
  172. try
  173. {
  174. if (!string.IsNullOrEmpty(keyValue))
  175. {
  176. entity.Modify(keyValue,userInfo);
  177. this.BaseRepository().Update(entity);
  178. }
  179. else
  180. {
  181. entity.Create(userInfo);
  182. this.BaseRepository().Insert(entity);
  183. }
  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. }