AdminArticleGroupController.cs 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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.Article;
  7. using GxPress.Result.ArticleGroupUser;
  8. using Microsoft.AspNetCore.Authorization;
  9. using Microsoft.AspNetCore.Mvc;
  10. namespace GxPress.Api.AdminControllers
  11. {
  12. /// <summary>
  13. /// 文章组
  14. /// </summary>
  15. [Route("api/admin/articleGroup")]
  16. [ApiController]
  17. [Authorize]
  18. public class AdminArticleGroupController : Controller
  19. {
  20. private readonly IArticleGroupRepository _processGroupRepository;
  21. public AdminArticleGroupController(IArticleGroupRepository processGroupRepository)
  22. {
  23. _processGroupRepository = processGroupRepository;
  24. }
  25. /// <summary>
  26. /// 添加
  27. /// </summary>
  28. /// <param name="request"></param>
  29. /// <returns></returns>
  30. [HttpPost]
  31. public async Task<ArticleGroup> Add([FromBody] ArticleGroupAddRequest request)
  32. {
  33. return await _processGroupRepository.AddAsync(request);
  34. }
  35. /// <summary>
  36. /// 获取详情
  37. /// </summary>
  38. /// <param name="id"></param>
  39. /// <returns></returns>
  40. [HttpGet("{id}")]
  41. [AllowAnonymous]
  42. public async Task<ArticleGroupResult> GetAsync(int id)
  43. {
  44. return await _processGroupRepository.GetAsync(id);
  45. }
  46. /// <summary>
  47. /// 列表
  48. /// </summary>
  49. /// <returns></returns>
  50. [HttpGet("list")]
  51. public async Task<IEnumerable<ArticleGroupUserListResult>> GetList()
  52. {
  53. return await _processGroupRepository.GetListAsync(0);
  54. }
  55. /// <summary>
  56. /// 修改
  57. /// </summary>
  58. /// <param name="id"></param>
  59. /// <param name="request"></param>
  60. /// <returns></returns>
  61. [HttpPut("{id}")]
  62. public async Task<bool> Update(int id, [FromBody] ArticleGroupAddRequest request)
  63. {
  64. return await _processGroupRepository.UpdateAsync(id, request);
  65. }
  66. /// <summary>
  67. /// 删除
  68. /// </summary>
  69. /// <param name="id"></param>
  70. /// <returns></returns>
  71. [HttpDelete("{id}")]
  72. public async Task<bool> Delete(int id)
  73. {
  74. return await _processGroupRepository.DeleteAsync(id);
  75. }
  76. }
  77. }