using System.Collections.Generic;
using System.Threading.Tasks;
using GxPress.Auth;
using GxPress.Entity;
using GxPress.Repository.Interface;
using GxPress.Request.BlacklistUser;
using GxPress.Service.Interface.IM;
using GxPress.Service.Interface.OftenContact;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
namespace GxPress.Api.AppControllers
{
///
/// 用户黑名单
///
[Route("api/app/blacklist")]
[ApiController]
[Authorize]
public class BlacklistController : ControllerBase
{
private readonly ILogger _logger;
private readonly IBlacklistUserRepository _blacklistUserRepository;
private readonly ILoginContext _loginContext;
private readonly IOftenContactService _oftenContactService;
private readonly IIMService _imService;
public BlacklistController(ILogger logger,
IBlacklistUserRepository blacklistUserRepository, ILoginContext loginContext,
IOftenContactService oftenContactService, IIMService imService)
{
_logger = logger;
_blacklistUserRepository = blacklistUserRepository;
_loginContext = loginContext;
_oftenContactService = oftenContactService;
_imService = imService;
}
///
/// 获取黑名单
///
///
[HttpPost("list")]
public async Task> GetBlacklistUser()
{
var request = new BlacklistUserSearchRequest { UserId = _loginContext.AccountId };
return await _blacklistUserRepository.GetBlacklistUserAsync(request);
}
///
/// 添加黑名单
///
///
///
[HttpPost("add")]
public async Task Insert(BlacklistUserInRequest request)
{
return await _imService.AddBlacklistUserAsync(_loginContext.AccountId, request.UserId);
}
///
/// 删除黑名单
///
///
///
[HttpDelete("{blackUserId}")]
public async Task Delete(int blackUserId)
{
return await _imService.ReMoveBlacklistUserAsync(blackUserId, _loginContext.AccountId);
}
}
}