AdminNavigationController.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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.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/navigation")]
  14. [ApiController]
  15. [Authorize]
  16. public class AdminNavigationController : ControllerBase
  17. {
  18. private readonly INavigationRepository navigationRepository;
  19. public AdminNavigationController(INavigationRepository navigationRepository)
  20. {
  21. this.navigationRepository = navigationRepository;
  22. }
  23. /// <summary>
  24. /// 列表 pc 1 移动 2
  25. /// </summary>
  26. /// <returns></returns>
  27. [HttpGet("{terminal}")]
  28. public async Task<IEnumerable<NavigationResult>> GetList(int terminal)
  29. {
  30. return await navigationRepository.GetAllAsync(terminal);
  31. }
  32. /// <summary>
  33. /// 添加导航
  34. /// </summary>
  35. /// <param name="note"></param>
  36. /// <returns></returns>
  37. [HttpPost]
  38. public async Task<int> Insert(Entity.Navigations.Navigation note)
  39. {
  40. return await navigationRepository.InsertAsync(note);
  41. }
  42. /// <summary>
  43. /// 修改导航
  44. /// </summary>
  45. /// <param name="request"></param>
  46. /// <returns></returns>
  47. [HttpPut]
  48. public async Task<bool> Update(NavigationUpRequest request)
  49. {
  50. return await navigationRepository.UpdateAsync(request);
  51. }
  52. /// <summary>
  53. /// 删除导航
  54. /// </summary>
  55. /// <param name="id"></param>
  56. /// <returns></returns>
  57. [HttpDelete("{id}")]
  58. public async Task<bool> DeleteAsync(int id)
  59. {
  60. return await navigationRepository.DeleteAsync(id);
  61. }
  62. }
  63. }