using System.Collections.Generic;
using System.Threading.Tasks;
using GxPress.Repository.Interface.Navigation;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

namespace GxPress.Api.AdminControllers
{
    /// <summary>
    /// 导航
    /// </summary>
    [Route("api/admin/navigation")]
    [ApiController]
    [Authorize]
    public class AdminNavigationController : ControllerBase
    {
        private readonly INavigationRepository navigationRepository;

        public AdminNavigationController(INavigationRepository navigationRepository)
        {
            this.navigationRepository = navigationRepository;

        }


        /// <summary>
        /// 列表
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<IEnumerable<Entity.Navigations.Navigation>> GetList()
        {
            return await navigationRepository.GetAllAsync();
        }
        /// <summary>
        /// 添加导航
        /// </summary>
        /// /// <param name="note"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> Insert(Entity.Navigations.Navigation note)
        {
            return await navigationRepository.InsertAsync(note);
        }
        /// <summary>
        /// 修改导航
        /// </summary>
        /// <param name="note"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<bool> Update(Entity.Navigations.Navigation note)
        {
            return await navigationRepository.UpdateAsync(note);
        }
    }
}