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.

MSRIntentionManagementService.cs 5.9 KiB

4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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. using Learun.Application.TwoDevelopment.EducationalAdministration;
  9. namespace Learun.Application.TwoDevelopment.LogisticsManagement
  10. {
  11. /// <summary>
  12. /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
  13. /// Copyright (c) 2013-2018 北京泉江科技有限公司
  14. /// 创 建:超级管理员
  15. /// 日 期:2020-05-19 13:38
  16. /// 描 述:参军意向管理
  17. /// </summary>
  18. public class MSRIntentionManagementService : RepositoryFactory
  19. {
  20. #region 获取数据
  21. /// <summary>
  22. /// 获取页面显示列表数据
  23. /// <summary>
  24. /// <param name="queryJson">查询参数</param>
  25. /// <returns></returns>
  26. public IEnumerable<MSRIntentionManagementEntity> 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.DeptNo,
  35. t.MajorNo,
  36. t.ClassNo,
  37. t.StuNo,
  38. t.Mobile,
  39. t.Age,
  40. t.High,
  41. t.Weight,
  42. t.Vision
  43. ");
  44. strSql.Append(" FROM MSRIntentionManagement t ");
  45. strSql.Append(" WHERE 1=1 ");
  46. var queryParam = queryJson.ToJObject();
  47. // 虚拟参数
  48. var dp = new DynamicParameters(new { });
  49. if (!queryParam["DeptNo"].IsEmpty())
  50. {
  51. dp.Add("DeptNo",queryParam["DeptNo"].ToString(), DbType.String);
  52. strSql.Append(" AND t.DeptNo = @DeptNo ");
  53. }
  54. if (!queryParam["MajorNo"].IsEmpty())
  55. {
  56. dp.Add("MajorNo",queryParam["MajorNo"].ToString(), DbType.String);
  57. strSql.Append(" AND t.MajorNo = @MajorNo ");
  58. }
  59. if (!queryParam["ClassNo"].IsEmpty())
  60. {
  61. dp.Add("ClassNo",queryParam["ClassNo"].ToString(), DbType.String);
  62. strSql.Append(" AND t.ClassNo = @ClassNo ");
  63. }
  64. if (!queryParam["StuNo"].IsEmpty())
  65. {
  66. dp.Add("StuNo",queryParam["StuNo"].ToString(), DbType.String);
  67. strSql.Append(" AND t.StuNo = @StuNo ");
  68. }
  69. return this.BaseRepository("CollegeMIS").FindList<MSRIntentionManagementEntity>(strSql.ToString(),dp, pagination);
  70. }
  71. catch (Exception ex)
  72. {
  73. if (ex is ExceptionEx)
  74. {
  75. throw;
  76. }
  77. else
  78. {
  79. throw ExceptionEx.ThrowServiceException(ex);
  80. }
  81. }
  82. }
  83. /// <summary>
  84. /// 获取MSRIntentionManagement表实体数据
  85. /// <param name="keyValue">主键</param>
  86. /// <summary>
  87. /// <returns></returns>
  88. public MSRIntentionManagementEntity GetMSRIntentionManagementEntity(string keyValue)
  89. {
  90. try
  91. {
  92. return this.BaseRepository("CollegeMIS").FindEntity<MSRIntentionManagementEntity>(keyValue);
  93. }
  94. catch (Exception ex)
  95. {
  96. if (ex is ExceptionEx)
  97. {
  98. throw;
  99. }
  100. else
  101. {
  102. throw ExceptionEx.ThrowServiceException(ex);
  103. }
  104. }
  105. }
  106. #endregion
  107. #region 提交数据
  108. /// <summary>
  109. /// 删除实体数据
  110. /// <param name="keyValue">主键</param>
  111. /// <summary>
  112. /// <returns></returns>
  113. public void DeleteEntity(string keyValue)
  114. {
  115. try
  116. {
  117. this.BaseRepository("CollegeMIS").Delete<MSRIntentionManagementEntity>(t=>t.ID == keyValue);
  118. }
  119. catch (Exception ex)
  120. {
  121. if (ex is ExceptionEx)
  122. {
  123. throw;
  124. }
  125. else
  126. {
  127. throw ExceptionEx.ThrowServiceException(ex);
  128. }
  129. }
  130. }
  131. /// <summary>
  132. /// 保存实体数据(新增、修改)
  133. /// <param name="keyValue">主键</param>
  134. /// <summary>
  135. /// <returns></returns>
  136. public void SaveEntity(string keyValue, MSRIntentionManagementEntity entity)
  137. {
  138. try
  139. {
  140. if (!string.IsNullOrEmpty(keyValue))
  141. {
  142. entity.Modify(keyValue);
  143. this.BaseRepository("CollegeMIS").Update(entity);
  144. }
  145. else
  146. {
  147. //获取当前学生的名字、系、专业、班级
  148. var loginUser = LoginUserInfo.Get();
  149. var userEntity = this.BaseRepository("CollegeMIS")
  150. .FindEntity<StuInfoBasicEntity>(a => a.StuNo == loginUser.account);
  151. entity.StuNo = userEntity?.StuNo;
  152. entity.DeptNo = userEntity?.DeptNo;
  153. entity.MajorNo = userEntity?.MajorNo;
  154. entity.ClassNo = userEntity?.ClassNo;
  155. entity.Create();
  156. this.BaseRepository("CollegeMIS").Insert(entity);
  157. }
  158. }
  159. catch (Exception ex)
  160. {
  161. if (ex is ExceptionEx)
  162. {
  163. throw;
  164. }
  165. else
  166. {
  167. throw ExceptionEx.ThrowServiceException(ex);
  168. }
  169. }
  170. }
  171. #endregion
  172. }
  173. }