NoticeService.cs 3.4 KB

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