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.AppControllers { /// /// 个人笔记 /// [Route("api/app/note")] [ApiController] [Authorize] public class NoteController : ControllerBase { private readonly ILogger _logger; private readonly INoteService _noteService; private readonly ILoginContext _loginContext; public NoteController(ILogger logger, INoteService noteService, ILoginContext loginContext) { _logger = logger; _noteService = noteService; _loginContext = loginContext; } /// /// 添加笔记 /// /// /// [HttpPut("add")] public async Task InsertNote(NoteInRequest request) { // request.HtmlContent = StringUtils.RemoveEmoji(request.HtmlContent); // request.Content = StringUtils.RemoveEmoji(request.Content); request.UserId = _loginContext.AccountId; return await _noteService.InsertNoteAsync(request); } /// /// 获取笔记分页 /// /// /// [HttpPost("search")] public async Task> NotePageList(NoteSearchPageListRequest request) { request.UserId = _loginContext.AccountId; return await _noteService.NotePageListAsync(request); } /// /// 获取笔记详情 /// /// /// [HttpGet("{id}")] public async Task GetNoteDetail(int id) { var note = await _noteService.GetNoteDetailAsync(id, _loginContext.AccountId); return note; } /// /// 获取笔记详情 /// /// /// [HttpGet("web/{id}")] public async Task GetWebNoteDetail(int id) { var note = await _noteService.GetNoteDetailAsync(id, 0); return note; } /// /// 修改笔记 /// /// /// [HttpPut("update")] public async Task 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); } /// /// 删除笔记 /// /// /// [HttpDelete("{id}")] public async Task DeleteAsync(int id) => await _noteService.DeleteAsync(id, _loginContext.AccountId); } }