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.
 
 
 
 
 
 

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