12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- using System;
- using System.Collections.Generic;
- using System.Threading.Tasks;
- using GxPress.EnumConst;
- using GxPress.Repository.Interface.AppChannel;
- using GxPress.Result.AppChannel;
- using GxPress.Service.Interface.AppChannel;
- using GxPress.Common.Tools;
- using GxPress.Result.Media;
- using GxPress.Request.AppChannel;
- using GxPress.Repository.Interface.Media;
- using System.Linq;
- using GxPress.Common.Page;
- namespace GxPress.Service.Implement.AppChannel
- {
- /// <summary>
- /// app频道
- /// </summary>
- public class AppChannelService : IAppChannelService
- {
- private readonly IChannelCategoryMediaRepository channelCategoryMediaRepository;
- private readonly IChannelCategoryRepository channelCategoryRepository;
- private readonly IAppChannelRepository appChannelRepository;
- private readonly IMediaRepository mediaRepository;
- public AppChannelService(IChannelCategoryMediaRepository channelCategoryMediaRepository, IChannelCategoryRepository channelCategoryRepository, IAppChannelRepository appChannelRepository, IMediaRepository mediaRepository)
- {
- this.channelCategoryMediaRepository = channelCategoryMediaRepository;
- this.channelCategoryRepository = channelCategoryRepository;
- this.appChannelRepository = appChannelRepository;
- this.mediaRepository = mediaRepository;
- }
- /// <summary>
- /// 获取App频道
- /// </summary>
- /// <returns></returns>
- public async Task<IEnumerable<AppChannelModelResult>> GetAppChannelsAsync()
- {
- var result = new List<AppChannelModelResult>();
- //递归频道
- foreach (int v in Enum.GetValues(typeof(AppChannelConst)))
- {
- var constEnum = (AppChannelConst)v;
- var appChannelModelResult = new AppChannelModelResult()
- {
- Name = constEnum.GetDescriptionOriginal(),
- Id = constEnum,
- Items = await appChannelRepository.GetAllAsync(constEnum)
- };
- result.Add(appChannelModelResult);
- }
- return result;
- }
- /// <summary>
- /// 查询 获取频道分类
- /// </summary>
- /// <returns></returns>
- public async Task<IEnumerable<ChannelCategoryResult>> GetAllAsync(int appChannelId)
- {
- var result = await channelCategoryRepository.GetAllAsync(appChannelId);
- foreach (var item in result)
- {
- if (!item.IsChildren)
- item.MediaIds = await channelCategoryMediaRepository.GetAllAsync(item.Id);
- if (item.IsChildren)
- {
- foreach (var category in item.Children)
- {
- if (!category.IsChildren)
- category.MediaIds = await channelCategoryMediaRepository.GetAllAsync(category.Id);
- }
- }
- }
- return result;
- }
- /// <summary>
- /// 根据app频道分类id获取媒体分页数据
- /// </summary>
- /// <returns></returns>
- public async Task<PagedList<MediaCathedraResult>> GetChannelCategoryMediaPageAsync(AppChannelSearchRequest request)
- {
- //获取标签
- var ids = await channelCategoryMediaRepository.GetAllAsync(request.CategoryId);
- request.Ids = ids.ToList();
- return await mediaRepository.GetAppChannelsAsync(request);
- }
- }
- }
|