AdminMiddleLableController.cs 2.5 KB

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