李昊 4 anos atrás
pai
commit
7686accbbe

+ 6 - 0
gx_api/GxPress/Repository/GxPress.Repository.Implement/Media/MediaLableRepository.cs

@@ -1,4 +1,5 @@
 using System.Collections.Generic;
+using System.Threading.Tasks;
 using AutoMapper;
 using Datory;
 using GxPress.Common.AppOptions;
@@ -28,5 +29,10 @@ namespace GxPress.Repository.Implement.Media
         public IDatabase Database => _repository.Database;
         public string TableName => _repository.TableName;
         public List<TableColumn> TableColumns => _repository.TableColumns;
+
+        public async Task<IEnumerable<int>> GetMediaIdsAysnc(int lableId)
+        {
+            return await _repository.GetAllAsync<int>(Q.Select(nameof(Entity.tede2.Media.MediaLable.MediaId)).Where(nameof(Entity.tede2.Media.MediaLable.LableId), lableId));
+        }
     }
 }

+ 7 - 3
gx_api/GxPress/Repository/GxPress.Repository.Implement/Media/MediaRepository.cs

@@ -361,8 +361,12 @@ namespace GxPress.Repository.Implement.Media
             var result = await _repository.GetAsync(Q.Where(nameof(Entity.tede2.Media.Media.Id), mediaId).Where(nameof(Entity.tede2.Media.Media.IsChecked), true).Where(nameof(Entity.tede2.Media.Media.IsDelete), false));
             return _mapper.Map<VideoMediaResult>(result);
         }
-
-        public async Task<IEnumerable<NavigationMediaResult>> GetNavigationMediaResults(IEnumerable<int> mediaLables)
+        /// <summary>
+        /// 根据
+        /// </summary>
+        /// <param name="mediaIds"></param>
+        /// <returns></returns>
+        public async Task<IEnumerable<NavigationMediaResult>> GetNavigationMediaResults(IEnumerable<int> mediaIds)
         {
             //获取媒体
             var query = Q.NewQuery();
@@ -374,7 +378,7 @@ namespace GxPress.Repository.Implement.Media
             query.Select(nameof(Entity.tede2.Media.Media.AutoNumber));
             query.Select(nameof(Entity.tede2.Media.Media.Author));
             query.Select(nameof(Entity.tede2.Media.Media.MediaType));
-            query.WhereIn(nameof(Entity.tede2.Media.Media.LableId), mediaLables);
+            query.WhereIn(nameof(Entity.tede2.Media.Media.Id), mediaIds);
             query.Where(nameof(Entity.tede2.Media.Media.IsChecked), true);
             query.Where(nameof(Entity.tede2.Media.Media.IsDelete), false);
             query.OrderByDesc(nameof(Entity.tede2.Media.Media.IsTop));

+ 3 - 1
gx_api/GxPress/Repository/GxPress.Repository.Interface/Media/IMediaLableRepository.cs

@@ -1,9 +1,11 @@
+using System.Collections.Generic;
+using System.Threading.Tasks;
 using Datory;
 
 namespace GxPress.Repository.Interface.Media
 {
     public interface IMediaLableRepository:IRepository
     {
-         
+         Task<IEnumerable<int>> GetMediaIdsAysnc(int lableId);
     }
 }

+ 2 - 2
gx_api/GxPress/Service/GxPress.Service.Implement/Navigation/NavigationService.cs

@@ -93,8 +93,8 @@ namespace GxPress.Service.Implement.Navigation
                         continue;
                     }
                     //获取媒体标签
-                    var lableInts = new List<int> { item.Id };
-                    var medias = await _mediaRepository.GetNavigationMediaResults(lableInts);
+                    var mediaIds = await _mediaLableRepository.GetMediaIdsAysnc(item.Id);
+                    var medias = await _mediaRepository.GetNavigationMediaResults(mediaIds);
                     navigationLabelMediaResult.MediaResults = medias.ToList();
                     foreach (var itemMedia in navigationLabelMediaResult.MediaResults)
                         itemMedia.ImageUrls = StringUtils.AddDomain(itemMedia.ImageUrls);