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.
 
 
 
 
 
 

255 lines
7.5 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.Linq;
  8. using System.Text;
  9. namespace Learun.Application.TwoDevelopment.EducationalAdministration
  10. {
  11. /// <summary>
  12. /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
  13. /// Copyright (c) 2013-2018 北京泉江科技有限公司
  14. /// 创 建:超级管理员
  15. /// 日 期:2019-06-17 14:54
  16. /// 描 述:学生处分管理
  17. /// </summary>
  18. public class StuPunishmentService : RepositoryFactory
  19. {
  20. #region 获取数据
  21. /// <summary>
  22. /// 获取页面显示列表数据
  23. /// <summary>
  24. /// <param name="queryJson">查询参数</param>
  25. /// <returns></returns>
  26. public IEnumerable<StuPunishmentEntity> 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.StuNo,
  35. t.StuName,
  36. t.PunishNo,
  37. t.PunishName,
  38. t.PunishReason,
  39. t.PunishDate,
  40. t.FileNo
  41. ");
  42. strSql.Append(" FROM StuPunishment t ");
  43. strSql.Append(" WHERE 1=1 ");
  44. var queryParam = queryJson.ToJObject();
  45. // 虚拟参数
  46. var dp = new DynamicParameters(new { });
  47. return this.BaseRepository("CollegeMIS").FindList<StuPunishmentEntity>(strSql.ToString(), dp, pagination);
  48. }
  49. catch (Exception ex)
  50. {
  51. if (ex is ExceptionEx)
  52. {
  53. throw;
  54. }
  55. else
  56. {
  57. throw ExceptionEx.ThrowServiceException(ex);
  58. }
  59. }
  60. }
  61. public IEnumerable<StuPunishmentEntity> GetAllList()
  62. {
  63. try
  64. {
  65. return this.BaseRepository("CollegeMIS").FindList<StuPunishmentEntity>();
  66. }
  67. catch (Exception ex)
  68. {
  69. if (ex is ExceptionEx)
  70. {
  71. throw;
  72. }
  73. else
  74. {
  75. throw ExceptionEx.ThrowServiceException(ex);
  76. }
  77. }
  78. }
  79. /// <summary>
  80. /// 获取StuPunishment表实体数据
  81. /// <param name="keyValue">主键</param>
  82. /// <summary>
  83. /// <returns></returns>
  84. public StuPunishmentEntity GetStuPunishmentEntity(string keyValue)
  85. {
  86. try
  87. {
  88. var keyvalue = Convert.ToInt32(keyValue);
  89. return this.BaseRepository("CollegeMIS").FindEntity<StuPunishmentEntity>(keyvalue);
  90. }
  91. catch (Exception ex)
  92. {
  93. if (ex is ExceptionEx)
  94. {
  95. throw;
  96. }
  97. else
  98. {
  99. throw ExceptionEx.ThrowServiceException(ex);
  100. }
  101. }
  102. }
  103. #endregion
  104. #region 提交数据
  105. /// <summary>
  106. /// 删除实体数据
  107. /// <param name="keyValue">主键</param>
  108. /// <summary>
  109. /// <returns></returns>
  110. public void DeleteEntity(string keyValue)
  111. {
  112. try
  113. {
  114. var keyvalue = Convert.ToInt32(keyValue);
  115. this.BaseRepository("CollegeMIS").Delete<StuPunishmentEntity>(t => t.Id == keyvalue);
  116. }
  117. catch (Exception ex)
  118. {
  119. if (ex is ExceptionEx)
  120. {
  121. throw;
  122. }
  123. else
  124. {
  125. throw ExceptionEx.ThrowServiceException(ex);
  126. }
  127. }
  128. }
  129. /// <summary>
  130. /// 保存实体数据(新增、修改)
  131. /// <param name="keyValue">主键</param>
  132. /// <summary>
  133. /// <returns></returns>
  134. public void SaveEntity(string keyValue, StuPunishmentEntity entity)
  135. {
  136. try
  137. {
  138. if (!string.IsNullOrEmpty(keyValue))
  139. {
  140. entity.Modify(keyValue);
  141. this.BaseRepository("CollegeMIS").Update(entity);
  142. }
  143. else
  144. {
  145. entity.Create();
  146. this.BaseRepository("CollegeMIS").Insert(entity);
  147. }
  148. }
  149. catch (Exception ex)
  150. {
  151. if (ex is ExceptionEx)
  152. {
  153. throw;
  154. }
  155. else
  156. {
  157. throw ExceptionEx.ThrowServiceException(ex);
  158. }
  159. }
  160. }
  161. #endregion
  162. #region 扩展数据
  163. /// <summary>
  164. /// 获取学年学期列表
  165. /// </summary>
  166. /// <returns></returns>
  167. public IEnumerable<WebHelper.YearGrade> GetAcademicAndSemesterList()
  168. {
  169. try
  170. {
  171. var aa = this.BaseRepository("CollegeMIS").FindList<StuPunishmentEntity>();
  172. var aaa = aa.GroupBy(x => new { x.AcademicYearNo, x.Semester }).Select(x => new WebHelper.YearGrade()
  173. {
  174. text = string.Format("{0}学年第{1}学期", x.Key.AcademicYearNo, x.Key.Semester),
  175. value = string.Format("{0},{1}", x.Key.AcademicYearNo, x.Key.Semester)
  176. });
  177. return aaa;
  178. }
  179. catch (Exception ex)
  180. {
  181. if (ex is ExceptionEx)
  182. {
  183. throw;
  184. }
  185. else
  186. {
  187. throw ExceptionEx.ThrowServiceException(ex);
  188. }
  189. }
  190. }
  191. /// <summary>
  192. /// 获取页面显示列表数据
  193. /// <summary>
  194. /// <param name="queryJson">查询参数</param>
  195. /// <returns></returns>
  196. public IEnumerable<StuPunishmentEntity> GetPunishmentListByStuNo(string acdemic, string semester, string stuNo)
  197. {
  198. try
  199. {
  200. var result = this.BaseRepository("CollegeMIS").FindList<StuPunishmentEntity>(x => x.AcademicYearNo == acdemic && x.Semester == semester && x.StuNo == stuNo);
  201. return result;
  202. }
  203. catch (Exception ex)
  204. {
  205. if (ex is ExceptionEx)
  206. {
  207. throw;
  208. }
  209. else
  210. {
  211. throw ExceptionEx.ThrowServiceException(ex);
  212. }
  213. }
  214. }
  215. /// <summary>
  216. /// 获取页面显示列表数据
  217. /// <summary>
  218. /// <param name="queryJson">查询参数</param>
  219. /// <returns></returns>
  220. public IEnumerable<StuPunishmentEntity> GetPunishmentListByStuNo(string stuNo)
  221. {
  222. try
  223. {
  224. var result = this.BaseRepository("CollegeMIS").FindList<StuPunishmentEntity>(x => x.StuNo == stuNo);
  225. return result;
  226. }
  227. catch (Exception ex)
  228. {
  229. if (ex is ExceptionEx)
  230. {
  231. throw;
  232. }
  233. else
  234. {
  235. throw ExceptionEx.ThrowServiceException(ex);
  236. }
  237. }
  238. }
  239. #endregion
  240. }
  241. }