using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using System; using System.Collections.Generic; using System.Threading.Tasks; using VOL.Business.IServices.Training; using VOL.Business.Services.Training; using VOL.Core.Filters; using VOL.Core.Utilities; using VOL.Model; namespace VOL.WebApi.Controllers.Business { /// /// 学生课程训练 /// [Route("api/[controller]")] [ApiController] [ApiExplorerSettings(GroupName = "v3")] [TypeFilter(typeof(CustomApiResponseFilter))] public class TrainingStudentDataController : ControllerBase { #region 初始化 private readonly II_TrainingStudentDataService _trainingStudentDataService; public TrainingStudentDataController( II_TrainingStudentDataService trainingStudentDataService) { _trainingStudentDataService = trainingStudentDataService; } #endregion /// /// 获取达标率 /// /// [HttpGet(nameof(GetAttainmentRate))] public async Task> GetAttainmentRate(TrainingDataParam paramDto) { return await _trainingStudentDataService.GetAttainmentRate(paramDto); } /// /// 年级分数比例 /// /// [HttpGet(nameof(GetScoreProportion))] public async Task> GetScoreProportion(TrainingDataParam paramDto) { return await _trainingStudentDataService.GetScoreProportion(paramDto); } /// /// 项目训练学生列表 /// /// /// [HttpGet(nameof(GetItemTrainingStudentDataList))] public async Task> GetItemTrainingStudentDataList(ItemTrainingStudentDataListParam paramDto) { return await _trainingStudentDataService.GetItemTrainingStudentDataList(paramDto); } /// /// 项目训练学生列表导出 /// /// /// [HttpGet(nameof(ItemTrainingStudentDataExport))] public async Task ItemTrainingStudentDataExport(ItemTrainingStudentDataListParam paramDto) { var rseList = await _trainingStudentDataService.GetItemTrainingStudentDataList(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")}"); } /// /// 训练学生详情 /// /// /// [HttpGet(nameof(GetTrainingStudentData))] public async Task GetTrainingStudentData(TrainingStudentDataParam paramDto) { return await _trainingStudentDataService.GetTrainingStudentData(paramDto); } /// /// 项目训练学生详情列表 /// /// /// [HttpGet(nameof(GetTrainingStudentDataList))] public async Task> GetTrainingStudentDataList(TrainingStudentDataListParam paramDto) { return await _trainingStudentDataService.GetTrainingStudentDataList(paramDto); } /// /// 项目训练学生详情列表导出 /// /// /// [HttpGet(nameof(TrainingStudentDataExport))] public async Task TrainingStudentDataExport(TrainingStudentDataListParam paramDto) { var rseList = await _trainingStudentDataService.GetTrainingStudentDataList(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")}"); } /// /// 训练学生趋势列表 /// /// /// [HttpGet(nameof(GetTrainingStudentDataTrendList))] public async Task> GetTrainingStudentDataTrendList(TrainingStudentDataTrendListParam paramDto) { return await _trainingStudentDataService.GetTrainingStudentDataTrendList(paramDto); } } }