李昊 4 年之前
父節點
當前提交
f3e45532ea

+ 27 - 2
gx_api/GxPress/Model/GxPress.Result/App/Note/NotePageListRequest.cs

@@ -1,5 +1,6 @@
 using System;
 using System.Collections.Generic;
+using GxPress.Result.Media;
 
 namespace GxPress.Result.App.Note
 {
@@ -92,10 +93,34 @@ namespace GxPress.Result.App.Note
         /// </summary>
         /// <value></value>
         public bool IsCollect { get; set; }
-         /// <summary>
+        /// <summary>
         /// 数据类型 1 没有 2 图 3 文件
         /// </summary>
         public int DataType { get; set; }
-
+        /// <summary>
+        /// 媒体ID
+        /// </summary>
+        /// <value></value>
+        public int MediaId { get; set; }
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <value></value>
+        public string CatalogId { get; set; }
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <value></value>
+        public string ChapterId { get; set; }
+        /// <summary>
+        /// 是否摘录
+        /// </summary>
+        /// <value></value>
+        public bool IsExtract { get; set; }
+        /// <summary>
+        /// 笔记摘录
+        /// </summary>
+        /// <value></value>
+        public MediaNoteResult MediaNoteResult { get; set; }
     }
 }

+ 29 - 0
gx_api/GxPress/Model/GxPress.Result/Media/MediaResult.cs

@@ -415,4 +415,33 @@ namespace GxPress.Result.Media
         public string LableName { get; set; }
 
     }
+    /// <summary>
+    /// 笔记显示摘录
+    /// </summary>
+    public class MediaNoteResult
+    {
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <value></value>
+        public int Id { get; set; }
+        /// <summary>
+        /// 标题
+        /// </summary>
+
+        public string Title { get; set; }
+
+        /// <summary>
+        /// 标题图片
+        /// </summary>
+
+        public string ImageUrls { get; set; }
+
+
+        /// <summary>
+        /// 作者
+        /// </summary>
+
+        public string Author { get; set; }
+    }
 }

+ 13 - 0
gx_api/GxPress/Repository/GxPress.Repository.Implement/Media/MediaRepository.cs

@@ -155,6 +155,19 @@ namespace GxPress.Repository.Implement.Media
             return true;
         }
 
+        /// <summary>
+        /// 获取媒体
+        /// </summary>
+        /// <param name="query"></param>
+        /// <returns></returns>
+        public async Task<MediaNoteResult> GetAsync(SqlKata.Query query)
+        {
+            query.Select(nameof(Entity.tede2.Media.Media.Id));
+            query.Select(nameof(Entity.tede2.Media.Media.Title));
+            query.Select(nameof(Entity.tede2.Media.Media.Author));
+            query.Select(nameof(Entity.tede2.Media.Media.ImageUrls));
+            return await _repository.GetAsync<MediaNoteResult>(query);
+        }
         public async Task<bool> UpdateAsync(Entity.tede2.Media.Media note)
         {
             return await _repository.UpdateAsync(note);

+ 2 - 1
gx_api/GxPress/Repository/GxPress.Repository.Implement/Note/NoteRepository.cs

@@ -166,7 +166,8 @@ namespace GxPress.Repository.Implement.Note
                 FROM
                     tede_middle
         WHERE
-            ParentId = a.Id and IsDelete=0) FileCount, b.Title, b.Content,b.ReadCount,c.Name,c.AvatarUrl,c.Nick,d.Name FROM tede_middle a LEFT JOIN tede_note b ON a.MiddleId = b.Id left join tede_user c on c.Id=b.UserId left join tede_department d on d.Id=c.DepartmentId
+            ParentId = a.Id and IsDelete=0) FileCount, b.Title, b.Content,b.ReadCount,b.MediaId,b.CatalogId,
+    b.ChapterId,c.Name,c.AvatarUrl,c.Nick,d.Name FROM tede_middle a LEFT JOIN tede_note b ON a.MiddleId = b.Id left join tede_user c on c.Id=b.UserId left join tede_department d on d.Id=c.DepartmentId
                         WHERE a.UserId = {request.VisitUserId} AND a.FolderType = 4 AND a.IsDelete = 0";
                 if (request.FolderId == 0)
                     sql += @" AND(a.RoleId = 1 OR a.RoleId = 3) AND a.ParentId = 0";

+ 8 - 2
gx_api/GxPress/Repository/GxPress.Repository.Interface/Media/IMediaRepository.cs

@@ -56,11 +56,17 @@ namespace GxPress.Repository.Interface.Media
         /// <returns></returns>
         Task<IEnumerable<NavigationMediaResult>> GetRecommendMediaResults();
 
-         /// <summary>
+        /// <summary>
         /// 排行榜
         /// </summary>
         /// <param name="request"></param>
         /// <returns></returns>
-         Task<IEnumerable<RankingListResult>> GetRankingListResults(RankingListRequest request);
+        Task<IEnumerable<RankingListResult>> GetRankingListResults(RankingListRequest request);
+        /// <summary>
+        /// 获取笔记摘录媒体
+        /// </summary>
+        /// <param name="query"></param>
+        /// <returns></returns>
+        Task<MediaNoteResult> GetAsync(SqlKata.Query query);
     }
 }

+ 12 - 1
gx_api/GxPress/Service/GxPress.Service.Implement/Note/NoteService.cs

@@ -29,6 +29,7 @@ using GxPress.EnumConst;
 using GxPress.Request.App.Analyze;
 using GxPress.Result.Web;
 using GxPress.Request.Web;
+using GxPress.Repository.Interface.Media;
 
 namespace GxPress.Service.Implement.Note
 {
@@ -52,11 +53,12 @@ namespace GxPress.Service.Implement.Note
         private readonly IAnalyzeService _analyzeService;
         private readonly IUserMiddleService _userMiddleService;
         private readonly IRecordFolderRepository recordFolderRepository;
+        private readonly IMediaRepository mediaRepository;
         public NoteService(IMiddleService middleService, INoteRepository noteRepository,
             IMiddleRepository middleRepository, IMapper mapper, IUserRepository userRepository,
             IArticleRepository articleRepository, INoticeRepository noticeRepository,
             IMissiveRepository missiveRepository, ITopicRepository topicRepository, IGroupRepository groupRepository,
-            ICollectionRepository collectionRepository, ICommentRepository commentRepository, IVisitRepository visitRepository, IVisitService visitService, IFolderUserRepository folderUserRepository, IAnalyzeService analyzeService, IUserMiddleService userMiddleService, IRecordFolderRepository recordFolderRepository)
+            ICollectionRepository collectionRepository, ICommentRepository commentRepository, IVisitRepository visitRepository, IVisitService visitService, IFolderUserRepository folderUserRepository, IAnalyzeService analyzeService, IUserMiddleService userMiddleService, IRecordFolderRepository recordFolderRepository, IMediaRepository mediaRepository)
         {
             _middleService = middleService;
             _noteRepository = noteRepository;
@@ -77,6 +79,7 @@ namespace GxPress.Service.Implement.Note
             _analyzeService = analyzeService;
             _userMiddleService = userMiddleService;
             this.recordFolderRepository = recordFolderRepository;
+            this.mediaRepository = mediaRepository;
         }
 
         /// <summary>
@@ -156,6 +159,14 @@ namespace GxPress.Service.Implement.Note
             }
             foreach (var item in result.Items)
             {
+                //是否摘录
+                if (item.MediaId > 0)
+                {
+                    item.IsExtract = true;
+                    var query = Q.NewQuery();
+                    query.Where(nameof(Entity.tede2.Media.Media.Id), item.MediaId);
+                    item.MediaNoteResult = await mediaRepository.GetAsync(query);
+                }
                 if (string.IsNullOrWhiteSpace(item.Content))
                     item.Content = "[]";
                 var contentJsonData = JsonConvert.DeserializeObject<List<ContentJsonData>>(item.Content);