|
@@ -0,0 +1,120 @@
|
|
|
+using System.Collections.Generic;
|
|
|
+using System.Threading.Tasks;
|
|
|
+using GxPress.Auth;
|
|
|
+using GxPress.Common.Page;
|
|
|
+using GxPress.Repository.Interface.Missive;
|
|
|
+using GxPress.Request.App.Missive;
|
|
|
+using GxPress.Result.App.Missive;
|
|
|
+using GxPress.Service.Interface.Missive;
|
|
|
+using Microsoft.AspNetCore.Authorization;
|
|
|
+using Microsoft.AspNetCore.Mvc;
|
|
|
+using System.Linq;
|
|
|
+using System;
|
|
|
+namespace GxPress.Api.AppControllers
|
|
|
+{
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ [Route("api/web/missive")]
|
|
|
+ [ApiController]
|
|
|
+ [Authorize]
|
|
|
+ public class WebMissiveController : ControllerBase
|
|
|
+ {
|
|
|
+ private readonly IMissiveRepository _missiveRepository;
|
|
|
+ private readonly IMissiveService _missiveService;
|
|
|
+ private readonly ILoginContext _loginContext;
|
|
|
+
|
|
|
+ public WebMissiveController(IMissiveRepository missiveRepository, IMissiveService missiveService,
|
|
|
+ ILoginContext loginContext)
|
|
|
+ {
|
|
|
+ _missiveRepository = missiveRepository;
|
|
|
+ _missiveService = missiveService;
|
|
|
+ _loginContext = loginContext;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ [HttpGet("get/{missiveId}")]
|
|
|
+ public async Task<MissiveInfoResult> GetMissiveInfo(int missiveId)
|
|
|
+ {
|
|
|
+ return await _missiveService.GetMissiveInfoAsync(missiveId, _loginContext.AccountId);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ [HttpPut("add")]
|
|
|
+ public async Task<bool> Insert(MissiveInRequest request)
|
|
|
+ {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ request.UserId = _loginContext.AccountId;
|
|
|
+ request.MissiveAddresseeUserIds.Remove(request.UserId);
|
|
|
+ request.MissiveCcUserIds.Remove(request.UserId);
|
|
|
+ return await _missiveService.InsertOrUpdateAsync(request);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ [HttpPost("search")]
|
|
|
+ public async Task<PagedList<MissiveSearchResult>> GetMissiveSearchResult(MissiveSearchRequest request)
|
|
|
+ {
|
|
|
+ request.UserId = _loginContext.AccountId;
|
|
|
+ return await _missiveService.GetMissiveSearchResultAsync(request);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ [HttpGet("{id}")]
|
|
|
+ public async Task<MissiveDetailResult> GetMissiveDetail(int id)
|
|
|
+ {
|
|
|
+ return await _missiveService.GetMissiveDetailAsync(id);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ [HttpGet("web/{id}")]
|
|
|
+ [AllowAnonymous]
|
|
|
+ public async Task<MissiveInfoResult> GetWebMissiveDetail(int id)
|
|
|
+ {
|
|
|
+ var missiveInfos = await _missiveService.GetMissiveInfoAsync(id, 0);
|
|
|
+ missiveInfos.Items = missiveInfos.Items.OrderByDescending(n => Convert.ToDateTime(n.CreatedDate)).ToList();
|
|
|
+ return missiveInfos;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ [HttpPost("read")]
|
|
|
+ public async Task<IEnumerable<MissiveReadListResult>> GetMissiveReadListAsync(MissiveReadListRequest request)
|
|
|
+ {
|
|
|
+ return await _missiveService.GetMissiveReadListAsync(request);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ [HttpPut("recall/{missiveId}")]
|
|
|
+ public async Task<bool> RecallAsync(int missiveId)
|
|
|
+ {
|
|
|
+ return await _missiveService.RecallAsync(missiveId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|