/// <summary> /// 创建 <see cref="DiscoveryPage"/> /// </summary> /// <param name="currentUserId">当前登录用户 ID</param> /// <param name="dbContext"><see cref="KeylolDbContext"/></param> /// <param name="cachedData"><see cref="CachedDataProvider"/></param> /// <returns><see cref="DiscoveryPage"/></returns> public static async Task <DiscoveryPage> CreateAsync(string currentUserId, KeylolDbContext dbContext, CachedDataProvider cachedData) { var onSalePoints = await OnSalePointList.CreateAsync(currentUserId, 1, true, true, dbContext, cachedData); var latestArticles = await LatestArticleList.CreateAsync(1, true, true, dbContext, cachedData); return(new DiscoveryPage { SlideshowEntries = await SlideshowEntryList.CreateAsync(1, 4, dbContext), SpotlightPoints = await SpotlightPointList.CreateAsync(currentUserId, 1, 30, dbContext, cachedData), SpotlightReviews = await SpotlightArticleList.CreateAsync(currentUserId, 1, 4, SpotlightArticleStream.ArticleCategory.Review, dbContext, cachedData), SpotlightStudies = await SpotlightArticleList.CreateAsync(currentUserId, 1, 4, SpotlightArticleStream.ArticleCategory.Study, dbContext, cachedData), OnSalePointHeaderImage = onSalePoints.Item3, OnSalePointPageCount = onSalePoints.Item2, OnSalePoints = onSalePoints.Item1, SpotlightStories = await SpotlightArticleList.CreateAsync(currentUserId, 1, 4, SpotlightArticleStream.ArticleCategory.Story, dbContext, cachedData), LatestArticleHeaderImage = latestArticles.Item3, LatestArticlePageCount = latestArticles.Item2, LatestArticles = latestArticles.Item1, LatestActivityHeaderImage = onSalePoints.Item4, LatestActivities = await TimelineCardList.CreateAsync(LatestActivityStream.Name, currentUserId, 12, false, dbContext, cachedData) }); }
/// <summary> /// 获取时间轴卡片列表 /// </summary> /// <param name="before">起始位置</param> /// <param name="take">获取数量</param> /// <param name="dbContext"><see cref="KeylolDbContext"/></param> /// <param name="cachedData"><see cref="CachedDataProvider"/></param> /// <returns><see cref="TimelineCardList"/></returns> public static async Task <TimelineCardList> GetCards(int before, int take, [Injected] KeylolDbContext dbContext, [Injected] CachedDataProvider cachedData) { var currentUserId = StateTreeHelper.GetCurrentUserId(); return(await TimelineCardList.CreateAsync(SubscriptionStream.Name(currentUserId), currentUserId, take, false, dbContext, cachedData, before)); }
/// <summary> /// 创建 <see cref="TimelinePage"/> /// </summary> /// <param name="currentUserId">当前登录用户 ID</param> /// <param name="dbContext"><see cref="KeylolDbContext"/></param> /// <param name="cachedData"><see cref="CachedDataProvider"/></param> /// <returns><see cref="TimelinePage"/></returns> public static async Task <TimelinePage> CreateAsync(string currentUserId, KeylolDbContext dbContext, CachedDataProvider cachedData) { return(new TimelinePage { Cards = await TimelineCardList.CreateAsync(SubscriptionStream.Name(currentUserId), currentUserId, 18, false, dbContext, cachedData) }); }
/// <summary> /// 获取时间轴卡片列表 /// </summary> /// <param name="pointId">据点 ID</param> /// <param name="before">起始位置</param> /// <param name="take">获取数量</param> /// <param name="dbContext"><see cref="KeylolDbContext"/></param> /// <param name="cachedData"><see cref="CachedDataProvider"/></param> /// <returns><see cref="TimelineCardList"/></returns> public static async Task <TimelineCardList> GetCards(string pointId, int before, int take, [Injected] KeylolDbContext dbContext, [Injected] CachedDataProvider cachedData) { return(await TimelineCardList.CreateAsync(PointStream.Name(pointId), StateTreeHelper.GetCurrentUserId(), take, false, dbContext, cachedData, before)); }