as is
This commit is contained in:
31
StopShopping.FileApi/Routes.cs
Normal file
31
StopShopping.FileApi/Routes.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using StopShopping.FileApi.Extensions;
|
||||
using StopShopping.FileApi.Services;
|
||||
|
||||
namespace StopShopping.FileApi;
|
||||
|
||||
public static class Routes
|
||||
{
|
||||
public static void MapRoutes(WebApplication app)
|
||||
{
|
||||
app.MapGroup("")
|
||||
.MapRoutes()
|
||||
.WithInternalOnly();
|
||||
}
|
||||
|
||||
public static RouteGroupBuilder MapRoutes(this RouteGroupBuilder routes)
|
||||
{
|
||||
routes.MapPost("/upload", UploadAsync)
|
||||
.DisableAntiforgery()
|
||||
.WithDescription("上传文件,对外接口自己实现anti-forgery(重要)");
|
||||
|
||||
return routes;
|
||||
}
|
||||
|
||||
private static async Task<ApiResponse<FileUploadResp>> UploadAsync(
|
||||
[FromForm] UploadParams payload,
|
||||
IFileService fileService)
|
||||
{
|
||||
return await fileService.UploadFileAsync(payload);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user