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.
 
 
 
 
 
 

176 lines
5.0 KiB

  1. using Learun.DataBase.Repository;
  2. using Learun.Util;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Text;
  6. namespace Learun.Application.OA
  7. {
  8. /// <summary>
  9. /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
  10. /// Copyright (c) 2013-2018 北京泉江科技有限公司
  11. /// 创建人:陈彬彬
  12. /// 日 期:2017.04.17
  13. /// 描 述:新闻管理
  14. /// </summary>
  15. public class NewsService : RepositoryFactory
  16. {
  17. #region 获取数据
  18. /// <summary>
  19. /// 新闻列表
  20. /// </summary>
  21. /// <param name="pagination">分页参数</param>
  22. /// <param name="categoryId">类型</param>
  23. /// <param name="keyword">关键词</param>
  24. /// <returns></returns>
  25. public IEnumerable<NewsEntity> GetPageList(Pagination pagination, string keyword)
  26. {
  27. try
  28. {
  29. var strSql = new StringBuilder();
  30. strSql.Append("SELECT * FROM LR_OA_News t WHERE t.F_TypeId = 1 ");
  31. if (!string.IsNullOrEmpty(keyword))
  32. {
  33. strSql.Append(" AND F_FullHead like @keyword");
  34. }
  35. return this.BaseRepository().FindList<NewsEntity>(strSql.ToString(), new { keyword = "%" + keyword + "%" }, pagination);
  36. }
  37. catch (Exception ex)
  38. {
  39. if (ex is ExceptionEx)
  40. {
  41. throw;
  42. }
  43. else
  44. {
  45. throw ExceptionEx.ThrowServiceException(ex);
  46. }
  47. }
  48. }
  49. public IEnumerable<NewsEntity> GetAboutSchool()
  50. {
  51. try
  52. {
  53. return this.BaseRepository().FindList<NewsEntity>(a => a.F_Category == "关于学院");
  54. }
  55. catch (Exception ex)
  56. {
  57. if (ex is ExceptionEx)
  58. {
  59. throw;
  60. }
  61. else
  62. {
  63. throw ExceptionEx.ThrowServiceException(ex);
  64. }
  65. }
  66. }
  67. public IEnumerable<NewsEntity> GetNews()
  68. {
  69. try
  70. {
  71. return this.BaseRepository().FindList<NewsEntity>(a => a.F_Category == "新闻公告");
  72. }
  73. catch (Exception ex)
  74. {
  75. if (ex is ExceptionEx)
  76. {
  77. throw;
  78. }
  79. else
  80. {
  81. throw ExceptionEx.ThrowServiceException(ex);
  82. }
  83. }
  84. }
  85. /// <summary>
  86. /// 新闻公告实体
  87. /// </summary>
  88. /// <param name="keyValue">主键值</param>
  89. /// <returns></returns>
  90. public NewsEntity GetEntity(string keyValue)
  91. {
  92. try
  93. {
  94. return this.BaseRepository().FindEntity<NewsEntity>(keyValue);
  95. }
  96. catch (Exception ex)
  97. {
  98. if (ex is ExceptionEx)
  99. {
  100. throw;
  101. }
  102. else
  103. {
  104. throw ExceptionEx.ThrowServiceException(ex);
  105. }
  106. }
  107. }
  108. #endregion
  109. #region 提交数据
  110. /// <summary>
  111. /// 删除
  112. /// </summary>
  113. /// <param name="keyValue">主键</param>
  114. public void DeleteEntity(string keyValue)
  115. {
  116. try
  117. {
  118. NewsEntity entity = new NewsEntity()
  119. {
  120. F_NewsId = keyValue,
  121. };
  122. this.BaseRepository().Delete(entity);
  123. }
  124. catch (Exception ex)
  125. {
  126. if (ex is ExceptionEx)
  127. {
  128. throw;
  129. }
  130. else
  131. {
  132. throw ExceptionEx.ThrowServiceException(ex);
  133. }
  134. }
  135. }
  136. /// <summary>
  137. /// 保存(新增、修改)
  138. /// </summary>
  139. /// <param name="keyValue">主键值</param>
  140. /// <param name="newsEntity">新闻公告实体</param>
  141. /// <returns></returns>
  142. public void SaveEntity(string keyValue, NewsEntity newsEntity)
  143. {
  144. try
  145. {
  146. newsEntity.F_TypeId = 1;
  147. if (!string.IsNullOrEmpty(keyValue))
  148. {
  149. newsEntity.Modify(keyValue);
  150. this.BaseRepository().Update(newsEntity);
  151. }
  152. else
  153. {
  154. newsEntity.Create();
  155. this.BaseRepository().Insert(newsEntity);
  156. }
  157. }
  158. catch (Exception ex)
  159. {
  160. if (ex is ExceptionEx)
  161. {
  162. throw;
  163. }
  164. else
  165. {
  166. throw ExceptionEx.ThrowServiceException(ex);
  167. }
  168. }
  169. }
  170. #endregion
  171. }
  172. }