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.
 
 
 
 
 
 

179 lines
5.2 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.PersonnelManagement
  9. {
  10. /// <summary>
  11. /// 版 本 Learun-ADMS V7.0.6 力软敏捷开发框架
  12. /// Copyright (c) 2013-2020 力软信息技术(苏州)有限公司
  13. /// 创 建:超级管理员
  14. /// 日 期:2021-05-12 11:43
  15. /// 描 述:研究指导
  16. /// </summary>
  17. public class StudyGuideService : RepositoryFactory
  18. {
  19. #region 获取数据
  20. /// <summary>
  21. /// 获取页面显示列表数据
  22. /// </summary>
  23. /// <param name="pagination">查询参数</param>
  24. /// <param name="queryJson">查询参数</param>
  25. /// <returns></returns>
  26. public IEnumerable<StudyGuideEntity> GetPageList(Pagination pagination, string queryJson)
  27. {
  28. try
  29. {
  30. var strSql = new StringBuilder();
  31. strSql.Append("SELECT ");
  32. strSql.Append(@"
  33. t.*
  34. ");
  35. strSql.Append(" FROM StudyGuide t ");
  36. strSql.Append(" WHERE 1=1 ");
  37. var queryParam = queryJson.ToJObject();
  38. // 虚拟参数
  39. var dp = new DynamicParameters(new { });
  40. if (!queryParam["StudyName"].IsEmpty())
  41. {
  42. dp.Add("StudyName", "%" + queryParam["StudyName"].ToString() + "%", DbType.String);
  43. strSql.Append(" AND t.StudyName Like @StudyName ");
  44. }
  45. return this.BaseRepository("CollegeMIS").FindList<StudyGuideEntity>(strSql.ToString(), dp, pagination);
  46. }
  47. catch (Exception ex)
  48. {
  49. if (ex is ExceptionEx)
  50. {
  51. throw;
  52. }
  53. else
  54. {
  55. throw ExceptionEx.ThrowServiceException(ex);
  56. }
  57. }
  58. }
  59. /// <summary>
  60. /// 获取StudyGuide表实体数据
  61. /// </summary>
  62. /// <param name="keyValue">主键</param>
  63. /// <returns></returns>
  64. public StudyGuideEntity GetStudyGuideEntity(string keyValue)
  65. {
  66. try
  67. {
  68. return this.BaseRepository("CollegeMIS").FindEntity<StudyGuideEntity>(keyValue);
  69. }
  70. catch (Exception ex)
  71. {
  72. if (ex is ExceptionEx)
  73. {
  74. throw;
  75. }
  76. else
  77. {
  78. throw ExceptionEx.ThrowServiceException(ex);
  79. }
  80. }
  81. }
  82. #endregion
  83. #region 提交数据
  84. /// <summary>
  85. /// 删除实体数据
  86. /// </summary>
  87. /// <param name="keyValue">主键</param>
  88. public void DeleteEntity(string keyValue)
  89. {
  90. try
  91. {
  92. this.BaseRepository("CollegeMIS").Delete<StudyGuideEntity>(t => t.StudyID == 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. /// <summary>
  107. /// 发布
  108. /// </summary>
  109. /// <param name="keyValue">主键</param>
  110. public void Publish(string keyValue,int GuideState)
  111. {
  112. try
  113. {
  114. if (keyValue.Contains(","))
  115. {
  116. keyValue = string.Join("','", keyValue.Split(','));
  117. }
  118. string sql = $" update StudyGuide set guidestate={GuideState} where StudyID in ('{keyValue}')";
  119. this.BaseRepository("CollegeMIS").ExecuteBySql(sql);
  120. }
  121. catch (Exception ex)
  122. {
  123. if (ex is ExceptionEx)
  124. {
  125. throw;
  126. }
  127. else
  128. {
  129. throw ExceptionEx.ThrowServiceException(ex);
  130. }
  131. }
  132. }
  133. /// <summary>
  134. /// 保存实体数据(新增、修改)
  135. /// </summary>
  136. /// <param name="keyValue">主键</param>
  137. /// <param name="entity">实体</param>
  138. public void SaveEntity(string keyValue, StudyGuideEntity entity)
  139. {
  140. try
  141. {
  142. if (!string.IsNullOrEmpty(keyValue))
  143. {
  144. entity.Modify(keyValue);
  145. this.BaseRepository("CollegeMIS").Update(entity);
  146. }
  147. else
  148. {
  149. entity.Create();
  150. this.BaseRepository("CollegeMIS").Insert(entity);
  151. }
  152. }
  153. catch (Exception ex)
  154. {
  155. if (ex is ExceptionEx)
  156. {
  157. throw;
  158. }
  159. else
  160. {
  161. throw ExceptionEx.ThrowServiceException(ex);
  162. }
  163. }
  164. }
  165. #endregion
  166. }
  167. }