李昊 il y a 4 ans
Parent
commit
82a6faccc0

+ 2 - 0
gx_api/GxPress/Model/GxPress.Mappings/MediaMapping.cs

@@ -17,6 +17,8 @@ namespace GxPress.Mappings
             CreateMap<MediaLable, MediaLableResult>();
             CreateMap<Media, BookMediaResult>();
             CreateMap<Media, VideoMediaResult>();
+            CreateMap<Media, NavigationMediaResult>();
+            
         }
 
     }

+ 46 - 1
gx_api/GxPress/Model/GxPress.Result/Media/MediaResult.cs

@@ -5,11 +5,56 @@ using GxPress.Result.Category;
 namespace GxPress.Result.Media
 {
     /// <summary>
+    /// 导航显示
+    /// </summary>
+    public class NavigationMediaResult
+    {
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <value></value>
+        public int Id { get; set; }
+        /// <summary>
+        /// 编号
+        /// </summary>
+        /// <value></value>
+        public string AutoNumber { get; set; }
+        /// <summary>
+        /// 媒体类型
+        /// </summary>
+        public int MediaType { get; set; }
+        /// <summary>
+        /// 标题
+        /// </summary>
+        public string Title { get; set; }
+
+        /// <summary>
+        /// 标题图片
+        /// </summary>
+        public string ImageUrls { get; set; }
+
+        /// <summary>
+        /// 简介
+        /// </summary>
+        public string Summary { get; set; }
+
+        /// <summary>
+        /// 作者
+        /// </summary>
+        public string Author { get; set; }
+        /// <summary>
+        /// 名师ID
+        /// </summary>
+        /// <value></value>
+        public int TeacherId { get; set; }
+
+    }
+    /// <summary>
     /// 媒体
     /// </summary>
     public class MediaResult
     {
-         /// <summary>
+        /// <summary>
         /// 编号
         /// </summary>
         /// <value></value>

+ 3 - 3
gx_api/GxPress/Model/GxPress.Result/Navigation/NavigationResult.cs

@@ -6,7 +6,7 @@ namespace GxPress.Result.Navigation
     /// <summary>
     /// 导航数据的显示
     /// </summary>
-    public class NavigationMediaResult
+    public class NavigationLabelMediaResult
     {
         /// <summary>
         /// id
@@ -82,7 +82,7 @@ namespace GxPress.Result.Navigation
         /// 媒体
         /// </summary>
         /// <value></value>
-        public List<MediaResult> MediaResults { get; set; }
+        public List<NavigationMediaResult> MediaResults { get; set; }
 
     }
     /// <summary>
@@ -136,7 +136,7 @@ namespace GxPress.Result.Navigation
         /// 导航数据的显示
         /// </summary>
         /// <value></value>
-        public List<NavigationMediaResult> NavigationMediaResults { get; set; }
+        public List<NavigationLabelMediaResult> NavigationLabelMediaResults { get; set; }
 
         /// <summary>
         /// 获取轮播

+ 18 - 10
gx_api/GxPress/Repository/GxPress.Repository.Implement/Navigation/NavigationRepository.cs

@@ -159,16 +159,16 @@ namespace GxPress.Repository.Implement.Navigation
                 if (string.IsNullOrEmpty(middleLable.LabelId))
                     return result;
                 result = _mapper.Map<MiddleLableResult>(middleLable);
-                result.NavigationMediaResults = new List<NavigationMediaResult>();
+                result.NavigationLabelMediaResults = new List<NavigationLabelMediaResult>();
                 //获取轮播
                 if (middleLable.IsSlide)
                 {
                     if (result.IsSlide)
                     {
                         result.Sildes = await slideRepository.GetAllAsync(Q.Where(nameof(Entity.Slide.TypeId), result.TypeId).Where(nameof(Entity.Slide.IsDisable), false).OrderByDesc(nameof(Entity.Slide.Sort)));
-                        foreach (var item in  result.Sildes)
+                        foreach (var item in result.Sildes)
                         {
-                            item.ImageUrl=StringUtils.AddDomain(item.ImageUrl);
+                            item.ImageUrl = StringUtils.AddDomain(item.ImageUrl);
                         }
                     }
 
@@ -177,7 +177,7 @@ namespace GxPress.Repository.Implement.Navigation
                 var systemLabels = await _systemLabelRepository.GetAllAsync(Q.WhereIn(nameof(Entity.SystemLabel.SystemLabel.Id), StringUtils.StringCollectionToIntList(middleLable.LabelId)));
                 foreach (var item in systemLabels)
                 {
-                    var navigationMediaResult = new NavigationMediaResult()
+                    var navigationLabelMediaResult = new NavigationLabelMediaResult()
                     {
                         Id = item.Id,
                         Sort = item.Sort,
@@ -192,22 +192,30 @@ namespace GxPress.Repository.Implement.Navigation
                         Remark = item.Remark
                     };
                     //获取媒体标签
-                    var mediaLables = await _mediaLableRepository.GetAllAsync(Q.Where(nameof(Entity.tede2.Media.MediaLable.LableId), item.Id));
+                    var mediaLables = await _mediaLableRepository.GetAllAsync<int>(Q.Select(nameof(Entity.tede2.Media.MediaLable.MediaId)).Where(nameof(Entity.tede2.Media.MediaLable.LableId), item.Id));
                     //获取媒体
                     var query = Q.NewQuery();
-                    query.WhereIn(nameof(Entity.tede2.Media.Media.Id), mediaLables.Select(n => n.MediaId));
+                    query.Select(nameof(Entity.tede2.Media.Media.Id));
+                    query.Select(nameof(Entity.tede2.Media.Media.ImageUrls));
+                    query.Select(nameof(Entity.tede2.Media.Media.Title));
+                    query.Select(nameof(Entity.tede2.Media.Media.Summary));
+                    query.Select(nameof(Entity.tede2.Media.Media.TeacherId));
+                    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.Id), mediaLables);
                     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));
                     query.OrderByDesc(nameof(Entity.tede2.Media.Media.IsRecommend));
                     query.ForPage(1, 10);
-                    var medias = await _mediaRepository.GetAllAsync(query);
-                    navigationMediaResult.MediaResults = medias.Select(n => _mapper.Map<MediaResult>(n)).ToList();
-                    foreach (var itemMedia in navigationMediaResult.MediaResults)
+                    var medias = await _mediaRepository.GetAllAsync<NavigationMediaResult>(query);
+                    navigationLabelMediaResult.MediaResults = medias.ToList();
+                    foreach (var itemMedia in navigationLabelMediaResult.MediaResults)
                     {
                         itemMedia.ImageUrls = StringUtils.AddDomain(itemMedia.ImageUrls);
                     }
-                    result.NavigationMediaResults.Add(navigationMediaResult);
+                    result.NavigationLabelMediaResults.Add(navigationLabelMediaResult);
                 }
             }
             return result;