public async Task <Protocols.Response.CrawlingList> Get(Protocols.Request.CrawlingList crawlingList) { var builder = Builders <CrawlingData> .Filter; var filter = FilterDefinition <CrawlingData> .Empty; if (!string.IsNullOrEmpty(crawlingList.Keyword)) { filter &= builder.Regex(x => x.Title, ".*" + crawlingList.Keyword + ".*"); } if (crawlingList.Type.HasValue) { filter &= builder.Eq(x => x.Type, crawlingList.Type.Value); } return(new Protocols.Response.CrawlingList { ResultCode = Code.ResultCode.Success, Limit = crawlingList.Limit, Offset = crawlingList.Offset, Sort = crawlingList.Sort, Asc = crawlingList.Asc, Datas = (await _mongoCrawlingData.Page(filter, crawlingList.Limit, crawlingList.Offset, crawlingList.Sort, crawlingList.Asc)).ConvertAll(x => x.ToProtocol()), Total = await _mongoCrawlingData.CountAsync(filter) }); }
public async Task <Protocols.Response.FeedList> Get(Protocols.Request.FeedList feedList) { var builder = Builders <FeedData> .Filter; var filter = FilterDefinition <FeedData> .Empty; if (!string.IsNullOrEmpty(feedList.Keyword)) { filter &= builder.Regex(x => x.FeedTitle, "^" + feedList.Keyword + ".*"); } return(new Protocols.Response.FeedList { ResultCode = Code.ResultCode.Success, Limit = feedList.Limit, Offset = feedList.Offset, Sort = feedList.Sort, Asc = feedList.Asc, Datas = (await _mongoFeedData.Page(filter, feedList.Limit, feedList.Offset, feedList.Sort, feedList.Asc)).ConvertAll(x => x.ToProtocol()), Total = await _mongoFeedData.CountAsync(filter) }); }