123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- using System.Threading.Tasks;
- using GxPress.Auth;
- using GxPress.Repository.Interface;
- using GxPress.Request.App.OftenContact;
- using GxPress.Result.App.OftenContact;
- using Microsoft.AspNetCore.Authorization;
- using Microsoft.AspNetCore.Mvc;
- using Microsoft.Extensions.Logging;
- using GxPress.Service.Interface.OftenContact;
- using System.Collections.Generic;
- using GxPress.Result.Chat;
- using GxPress.Service.Interface.Chat;
- namespace GxPress.Api.AppControllers
- {
- /// <summary>
- /// 好友
- /// </summary>
- [Route("api/app/often-contact")]
- [ApiController]
- [Authorize]
- public partial class OftenContactController : ControllerBase
- {
- private readonly ILogger<OftenContactController> _logger;
- private readonly IOftenContactRepository _repository;
- private readonly ILoginContext _loginContext;
- private readonly IOftenContactService _oftenContactService;
- private readonly IChatSearchService chatSearchService;
- public OftenContactController(ILogger<OftenContactController> logger, IOftenContactRepository repository, ILoginContext loginContext, IOftenContactService oftenContactService, IChatSearchService chatSearchService)
- {
- _logger = logger;
- _repository = repository;
- _loginContext = loginContext;
- _oftenContactService = oftenContactService;
- this.chatSearchService = chatSearchService;
- }
- /// <summary>
- /// 根据文件ID获取用户和下面的数据
- /// </summary>
- /// <param name="request"></param>
- /// <returns></returns>
- [HttpPost("list")]
- public async Task<IEnumerable<OftenContactInfo>> GetOftenContactsAsync(OftenContactSearchRequest request)
- {
- request.UserId = _loginContext.AccountId;
- return await _oftenContactService.GetOftenContacts(request);
- }
- /// <summary>
- /// 获取聊天界面和验证最新时间
- /// </summary>
- /// <param name="individualGroupId"></param>
- /// <returns></returns>
- [HttpGet("list/{individualGroupId}")]
- public async Task<OftenContactInfoGenericResult> GetOftenContactInfoGenericResult(int individualGroupId)
- {
- var request = new OftenContactSearchRequest()
- {
- UserId = _loginContext.AccountId,
- IndividualGroupId = individualGroupId
- };
- return await _oftenContactService.GetOftenContactInfoGenericResult(request);
- }
- /// <summary>
- /// 根据文件ID获取用户和下面的数据
- /// </summary>
- /// <param name="request"></param>
- /// <returns></returns>
- [HttpPost("all-list")]
- public async Task<IEnumerable<OftenContactInfo>> GetOftenContactAllAsync(OftenContactSearchRequest request)
- {
- request.UserId = _loginContext.AccountId;
- return await _oftenContactService.GetOftenContactsAll(request);
- }
- /// <summary>
- /// 添加
- /// </summary>
- /// <param name="request"></param>
- /// <returns></returns>
- [HttpPost("add")]
- public async Task<OftenContactDto> Insert(OftenContactInRequest request)
- {
- var result = new OftenContactDto();
- result = await _oftenContactService.InsertAsync(request, _loginContext.AccountId);
- return result;
- }
- /// <summary>
- /// /// 移除文件夹关系
- /// </summary>
- /// <param name="request"></param>
- /// <returns></returns>
- [HttpPost("remove")]
- public async Task<bool> RemoveOftenContact(OftenContactDeRequest request)
- {
- return await _repository.RemoveOftenContactAsync(request);
- }
- /// <summary>
- /// 设置置顶
- /// </summary>
- /// <param name="request"></param>
- /// <returns></returns>
- [HttpPost("is-top")]
- public async Task<bool> SetOftenContactIsTop(OftenContactDeRequest request)
- {
- return await _repository.SetOftenContactIsTopAsync(request);
- }
- /// <summary>
- /// 移动到文件夹
- /// </summary>
- /// <param name="request"></param>
- /// <returns></returns>
- [HttpPost("move")]
- public async Task<bool> MoveOftenContactToIndividualGroup(OftenContactUpRequest request)
- {
- return await _repository.MoveOftenContactToIndividualGroupAsync(request);
- }
- /// <summary>
- /// 删除聊天界面
- /// </summary>
- /// <param name="oftenContactIds"></param>
- /// <returns></returns>
- [HttpPost("delete")]
- public async Task<bool> DeleteAsync(OftenContactsDeRequest oftenContactIds)
- {
- return await _repository.DeleteAsync(oftenContactIds.OftenContactIds);
- }
- /// <summary>
- /// 搜索单聊
- /// </summary>
- /// <param name="keyWord"></param>
- /// <returns></returns>
- [HttpGet("search/{keyWord}")]
- public async Task<IEnumerable<ChatSearchResult>> GetChatSearchAsync(string keyWord)
- {
- var result = new List<ChatSearchResult>();
- //搜索文件夹
- result.AddRange(await chatSearchService.GetChatFolderNameSearchAsync(keyWord, _loginContext.AccountId));
- //群聊
- result.AddRange(await chatSearchService.GetGroupChatNameSearchAsync(keyWord, _loginContext.AccountId));
- //单聊
- result.AddRange(await chatSearchService.GetChatSearchAsync(keyWord, _loginContext.AccountId));
- //好友
- result.AddRange(await chatSearchService.GetFriendUserInfoResult(keyWord, _loginContext.AccountId));
- return result;
- }
- }
- }
|