123456789101112131415161718192021222324252627282930313233 |
- using Hotline.Api.Filter;
- using Microsoft.AspNetCore.Mvc;
- using MiniExcelLibs;
- using System.IO;
- namespace Hotline.Api.Controllers;
- [ApiController]
- [Produces("application/json")]
- [Route("api/v1/[controller]")]
- [LogFilter]
- public class BaseController : ControllerBase
- {
- protected FileStreamResult ExcelStreamResult(Stream stream, string fileName = null)
- {
- var tail = DateTime.Now.ToString("yyyyMMddhhmmss") + ".xlsx";
- fileName = string.IsNullOrEmpty(fileName)
- ? tail
- : $"{fileName}_{tail}";
- HttpContext.Response.Headers.Add("Access-Control-Expose-Headers", "Content-Disposition");
- return new FileStreamResult(stream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
- {
- FileDownloadName = fileName
- };
- }
- }
- [ApiController]
- [Route("api/v1/[controller]")]
- public class OriginController : ControllerBase
- {
- }
|