using System.Threading.Tasks;
using GxPress.Auth;
using GxPress.Common.Page;
using GxPress.Repository.Interface.SensitiveWord;
using GxPress.Request.SensitiveWord;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace GxPress.Api.AdminControllers
{
///
/// 敏感词
///
[Route("api/admin/sensitive-word")]
[ApiController]
[Authorize]
public class AdminSensitiveWordController : Controller
{
private readonly ISensitiveWordRepository _repository;
private readonly ILoginContext _loginContext;
public AdminSensitiveWordController(ISensitiveWordRepository _repository, ILoginContext _loginContext)
{
this._repository = _repository;
this._loginContext = _loginContext;
}
///
/// 查询详情
///
///
///
[HttpGet("{id}")]
public async Task GetAsync(int id)
{
return await _repository.GetAsync(id);
}
///
/// 删除
///
///
///
[HttpDelete("{id}")]
public async Task DeleteAsync(int id)
{
return await _repository.DeleteAsync(id);
}
///
/// 添加
///
///
///
[HttpPost]
public async Task InsertAsync(Entity.tede2.SensitiveWord.SensitiveWord note)
{
note.AdminId = _loginContext.AccountId;
note.Creator = _loginContext.Name;
return await _repository.InsertAsync(note);
}
///
/// 修改
///
///
///
[HttpPut]
public async Task UpdateAsync(Entity.tede2.SensitiveWord.SensitiveWord note)
{
note.AdminId = _loginContext.AccountId;
note.Creator = _loginContext.Name;
return await _repository.UpdateAsync(note);
}
///
/// 查询
///
///
///
[HttpPost("list")]
public async Task> GetAllAsync(SensitiveWordRequest request)
{
return await _repository.GetAllAsync(request);
}
}
}