using System.Collections.Generic; using System.Linq; using CZFW.Framework.Logic; using CZKJ.GBRS2.Entity; using CZKJ.GBRS2.Interface; namespace CZKJ.GBRS2.Logic { public class PublicInfoLogic : LogicBase, IPublicInfo { public IList GetList(IList typeIdList, int? typeId, string keywords, int pageIndex, int pageSize, out int rowsCount) { var queryable = Queryable; if (typeIdList.Count > 0) { var typeList = queryable = queryable.Where(x => typeIdList.Contains(x.TypeId)); } if (typeId.HasValue) { queryable = queryable.Where(x => x.TypeId == typeId); } if (!string.IsNullOrWhiteSpace(keywords)) { queryable = queryable.Where(x => x.Title.Contains(keywords) || x.Summary.Contains(keywords)); } rowsCount = queryable.Count(); var result = queryable.Join(DbContext.Set(), x => x.TypeId, y => y.Id, (x, y) => new { x, y.Name }).OrderByDescending(x => x.x.SortOrder).Skip((pageIndex - 1) * pageSize).Take(pageSize); return result.ToList().Select(x => new PublicInfoEntity { Id = x.x.Id, Image = x.x.Image, PublishTime = x.x.PublishTime, TypeName = x.Name, Summary = x.x.Summary, Title = x.x.Title, TypeId = x.x.TypeId, FileName = x.x.FileName, FileUrl = x.x.FileUrl, SortOrder = x.x.SortOrder }).ToList(); } public bool JudgeQuote(int typeId) { return Queryable.Any(x => x.TypeId == typeId); } } }