using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using System; using System.Collections.Generic; using System.Threading.Tasks; using VOL.Business.IServices; using VOL.Business.IServices.School; using VOL.Business.Services; using VOL.Business.Services.Norm; using VOL.Business.Services.School; using VOL.Core.Filters; using VOL.Core.ManageUser; using VOL.Core.Utilities; using VOL.Model; namespace VOL.WebApi.Controllers.Business { /// /// 体测管理 /// [Route("api/[controller]")] [ApiController] [ApiExplorerSettings(GroupName = "v3")] [TypeFilter(typeof(CustomApiResponseFilter))] public class HealthStandardsController : ControllerBase { #region 初始化 private readonly IN_HealthStandardsService _healthStandardsService; public HealthStandardsController( IN_HealthStandardsService healthStandardsService) { _healthStandardsService = healthStandardsService; } #endregion /// /// 分页获体测标准列表 /// /// [HttpGet(nameof(GetHealthStandardsPageList))] public async Task> GetHealthStandardsPageList(HealthStandardsPageListParam paramDto) { return await _healthStandardsService.GetHealthStandardsPageList(paramDto); } /// /// 新增 /// /// /// [HttpPost(nameof(AddHealthStandards))] public async Task AddHealthStandards([FromBody] List paramDto) { await _healthStandardsService.AddHealthStandards(paramDto); return Ok("新增成功"); } /// /// 更新 /// /// /// [HttpPost(nameof(ModifyHealthStandards))] public async Task ModifyHealthStandards([FromBody] List paramDto) { await _healthStandardsService.ModifyHealthStandards(paramDto); return Ok("更新成功"); } /// /// 导出体测标准列表 /// /// /// [HttpGet(nameof(GetHealthStandardsList))] public async Task GetHealthStandardsList(HealthStandardsExportParam paramDto) { var rseList = await _healthStandardsService.GetHealthStandardsList(paramDto); var disList = new Dictionary>(); disList.Add("体测标准", rseList); var exportColumns = Tool.GetPropertyNames(); var excelBytes = Tool.ExportToExcel(disList, exportColumns); Response.Headers.Add("Content-Disposition", "attachment; filename=ExportedData.xlsx"); Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; return File(excelBytes, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", $"体测标准{DateTime.Now.ToString("yyyyMMddHHmmss")}"); } } }