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

namespace GxPress.Api.AdminControllers
{
    /// <summary>
    /// app启动页管理
    /// </summary>
    [Route("api/admin/app-start-page")]
    [ApiController]
    [Authorize]
    public class AdminAppStartPageController : Controller
    {
        private readonly IAppStartPageRepository appStartPageRepository;
        public AdminAppStartPageController(IAppStartPageRepository appStartPageRepository)
        {
            this.appStartPageRepository = appStartPageRepository;
        }
        /// <summary>
        /// 查询
        /// </summary>
        /// <returns></returns>
        [HttpGet("list")]
        public async Task<IEnumerable<Entity.tede2.AppStartPage.AppStartPage>> GetAllAsync()
        {
            return await appStartPageRepository.GetAllAsync();
        }
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpDelete("{id}")]
        public async Task<bool> DeleteAsync(int id)
        {
            return await appStartPageRepository.DeleteAsync(id);
        }
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPut("")]
        public async Task<bool> UpdateAsync(Entity.tede2.AppStartPage.AppStartPage model)
        {
            return await appStartPageRepository.UpdateAsync(model);
        }
    }
}