AppHomePageService.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using GxPress.Service.Interface.AppHomePage;
  2. using GxPress.Repository.Interface;
  3. using GxPress.Repository.Interface.Media;
  4. using GxPress.Request.ArticleGroup;
  5. using System.Threading.Tasks;
  6. using System.Collections.Generic;
  7. using GxPress.Result.SystemLabel;
  8. using GxPress.Result.Media;
  9. namespace GxPress.Service.Implement.AppHomePage
  10. {
  11. public class AppHomePageService : IAppHomePageService
  12. {
  13. private readonly IArticleGroupRepository articleGroupRepository;
  14. private readonly IMediaRepository mediaRepository;
  15. public AppHomePageService(IArticleGroupRepository articleGroupRepository, IMediaRepository mediaRepository)
  16. {
  17. this.articleGroupRepository = articleGroupRepository;
  18. this.mediaRepository = mediaRepository;
  19. }
  20. /// <summary>
  21. /// 大咖讲座
  22. /// </summary>
  23. /// <param name="request"></param>
  24. /// <returns></returns>
  25. public async Task<List<AppLabelResult<MediaCathedraResult>>> GetMediasByTeacherAsync(ArticleGroupRequest request)
  26. {
  27. var results = new List<AppLabelResult<MediaCathedraResult>>();
  28. request.Sort = "recommend";
  29. var items = await mediaRepository.GetMediasByTeacherAsync(request);
  30. results.Add(new AppLabelResult<MediaCathedraResult>() { LabelName = "今日推荐", IsPage = false, ResourceType = 40, Method = "", Items = items });
  31. request.Sort = "";
  32. items = await mediaRepository.GetMediasByTeacherAsync(request);
  33. results.Add(new AppLabelResult<MediaCathedraResult>() { LabelName = "更多精彩", IsPage = true, ResourceType = 40, Method = "post", Items = items, ActionUrl = "api/app/page/cathedra-page" });
  34. foreach (var item in results)
  35. {
  36. foreach (var model in item.Items)
  37. model.Duration = "02:19:20";
  38. }
  39. return results;
  40. }
  41. /// <summary>
  42. /// 大咖讲座
  43. /// </summary>
  44. /// <returns></returns>
  45. public async Task<IEnumerable<MediaCathedraResult>> MediaCathedraResult(ArticleGroupRequest request)
  46. {
  47. return await mediaRepository.GetMediasByTeacherAsync(request);
  48. }
  49. }
  50. }