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.
 
 
 
 
 
 

254 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-18 10:08
  16. /// 描 述:学生奖励管理
  17. /// </summary>
  18. public class StuEncourgementService : RepositoryFactory
  19. {
  20. #region 获取数据
  21. /// <summary>
  22. /// 获取页面显示列表数据
  23. /// <summary>
  24. /// <param name="queryJson">查询参数</param>
  25. /// <returns></returns>
  26. public IEnumerable<StuEncourgementEntity> 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.EncourgeName,
  37. t.Reason,
  38. t.Fee,
  39. t.EncourgeDate
  40. ");
  41. strSql.Append(" FROM StuEncourgement t ");
  42. strSql.Append(" WHERE 1=1 ");
  43. var queryParam = queryJson.ToJObject();
  44. // 虚拟参数
  45. var dp = new DynamicParameters(new { });
  46. return this.BaseRepository("CollegeMIS").FindList<StuEncourgementEntity>(strSql.ToString(), dp, pagination);
  47. }
  48. catch (Exception ex)
  49. {
  50. if (ex is ExceptionEx)
  51. {
  52. throw;
  53. }
  54. else
  55. {
  56. throw ExceptionEx.ThrowServiceException(ex);
  57. }
  58. }
  59. }
  60. public IEnumerable<StuEncourgementEntity> GetAllList()
  61. {
  62. try
  63. {
  64. return this.BaseRepository("CollegeMIS").FindList<StuEncourgementEntity>();
  65. }
  66. catch (Exception ex)
  67. {
  68. if (ex is ExceptionEx)
  69. {
  70. throw;
  71. }
  72. else
  73. {
  74. throw ExceptionEx.ThrowServiceException(ex);
  75. }
  76. }
  77. }
  78. /// <summary>
  79. /// 获取StuEncourgement表实体数据
  80. /// <param name="keyValue">主键</param>
  81. /// <summary>
  82. /// <returns></returns>
  83. public StuEncourgementEntity GetStuEncourgementEntity(string keyValue)
  84. {
  85. try
  86. {
  87. var keyvalue = Convert.ToInt32(keyValue);
  88. return this.BaseRepository("CollegeMIS").FindEntity<StuEncourgementEntity>(keyvalue);
  89. }
  90. catch (Exception ex)
  91. {
  92. if (ex is ExceptionEx)
  93. {
  94. throw;
  95. }
  96. else
  97. {
  98. throw ExceptionEx.ThrowServiceException(ex);
  99. }
  100. }
  101. }
  102. #endregion
  103. #region 提交数据
  104. /// <summary>
  105. /// 删除实体数据
  106. /// <param name="keyValue">主键</param>
  107. /// <summary>
  108. /// <returns></returns>
  109. public void DeleteEntity(string keyValue)
  110. {
  111. try
  112. {
  113. var keyvalue = Convert.ToInt32(keyValue);
  114. this.BaseRepository("CollegeMIS").Delete<StuEncourgementEntity>(t => t.ID == keyvalue);
  115. }
  116. catch (Exception ex)
  117. {
  118. if (ex is ExceptionEx)
  119. {
  120. throw;
  121. }
  122. else
  123. {
  124. throw ExceptionEx.ThrowServiceException(ex);
  125. }
  126. }
  127. }
  128. /// <summary>
  129. /// 保存实体数据(新增、修改)
  130. /// <param name="keyValue">主键</param>
  131. /// <summary>
  132. /// <returns></returns>
  133. public void SaveEntity(string keyValue, StuEncourgementEntity entity)
  134. {
  135. try
  136. {
  137. if (!string.IsNullOrEmpty(keyValue))
  138. {
  139. entity.Modify(keyValue);
  140. this.BaseRepository("CollegeMIS").Update(entity);
  141. }
  142. else
  143. {
  144. entity.Create();
  145. this.BaseRepository("CollegeMIS").Insert(entity);
  146. }
  147. }
  148. catch (Exception ex)
  149. {
  150. if (ex is ExceptionEx)
  151. {
  152. throw;
  153. }
  154. else
  155. {
  156. throw ExceptionEx.ThrowServiceException(ex);
  157. }
  158. }
  159. }
  160. #endregion
  161. #region 扩展数据
  162. /// <summary>
  163. /// 获取学年学期列表
  164. /// </summary>
  165. /// <returns></returns>
  166. public IEnumerable<WebHelper.YearGrade> GetAcademicAndSemesterList()
  167. {
  168. try
  169. {
  170. var aa = this.BaseRepository("CollegeMIS").FindList<StuEncourgementEntity>();
  171. var aaa = aa.GroupBy(x => new { x.AcademicYearNo, x.Semester }).Select(x => new WebHelper.YearGrade()
  172. {
  173. text = string.Format("{0}学年第{1}学期", x.Key.AcademicYearNo, x.Key.Semester),
  174. value = string.Format("{0},{1}", x.Key.AcademicYearNo, x.Key.Semester)
  175. });
  176. return aaa;
  177. }
  178. catch (Exception ex)
  179. {
  180. if (ex is ExceptionEx)
  181. {
  182. throw;
  183. }
  184. else
  185. {
  186. throw ExceptionEx.ThrowServiceException(ex);
  187. }
  188. }
  189. }
  190. /// <summary>
  191. /// 获取页面显示列表数据
  192. /// <summary>
  193. /// <param name="queryJson">查询参数</param>
  194. /// <returns></returns>
  195. public IEnumerable<StuEncourgementEntity> GetEncourgementListByStuNo(string acdemic, string semester, string stuNo)
  196. {
  197. try
  198. {
  199. var result = this.BaseRepository("CollegeMIS").FindList<StuEncourgementEntity>(x => x.AcademicYearNo == acdemic && x.Semester == semester && x.StuNo == stuNo);
  200. return result;
  201. }
  202. catch (Exception ex)
  203. {
  204. if (ex is ExceptionEx)
  205. {
  206. throw;
  207. }
  208. else
  209. {
  210. throw ExceptionEx.ThrowServiceException(ex);
  211. }
  212. }
  213. }
  214. /// <summary>
  215. /// 获取页面显示列表数据
  216. /// <summary>
  217. /// <param name="queryJson">查询参数</param>
  218. /// <returns></returns>
  219. public IEnumerable<StuEncourgementEntity> GetEncourgementListByStuNo(string stuNo)
  220. {
  221. try
  222. {
  223. var result = this.BaseRepository("CollegeMIS").FindList<StuEncourgementEntity>(x => x.StuNo == stuNo);
  224. return result;
  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. }