Tk_GalleryService.cs 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. using System;
  2. using Lottomat.Application.Entity.BaseManage;
  3. using Lottomat.Application.Entity.GalleryManage;
  4. using Lottomat.Application.IService.BaseManage;
  5. using Lottomat.Application.IService.GalleryManage;
  6. using Lottomat.Data.Repository;
  7. using Lottomat.Util.Extension;
  8. using Lottomat.Util.WebControl;
  9. using Newtonsoft.Json.Linq;
  10. using System.Collections.Generic;
  11. using System.Linq;
  12. using System.Linq.Expressions;
  13. namespace Lottomat.Application.Service.GalleryManage
  14. {
  15. /// <summary>
  16. /// 版 本 1.0
  17. /// Copyright (c) 2016-2017
  18. /// 创 建:开发者账号
  19. /// 日 期:2017-10-19 14:24
  20. /// 描 述:图库标题表
  21. /// </summary>
  22. public class Tk_GalleryService : RepositoryFactory<Tk_Gallery>, ITk_GalleryIService
  23. {
  24. #region 获取数据
  25. /// <summary>
  26. /// 获取列表
  27. /// </summary>
  28. /// <param name="queryJson">查询参数</param>
  29. /// <returns>返回列表</returns>
  30. public IEnumerable<Tk_Gallery> GetList(string queryJson)
  31. {
  32. return this.BaseRepository().IQueryable().ToList();
  33. }
  34. public IEnumerable<Tk_Gallery> GetList(Expression<Func<Tk_Gallery, bool>> condition)
  35. {
  36. return this.BaseRepository().FindList(condition);
  37. }
  38. /// <summary>
  39. /// 获取实体
  40. /// </summary>
  41. /// <param name="keyValue">主键值</param>
  42. /// <returns></returns>
  43. public Tk_Gallery GetEntity(string keyValue)
  44. {
  45. return this.BaseRepository().FindEntity(keyValue);
  46. }
  47. #endregion
  48. #region 提交数据
  49. /// <summary>
  50. /// 删除数据
  51. /// </summary>
  52. /// <param name="keyValue">主键</param>
  53. public void RemoveForm(string keyValue)
  54. {
  55. this.BaseRepository().Delete(keyValue);
  56. }
  57. /// <summary>
  58. /// 保存表单(新增、修改)
  59. /// </summary>
  60. /// <param name="keyValue">主键值</param>
  61. /// <param name="entity">实体对象</param>
  62. /// <returns></returns>
  63. public void SaveForm(string keyValue, Tk_Gallery entity)
  64. {
  65. if (!string.IsNullOrEmpty(keyValue))
  66. {
  67. entity.Modify(keyValue);
  68. this.BaseRepository().Update(entity);
  69. }
  70. else
  71. {
  72. entity.Create();
  73. this.BaseRepository().Insert(entity);
  74. }
  75. }
  76. public IEnumerable<Tk_Gallery> GetPageList(Pagination pagination, string queryJson)
  77. {
  78. var expression = LinqExtensions.True<Tk_Gallery>();
  79. JObject queryParam = queryJson.ToJObject();
  80. if (queryParam != null)
  81. {
  82. if (!queryParam["ID"].IsEmpty())
  83. {
  84. string ID = queryParam["ID"].ToString();
  85. expression = expression.And(t => t.ID == ID);
  86. }
  87. if (!queryParam["GalleryNumber"].IsEmpty())
  88. {
  89. string GalleryNumber = queryParam["GalleryNumber"].ToString();
  90. expression = expression.And(t => t.GalleryNumber.Value == GalleryNumber.TryToInt32());
  91. }
  92. if (!queryParam["GalleryName"].IsEmpty())
  93. {
  94. string GalleryName = queryParam["GalleryName"].ToString();
  95. expression = expression.And(t => t.GalleryName.Contains(GalleryName));
  96. }
  97. if (!queryParam["CategoryId"].IsEmpty())
  98. {
  99. string CategoryId = queryParam["CategoryId"].ToString();
  100. expression = expression.And(t => t.CategoryId == CategoryId);
  101. }
  102. if (!queryParam["SortCode"].IsEmpty())
  103. {
  104. string SortCode = queryParam["SortCode"].ToString();
  105. expression = expression.And(t => t.SortCode.Value == SortCode.TryToInt32());
  106. }
  107. if (!queryParam["IsPicZip"].IsEmpty())
  108. {
  109. string IsPicZip = queryParam["IsPicZip"].ToString();
  110. expression = expression.And(t => IsPicZip == "1" ? true : false);
  111. }
  112. if (!queryParam["Reamrk"].IsEmpty())
  113. {
  114. string Reamrk = queryParam["Reamrk"].ToString();
  115. expression = expression.And(t => t.Reamrk.Contains(Reamrk));
  116. }
  117. if (!queryParam["SeoKey"].IsEmpty())
  118. {
  119. string SeoKey = queryParam["SeoKey"].ToString();
  120. expression = expression.And(t => t.SeoKey.Contains(SeoKey));
  121. }
  122. if (!queryParam["CreateTime"].IsEmpty())
  123. {
  124. string CreateTime = queryParam["CreateTime"].ToString();
  125. expression = expression.And(t => t.CreateTime.Value > System.DateTime.Parse(CreateTime));
  126. }
  127. if (!queryParam["HotNumber"].IsEmpty())
  128. {
  129. string HotNumber = queryParam["HotNumber"].ToString();
  130. expression = expression.And(t => t.HotNumber.Value > HotNumber.TryToInt32());
  131. }
  132. if (!queryParam["AreaCode"].IsEmpty())
  133. {
  134. string AreaCode = queryParam["AreaCode"].ToString();
  135. expression = expression.And(t => t.AreaCode == AreaCode);
  136. }
  137. }
  138. return this.BaseRepository().FindList(expression, pagination);
  139. }
  140. /// <summary>
  141. /// sql查询全部图库
  142. /// </summary>
  143. /// <returns></returns>
  144. public List<Tk_Gallery> QueryAll(int count)
  145. {
  146. string sql = string.Format(@" select top {0} * from Tk_Gallery where AreaCode='A'
  147. UNION
  148. select top {0} * from Tk_Gallery where AreaCode='B'
  149. UNION
  150. select top {0} * from Tk_Gallery where AreaCode='C'
  151. order by HotNumber desc", count);
  152. return this.BaseRepository().FindList(sql).ToList();
  153. }
  154. #endregion
  155. }
  156. }