|
@@ -0,0 +1,72 @@
|
|
|
+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
|
|
|
+{
|
|
|
+ /// <summary>
|
|
|
+ /// 用户黑名单
|
|
|
+ /// </summary>
|
|
|
+ [Route("api/web/blacklist")]
|
|
|
+ [ApiController]
|
|
|
+ [Authorize]
|
|
|
+ public class WebBlacklistController : ControllerBase
|
|
|
+ {
|
|
|
+ private readonly ILogger<WebBlacklistController> _logger;
|
|
|
+ private readonly IBlacklistUserRepository _blacklistUserRepository;
|
|
|
+ private readonly ILoginContext _loginContext;
|
|
|
+ private readonly IOftenContactService _oftenContactService;
|
|
|
+ private readonly IIMService _imService;
|
|
|
+
|
|
|
+ public WebBlacklistController(ILogger<WebBlacklistController> logger,
|
|
|
+ IBlacklistUserRepository blacklistUserRepository, ILoginContext loginContext,
|
|
|
+ IOftenContactService oftenContactService, IIMService imService)
|
|
|
+ {
|
|
|
+ _logger = logger;
|
|
|
+ _blacklistUserRepository = blacklistUserRepository;
|
|
|
+ _loginContext = loginContext;
|
|
|
+ _oftenContactService = oftenContactService;
|
|
|
+ _imService = imService;
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 获取黑名单
|
|
|
+ /// </summary>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpPost("list")]
|
|
|
+ public async Task<IEnumerable<BlacklistUser>> GetBlacklistUser()
|
|
|
+ {
|
|
|
+ var request = new BlacklistUserSearchRequest { UserId = _loginContext.AccountId };
|
|
|
+ return await _blacklistUserRepository.GetBlacklistUserAsync(request);
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 添加黑名单
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="request"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpPost("add")]
|
|
|
+ public async Task<bool> Insert(BlacklistUserInRequest request)
|
|
|
+ {
|
|
|
+ return await _imService.AddBlacklistUserAsync(_loginContext.AccountId, request.UserId);
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
+ /// 删除黑名单
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="blackUserId"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpDelete("{blackUserId}")]
|
|
|
+ public async Task<bool> Delete(int blackUserId)
|
|
|
+ {
|
|
|
+ return await _imService.ReMoveBlacklistUserAsync(blackUserId, _loginContext.AccountId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|