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.
 
 
 
 
 
 

173 lines
5.7 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. 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 MSRIntentionManagementTranService : RepositoryFactory
  19. {
  20. #region 获取数据
  21. /// <summary>
  22. /// 获取页面显示列表数据
  23. /// <summary>
  24. /// <param name="queryJson">查询参数</param>
  25. /// <returns></returns>
  26. public IEnumerable<MSRIntentionManagementTranEntity> GetPageList(Pagination pagination, string queryJson)
  27. {
  28. try
  29. {
  30. var strSql = new StringBuilder();
  31. strSql.Append("SELECT ");
  32. strSql.Append(@" t.* ");
  33. strSql.Append(" FROM MSRIntentionManagementTran t ");
  34. strSql.Append(" WHERE 1=1 ");
  35. var queryParam = queryJson.ToJObject();
  36. // 虚拟参数
  37. var dp = new DynamicParameters(new { });
  38. if (!queryParam["DeptNo"].IsEmpty())
  39. {
  40. dp.Add("DeptNo",queryParam["DeptNo"].ToString(), DbType.String);
  41. strSql.Append(" AND t.DeptNo = @DeptNo ");
  42. }
  43. if (!queryParam["MajorNo"].IsEmpty())
  44. {
  45. dp.Add("MajorNo",queryParam["MajorNo"].ToString(), DbType.String);
  46. strSql.Append(" AND t.MajorNo = @MajorNo ");
  47. }
  48. if (!queryParam["ClassNo"].IsEmpty())
  49. {
  50. dp.Add("ClassNo",queryParam["ClassNo"].ToString(), DbType.String);
  51. strSql.Append(" AND t.ClassNo = @ClassNo ");
  52. }
  53. if (!queryParam["StuNo"].IsEmpty())
  54. {
  55. dp.Add("StuNo",queryParam["StuNo"].ToString(), DbType.String);
  56. strSql.Append(" AND t.StuNo = @StuNo ");
  57. }
  58. return this.BaseRepository("CollegeMIS").FindList<MSRIntentionManagementTranEntity>(strSql.ToString(),dp, pagination);
  59. }
  60. catch (Exception ex)
  61. {
  62. if (ex is ExceptionEx)
  63. {
  64. throw;
  65. }
  66. else
  67. {
  68. throw ExceptionEx.ThrowServiceException(ex);
  69. }
  70. }
  71. }
  72. /// <summary>
  73. /// 获取MSRIntentionManagementTran表实体数据
  74. /// <param name="keyValue">主键</param>
  75. /// <summary>
  76. /// <returns></returns>
  77. public MSRIntentionManagementTranEntity GetMSRIntentionManagementEntity(string keyValue)
  78. {
  79. try
  80. {
  81. return this.BaseRepository("CollegeMIS").FindEntity<MSRIntentionManagementTranEntity>(keyValue);
  82. }
  83. catch (Exception ex)
  84. {
  85. if (ex is ExceptionEx)
  86. {
  87. throw;
  88. }
  89. else
  90. {
  91. throw ExceptionEx.ThrowServiceException(ex);
  92. }
  93. }
  94. }
  95. #endregion
  96. #region 提交数据
  97. /// <summary>
  98. /// 删除实体数据
  99. /// <param name="keyValue">主键</param>
  100. /// <summary>
  101. /// <returns></returns>
  102. public void DeleteEntity(string keyValue)
  103. {
  104. try
  105. {
  106. this.BaseRepository("CollegeMIS").Delete<MSRIntentionManagementTranEntity>(t=>t.ID == keyValue);
  107. }
  108. catch (Exception ex)
  109. {
  110. if (ex is ExceptionEx)
  111. {
  112. throw;
  113. }
  114. else
  115. {
  116. throw ExceptionEx.ThrowServiceException(ex);
  117. }
  118. }
  119. }
  120. /// <summary>
  121. /// 保存实体数据(新增、修改)
  122. /// <param name="keyValue">主键</param>
  123. /// <summary>
  124. /// <returns></returns>
  125. public void SaveEntity(string keyValue, MSRIntentionManagementTranEntity entity)
  126. {
  127. try
  128. {
  129. if (!string.IsNullOrEmpty(keyValue))
  130. {
  131. entity.Modify(keyValue);
  132. this.BaseRepository("CollegeMIS").Update(entity);
  133. }
  134. else
  135. {
  136. //获取当前学生的名字、系、专业、班级
  137. var loginUser = LoginUserInfo.Get();
  138. var userEntity = this.BaseRepository("CollegeMIS")
  139. .FindEntity<StuInfoBasicEntity>(a => a.StuNo == loginUser.account);
  140. entity.StuNo = userEntity?.StuNo;
  141. entity.DeptNo = userEntity?.DeptNo;
  142. entity.MajorNo = userEntity?.MajorNo;
  143. entity.ClassNo = userEntity?.ClassNo;
  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. }
  162. }