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; namespace GxPress.Api.AppControllers { /// /// 好友 /// [Route("api/app/often-contact")] [ApiController] [Authorize] public partial class OftenContactController : ControllerBase { private readonly ILogger _logger; private readonly IOftenContactRepository _repository; private readonly ILoginContext _loginContext; private readonly IOftenContactService _oftenContactService; public OftenContactController(ILogger logger, IOftenContactRepository repository, ILoginContext loginContext, IOftenContactService oftenContactService) { _logger = logger; _repository = repository; _loginContext = loginContext; _oftenContactService = oftenContactService; } /// /// 根据文件ID获取用户和下面的数据 /// /// /// [HttpPost("list")] public async Task> GetOftenContactsAsync(OftenContactSearchRequest request) { request.UserId = _loginContext.AccountId; return await _oftenContactService.GetOftenContacts(request); } /// /// 添加 /// /// /// [HttpPost("add")] public async Task Insert(OftenContactInRequest request) { var result = new OftenContactDto(); result = await _oftenContactService.InsertAsync(request, _loginContext.AccountId); return result; } /// /// /// 移除文件夹关系 /// /// /// [HttpPost("remove")] public async Task RemoveOftenContact(OftenContactDeRequest request) { return await _repository.RemoveOftenContactAsync(request); } /// /// 设置置顶 /// /// /// [HttpPost("is-top")] public async Task SetOftenContactIsTop(OftenContactDeRequest request) { return await _repository.SetOftenContactIsTopAsync(request); } /// /// 移动到文件夹 /// /// /// [HttpPost("move")] public async Task MoveOftenContactToIndividualGroup(OftenContactUpRequest request) { return await _repository.MoveOftenContactToIndividualGroupAsync(request); } /// /// 删除聊天界面 /// /// /// [HttpPost("delete")] public async Task DeleteAsync(OftenContactsDeRequest oftenContactIds) { return await _repository.DeleteAsync(oftenContactIds.OftenContactIds); } } }