BannerService.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. using Lottomat.Application.Entity.BaseManage;
  2. using Lottomat.Application.IService.BaseManage;
  3. using Lottomat.Data.Repository;
  4. using Lottomat.Util.WebControl;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using Lottomat.Application.Code;
  8. using Lottomat.Application.Entity.LotteryNumberManage;
  9. using Lottomat.Util.Extension;
  10. using Newtonsoft.Json.Linq;
  11. namespace Lottomat.Application.Service.BaseManage
  12. {
  13. /// <summary>
  14. /// 版 本 1.0
  15. /// Copyright (c) 2016-2017
  16. /// 创 建:超级管理员
  17. /// 日 期:2018-05-28 09:54
  18. /// 描 述:轮播图
  19. /// </summary>
  20. public class BannerService : RepositoryFactory<BannerEntity>, IBannerService
  21. {
  22. #region 获取数据
  23. /// <summary>
  24. /// 获取列表
  25. /// </summary>
  26. /// <param name="pagination">分页</param>
  27. /// <param name="queryJson">查询参数</param>
  28. /// <returns>返回分页列表</returns>
  29. public IEnumerable<BannerEntity> GetPageList(Pagination pagination, string queryJson)
  30. {
  31. var expression = LinqExtensions.True<BannerEntity>();
  32. JObject queryParam = queryJson.ToJObject();
  33. if (queryParam != null)
  34. {
  35. if (!queryParam["Title"].IsEmpty())
  36. {
  37. string Title = queryParam["Title"].ToString();
  38. expression = expression.And(t => t.Title.Contains(Title));
  39. }
  40. }
  41. return this.BaseRepository().FindList(expression, pagination);
  42. }
  43. /// <summary>
  44. /// 获取列表
  45. /// </summary>
  46. /// <param name="queryJson">查询参数</param>
  47. /// <returns>返回列表</returns>
  48. public IEnumerable<BannerEntity> GetList(string queryJson)
  49. {
  50. return this.BaseRepository().IQueryable().ToList();
  51. }
  52. /// <summary>
  53. /// 获取实体
  54. /// </summary>
  55. /// <param name="keyValue">主键值</param>
  56. /// <returns></returns>
  57. public BannerEntity GetEntity(string keyValue)
  58. {
  59. return this.BaseRepository().FindEntity(keyValue);
  60. }
  61. #endregion
  62. #region 提交数据
  63. /// <summary>
  64. /// 删除数据
  65. /// </summary>
  66. /// <param name="keyValue">主键</param>
  67. public void RemoveForm(string keyValue)
  68. {
  69. this.BaseRepository().Delete(keyValue);
  70. }
  71. /// <summary>
  72. /// 保存表单(新增、修改)
  73. /// </summary>
  74. /// <param name="keyValue">主键值</param>
  75. /// <param name="entity">实体对象</param>
  76. /// <returns></returns>
  77. public void SaveForm(string keyValue, BannerEntity entity)
  78. {
  79. if (!string.IsNullOrEmpty(keyValue))
  80. {
  81. entity.Modify(keyValue);
  82. this.BaseRepository().Update(entity);
  83. }
  84. else
  85. {
  86. entity.Create();
  87. this.BaseRepository().Insert(entity);
  88. }
  89. }
  90. #endregion
  91. }
  92. }