李昊 4 gadi atpakaļ
vecāks
revīzija
f40400c3b2

+ 101 - 0
gx_api/GxPress/Api/GxPress.Api/WebControllers/WebNoteController.cs

@@ -0,0 +1,101 @@
+using System.Threading.Tasks;
+using GxPress.Auth;
+using GxPress.Common.Page;
+using GxPress.Request.App.Note;
+using GxPress.Result.App.Note;
+using GxPress.Service.Interface.Note;
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Logging;
+
+namespace GxPress.Api.WebControllers
+{
+    /// <summary>
+    /// 网页笔记
+    /// </summary>
+    [Route("api/web/note")]
+    [ApiController]
+    [Authorize]
+    public class WebNoteController : Controller
+    {
+        private readonly ILogger<WebNoteController> _logger;
+        private readonly INoteService _noteService;
+        private readonly ILoginContext _loginContext;
+
+        public WebNoteController(ILogger<WebNoteController> logger, INoteService noteService, ILoginContext loginContext)
+        {
+            _logger = logger;
+            _noteService = noteService;
+            _loginContext = loginContext;
+        }
+        /// <summary>
+        /// 添加笔记
+        /// </summary>
+        /// <param name="request"></param>
+        /// <returns></returns>
+        [HttpPut("add")]
+        public async Task<bool> InsertNote(NoteInRequest request)
+        {
+            // request.HtmlContent = StringUtils.RemoveEmoji(request.HtmlContent);
+            // request.Content = StringUtils.RemoveEmoji(request.Content);
+            request.UserId = _loginContext.AccountId;
+            return await _noteService.InsertNoteAsync(request);
+        }
+
+        /// <summary>
+        /// 获取笔记分页
+        /// </summary>
+        /// <param name="request"></param>
+        /// <returns></returns>
+        [HttpPost("search")]
+        public async Task<PagedList<NotePageListRequest>> NotePageList(NoteSearchPageListRequest request)
+        {
+            request.UserId = _loginContext.AccountId;
+            return await _noteService.NotePageListAsync(request);
+        }
+        /// <summary>
+        /// 获取笔记详情
+        /// </summary>
+        /// <param name="id"></param>
+        /// <returns></returns>
+        [HttpGet("{id}")]
+        public async Task<NoteDetailResult> GetNoteDetail(int id)
+        {
+            var note = await _noteService.GetNoteDetailAsync(id, _loginContext.AccountId);
+            return note;
+        }
+        /// <summary>
+        /// 获取笔记详情
+        /// </summary>
+        /// <param name="id"></param>
+        /// <returns></returns>
+        [HttpGet("web/{id}")]
+        [AllowAnonymous]
+        public async Task<NoteDetailResult> GetWebNoteDetail(int id)
+        {
+            var note = await _noteService.GetNoteDetailAsync(id, 0);
+            return note;
+        }
+
+        /// <summary>
+        /// 修改笔记
+        /// </summary>
+        /// <param name="note"></param>
+        /// <returns></returns>
+        [HttpPut("update")]
+        public async Task<bool> UpdateNote(Entity.Note.Note note)
+        {
+            // note.HtmlContent = StringUtils.RemoveEmoji(note.HtmlContent);
+            // note.Content = StringUtils.RemoveEmoji(note.Content);
+            // note.Title = StringUtils.RemoveEmoji(note.Title);
+            return await _noteService.UpdateNoteAsync(note);
+        }
+        /// <summary>
+        /// 删除笔记
+        /// </summary>
+        /// <param name="id"></param>
+        /// <returns></returns>
+        [HttpDelete("{id}")]
+        public async Task<bool> DeleteAsync(int id) => await _noteService.DeleteAsync(id, _loginContext.AccountId);
+    }
+}

+ 25 - 0
gx_api/GxPress/Model/GxPress.Entity/Note/Note.cs

@@ -51,5 +51,30 @@ namespace GxPress.Entity.Note
         /// <value></value>
         [DataColumn]
         public int FolderId { get; set; }
+        /// <summary>
+        /// 媒体ID
+        /// </summary>
+        /// <value></value>
+        [DataColumn]
+        public int MediaId { get; set; }
+
+        /// <summary>
+        /// 媒体类型
+        /// </summary>
+        /// <value></value>
+        [DataColumn]
+        public int MediaType{ get; set; }
+        /// <summary>
+        /// 目录ID
+        /// </summary>
+        /// <value></value>
+        [DataColumn]
+        public string CatalogId { get; set; }
+        /// <summary>
+        /// 章节ID
+        /// </summary>
+        /// <value></value>
+        [DataColumn]
+        public string ChapterId { get; set; }
     }
 }

+ 27 - 1
gx_api/GxPress/Model/GxPress.Request/App/Note/NoteInRequest.cs

@@ -33,6 +33,32 @@ namespace GxPress.Request.App.Note
         /// 是否话题
         /// </summary>
         /// <value></value>
-        public bool IsTopic{get;set;}
+        public bool IsTopic { get; set; }
+
+        /// <summary>
+        /// 媒体ID
+        /// </summary>
+        /// <value></value>
+
+        public int MediaId { get; set; }
+
+        /// <summary>
+        /// 媒体类型
+        /// </summary>
+        /// <value></value>
+
+        public int MediaType { get; set; }
+        /// <summary>
+        /// 目录ID
+        /// </summary>
+        /// <value></value>
+
+        public string CatalogId { get; set; }
+        /// <summary>
+        /// 章节ID
+        /// </summary>
+        /// <value></value>
+
+        public string ChapterId { get; set; }
     }
 }

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

@@ -95,7 +95,7 @@ namespace GxPress.Service.Implement.Note
                         item.File = StringUtils.RemoveDomain(item.File);
                     //添加笔记
                     var note = new Entity.Note.Note
-                    { Title = request.Title, Content = JsonConvert.SerializeObject(noteContent), HtmlContent = request.HtmlContent, UserId = request.UserId, IsDelete = false, IsTopic = request.IsTopic, FolderId = request.FolderId };
+                    { Title = request.Title, Content = JsonConvert.SerializeObject(noteContent), HtmlContent = request.HtmlContent, UserId = request.UserId, IsDelete = false, IsTopic = request.IsTopic, FolderId = request.FolderId, MediaId = request.MediaId, MediaType = request.MediaType, CatalogId = request.CatalogId, ChapterId = request.ChapterId };
                     var noteId = await _noteRepository.InsertAsync(note);
                     //添加中间件
                     var middleInsertTypes = new MiddleInsertTypeRequest