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/middle-label")]
    [ApiController]
    [Authorize]
    public class AdminMiddleLableController : ControllerBase
    {
        private readonly IMiddleLableRepository middleLableRepository;

        public AdminMiddleLableController(IMiddleLableRepository middleLableRepository)
        {
            this.middleLableRepository = middleLableRepository;

        }


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