using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;
using XYY.Common.Standard;
using XYY.Core.Standard.Mvc;
using XYY.Service.Standard.TrackingService;
using System.Net.Http;
using System.Net;

namespace XYY.API.Tracking.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class TrackingTracesController : ApiControllerBase
    {
        private readonly ITraceSupplementLogService _traceSupplementLogService;
        public TrackingTracesController(ITraceSupplementLogService traceSupplementLogService)
        {
            _traceSupplementLogService = traceSupplementLogService;
        }

        [HttpPost]
        public async Task<IActionResult> DownloadTraces(QueryModel queryModel)
        {
            var data = await _traceSupplementLogService.DownloadLogs(queryModel);
            return File(data, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
        }
    }
}
