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.
 
 
 
 
 
 

191 lines
6.0 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. namespace Learun.Application.TwoDevelopment.EducationalAdministration
  9. {
  10. /// <summary>
  11. /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
  12. /// Copyright (c) 2013-2018 北京泉江科技有限公司
  13. /// 创 建:超级管理员
  14. /// 日 期:2019-08-11 09:51
  15. /// 描 述:新生在线咨询
  16. /// </summary>
  17. public class StuInfoFreshOnlineServiceService : RepositoryFactory
  18. {
  19. #region 获取数据
  20. /// <summary>
  21. /// 获取页面显示列表数据
  22. /// <summary>
  23. /// <param name="queryJson">查询参数</param>
  24. /// <returns></returns>
  25. public IEnumerable<StuInfoFreshOnlineServiceEntity> GetPageList(Pagination pagination, string queryJson)
  26. {
  27. try
  28. {
  29. var strSql = new StringBuilder();
  30. strSql.Append("SELECT t.* ");
  31. strSql.Append(" FROM StuInfoFreshOnlineService t ");
  32. strSql.Append(" WHERE 1=1 ");
  33. var queryParam = queryJson.ToJObject();
  34. // 虚拟参数
  35. var dp = new DynamicParameters(new { });
  36. if (!queryParam["QuestionCode"].IsEmpty())
  37. {
  38. dp.Add("QuestionCode", "%" + queryParam["QuestionCode"].ToString() + "%", DbType.String);
  39. strSql.Append(" AND t.QuestionCode Like @QuestionCode ");
  40. }
  41. if (!queryParam["QuestionTitle"].IsEmpty())
  42. {
  43. dp.Add("QuestionTitle", "%" + queryParam["QuestionTitle"].ToString() + "%", DbType.String);
  44. strSql.Append(" AND t.QuestionTitle Like @QuestionTitle ");
  45. }
  46. if (!queryParam["QuestionUserId"].IsEmpty())
  47. {
  48. dp.Add("QuestionUserId", queryParam["QuestionUserId"].ToString(), DbType.String);
  49. strSql.Append(" AND t.QuestionUserId = @QuestionUserId ");
  50. }
  51. if (!queryParam["QuestionStatus"].IsEmpty())
  52. {
  53. dp.Add("QuestionStatus", queryParam["QuestionStatus"].ToString(), DbType.String);
  54. strSql.Append(" AND t.QuestionStatus = @QuestionStatus ");
  55. }
  56. return this.BaseRepository("CollegeMIS").FindList<StuInfoFreshOnlineServiceEntity>(strSql.ToString(), dp, pagination);
  57. }
  58. catch (Exception ex)
  59. {
  60. if (ex is ExceptionEx)
  61. {
  62. throw;
  63. }
  64. else
  65. {
  66. throw ExceptionEx.ThrowServiceException(ex);
  67. }
  68. }
  69. }
  70. /// <summary>
  71. /// 获取StuInfoFreshOnlineService表实体数据
  72. /// <param name="keyValue">主键</param>
  73. /// <summary>
  74. /// <returns></returns>
  75. public StuInfoFreshOnlineServiceEntity GetStuInfoFreshOnlineServiceEntity(string keyValue)
  76. {
  77. try
  78. {
  79. return this.BaseRepository("CollegeMIS").FindEntity<StuInfoFreshOnlineServiceEntity>(keyValue);
  80. }
  81. catch (Exception ex)
  82. {
  83. if (ex is ExceptionEx)
  84. {
  85. throw;
  86. }
  87. else
  88. {
  89. throw ExceptionEx.ThrowServiceException(ex);
  90. }
  91. }
  92. }
  93. #endregion
  94. #region 提交数据
  95. /// <summary>
  96. /// 删除实体数据
  97. /// <param name="keyValue">主键</param>
  98. /// <summary>
  99. /// <returns></returns>
  100. public void DeleteEntity(string keyValue)
  101. {
  102. try
  103. {
  104. this.BaseRepository("CollegeMIS").Delete<StuInfoFreshOnlineServiceEntity>(t => t.Id == keyValue);
  105. }
  106. catch (Exception ex)
  107. {
  108. if (ex is ExceptionEx)
  109. {
  110. throw;
  111. }
  112. else
  113. {
  114. throw ExceptionEx.ThrowServiceException(ex);
  115. }
  116. }
  117. }
  118. /// <summary>
  119. /// 保存实体数据(新增、修改)
  120. /// <param name="keyValue">主键</param>
  121. /// <summary>
  122. /// <returns></returns>
  123. public void SaveEntity(string keyValue, StuInfoFreshOnlineServiceEntity entity)
  124. {
  125. try
  126. {
  127. if (!string.IsNullOrEmpty(keyValue))
  128. {
  129. entity.Modify(keyValue);
  130. this.BaseRepository("CollegeMIS").Update(entity);
  131. }
  132. else
  133. {
  134. entity.Create();
  135. this.BaseRepository("CollegeMIS").Insert(entity);
  136. }
  137. }
  138. catch (Exception ex)
  139. {
  140. if (ex is ExceptionEx)
  141. {
  142. throw;
  143. }
  144. else
  145. {
  146. throw ExceptionEx.ThrowServiceException(ex);
  147. }
  148. }
  149. }
  150. #endregion
  151. #region 扩展数据
  152. /// <summary>
  153. /// 提交咨询问题
  154. /// <param name="keyValue">主键</param>
  155. /// <summary>
  156. /// <returns></returns>
  157. public void SumbitQuestion(string keyValue)
  158. {
  159. try
  160. {
  161. this.BaseRepository("CollegeMIS").ExecuteBySql("update StuInfoFreshOnlineService set QuestionStatus='1',QuestionSubmitTime='" + DateTime.Now + "' where Id='" + keyValue + "' ");
  162. }
  163. catch (Exception ex)
  164. {
  165. if (ex is ExceptionEx)
  166. {
  167. throw;
  168. }
  169. else
  170. {
  171. throw ExceptionEx.ThrowServiceException(ex);
  172. }
  173. }
  174. }
  175. #endregion
  176. }
  177. }