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.
 
 
 
 
 
 

252 lines
7.9 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. /// <summary>
  141. /// 获取列表
  142. /// </summary>
  143. /// <returns>返回列表</returns>
  144. public IEnumerable<SchoolCalendarEntity> GetList()
  145. {
  146. try
  147. {
  148. return this.BaseRepository().FindList<SchoolCalendarEntity>();
  149. }
  150. catch (Exception ex)
  151. {
  152. if (ex is ExceptionEx)
  153. throw;
  154. else
  155. throw ExceptionEx.ThrowServiceException(ex);
  156. }
  157. }
  158. /// <summary>
  159. /// 获取SchoolCalendar表实体数据
  160. /// <param name="keyValue">主键</param>
  161. /// <summary>
  162. /// <returns></returns>
  163. public SchoolCalendarEntity GetSchoolCalendarEntityByNo(string academicYearNo, string semester)
  164. {
  165. try
  166. {
  167. return this.BaseRepository().FindEntity<SchoolCalendarEntity>(x => x.AcademicYearNo == academicYearNo && x.Semester == semester);
  168. }
  169. catch (Exception ex)
  170. {
  171. if (ex is ExceptionEx)
  172. {
  173. throw;
  174. }
  175. else
  176. {
  177. throw ExceptionEx.ThrowServiceException(ex);
  178. }
  179. }
  180. }
  181. #endregion
  182. #region 提交数据
  183. /// <summary>
  184. /// 删除实体数据
  185. /// <param name="keyValue">主键</param>
  186. /// <summary>
  187. /// <returns></returns>
  188. public void DeleteEntity(string keyValue)
  189. {
  190. try
  191. {
  192. this.BaseRepository().Delete<SchoolCalendarEntity>(t=>t.ID == keyValue);
  193. }
  194. catch (Exception ex)
  195. {
  196. if (ex is ExceptionEx)
  197. {
  198. throw;
  199. }
  200. else
  201. {
  202. throw ExceptionEx.ThrowServiceException(ex);
  203. }
  204. }
  205. }
  206. /// <summary>
  207. /// 保存实体数据(新增、修改)
  208. /// <param name="keyValue">主键</param>
  209. /// <summary>
  210. /// <returns></returns>
  211. public void SaveEntity( UserInfo userInfo, string keyValue, SchoolCalendarEntity entity)
  212. {
  213. try
  214. {
  215. if (!string.IsNullOrEmpty(keyValue))
  216. {
  217. entity.Modify(keyValue,userInfo);
  218. this.BaseRepository().Update(entity);
  219. }
  220. else
  221. {
  222. entity.Create(userInfo);
  223. this.BaseRepository().Insert(entity);
  224. }
  225. }
  226. catch (Exception ex)
  227. {
  228. if (ex is ExceptionEx)
  229. {
  230. throw;
  231. }
  232. else
  233. {
  234. throw ExceptionEx.ThrowServiceException(ex);
  235. }
  236. }
  237. }
  238. #endregion
  239. }
  240. }