1111
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using FileService.Application.UploadFileTask;
|
||||
using FileService.Infrastructure;
|
||||
using IM.ASPNETCore;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Security.Claims;
|
||||
|
||||
namespace FileService.WebApi.Controllers.FileTask
|
||||
{
|
||||
@@ -9,11 +13,27 @@ namespace FileService.WebApi.Controllers.FileTask
|
||||
[ApiController]
|
||||
public class FileTaskController : ControllerBase
|
||||
{
|
||||
private readonly UploadFileTaskService service;
|
||||
|
||||
public FileTaskController(UploadFileTaskService service)
|
||||
{
|
||||
this.service = service;
|
||||
}
|
||||
|
||||
[HttpPost("init")]
|
||||
public async Task<IActionResult> Init()
|
||||
[UnitOfWork(typeof(FileDbContext))]
|
||||
public async Task<IActionResult> Init(FileTaskInitRequest request)
|
||||
{
|
||||
|
||||
var userId = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
var res = await service.InitTaskAsync(new UploadTaskInitCommand(
|
||||
UploaderId: Guid.Parse(userId),
|
||||
ConversationId: request.ConversationId,
|
||||
FileName: request.FileName,
|
||||
FileSize: request.FileSize,
|
||||
contentType: request.ContentType,
|
||||
checkSum: request.CheckSum
|
||||
));
|
||||
return Ok(res);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
using FluentValidation;
|
||||
|
||||
namespace FileService.WebApi.Controllers.FileTask
|
||||
{
|
||||
public class FileTaskInitRequest
|
||||
{
|
||||
public Guid ConversationId { get; set; }
|
||||
public string FileName { get; set; }
|
||||
public long FileSize { get; set; }
|
||||
public string ContentType { get; set; }
|
||||
public string CheckSum { get; set; }
|
||||
|
||||
}
|
||||
public class FileTaskInitRequestValidator: AbstractValidator<FileTaskInitRequest>
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user