119 lines
4.0 KiB
C#
119 lines
4.0 KiB
C#
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;
|
|
using VOL.Business.Services;
|
|
using VOL.Core.Filters;
|
|
using VOL.Core.ManageUser;
|
|
using VOL.Core.Utilities;
|
|
using VOL.Model;
|
|
using VOL.Model.Norm.Response;
|
|
|
|
namespace VOL.WebApi.Controllers.Business
|
|
{
|
|
/// <summary>
|
|
/// 体测数据
|
|
/// </summary>
|
|
[Route("api/[controller]")]
|
|
[ApiController]
|
|
[ApiExplorerSettings(GroupName = "v3")]
|
|
[TypeFilter(typeof(CustomApiResponseFilter))]
|
|
public class SportsTestResultController : ControllerBase
|
|
{
|
|
#region 初始化
|
|
|
|
private readonly IN_SportsTestResultService _sportsTestResultService;
|
|
public SportsTestResultController(
|
|
IN_SportsTestResultService sportsTestResultService)
|
|
{
|
|
_sportsTestResultService = sportsTestResultService;
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
/// <summary>
|
|
/// 学生成绩分页
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpGet(nameof(GetSportsTestCategoryPageList))]
|
|
public async Task<PageDataDto<StudentsTestDataModel>> GetSportsTestCategoryPageList(StudentsTestDataListParam paramDto)
|
|
{
|
|
return await _sportsTestResultService.GetSportsTestCategoryPageList(paramDto);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 导入学生体测数据
|
|
/// </summary>
|
|
/// <param name="file"></param>
|
|
/// <returns></returns>
|
|
/// <exception cref="Exception"></exception>
|
|
[HttpPost(nameof(ImportStudentsTestData))]
|
|
public async Task<ActionResult> ImportStudentsTestData(IFormFile file)
|
|
{
|
|
await _sportsTestResultService.ImportStudentsTestData(file);
|
|
return Ok("导入成功");
|
|
}
|
|
|
|
/// <summary>
|
|
/// 导出
|
|
/// </summary>
|
|
/// <param name="paramDto"></param>
|
|
/// <returns></returns>
|
|
[HttpGet(nameof(Export))]
|
|
public async Task<ActionResult> Export(StudentsTestDataListParam paramDto)
|
|
{
|
|
var rseList = await _sportsTestResultService.GetStudentsTestDataList(paramDto);
|
|
|
|
var disList = new Dictionary<string, List<StudentsTestDataModel>>();
|
|
disList.Add("学生成绩", rseList);
|
|
|
|
var exportColumns = Tool.GetPropertyNames<StudentsTestDataModel>();
|
|
|
|
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")}");
|
|
}
|
|
|
|
/// <summary>
|
|
/// 新增
|
|
/// </summary>
|
|
/// <param name="paramDto"></param>
|
|
/// <returns></returns>
|
|
[HttpPost(nameof(Add))]
|
|
public async Task<ActionResult> Add([FromBody] List<AddStudentsTestDataParam> paramDto)
|
|
{
|
|
await _sportsTestResultService.AddStudentsTestData(paramDto);
|
|
return Ok("新增成功");
|
|
}
|
|
|
|
/// <summary>
|
|
/// 更新
|
|
/// </summary>
|
|
/// <param name="paramDto"></param>
|
|
/// <returns></returns>
|
|
[HttpPost(nameof(Modify))]
|
|
public async Task<ActionResult> Modify([FromBody] List<AddStudentsTestDataParam> paramDto)
|
|
{
|
|
await _sportsTestResultService.ModifyStudentsTestData(paramDto);
|
|
return Ok("更新成功");
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除
|
|
/// </summary>
|
|
/// <param name="paramDto"></param>
|
|
/// <returns></returns>
|
|
[HttpPost(nameof(Delete))]
|
|
public async Task<ActionResult> Delete(List<int> ids)
|
|
{
|
|
await _sportsTestResultService.DeleteStudentsTestData(ids);
|
|
return Ok("更新成功");
|
|
}
|
|
}
|
|
} |