using System.Collections.Generic; using System.Threading.Tasks; using GxPress.Auth; using GxPress.Common.Page; using GxPress.Repository.Interface; using GxPress.Request.Notice; using GxPress.Result.Notice; using GxPress.Service.Interface.Notice; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace GxPress.Api.AppControllers { /// /// 通知 /// [Route("api/app/notice")] [ApiController] [Authorize] public class NoticeController : ControllerBase { private readonly INoticeRepository _noticeRepository; private readonly INoticeFolderRepository _noticeFolderRepository; private readonly INoticeService _noticeService; private readonly ILoginContext _loginContext; public NoticeController(INoticeRepository noticeRepository, INoticeFolderRepository noticeFolderRepository,INoticeService noticeService, ILoginContext loginContext) { _noticeRepository = noticeRepository; _noticeFolderRepository = noticeFolderRepository; _noticeService = noticeService; _loginContext = loginContext; } /// /// 添加通知 /// /// /// [HttpPut("add")] public async Task Insert(NoticeInRequest request) { // request.HtmlContent = StringUtils.RemoveEmoji(request.HtmlContent); // request.Content = StringUtils.RemoveEmoji(request.Content); request.UserId = _loginContext.AccountId; var boolValue = await _noticeService.InsertAsync(request); return boolValue; } /// /// 自己删除 /// /// /// [HttpDelete("delete")] public async Task Delete(NoticeDeRequest request) { return await _noticeRepository.DeleteAsync(request); } /// /// 获取通知详情 /// /// /// [HttpGet("app-detail/{id}")] public async Task GetNoticeDetailResult(int id) { return await _noticeService.GetNoticeDetailAsync(id, _loginContext.AccountId); } /// /// app通知分页列表 /// /// /// [HttpPost("list-page")] public async Task> GetNoticeListPage(NoticePageSearchRequest request) { request.UserId = _loginContext.AccountId; return await _noticeService.GetNoticeListPageAsync(request); } /// /// 恢复删除通知 /// /// /// [HttpPost("recover")] public async Task RecoverDelete(NoticeDeRequest request) { return await _noticeRepository.RecoverDeleteAsync(request); } /// /// 详情 /// /// /// [HttpGet("detail/{id}")] public async Task Detail(int id) { return await _noticeService.NoticeEditDetailAsync(id); } /// /// 详情 web专属 /// /// /// [HttpGet("web-detail/{id}")] [AllowAnonymous] public async Task WebDetail(int id) { return await _noticeService.NoticeEditDetailAsync(id); } /// /// 修改详情 /// /// /// [HttpPost("edit")] public async Task Edit([FromBody] NoticeUpRequest request) { // request.HtmlContent = StringUtils.RemoveEmoji(request.HtmlContent); // request.Content = StringUtils.RemoveEmoji(request.Content); request.UserId = _loginContext.AccountId; return await _noticeService.NoticeUpAsync(request); } /// /// 查询通知已读未读信息 /// /// /// [HttpPost("read")] public async Task> NoticeReadList(NoticeReadListRequest request) { return await _noticeService.NoticeReadListAsync(request); } /// /// 撤销通知 /// /// /// [HttpPut("recall/{id}")] public async Task RecallAsync(int id) { return await _noticeService.RecallAsync(id); } } }