AdminMiddleLableController.cs 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. using System.Collections.Generic;
  2. using System.Threading.Tasks;
  3. using GxPress.Repository.Interface.Navigation;
  4. using GxPress.Request.Navigation;
  5. using GxPress.Service.Interface.Navigation;
  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/middle-label")]
  14. [ApiController]
  15. [Authorize]
  16. public class AdminMiddleLableController : ControllerBase
  17. {
  18. private readonly IMiddleLableRepository middleLableRepository;
  19. private readonly IMiddleLableService middleLableService;
  20. public AdminMiddleLableController(IMiddleLableRepository middleLableRepository, IMiddleLableService middleLableService)
  21. {
  22. this.middleLableRepository = middleLableRepository;
  23. this.middleLableService = middleLableService;
  24. }
  25. /// <summary>
  26. /// 列表
  27. /// </summary>
  28. /// <returns></returns>
  29. [HttpGet]
  30. public async Task<IEnumerable<Entity.Navigations.MiddleLable>> GetList()
  31. {
  32. return await middleLableRepository.GetAllAsync();
  33. }
  34. /// <summary>
  35. /// 详情
  36. /// </summary>
  37. /// <param name="id"></param>
  38. /// <returns></returns>
  39. [HttpGet("{id}")]
  40. public async Task<Entity.Navigations.MiddleLable> GetAsync(int id)
  41. {
  42. return await middleLableRepository.GetAsync(id);
  43. }
  44. /// <summary>
  45. /// 添加导航中间件
  46. /// </summary>
  47. /// /// <param name="request"></param>
  48. /// <returns></returns>
  49. [HttpPost]
  50. public async Task<bool> Insert(MiddleLableInRequest request)
  51. {
  52. return await middleLableService.InsertAsync(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 middleLableService.DeleteAsync(id);
  63. }
  64. /// <summary>
  65. /// 修改导航中间件
  66. /// </summary>
  67. /// <param name="request"></param>
  68. /// <returns></returns>
  69. [HttpPut]
  70. public async Task<bool> Update(MiddleLableUpRequest request)
  71. {
  72. return await middleLableService.UpdateAsync(request);
  73. }
  74. }
  75. }