using Interface; using Models; using Models.Entity.LottomatBaseDB; using Services; using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace Business.TK { public static class Tk_GalleryDetailBLL { static BaseInterface service; static Tk_GalleryDetailBLL() { service = new ZXServic(); } public static List<Tk_GalleryDetail> QueryDetailByGalleryId(List<string> galleryIds, int periodsNumber) { List<EExpression> listexp = new List<EExpression>(); listexp.Add( new EExpression("periodsNumber", "=", periodsNumber)); listexp.Add(new EExpression("isDelete", "=", 0)); listexp.Add(new EExpression("galleryId", EnumExpression.In, galleryIds)); List<Tk_GalleryDetail> list = service.GetList<Tk_GalleryDetail>(null, listexp); return list; } /// <summary> /// 根据可选条件查询匹配上的最新一条 /// </summary> /// <param name="ID">key</param> /// <param name="PeriodsNumber">期号</param> /// <param name="GalleryId">栏目id</param> /// <returns></returns> public static Tk_GalleryDetail QueryItem(string ID = null, string PeriodsNumber = null, string pk = null) { List<EExpression> listexp = new List<EExpression>(); if (!string.IsNullOrEmpty(ID)) { listexp.Add(new EExpression("ID", "=", ID)); } if (!string.IsNullOrEmpty(PeriodsNumber)) { listexp.Add(new EExpression("PeriodsNumber", "=", PeriodsNumber)); } if (!string.IsNullOrEmpty(pk)) { listexp.Add(new EExpression("PK", "=", pk)); } var list = service.GetList<Tk_GalleryDetail>("PeriodsNumber", listexp, true); if (list.Count>0) { return list[0]; } else { return new Tk_GalleryDetail(); } } /// <summary> /// 根据期号和pk查询左右三期 /// </summary> /// <param name="num"></param> /// <param name="pk"></param> /// <returns></returns> public static List<Tk_GalleryDetail> Qthreelist( int pk,out int PeriodsNumber) { var data = service.QueryItembyKey<Tk_GalleryDetail>(pk); int num = data.PeriodsNumber; PeriodsNumber = num; string lastnum = (num - 1).ToString().PadLeft(3, '0'); string onlinenum = num.ToString().PadLeft(3, '0'); string nextnum = (num + 1).ToString().PadLeft(3, '0'); List<EExpression> listexp = new List<EExpression>(); listexp.Add(new EExpression("GalleryId", "=", data.GalleryId)); listexp.Add(new EExpression("PeriodsNumber", EnumExpression.In, new List<string>() {lastnum,onlinenum,nextnum})); List<Tk_GalleryDetail> list = service.GetList<Tk_GalleryDetail>(null, listexp); return list; } } }