diff --git a/PaydayBackend/Controllers/UserController.cs b/PaydayBackend/Controllers/UserController.cs
new file mode 100644
index 0000000..32c1ae0
--- /dev/null
+++ b/PaydayBackend/Controllers/UserController.cs
@@ -0,0 +1,29 @@
+using Microsoft.AspNetCore.Mvc;
+using PaydayBackend.Services;
+
+namespace PaydayBackend.Controllers;
+
+[Route("v1/user")]
+[ApiController]
+public class UserController : ControllerBase
+{
+ private readonly IUserService _userService;
+
+ public UserController(IUserService userService)
+ {
+ _userService = userService;
+ }
+
+ ///
+ /// Загрузить документы
+ ///
+ [HttpPost("banks")]
+ public async Task AddBank(long userId, IFormFile file)
+ {
+ string result = await _userService.UploadDocs(userId, file);
+ if (result == "ОК")
+ return Ok(result);
+
+ return BadRequest(result);
+ }
+}
\ No newline at end of file
diff --git a/PaydayBackend/Models/Bank.cs b/PaydayBackend/Models/Bank.cs
index 7465bc4..f2fcaa5 100644
--- a/PaydayBackend/Models/Bank.cs
+++ b/PaydayBackend/Models/Bank.cs
@@ -8,4 +8,6 @@ public class Bank
public long Id { get; set; }
public string Name { get; set; }
public string ImageUrl { get; set; }
+ public string CallbackUrl { get; set; }
+ public string SecretKey { get; set; }
}
\ No newline at end of file
diff --git a/PaydayBackend/Program.cs b/PaydayBackend/Program.cs
index 7f1e4ad..83594f8 100644
--- a/PaydayBackend/Program.cs
+++ b/PaydayBackend/Program.cs
@@ -42,6 +42,7 @@ builder.Services.AddHealthChecks()
// Services
builder.Services.AddSingleton();
builder.Services.AddScoped();
+builder.Services.AddScoped();
builder.Services.AddScoped();
// Minio
diff --git a/PaydayBackend/Services/IUserService.cs b/PaydayBackend/Services/IUserService.cs
new file mode 100644
index 0000000..dbc4c10
--- /dev/null
+++ b/PaydayBackend/Services/IUserService.cs
@@ -0,0 +1,46 @@
+using PaydayBackend.Utils;
+
+namespace PaydayBackend.Services;
+
+public interface IUserService
+{
+ public Task UploadDocs(long userId, IFormFile file);
+}
+
+public class UserService : IUserService
+{
+ private readonly DatabaseContext _databaseContext;
+ private readonly IStorageService _storageService;
+
+ public UserService(DatabaseContext databaseContext, IStorageService storageService)
+ {
+ _databaseContext = databaseContext;
+ _storageService = storageService;
+ }
+
+ public async Task UploadDocs(long userId, IFormFile file)
+ {
+ string sizeValidator = FileHelper.ValidateMaxFileSize(file, 5, new []{".png"});
+ if (sizeValidator != "OK")
+ return sizeValidator;
+
+ var fileStream = new MemoryStream();
+ await file.CopyToAsync(fileStream);
+ fileStream.Position = 0;
+ string imageValidator = await FileHelper.ValidateImage(fileStream, null, 200, 200);
+ if (imageValidator != "OK")
+ return imageValidator;
+
+ await FileHelper.CropImage(fileStream);
+
+ var filename = "Doc" + userId + ".png";
+ if (await _storageService.UploadFile(fileStream, "personal", filename))
+ {
+ // Send Request to bank
+ return "ОК";
+ }
+
+ return "Image not uploaded";
+ }
+
+}
\ No newline at end of file