AdminSensitiveWordController.cs 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. using System.Threading.Tasks;
  2. using GxPress.Auth;
  3. using GxPress.Common.Page;
  4. using GxPress.Repository.Interface.SensitiveWord;
  5. using GxPress.Request.SensitiveWord;
  6. using Microsoft.AspNetCore.Authorization;
  7. using Microsoft.AspNetCore.Mvc;
  8. namespace GxPress.Api.AdminControllers
  9. {
  10. /// <summary>
  11. /// 敏感词
  12. /// </summary>
  13. [Route("api/admin/sensitive-word")]
  14. [ApiController]
  15. [Authorize]
  16. public class AdminSensitiveWordController : Controller
  17. {
  18. private readonly ISensitiveWordRepository _repository;
  19. private readonly ILoginContext _loginContext;
  20. public AdminSensitiveWordController(ISensitiveWordRepository _repository, ILoginContext _loginContext)
  21. {
  22. this._repository = _repository;
  23. this._loginContext = _loginContext;
  24. }
  25. /// <summary>
  26. /// 查询详情
  27. /// </summary>
  28. /// <param name="id"></param>
  29. /// <returns></returns>
  30. [HttpGet("{id}")]
  31. public async Task<Entity.tede2.SensitiveWord.SensitiveWord> GetAsync(int id)
  32. {
  33. return await _repository.GetAsync(id);
  34. }
  35. /// <summary>
  36. /// 删除
  37. /// </summary>
  38. /// <param name="id"></param>
  39. /// <returns></returns>
  40. [HttpDelete("{id}")]
  41. public async Task<bool> DeleteAsync(int id)
  42. {
  43. return await _repository.DeleteAsync(id);
  44. }
  45. /// <summary>
  46. /// 添加
  47. /// </summary>
  48. /// <param name="note"></param>
  49. /// <returns></returns>
  50. [HttpPost]
  51. public async Task<int> InsertAsync(Entity.tede2.SensitiveWord.SensitiveWord note)
  52. {
  53. note.AdminId = _loginContext.AccountId;
  54. note.Creator = _loginContext.Name;
  55. return await _repository.InsertAsync(note);
  56. }
  57. /// <summary>
  58. /// 修改
  59. /// </summary>
  60. /// <param name="note"></param>
  61. /// <returns></returns>
  62. [HttpPut]
  63. public async Task<bool> UpdateAsync(Entity.tede2.SensitiveWord.SensitiveWord note)
  64. {
  65. note.AdminId = _loginContext.AccountId;
  66. note.Creator = _loginContext.Name;
  67. return await _repository.UpdateAsync(note);
  68. }
  69. /// <summary>
  70. /// 查询
  71. /// </summary>
  72. /// <param name="request"></param>
  73. /// <returns></returns>
  74. [HttpPost("list")]
  75. public async Task<PagedList<Entity.tede2.SensitiveWord.SensitiveWord>> GetAllAsync(SensitiveWordRequest request)
  76. {
  77. return await _repository.GetAllAsync(request);
  78. }
  79. }
  80. }