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.
 
 
 
 
 
 

210 lines
6.1 KiB

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