AdminArticleGroupController.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. using System.Collections.Generic;
  2. using System.Threading.Tasks;
  3. using GxPress.Entity;
  4. using GxPress.Repository.Interface;
  5. using GxPress.Request.ArticleGroup;
  6. using GxPress.Result.ArticleGroupUser;
  7. using Microsoft.AspNetCore.Authorization;
  8. using Microsoft.AspNetCore.Mvc;
  9. namespace GxPress.Api.AdminControllers
  10. {
  11. /// <summary>
  12. /// 文章组
  13. /// </summary>
  14. [Route("api/admin/articleGroup")]
  15. [ApiController]
  16. [Authorize]
  17. public class AdminArticleGroupController : Controller
  18. {
  19. private readonly IArticleGroupRepository _processGroupRepository;
  20. public AdminArticleGroupController(IArticleGroupRepository processGroupRepository)
  21. {
  22. _processGroupRepository = processGroupRepository;
  23. }
  24. /// <summary>
  25. /// 添加
  26. /// </summary>
  27. /// <param name="request"></param>
  28. /// <returns></returns>
  29. [HttpPost]
  30. public async Task<ArticleGroup> Add([FromBody] ArticleGroupAddRequest request)
  31. {
  32. return await _processGroupRepository.AddAsync(request);
  33. }
  34. /// <summary>
  35. /// 列表
  36. /// </summary>
  37. /// <returns></returns>
  38. [HttpGet("list")]
  39. public async Task<IEnumerable<ArticleGroupUserListResult>> GetList()
  40. {
  41. return await _processGroupRepository.GetListAsync(0);
  42. }
  43. /// <summary>
  44. /// 修改
  45. /// </summary>
  46. /// <param name="id"></param>
  47. /// <param name="request"></param>
  48. /// <returns></returns>
  49. [HttpPut("{id}")]
  50. public async Task<bool> Update(int id, [FromBody]ArticleGroupAddRequest request)
  51. {
  52. return await _processGroupRepository.UpdateAsync(id, request);
  53. }
  54. /// <summary>
  55. /// 删除
  56. /// </summary>
  57. /// <param name="id"></param>
  58. /// <returns></returns>
  59. [HttpDelete("{id}")]
  60. public async Task<bool> Delete(int id)
  61. {
  62. return await _processGroupRepository.DeleteAsync(id);
  63. }
  64. }
  65. }