平安校园
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

FileController.cs 2.0 KiB

2 months ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. 
  2. //
  3. namespace SafeCampus.Web.Core;
  4. /// <summary>
  5. /// 文件管理控制器
  6. /// </summary>
  7. [ApiDescriptionSettings(Tag = "文件管理")]
  8. [Route("sys/dev/[controller]")]
  9. public class FileController : BaseController
  10. {
  11. private readonly IFileService _fileService;
  12. public FileController(IFileService fileService)
  13. {
  14. _fileService = fileService;
  15. }
  16. /// <summary>
  17. /// 文件查询分页
  18. /// </summary>
  19. /// <param name="input"></param>
  20. /// <returns></returns>
  21. [HttpGet("page")]
  22. public async Task<dynamic> Page([FromQuery] FilePageInput input)
  23. {
  24. return await _fileService.Page(input);
  25. }
  26. /// <summary>
  27. /// 上传本地文件
  28. /// </summary>
  29. /// <param name="file"></param>
  30. /// <returns></returns>
  31. [HttpPost("uploadLocal")]
  32. [DisplayName("上传本地文件")]
  33. [DisableRequestSizeLimit]
  34. public async Task<long> UploadLocal([FromForm] IFormFile file)
  35. {
  36. return await _fileService.UploadFile(SysDictConst.FILE_ENGINE_LOCAL, file);
  37. }
  38. /// <summary>
  39. /// 上传MINIO文件
  40. /// </summary>
  41. /// <param name="file"></param>
  42. /// <returns></returns>
  43. [HttpPost("uploadMinio")]
  44. [DisplayName("上传MINIO文件")]
  45. [DisableRequestSizeLimit]
  46. public async Task<long> UploadMinio([FromForm] IFormFile file)
  47. {
  48. return await _fileService.UploadFile(SysDictConst.FILE_ENGINE_MINIO, file);
  49. }
  50. /// <summary>
  51. /// 删除文件
  52. /// </summary>
  53. /// <param name="input"></param>
  54. /// <returns></returns>
  55. [HttpPost("delete")]
  56. [DisplayName("删除文件")]
  57. public async Task Delete([FromBody] BaseIdListInput input)
  58. {
  59. await _fileService.Delete(input);
  60. }
  61. /// <summary>
  62. /// 下载文件
  63. /// </summary>
  64. /// <param name="input"></param>
  65. /// <returns></returns>
  66. [HttpGet("download")]
  67. [DisplayName("下载文件")]
  68. public async Task<IActionResult> DownLoad([FromQuery] BaseIdInput input)
  69. {
  70. return await _fileService.Download(input);
  71. }
  72. }