LabelService.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. using System;
  2. using Lottomat.Application.Entity.InformationManage;
  3. using Lottomat.Application.IService.InformationManage;
  4. using Lottomat.Data.Repository;
  5. using Lottomat.Util.WebControl;
  6. using System.Collections.Generic;
  7. using System.Linq;
  8. using System.Linq.Expressions;
  9. using Lottomat.Application.Entity.PublicInfoManage;
  10. using Lottomat.Util.Extension;
  11. using Newtonsoft.Json.Linq;
  12. namespace Lottomat.Application.Service.InformationManage
  13. {
  14. /// <summary>
  15. /// 版 本 1.0
  16. /// Copyright (c) 2016-2017
  17. /// 创 建:超级管理员
  18. /// 日 期:2017-10-27 10:34
  19. /// 描 述:Zx_Label
  20. /// </summary>
  21. public class LabelService : RepositoryFactory<LabelEntity>, ILabelService
  22. {
  23. #region 获取数据
  24. /// <summary>
  25. /// 获取列表
  26. /// </summary>
  27. /// <param name="pagination">分页</param>
  28. /// <param name="queryJson">查询参数</param>
  29. /// <returns>返回分页列表</returns>
  30. public IEnumerable<LabelEntity> GetPageList(Pagination pagination, string queryJson)
  31. {
  32. var expression = LinqExtensions.True<LabelEntity>();
  33. JObject queryParam = queryJson.ToJObject();
  34. if (queryParam != null)
  35. {
  36. if (!queryParam["LabelName"].IsEmpty())
  37. {
  38. string LabelName = queryParam["LabelName"].ToString();
  39. expression = expression.And(t => t.LabelName.Contains(LabelName));
  40. }
  41. if (!queryParam["TitleElement"].IsEmpty())
  42. {
  43. string TitleElement = queryParam["TitleElement"].ToString();
  44. expression = expression.And(t => t.TitleElement == TitleElement);
  45. }
  46. if (!queryParam["DescriptionElement"].IsEmpty())
  47. {
  48. string DescriptionElement = queryParam["DescriptionElement"].ToString();
  49. expression = expression.And(t => t.DescriptionElement == DescriptionElement);
  50. }
  51. if (!queryParam["KeywordElement"].IsEmpty())
  52. {
  53. string KeywordElement = queryParam["KeywordElement"].ToString();
  54. expression = expression.And(t => t.KeywordElement == KeywordElement);
  55. }
  56. if (!queryParam["CategoryId"].IsEmpty())
  57. {
  58. string CategoryId = queryParam["CategoryId"].ToString();
  59. expression = expression.And(t => t.CategoryId == CategoryId);
  60. }
  61. }
  62. expression = expression.And(t => t.IsDelete == false);
  63. return this.BaseRepository().FindList(expression, pagination);
  64. }
  65. /// <summary>
  66. /// 获取列表
  67. /// </summary>
  68. /// <param name="queryJson">查询参数</param>
  69. /// <returns>返回列表</returns>
  70. public IEnumerable<LabelEntity> GetList(string queryJson)
  71. {
  72. return this.BaseRepository().IQueryable().ToList();
  73. }
  74. /// <summary>
  75. /// 获取实体
  76. /// </summary>
  77. /// <param name="keyValue">主键值</param>
  78. /// <returns></returns>
  79. public LabelEntity GetEntity(string keyValue)
  80. {
  81. return this.BaseRepository().FindEntity(keyValue);
  82. }
  83. /// <summary>
  84. /// 获取所有数据
  85. /// </summary>
  86. /// <param name="condition"></param>
  87. /// <returns></returns>
  88. public IEnumerable<LabelEntity> GetList(Expression<Func<LabelEntity, bool>> condition)
  89. {
  90. return this.BaseRepository().FindList(condition);
  91. }
  92. #endregion
  93. #region 提交数据
  94. /// <summary>
  95. /// 删除数据
  96. /// </summary>
  97. /// <param name="keyValue">主键</param>
  98. public void RemoveForm(string keyValue)
  99. {
  100. this.BaseRepository().Delete(keyValue);
  101. }
  102. /// <summary>
  103. /// 保存表单(新增、修改)
  104. /// </summary>
  105. /// <param name="keyValue">主键值</param>
  106. /// <param name="entity">实体对象</param>
  107. /// <returns></returns>
  108. public void SaveForm(string keyValue, LabelEntity entity)
  109. {
  110. if (!string.IsNullOrEmpty(keyValue))
  111. {
  112. entity.Modify(keyValue);
  113. this.BaseRepository().Update(entity);
  114. }
  115. else
  116. {
  117. entity.Create();
  118. this.BaseRepository().Insert(entity);
  119. }
  120. }
  121. #endregion
  122. }
  123. }