using System.Collections.Generic; using System.Threading.Tasks; using GxPress.Auth; using GxPress.Repository.Interface.AppStartPage; using GxPress.Request.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 ILoginContext _loginContext; private readonly IAppStartPageRepository appStartPageRepository; public AdminAppStartPageController(IAppStartPageRepository appStartPageRepository, ILoginContext _loginContext) { this.appStartPageRepository = appStartPageRepository; this._loginContext = _loginContext; } /// <summary> /// 查询 /// </summary> /// <returns></returns> [HttpGet("list")] public async Task<IEnumerable<Entity.tede2.AppStartPage.AppStartPage>> GetAllAsync() { var result = await appStartPageRepository.GetAllAsync(); return result; } /// <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="request"></param> /// <returns></returns> [HttpPut("")] public async Task<bool> UpdateAsync(AppStartPageUpdateRequest request) { return await appStartPageRepository.UpdateAsync(request); } /// <summary> /// 添加 /// </summary> /// <param name="model"></param> /// <returns></returns> [HttpPost] public async Task<bool> InsertAsync(Entity.tede2.AppStartPage.AppStartPage model) { model.Creator = _loginContext.Name; model.AdminId = _loginContext.AccountId; return await appStartPageRepository.InsertAsync(model); } } }