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.WebControllers
{
///
/// 用户黑名单
///
[Route("api/web/blacklist")]
[ApiController]
[Authorize]
public class WebBlacklistController : ControllerBase
{
private readonly ILogger _logger;
private readonly IBlacklistUserRepository _blacklistUserRepository;
private readonly ILoginContext _loginContext;
private readonly IOftenContactService _oftenContactService;
private readonly IIMService _imService;
public WebBlacklistController(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(BlacklistUserSearchRequest request)
{
request.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);
}
}
}