AdminSlideController.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. using System.Collections.Generic;
  2. using System.Threading.Tasks;
  3. using GxPress.Common.Page;
  4. using GxPress.Entity;
  5. using GxPress.Repository.Interface;
  6. using GxPress.Request.Slide;
  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/slide")]
  15. [ApiController]
  16. [Authorize]
  17. public class AdminSlideController : ControllerBase
  18. {
  19. private readonly ISlideRepository _slideRepository;
  20. public AdminSlideController(ISlideRepository slideRepository)
  21. {
  22. _slideRepository = slideRepository;
  23. }
  24. /// <summary>
  25. /// 添加轮播
  26. /// </summary>
  27. /// <param name="request"></param>
  28. /// <returns></returns>
  29. [HttpPost]
  30. public async Task<Slide> Add([FromBody] Slide request)
  31. {
  32. return await _slideRepository.AddAsync(request);
  33. }
  34. /// <summary>
  35. /// 修改轮播
  36. /// </summary>
  37. /// <param name="request"></param>
  38. /// <returns></returns>
  39. [HttpPut]
  40. public async Task<Slide> Edit([FromBody] Slide request)
  41. {
  42. return await _slideRepository.EditAsync(request);
  43. }
  44. /// <summary>
  45. /// 列表
  46. /// </summary>
  47. /// <returns></returns>
  48. [HttpPost("list")]
  49. public async Task<PagedList<Slide>> GetListAsync(SlideSearchRequest request)
  50. {
  51. var pagedList = await _slideRepository.GetListAsync(request);
  52. return pagedList;
  53. }
  54. /// <summary>
  55. /// 轮播
  56. /// </summary>
  57. /// <returns></returns>
  58. [HttpGet("{id}")]
  59. public async Task<Slide> Get(int id)
  60. {
  61. return await _slideRepository.GetAsync(id);
  62. }
  63. /// <summary>
  64. /// 删除轮播
  65. /// </summary>
  66. /// <param name="id"></param>
  67. /// <returns></returns>
  68. [HttpDelete("{id}")]
  69. public async Task<bool> Delete(int id)
  70. {
  71. return await _slideRepository.DeleteAsync(id);
  72. }
  73. }
  74. }