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.

84 lines
2.7 KiB

using Microsoft.AspNetCore.Mvc;
6 months ago
using System.ComponentModel.DataAnnotations;
using Entity.Dto.Req;
using Service.System;
using Entity.Base;
using Entity.DbModel.System;
using HybirdFrameworkCore.Entity;
6 months ago
namespace WebStarter.Controllers.System
{
[Produces("application/json")]
[ApiController]
public class SysFileController
{
private readonly SysFileServices _sysFileServices;
private readonly IWebHostEnvironment _webHostEnvironment;
public SysFileController(SysFileServices sysFileServices, IWebHostEnvironment webHostEnvironment)
{
_sysFileServices = sysFileServices;
_webHostEnvironment = webHostEnvironment;
}
[HttpPost]
[Route("/api/sysFile/page")]
6 months ago
public async Task<Result<PageResult<SysFile>>> Page(PageFileReq input)
6 months ago
{
6 months ago
return Result<PageResult<SysFile>>.Success(await _sysFileServices.Page(input));
6 months ago
}
[HttpPost]
[Route("/api/sysFile/uploadFile")]
public async Task<SysFile> UploadFile([Required] IFormFile file, [FromQuery] string? path)
{
return await _sysFileServices.UploadFile(file, _webHostEnvironment.WebRootPath);
}
[HttpPost]
[Route("/api/app/uploadFile")]
public async Task<Result<SysFile>> AppUploadFile([Required] IFormFile file)
{
return Result<SysFile>.Success(await _sysFileServices.UploadFile(file, _webHostEnvironment.WebRootPath));
6 months ago
}
[HttpPost]
[Route("/api/sysFile/uploadFileFromBase64")]
public async Task<SysFile> UploadFileFromBase64(UploadFileFromBase64Req input)
{
return await _sysFileServices.UploadFileFromBase64(input);
}
[HttpPost]
[Route("/api/sysFile/uploadFiles")]
public async Task<List<SysFile>> UploadFiles([Required] List<IFormFile> files)
{
return await _sysFileServices.UploadFiles(files);
}
[HttpPost]
[Route("/api/sysFile/uploadAvatar")]
public async Task<SysFile> UploadAvatar([Required] IFormFile file)
{
return await _sysFileServices.UploadAvatar(file, _webHostEnvironment.WebRootPath);
}
/// <summary>
/// App上传头像
/// </summary>
/// <param name="file"></param>
/// <param name="loginNo"></param>
/// <returns></returns>
[HttpPost]
[Route("/api/app/sysFile/uploadAvatar")]
public async Task<SysFile> UploadAppAvatar([Required] IFormFile file, [FromForm] string loginNo)
{
return await _sysFileServices.UploadAppAvatar(file, _webHostEnvironment.WebRootPath,loginNo);
}
6 months ago
}
}