123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- 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
- {
- /// <summary>
- /// 站内信
- /// </summary>
- [Route("api/app/missive")]
- [ApiController]
- [Authorize]
- public class MissiveController : ControllerBase
- {
- private readonly IMissiveRepository _missiveRepository;
- private readonly IMissiveAnalyzeRepository _missiveAnalyzeRepository;
- private readonly IMissiveService _missiveService;
- private readonly ILoginContext _loginContext;
- public MissiveController(IMissiveRepository missiveRepository, IMissiveService missiveService,
- ILoginContext loginContext, IMissiveAnalyzeRepository missiveAnalyzeRepository)
- {
- _missiveRepository = missiveRepository;
- _missiveService = missiveService;
- _loginContext = loginContext;
- _missiveAnalyzeRepository = missiveAnalyzeRepository;
- }
- /// <summary>
- /// 根据站内信ID获取详情
- /// </summary>
- /// <param name="missiveId"></param>
- /// <returns></returns>
- [HttpGet("get/{missiveId}")]
- public async Task<MissiveInfoResult> GetMissiveInfo(int missiveId)
- {
- return await _missiveService.GetMissiveInfoAsync(missiveId, _loginContext.AccountId);
- }
- /// <summary>
- /// 添加/修改站内信
- /// </summary>
- /// <param name="request"></param>
- /// <returns></returns>
- [HttpPut("add")]
- public async Task<bool> Insert(MissiveInRequest request)
- {
- // request.HtmlContent = StringUtils.RemoveEmoji(request.HtmlContent);
- // request.Content = StringUtils.RemoveEmoji(request.Content);
- // request.Title = StringUtils.RemoveEmoji(request.Title);
- request.UserId = _loginContext.AccountId;
- request.MissiveAddresseeUserIds.Remove(request.UserId);
- request.MissiveCcUserIds.Remove(request.UserId);
- return await _missiveService.InsertOrUpdateAsync(request);
- }
- /// <summary>
- /// 获取站内信列表
- /// </summary>
- /// <param name="request"></param>
- /// <returns></returns>
- [HttpPost("search")]
- public async Task<PagedList<MissiveSearchResult>> GetMissiveSearchResult(MissiveSearchRequest request)
- {
- request.UserId = _loginContext.AccountId;
- return await _missiveService.GetMissiveSearchResultAsync(request);
- }
- /// <summary>
- /// 文章点赞 评论点赞 文章收藏 文章转发 已废弃
- /// </summary>
- /// <returns></returns>
- [HttpPost("analyze")]
- public async Task<bool> AddMissiveAnalyze([FromBody] MissiveAnalyzeRequest request)
- {
- request.UserId = _loginContext.AccountId;
- return await _missiveAnalyzeRepository.SetMissiveAnalyzeAsync(request);
- }
- /// <summary>
- /// 获取站内信详情
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- [HttpGet("{id}")]
- public async Task<MissiveDetailResult> GetMissiveDetail(int id)
- {
- return await _missiveService.GetMissiveDetailAsync(id);
- }
- /// <summary>
- /// 获取站内信详情-web专属
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- [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;
- }
- /// <summary>
- /// 获取站内信已读未读数据
- /// </summary>
- /// <param name="request"></param>
- /// <returns></returns>
- [HttpPost("read")]
- public async Task<IEnumerable<MissiveReadListResult>> GetMissiveReadListAsync(MissiveReadListRequest request)
- {
- return await _missiveService.GetMissiveReadListAsync(request);
- }
- /// <summary>
- /// 站内信撤回
- /// </summary>
- /// <param name="missiveId"></param>
- /// <returns></returns>
- [HttpPut("recall/{missiveId}")]
- public async Task<bool> RecallAsync(int missiveId)
- {
- return await _missiveService.RecallAsync(missiveId);
- }
- }
- }
|