NoticeService.cs 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. using LeaRun.Application.Entity.PublicInfoManage;
  2. using LeaRun.Application.IService.PublicInfoManage;
  3. using LeaRun.Data.Repository;
  4. using LeaRun.Util;
  5. using LeaRun.Util.Extension;
  6. using LeaRun.Util.WebControl;
  7. using System.Collections.Generic;
  8. namespace LeaRun.Application.Service.PublicInfoManage
  9. {
  10. /// <summary>
  11. /// 版 本 6.1
  12. /// Copyright (c) 2013-2016 上海力软信息技术有限公司
  13. /// 创建人:佘赐雄
  14. /// 日 期:2015.12.7 16:40
  15. /// 描 述:电子公告
  16. /// </summary>
  17. public class NoticeService : RepositoryFactory<NewsEntity>, INoticeService
  18. {
  19. #region 获取数据
  20. /// <summary>
  21. /// 公告列表
  22. /// </summary>
  23. /// <param name="pagination">分页</param>
  24. /// <param name="queryJson">查询参数</param>
  25. /// <returns></returns>
  26. public IEnumerable<NewsEntity> GetPageList(Pagination pagination, string queryJson)
  27. {
  28. var expression = LinqExtensions.True<NewsEntity>();
  29. var queryParam = queryJson.ToJObject();
  30. if (!queryParam["FullHead"].IsEmpty())
  31. {
  32. string FullHead = queryParam["FullHead"].ToString();
  33. expression = expression.And(t => t.FullHead.Contains(FullHead));
  34. }
  35. if (!queryParam["Category"].IsEmpty())
  36. {
  37. string Category = queryParam["Category"].ToString();
  38. expression = expression.And(t => t.Category == Category);
  39. }
  40. expression = expression.And(t => t.TypeId == 2);
  41. return this.BaseRepository().FindList(expression, pagination);
  42. }
  43. /// <summary>
  44. /// 公告实体
  45. /// </summary>
  46. /// <param name="keyValue">主键值</param>
  47. /// <returns></returns>
  48. public NewsEntity GetEntity(string keyValue)
  49. {
  50. return this.BaseRepository().FindEntity(keyValue);
  51. }
  52. #endregion
  53. #region 提交数据
  54. /// <summary>
  55. /// 删除公告
  56. /// </summary>
  57. /// <param name="keyValue">主键</param>
  58. public void RemoveForm(string keyValue)
  59. {
  60. this.BaseRepository().Delete(keyValue);
  61. }
  62. /// <summary>
  63. /// 保存公告表单(新增、修改)
  64. /// </summary>
  65. /// <param name="keyValue">主键值</param>
  66. /// <param name="newsEntity">公告实体</param>
  67. /// <returns></returns>
  68. public void SaveForm(string keyValue, NewsEntity newsEntity)
  69. {
  70. if (!string.IsNullOrEmpty(keyValue))
  71. {
  72. newsEntity.Modify(keyValue);
  73. newsEntity.TypeId = 2;
  74. this.BaseRepository().Update(newsEntity);
  75. }
  76. else
  77. {
  78. newsEntity.Create();
  79. newsEntity.TypeId = 2;
  80. this.BaseRepository().Insert(newsEntity);
  81. }
  82. }
  83. #endregion
  84. }
  85. }