Tk_GalleryDetailBLL.cs 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. using Interface;
  2. using Models;
  3. using Models.Entity.LottomatBaseDB;
  4. using Services;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Linq;
  8. using System.Web;
  9. namespace Business.TK
  10. {
  11. public static class Tk_GalleryDetailBLL
  12. {
  13. static BaseInterface service;
  14. static Tk_GalleryDetailBLL()
  15. {
  16. service = new ZXServic();
  17. }
  18. public static List<Tk_GalleryDetail> QueryDetailByGalleryId(List<string> galleryIds, int periodsNumber)
  19. {
  20. List<EExpression> listexp = new List<EExpression>();
  21. listexp.Add( new EExpression("periodsNumber", "=", periodsNumber));
  22. listexp.Add(new EExpression("isDelete", "=", 0));
  23. listexp.Add(new EExpression("galleryId", EnumExpression.In, galleryIds));
  24. List<Tk_GalleryDetail> list = service.GetList<Tk_GalleryDetail>(null, listexp);
  25. return list;
  26. }
  27. /// <summary>
  28. /// 根据可选条件查询匹配上的最新一条
  29. /// </summary>
  30. /// <param name="ID">key</param>
  31. /// <param name="PeriodsNumber">期号</param>
  32. /// <param name="GalleryId">栏目id</param>
  33. /// <returns></returns>
  34. public static Tk_GalleryDetail QueryItem(string ID = null, string PeriodsNumber = null, string pk = null)
  35. {
  36. List<EExpression> listexp = new List<EExpression>();
  37. if (!string.IsNullOrEmpty(ID))
  38. {
  39. listexp.Add(new EExpression("ID", "=", ID));
  40. }
  41. if (!string.IsNullOrEmpty(PeriodsNumber))
  42. {
  43. listexp.Add(new EExpression("PeriodsNumber", "=", PeriodsNumber));
  44. }
  45. if (!string.IsNullOrEmpty(pk))
  46. {
  47. listexp.Add(new EExpression("PK", "=", pk));
  48. }
  49. var list = service.GetList<Tk_GalleryDetail>("PeriodsNumber", listexp, true);
  50. if (list.Count>0)
  51. {
  52. return list[0];
  53. }
  54. else
  55. {
  56. return new Tk_GalleryDetail();
  57. }
  58. }
  59. /// <summary>
  60. /// 根据期号和pk查询左右三期
  61. /// </summary>
  62. /// <param name="num"></param>
  63. /// <param name="pk"></param>
  64. /// <returns></returns>
  65. public static List<Tk_GalleryDetail> Qthreelist( int pk,out int PeriodsNumber)
  66. {
  67. var data = service.QueryItembyKey<Tk_GalleryDetail>(pk);
  68. int num = data.PeriodsNumber;
  69. PeriodsNumber = num;
  70. string lastnum = (num - 1).ToString().PadLeft(3, '0');
  71. string onlinenum = num.ToString().PadLeft(3, '0');
  72. string nextnum = (num + 1).ToString().PadLeft(3, '0');
  73. List<EExpression> listexp = new List<EExpression>();
  74. listexp.Add(new EExpression("GalleryId", "=", data.GalleryId));
  75. listexp.Add(new EExpression("PeriodsNumber", EnumExpression.In, new List<string>() {lastnum,onlinenum,nextnum}));
  76. List<Tk_GalleryDetail> list = service.GetList<Tk_GalleryDetail>(null, listexp);
  77. return list;
  78. }
  79. }
  80. }