ltx cd7206ede5 feat: 添加AI阳光跑数据接口与班级筛选
从 XW_SunshineRunTrain 按学校权限查询运动记录,支持分页、姓名、日期和年级班级 ID 精确筛选。

提供 Excel 导出并附带学校角色的菜单授权脚本。
2026-10-10 10:06:33 +08:00

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");
}
}
}