61 lines
2.3 KiB
C#
61 lines
2.3 KiB
C#
using Microsoft.AspNetCore.Mvc;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Threading.Tasks;
|
|
using VOL.Business.IServices.SunshineRun;
|
|
using VOL.Core.Enums;
|
|
using VOL.Core.Filters;
|
|
using VOL.Core.Utilities;
|
|
using VOL.Model;
|
|
using VOL.Model.SunshineRun;
|
|
|
|
namespace VOL.WebApi.Controllers.Business
|
|
{
|
|
/// <summary>
|
|
/// AI阳光跑运动记录。
|
|
/// </summary>
|
|
[Route("api/[controller]")]
|
|
[ApiController]
|
|
[ApiExplorerSettings(GroupName = "v3")]
|
|
[TypeFilter(typeof(CustomApiResponseFilter))]
|
|
public class SunshineRunController : ControllerBase
|
|
{
|
|
private readonly ISunshineRunService _service;
|
|
|
|
public SunshineRunController(ISunshineRunService service)
|
|
{
|
|
_service = service;
|
|
}
|
|
|
|
[HttpGet(nameof(GetPageList))]
|
|
[ApiActionPermission("XW_SunshineRunTrain", ActionPermissionOptions.Search)]
|
|
public Task<PageDataDto<SunshineRunRecordModel>> GetPageList([FromQuery] SunshineRunPageParam param)
|
|
=> _service.GetPageList(param);
|
|
|
|
[HttpGet(nameof(Export))]
|
|
[ApiActionPermission("XW_SunshineRunTrain", ActionPermissionOptions.Search)]
|
|
public async Task<IActionResult> Export([FromQuery] SunshineRunFilterParam param)
|
|
{
|
|
var rows = await _service.GetExportList(param);
|
|
var columns = new List<string>
|
|
{
|
|
nameof(SunshineRunRecordModel.Index),
|
|
nameof(SunshineRunRecordModel.StudentName),
|
|
nameof(SunshineRunRecordModel.SexName),
|
|
nameof(SunshineRunRecordModel.ClassName),
|
|
nameof(SunshineRunRecordModel.EffectiveDistance),
|
|
nameof(SunshineRunRecordModel.EffectiveTime),
|
|
nameof(SunshineRunRecordModel.TotalDistance),
|
|
nameof(SunshineRunRecordModel.TotalTime),
|
|
nameof(SunshineRunRecordModel.StartTime),
|
|
nameof(SunshineRunRecordModel.EndTime)
|
|
};
|
|
var bytes = Tool.ExportToExcel(
|
|
new Dictionary<string, List<SunshineRunRecordModel>> { ["AI阳光跑"] = rows },
|
|
columns, autoFitColumns: false);
|
|
return File(bytes, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
$"AI阳光跑{DateTime.Now:yyyyMMddHHmmss}.xlsx");
|
|
}
|
|
}
|
|
}
|