From f683ac9dfcc4ce677fb9051cb2a65b51b3b57f7a Mon Sep 17 00:00:00 2001 From: Matheus Pigatto <1304matheus@gmail.com> Date: Mon, 3 Mar 2025 14:18:26 -0300 Subject: [PATCH 1/9] feat: adds new route to update folder name --- .../name/DefaultUpdateFolderNameUseCase.java | 48 +++++++++++++++++++ .../update/name/UpdateFolderNameInput.java | 9 ++++ .../update/name/UpdateFolderNameUseCase.java | 7 +++ .../drive/infrastructure/api/FolderAPI.java | 3 ++ .../api/controller/FolderController.java | 15 +++++- .../usecase/FolderUseCaseConfig.java | 7 +++ 6 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 application/src/main/java/com/callv2/drive/application/folder/update/name/DefaultUpdateFolderNameUseCase.java create mode 100644 application/src/main/java/com/callv2/drive/application/folder/update/name/UpdateFolderNameInput.java create mode 100644 application/src/main/java/com/callv2/drive/application/folder/update/name/UpdateFolderNameUseCase.java diff --git a/application/src/main/java/com/callv2/drive/application/folder/update/name/DefaultUpdateFolderNameUseCase.java b/application/src/main/java/com/callv2/drive/application/folder/update/name/DefaultUpdateFolderNameUseCase.java new file mode 100644 index 00000000..9f5d9604 --- /dev/null +++ b/application/src/main/java/com/callv2/drive/application/folder/update/name/DefaultUpdateFolderNameUseCase.java @@ -0,0 +1,48 @@ +package com.callv2.drive.application.folder.update.name; + +import com.callv2.drive.domain.exception.NotFoundException; +import com.callv2.drive.domain.exception.ValidationException; +import com.callv2.drive.domain.folder.Folder; +import com.callv2.drive.domain.folder.FolderGateway; +import com.callv2.drive.domain.folder.FolderID; +import com.callv2.drive.domain.folder.FolderName; +import com.callv2.drive.domain.validation.Error; +import com.callv2.drive.domain.validation.handler.Notification; + +public class DefaultUpdateFolderNameUseCase extends UpdateFolderNameUseCase { + + private final FolderGateway folderGateway; + + public DefaultUpdateFolderNameUseCase(final FolderGateway folderGateway) { + this.folderGateway = folderGateway; + } + + @Override + public void execute(final UpdateFolderNameInput input) { + + final Folder folder = this.folderGateway + .findById(FolderID.of(input.folderId())) + .orElseThrow(() -> NotFoundException.with(Folder.class, input.folderId().toString())); + + final Folder parentFolder = this.folderGateway + .findById(folder.getParentFolder()) + .orElseThrow( + () -> NotFoundException.with(Folder.class, folder.getParentFolder().getValue().toString())); + + final FolderName folderName = FolderName.of(input.name()); + validateFolderName(parentFolder, folderName); + + this.folderGateway.update(folder.changeName(folderName)); + } + + private void validateFolderName(Folder parentFolder, FolderName name) { + + final Notification notification = Notification.create(); + + if (parentFolder.getSubFolders().stream().anyMatch(subFolder -> subFolder.name().equals(name))) + notification.append(Error.with("Folder with the same name already exists")); + + if (notification.hasError()) + throw ValidationException.with("Could not update folder name Aggregate Folder", notification); + } +} \ No newline at end of file diff --git a/application/src/main/java/com/callv2/drive/application/folder/update/name/UpdateFolderNameInput.java b/application/src/main/java/com/callv2/drive/application/folder/update/name/UpdateFolderNameInput.java new file mode 100644 index 00000000..9531c6d6 --- /dev/null +++ b/application/src/main/java/com/callv2/drive/application/folder/update/name/UpdateFolderNameInput.java @@ -0,0 +1,9 @@ +package com.callv2.drive.application.folder.update.name; + +import java.util.UUID; + +public record UpdateFolderNameInput( + UUID folderId, + String name) { + +} diff --git a/application/src/main/java/com/callv2/drive/application/folder/update/name/UpdateFolderNameUseCase.java b/application/src/main/java/com/callv2/drive/application/folder/update/name/UpdateFolderNameUseCase.java new file mode 100644 index 00000000..5b588846 --- /dev/null +++ b/application/src/main/java/com/callv2/drive/application/folder/update/name/UpdateFolderNameUseCase.java @@ -0,0 +1,7 @@ +package com.callv2.drive.application.folder.update.name; + +import com.callv2.drive.application.UnitUseCase; + +public abstract class UpdateFolderNameUseCase extends UnitUseCase { + +} diff --git a/infrastructure/src/main/java/com/callv2/drive/infrastructure/api/FolderAPI.java b/infrastructure/src/main/java/com/callv2/drive/infrastructure/api/FolderAPI.java index 62856f1b..faa2c4c6 100644 --- a/infrastructure/src/main/java/com/callv2/drive/infrastructure/api/FolderAPI.java +++ b/infrastructure/src/main/java/com/callv2/drive/infrastructure/api/FolderAPI.java @@ -89,4 +89,7 @@ ResponseEntity> list( @RequestParam(name = "filterOperator", required = false, defaultValue = "AND") Filter.Operator filterOperator, @RequestParam(name = "filters", required = false) List filters); + @PatchMapping(value = "{id}/change-name", consumes = { MediaType.APPLICATION_JSON_VALUE }) + ResponseEntity changeName(@PathVariable(required = true) UUID id, @RequestBody String request); + } diff --git a/infrastructure/src/main/java/com/callv2/drive/infrastructure/api/controller/FolderController.java b/infrastructure/src/main/java/com/callv2/drive/infrastructure/api/controller/FolderController.java index f2c4e21a..73b4e19c 100644 --- a/infrastructure/src/main/java/com/callv2/drive/infrastructure/api/controller/FolderController.java +++ b/infrastructure/src/main/java/com/callv2/drive/infrastructure/api/controller/FolderController.java @@ -13,6 +13,8 @@ import com.callv2.drive.application.folder.retrieve.get.GetFolderUseCase; import com.callv2.drive.application.folder.retrieve.get.root.GetRootFolderUseCase; import com.callv2.drive.application.folder.retrieve.list.ListFoldersUseCase; +import com.callv2.drive.application.folder.update.name.UpdateFolderNameInput; +import com.callv2.drive.application.folder.update.name.UpdateFolderNameUseCase; import com.callv2.drive.domain.pagination.Filter; import com.callv2.drive.domain.pagination.Page; import com.callv2.drive.domain.pagination.Pagination; @@ -36,18 +38,21 @@ public class FolderController implements FolderAPI { private final GetFolderUseCase getFolderUseCase; private final MoveFolderUseCase moveFolderUseCase; private final ListFoldersUseCase listFoldersUseCase; + private final UpdateFolderNameUseCase updateFolderNameUseCase; public FolderController( final GetRootFolderUseCase getRootFolderUseCase, final CreateFolderUseCase createFolderUseCase, final GetFolderUseCase getFolderUseCase, final MoveFolderUseCase moveFolderUseCase, - final ListFoldersUseCase listFoldersUseCase) { + final ListFoldersUseCase listFoldersUseCase, + final UpdateFolderNameUseCase updateFolderNameUseCase) { this.getRootFolderUseCase = getRootFolderUseCase; this.createFolderUseCase = createFolderUseCase; this.getFolderUseCase = getFolderUseCase; this.moveFolderUseCase = moveFolderUseCase; this.listFoldersUseCase = listFoldersUseCase; + this.updateFolderNameUseCase = updateFolderNameUseCase; } @Override @@ -99,4 +104,12 @@ public ResponseEntity> list( return ResponseEntity.ok(listFoldersUseCase.execute(query).map(FolderPresenter::present)); } + @Override + public ResponseEntity changeName(UUID id, String request) { + + this.updateFolderNameUseCase.execute(new UpdateFolderNameInput(id, request)); + + return ResponseEntity.noContent().build(); + } + } diff --git a/infrastructure/src/main/java/com/callv2/drive/infrastructure/configuration/usecase/FolderUseCaseConfig.java b/infrastructure/src/main/java/com/callv2/drive/infrastructure/configuration/usecase/FolderUseCaseConfig.java index 79365121..cf5c326b 100644 --- a/infrastructure/src/main/java/com/callv2/drive/infrastructure/configuration/usecase/FolderUseCaseConfig.java +++ b/infrastructure/src/main/java/com/callv2/drive/infrastructure/configuration/usecase/FolderUseCaseConfig.java @@ -13,6 +13,8 @@ import com.callv2.drive.application.folder.retrieve.get.root.GetRootFolderUseCase; import com.callv2.drive.application.folder.retrieve.list.DefaultListFoldersUseCase; import com.callv2.drive.application.folder.retrieve.list.ListFoldersUseCase; +import com.callv2.drive.application.folder.update.name.DefaultUpdateFolderNameUseCase; +import com.callv2.drive.application.folder.update.name.UpdateFolderNameUseCase; import com.callv2.drive.domain.file.FileGateway; import com.callv2.drive.domain.folder.FolderGateway; @@ -54,4 +56,9 @@ ListFoldersUseCase listFoldersUseCase() { return new DefaultListFoldersUseCase(folderGateway); } + @Bean + UpdateFolderNameUseCase updateFolderNameUseCase() { + return new DefaultUpdateFolderNameUseCase(folderGateway); + } + } From a93b27ddd79215d7fe26561bf68519ef28b38d0e Mon Sep 17 00:00:00 2001 From: jhonatapers Date: Tue, 10 Jun 2025 11:39:51 -0300 Subject: [PATCH 2/9] refactor: improve folder name validation and update method parameters for clarity --- .../update/name/DefaultUpdateFolderNameUseCase.java | 8 ++++---- .../folder/update/name/UpdateFolderNameInput.java | 4 ++++ .../infrastructure/api/controller/FolderController.java | 4 ++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/application/src/main/java/com/callv2/drive/application/folder/update/name/DefaultUpdateFolderNameUseCase.java b/application/src/main/java/com/callv2/drive/application/folder/update/name/DefaultUpdateFolderNameUseCase.java index 9f5d9604..bbdb4fd2 100644 --- a/application/src/main/java/com/callv2/drive/application/folder/update/name/DefaultUpdateFolderNameUseCase.java +++ b/application/src/main/java/com/callv2/drive/application/folder/update/name/DefaultUpdateFolderNameUseCase.java @@ -6,7 +6,7 @@ import com.callv2.drive.domain.folder.FolderGateway; import com.callv2.drive.domain.folder.FolderID; import com.callv2.drive.domain.folder.FolderName; -import com.callv2.drive.domain.validation.Error; +import com.callv2.drive.domain.validation.ValidationError; import com.callv2.drive.domain.validation.handler.Notification; public class DefaultUpdateFolderNameUseCase extends UpdateFolderNameUseCase { @@ -35,14 +35,14 @@ public void execute(final UpdateFolderNameInput input) { this.folderGateway.update(folder.changeName(folderName)); } - private void validateFolderName(Folder parentFolder, FolderName name) { + private void validateFolderName(final Folder parentFolder, final FolderName name) { final Notification notification = Notification.create(); if (parentFolder.getSubFolders().stream().anyMatch(subFolder -> subFolder.name().equals(name))) - notification.append(Error.with("Folder with the same name already exists")); + notification.append(ValidationError.with("Folder with the same name already exists")); if (notification.hasError()) - throw ValidationException.with("Could not update folder name Aggregate Folder", notification); + throw ValidationException.with("Could not update folder name", notification); } } \ No newline at end of file diff --git a/application/src/main/java/com/callv2/drive/application/folder/update/name/UpdateFolderNameInput.java b/application/src/main/java/com/callv2/drive/application/folder/update/name/UpdateFolderNameInput.java index 9531c6d6..f590bf3b 100644 --- a/application/src/main/java/com/callv2/drive/application/folder/update/name/UpdateFolderNameInput.java +++ b/application/src/main/java/com/callv2/drive/application/folder/update/name/UpdateFolderNameInput.java @@ -6,4 +6,8 @@ public record UpdateFolderNameInput( UUID folderId, String name) { + public static UpdateFolderNameInput of(final UUID folderId, final String name) { + return new UpdateFolderNameInput(folderId, name); + } + } diff --git a/infrastructure/src/main/java/com/callv2/drive/infrastructure/api/controller/FolderController.java b/infrastructure/src/main/java/com/callv2/drive/infrastructure/api/controller/FolderController.java index d2f25dbf..7be0b3c3 100644 --- a/infrastructure/src/main/java/com/callv2/drive/infrastructure/api/controller/FolderController.java +++ b/infrastructure/src/main/java/com/callv2/drive/infrastructure/api/controller/FolderController.java @@ -110,9 +110,9 @@ public ResponseEntity> list( } @Override - public ResponseEntity changeName(UUID id, String request) { + public ResponseEntity changeName(UUID id, String newName) { - this.updateFolderNameUseCase.execute(new UpdateFolderNameInput(id, request)); + this.updateFolderNameUseCase.execute(new UpdateFolderNameInput(id, newName)); return ResponseEntity.noContent().build(); } From c86d5d1fc524f779914f7188365956f61eb15c9b Mon Sep 17 00:00:00 2001 From: jhonatapers Date: Tue, 10 Jun 2025 11:41:44 -0300 Subject: [PATCH 3/9] feat: add operation for changing folder name with appropriate responses --- .../com/callv2/drive/infrastructure/api/FolderAPI.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/infrastructure/src/main/java/com/callv2/drive/infrastructure/api/FolderAPI.java b/infrastructure/src/main/java/com/callv2/drive/infrastructure/api/FolderAPI.java index faa2c4c6..e9e406b7 100644 --- a/infrastructure/src/main/java/com/callv2/drive/infrastructure/api/FolderAPI.java +++ b/infrastructure/src/main/java/com/callv2/drive/infrastructure/api/FolderAPI.java @@ -90,6 +90,13 @@ ResponseEntity> list( @RequestParam(name = "filters", required = false) List filters); @PatchMapping(value = "{id}/change-name", consumes = { MediaType.APPLICATION_JSON_VALUE }) + @Operation(summary = "Change folder name", description = "This method changes the name of a folder", security = @SecurityRequirement(name = "bearerAuth")) + @ApiResponses({ + @ApiResponse(responseCode = "204", description = "Folder name changed successfully", content = @Content(schema = @Schema(implementation = Void.class))), + @ApiResponse(responseCode = "404", description = "Folder not found", content = @Content(schema = @Schema(implementation = Void.class))), + @ApiResponse(responseCode = "422", description = "A validation error was thrown", content = @Content(schema = @Schema(implementation = ApiError.class))), + @ApiResponse(responseCode = "500", description = "Internal Server Error", content = @Content(schema = @Schema(implementation = ApiError.class))) + }) ResponseEntity changeName(@PathVariable(required = true) UUID id, @RequestBody String request); } From eeb9b0d0f1c95e9d35ef035b88f61d042aabebdf Mon Sep 17 00:00:00 2001 From: jhonatapers Date: Sat, 23 Aug 2025 23:08:06 -0300 Subject: [PATCH 4/9] refactor: streamline folder name update logic and improve validation checks --- .../name/DefaultUpdateFolderNameUseCase.java | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/application/src/main/java/com/callv2/drive/application/folder/update/name/DefaultUpdateFolderNameUseCase.java b/application/src/main/java/com/callv2/drive/application/folder/update/name/DefaultUpdateFolderNameUseCase.java index bbdb4fd2..d3267a16 100644 --- a/application/src/main/java/com/callv2/drive/application/folder/update/name/DefaultUpdateFolderNameUseCase.java +++ b/application/src/main/java/com/callv2/drive/application/folder/update/name/DefaultUpdateFolderNameUseCase.java @@ -1,5 +1,7 @@ package com.callv2.drive.application.folder.update.name; +import java.util.Set; + import com.callv2.drive.domain.exception.NotFoundException; import com.callv2.drive.domain.exception.ValidationException; import com.callv2.drive.domain.folder.Folder; @@ -24,25 +26,19 @@ public void execute(final UpdateFolderNameInput input) { .findById(FolderID.of(input.folderId())) .orElseThrow(() -> NotFoundException.with(Folder.class, input.folderId().toString())); - final Folder parentFolder = this.folderGateway - .findById(folder.getParentFolder()) - .orElseThrow( - () -> NotFoundException.with(Folder.class, folder.getParentFolder().getValue().toString())); - final FolderName folderName = FolderName.of(input.name()); - validateFolderName(parentFolder, folderName); - - this.folderGateway.update(folder.changeName(folderName)); - } - - private void validateFolderName(final Folder parentFolder, final FolderName name) { final Notification notification = Notification.create(); - if (parentFolder.getSubFolders().stream().anyMatch(subFolder -> subFolder.name().equals(name))) + final Set subFolders = folderGateway.findByParentFolderId(folder.getParentFolder()); + + if (subFolders.stream().anyMatch(subFolder -> subFolder.getName().equals(folderName))) notification.append(ValidationError.with("Folder with the same name already exists")); if (notification.hasError()) throw ValidationException.with("Could not update folder name", notification); + + this.folderGateway.update(folder.changeName(folderName)); } + } \ No newline at end of file From 2c31098ba3c4a554987a128275e92ee17647fc2a Mon Sep 17 00:00:00 2001 From: jhonatapers Date: Sat, 23 Aug 2025 23:08:25 -0300 Subject: [PATCH 5/9] refactor: update endpoint for changing folder name to use a simplified path --- .../java/com/callv2/drive/infrastructure/api/FolderAPI.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/infrastructure/src/main/java/com/callv2/drive/infrastructure/api/FolderAPI.java b/infrastructure/src/main/java/com/callv2/drive/infrastructure/api/FolderAPI.java index 26b532e6..98ef6738 100644 --- a/infrastructure/src/main/java/com/callv2/drive/infrastructure/api/FolderAPI.java +++ b/infrastructure/src/main/java/com/callv2/drive/infrastructure/api/FolderAPI.java @@ -88,7 +88,7 @@ ResponseEntity> list( @RequestParam(name = "filterOperator", required = false, defaultValue = "AND") Filter.Operator filterOperator, @RequestParam(name = "filters", required = false) List filters); - @PatchMapping(value = "{id}/change-name", consumes = { MediaType.APPLICATION_JSON_VALUE }) + @PatchMapping(value = "{id}/name", consumes = { MediaType.APPLICATION_JSON_VALUE }) @Operation(summary = "Change folder name", description = "This method changes the name of a folder", security = @SecurityRequirement(name = "bearerAuth")) @ApiResponses({ @ApiResponse(responseCode = "204", description = "Folder name changed successfully", content = @Content(schema = @Schema(implementation = Void.class))), From 7fd4e4279326237a6079c0787050df8c42854157 Mon Sep 17 00:00:00 2001 From: jhonatapers Date: Sat, 23 Aug 2025 23:10:45 -0300 Subject: [PATCH 6/9] refactor: update endpoint for moving a folder to use a more descriptive path --- .../java/com/callv2/drive/infrastructure/api/FolderAPI.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/infrastructure/src/main/java/com/callv2/drive/infrastructure/api/FolderAPI.java b/infrastructure/src/main/java/com/callv2/drive/infrastructure/api/FolderAPI.java index 98ef6738..82c55ef4 100644 --- a/infrastructure/src/main/java/com/callv2/drive/infrastructure/api/FolderAPI.java +++ b/infrastructure/src/main/java/com/callv2/drive/infrastructure/api/FolderAPI.java @@ -62,7 +62,7 @@ public interface FolderAPI { }) ResponseEntity getById(@PathVariable(required = true) UUID id); - @PatchMapping(value = "{id}/move", consumes = { MediaType.APPLICATION_JSON_VALUE }, produces = { + @PatchMapping(value = "{id}/parent", consumes = { MediaType.APPLICATION_JSON_VALUE }, produces = { MediaType.APPLICATION_JSON_VALUE }) @Operation(summary = "Move a folder", description = "This method moves a folder to a new location", security = @SecurityRequirement(name = "bearerAuth")) @ApiResponses({ From cfe156dc4f51e664bca08aaa4d647d9d101d036e Mon Sep 17 00:00:00 2001 From: jhonatapers Date: Sat, 23 Aug 2025 23:34:31 -0300 Subject: [PATCH 7/9] refactor: clean up API annotations and improve response documentation --- .../drive/infrastructure/api/FileAPI.java | 91 ++++++++----------- .../drive/infrastructure/api/FolderAPI.java | 66 +++++--------- .../drive/infrastructure/api/MemberAPI.java | 17 ++-- .../infrastructure/api/MemberAdminAPI.java | 28 ++---- 4 files changed, 80 insertions(+), 122 deletions(-) diff --git a/infrastructure/src/main/java/com/callv2/drive/infrastructure/api/FileAPI.java b/infrastructure/src/main/java/com/callv2/drive/infrastructure/api/FileAPI.java index 6b8799fa..01ca14b3 100644 --- a/infrastructure/src/main/java/com/callv2/drive/infrastructure/api/FileAPI.java +++ b/infrastructure/src/main/java/com/callv2/drive/infrastructure/api/FileAPI.java @@ -4,7 +4,6 @@ import java.util.UUID; import org.springframework.core.io.Resource; -import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; @@ -27,7 +26,6 @@ import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.tags.Tag; @@ -35,59 +33,48 @@ @RequestMapping("files") public interface FileAPI { - @PostMapping(value = "/folders/{folderId}/upload", consumes = { MediaType.MULTIPART_FORM_DATA_VALUE }, produces = { - MediaType.APPLICATION_JSON_VALUE }) - @Operation(summary = "Upload a file to a specific folder", description = "This method uploads a file", security = @SecurityRequirement(name = "bearerAuth")) - @ApiResponses({ - @ApiResponse(responseCode = "201", description = "File uploaded successfully", content = @Content(schema = @Schema(implementation = CreateFileResponse.class))), - @ApiResponse(responseCode = "404", description = "Folder not found", content = @Content(schema = @Schema(implementation = Void.class))), - @ApiResponse(responseCode = "413", description = "File is too large", content = @Content(schema = @Schema(implementation = ApiError.class))), - @ApiResponse(responseCode = "500", description = "Internal Server Error", content = @Content(schema = @Schema(implementation = ApiError.class))) - }) - ResponseEntity create( - @PathVariable(required = true, name = "folderId") UUID folderId, - @RequestPart("file") MultipartFile file); + @Operation(summary = "Upload a file to a specific folder", description = "This method uploads a file", security = @SecurityRequirement(name = "bearerAuth")) + @ApiResponse(responseCode = "201", description = "File uploaded successfully", content = @Content(schema = @Schema(implementation = CreateFileResponse.class))) + @ApiResponse(responseCode = "404", description = "Folder not found", content = @Content(schema = @Schema(implementation = Void.class))) + @ApiResponse(responseCode = "413", description = "File is too large", content = @Content(schema = @Schema(implementation = ApiError.class))) + @ApiResponse(responseCode = "500", description = "Internal Server Error", content = @Content(schema = @Schema(implementation = ApiError.class))) + @PostMapping("/folders/{folderId}/upload") + ResponseEntity create( + @PathVariable(required = true, name = "folderId") UUID folderId, + @RequestPart("file") MultipartFile file); - @DeleteMapping(value = "{id}", produces = { MediaType.APPLICATION_JSON_VALUE }) - @Operation(summary = "Delete a file", description = "This method deletes a file", security = @SecurityRequirement(name = "bearerAuth")) - @ApiResponses({ - @ApiResponse(responseCode = "204", description = "File deleted successfully"), - @ApiResponse(responseCode = "404", description = "File not found", content = @Content(schema = @Schema(implementation = Void.class))), - @ApiResponse(responseCode = "500", description = "Internal Server Error", content = @Content(schema = @Schema(implementation = ApiError.class))) - }) - ResponseEntity delete(@PathVariable(required = true) UUID id); + @Operation(summary = "Delete a file", description = "This method deletes a file", security = @SecurityRequirement(name = "bearerAuth")) + @ApiResponse(responseCode = "204", description = "File deleted successfully") + @ApiResponse(responseCode = "404", description = "File not found", content = @Content(schema = @Schema(implementation = Void.class))) + @ApiResponse(responseCode = "500", description = "Internal Server Error", content = @Content(schema = @Schema(implementation = ApiError.class))) + @DeleteMapping("{id}") + ResponseEntity delete(@PathVariable(required = true) UUID id); - @GetMapping(value = "{id}", produces = { MediaType.APPLICATION_JSON_VALUE }) - @Operation(summary = "Retrive a file", description = "This method retrive a file", security = @SecurityRequirement(name = "bearerAuth")) - @ApiResponses({ - @ApiResponse(responseCode = "200", description = "File retrieved successfully", content = @Content(schema = @Schema(implementation = GetFileResponse.class))), - @ApiResponse(responseCode = "404", description = "File not found", content = @Content(schema = @Schema(implementation = Void.class))), - @ApiResponse(responseCode = "500", description = "Internal Server Error", content = @Content(schema = @Schema(implementation = ApiError.class))) - }) - ResponseEntity getById(@PathVariable(required = true) UUID id); + @Operation(summary = "Retrive a file", description = "This method retrive a file", security = @SecurityRequirement(name = "bearerAuth")) + @ApiResponse(responseCode = "200", description = "File retrieved successfully", content = @Content(schema = @Schema(implementation = GetFileResponse.class))) + @ApiResponse(responseCode = "404", description = "File not found", content = @Content(schema = @Schema(implementation = Void.class))) + @ApiResponse(responseCode = "500", description = "Internal Server Error", content = @Content(schema = @Schema(implementation = ApiError.class))) + @GetMapping("{id}") + ResponseEntity getById(@PathVariable(required = true) UUID id); - @GetMapping(value = "{id}/download", produces = { MediaType.APPLICATION_OCTET_STREAM_VALUE }) - @Operation(summary = "Download a file", description = "This method downloads a file", security = @SecurityRequirement(name = "bearerAuth")) - @ApiResponses({ - @ApiResponse(responseCode = "200", description = "File downloaded successfully", content = @Content(schema = @Schema(implementation = Resource.class))), - @ApiResponse(responseCode = "404", description = "File not found", content = @Content(schema = @Schema(implementation = Void.class))), - @ApiResponse(responseCode = "500", description = "Internal Server Error", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = ApiError.class))) - }) - ResponseEntity download(@PathVariable(required = true) UUID id); + @Operation(summary = "Download a file", description = "This method downloads a file", security = @SecurityRequirement(name = "bearerAuth")) + @ApiResponse(responseCode = "200", description = "File downloaded successfully", content = @Content(schema = @Schema(implementation = Resource.class))) + @ApiResponse(responseCode = "404", description = "File not found", content = @Content(schema = @Schema(implementation = Void.class))) + @ApiResponse(responseCode = "500", description = "Internal Server Error", content = @Content(schema = @Schema(implementation = ApiError.class))) + @GetMapping("{id}/download") + ResponseEntity download(@PathVariable(required = true) UUID id); - @GetMapping(produces = { MediaType.APPLICATION_JSON_VALUE }) - @Operation(summary = "List files", description = "This method list files", security = @SecurityRequirement(name = "bearerAuth")) - @ApiResponses({ - @ApiResponse(responseCode = "200", description = "Files listed successfully", content = @Content(schema = @Schema(implementation = Page.class, subTypes = { - FileListResponse.class }))), - @ApiResponse(responseCode = "500", description = "Internal Server Error", content = @Content(schema = @Schema(implementation = ApiError.class))) - }) - ResponseEntity> list( - @RequestParam(name = "page", required = false, defaultValue = "0") final int page, - @RequestParam(name = "perPage", required = false, defaultValue = "10") final int perPage, - @RequestParam(name = "orderField", required = false, defaultValue = "createdAt") String orderField, - @RequestParam(name = "orderDirection", required = false, defaultValue = "DESC") Pagination.Order.Direction orderDirection, - @RequestParam(name = "filterOperator", required = false, defaultValue = "AND") Filter.Operator filterOperator, - @RequestParam(name = "filters", required = false) List filters); + @Operation(summary = "List files", description = "This method list files", security = @SecurityRequirement(name = "bearerAuth")) + @ApiResponse(responseCode = "200", description = "Files listed successfully", content = @Content(schema = @Schema(implementation = Page.class, subTypes = { + FileListResponse.class }))) + @ApiResponse(responseCode = "500", description = "Internal Server Error", content = @Content(schema = @Schema(implementation = ApiError.class))) + @GetMapping + ResponseEntity> list( + @RequestParam(name = "page", required = false, defaultValue = "0") final int page, + @RequestParam(name = "perPage", required = false, defaultValue = "10") final int perPage, + @RequestParam(name = "orderField", required = false, defaultValue = "createdAt") String orderField, + @RequestParam(name = "orderDirection", required = false, defaultValue = "DESC") Pagination.Order.Direction orderDirection, + @RequestParam(name = "filterOperator", required = false, defaultValue = "AND") Filter.Operator filterOperator, + @RequestParam(name = "filters", required = false) List filters); } diff --git a/infrastructure/src/main/java/com/callv2/drive/infrastructure/api/FolderAPI.java b/infrastructure/src/main/java/com/callv2/drive/infrastructure/api/FolderAPI.java index 82c55ef4..0c5a9817 100644 --- a/infrastructure/src/main/java/com/callv2/drive/infrastructure/api/FolderAPI.java +++ b/infrastructure/src/main/java/com/callv2/drive/infrastructure/api/FolderAPI.java @@ -3,7 +3,6 @@ import java.util.List; import java.util.UUID; -import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PatchMapping; @@ -27,7 +26,6 @@ import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.tags.Tag; @@ -35,51 +33,39 @@ @RequestMapping("folders") public interface FolderAPI { - @GetMapping(value = "root", produces = { MediaType.APPLICATION_JSON_VALUE }) @Operation(summary = "Retrive a folder", description = "This method retrive a root folder", security = @SecurityRequirement(name = "bearerAuth")) - @ApiResponses({ - @ApiResponse(responseCode = "200", description = "Root folder retrieved successfully", content = @Content(schema = @Schema(implementation = GetFolderResponse.class))), - @ApiResponse(responseCode = "500", description = "Internal Server Error", content = @Content(schema = @Schema(implementation = ApiError.class))) - }) + @ApiResponse(responseCode = "200", description = "Root folder retrieved successfully", content = @Content(schema = @Schema(implementation = GetFolderResponse.class))) + @ApiResponse(responseCode = "500", description = "Internal Server Error", content = @Content(schema = @Schema(implementation = ApiError.class))) + @GetMapping("root") ResponseEntity getRoot(); - @PostMapping(consumes = { MediaType.APPLICATION_JSON_VALUE }, produces = { - MediaType.APPLICATION_JSON_VALUE }) @Operation(summary = "Create a folder", description = "This method creates a folder", security = @SecurityRequirement(name = "bearerAuth")) - @ApiResponses({ - @ApiResponse(responseCode = "201", description = "Folder created successfully", content = @Content(schema = @Schema(implementation = CreateFolderResponse.class))), - @ApiResponse(responseCode = "422", description = "A validation error was thrown", content = @Content(schema = @Schema(implementation = ApiError.class))), - @ApiResponse(responseCode = "500", description = "Internal Server Error", content = @Content(schema = @Schema(implementation = ApiError.class))) - }) + @ApiResponse(responseCode = "201", description = "Folder created successfully", content = @Content(schema = @Schema(implementation = CreateFolderResponse.class))) + @ApiResponse(responseCode = "422", description = "A validation error was thrown", content = @Content(schema = @Schema(implementation = ApiError.class))) + @ApiResponse(responseCode = "500", description = "Internal Server Error", content = @Content(schema = @Schema(implementation = ApiError.class))) + @PostMapping ResponseEntity create(@RequestBody CreateFolderRequest request); - @GetMapping(value = "{id}", produces = { MediaType.APPLICATION_JSON_VALUE }) @Operation(summary = "Retrive a folder", description = "This method retrive a folder", security = @SecurityRequirement(name = "bearerAuth")) - @ApiResponses({ - @ApiResponse(responseCode = "200", description = "Folder retrieved successfully", content = @Content(schema = @Schema(implementation = GetFolderResponse.class))), - @ApiResponse(responseCode = "404", description = "Folder not found", content = @Content(schema = @Schema(implementation = Void.class))), - @ApiResponse(responseCode = "500", description = "Internal Server Error", content = @Content(schema = @Schema(implementation = ApiError.class))) - }) + @ApiResponse(responseCode = "200", description = "Folder retrieved successfully", content = @Content(schema = @Schema(implementation = GetFolderResponse.class))) + @ApiResponse(responseCode = "404", description = "Folder not found", content = @Content(schema = @Schema(implementation = Void.class))) + @ApiResponse(responseCode = "500", description = "Internal Server Error", content = @Content(schema = @Schema(implementation = ApiError.class))) + @GetMapping("{id}") ResponseEntity getById(@PathVariable(required = true) UUID id); - @PatchMapping(value = "{id}/parent", consumes = { MediaType.APPLICATION_JSON_VALUE }, produces = { - MediaType.APPLICATION_JSON_VALUE }) @Operation(summary = "Move a folder", description = "This method moves a folder to a new location", security = @SecurityRequirement(name = "bearerAuth")) - @ApiResponses({ - @ApiResponse(responseCode = "204", description = "Folder moved successfully", content = @Content(schema = @Schema(implementation = Void.class))), - @ApiResponse(responseCode = "404", description = "Folder not found", content = @Content(schema = @Schema(implementation = Void.class))), - @ApiResponse(responseCode = "422", description = "A validation error was thrown", content = @Content(schema = @Schema(implementation = ApiError.class))), - @ApiResponse(responseCode = "500", description = "Internal Server Error", content = @Content(schema = @Schema(implementation = ApiError.class))) - }) + @ApiResponse(responseCode = "204", description = "Folder moved successfully", content = @Content(schema = @Schema(implementation = Void.class))) + @ApiResponse(responseCode = "404", description = "Folder not found", content = @Content(schema = @Schema(implementation = Void.class))) + @ApiResponse(responseCode = "422", description = "A validation error was thrown", content = @Content(schema = @Schema(implementation = ApiError.class))) + @ApiResponse(responseCode = "500", description = "Internal Server Error", content = @Content(schema = @Schema(implementation = ApiError.class))) + @PatchMapping("{id}/parent") ResponseEntity move(@PathVariable(required = true) UUID id, @RequestBody MoveFolderRequest request); - @GetMapping(produces = { MediaType.APPLICATION_JSON_VALUE }) @Operation(summary = "List folders", description = "This method list folders", security = @SecurityRequirement(name = "bearerAuth")) - @ApiResponses({ - @ApiResponse(responseCode = "200", description = "Folders listed successfully", content = @Content(schema = @Schema(implementation = Page.class, subTypes = { - FolderListResponse.class }))), - @ApiResponse(responseCode = "500", description = "Internal Server Error", content = @Content(schema = @Schema(implementation = ApiError.class))) - }) + @ApiResponse(responseCode = "200", description = "Folders listed successfully", content = @Content(schema = @Schema(implementation = Page.class, subTypes = { + FolderListResponse.class }))) + @ApiResponse(responseCode = "500", description = "Internal Server Error", content = @Content(schema = @Schema(implementation = ApiError.class))) + @GetMapping ResponseEntity> list( @RequestParam(name = "page", required = false, defaultValue = "0") final int page, @RequestParam(name = "perPage", required = false, defaultValue = "10") final int perPage, @@ -88,14 +74,12 @@ ResponseEntity> list( @RequestParam(name = "filterOperator", required = false, defaultValue = "AND") Filter.Operator filterOperator, @RequestParam(name = "filters", required = false) List filters); - @PatchMapping(value = "{id}/name", consumes = { MediaType.APPLICATION_JSON_VALUE }) @Operation(summary = "Change folder name", description = "This method changes the name of a folder", security = @SecurityRequirement(name = "bearerAuth")) - @ApiResponses({ - @ApiResponse(responseCode = "204", description = "Folder name changed successfully", content = @Content(schema = @Schema(implementation = Void.class))), - @ApiResponse(responseCode = "404", description = "Folder not found", content = @Content(schema = @Schema(implementation = Void.class))), - @ApiResponse(responseCode = "422", description = "A validation error was thrown", content = @Content(schema = @Schema(implementation = ApiError.class))), - @ApiResponse(responseCode = "500", description = "Internal Server Error", content = @Content(schema = @Schema(implementation = ApiError.class))) - }) + @ApiResponse(responseCode = "204", description = "Folder name changed successfully", content = @Content(schema = @Schema(implementation = Void.class))) + @ApiResponse(responseCode = "404", description = "Folder not found", content = @Content(schema = @Schema(implementation = Void.class))) + @ApiResponse(responseCode = "422", description = "A validation error was thrown", content = @Content(schema = @Schema(implementation = ApiError.class))) + @ApiResponse(responseCode = "500", description = "Internal Server Error", content = @Content(schema = @Schema(implementation = ApiError.class))) + @PatchMapping("{id}/name") ResponseEntity changeName(@PathVariable(required = true) UUID id, @RequestBody String request); } diff --git a/infrastructure/src/main/java/com/callv2/drive/infrastructure/api/MemberAPI.java b/infrastructure/src/main/java/com/callv2/drive/infrastructure/api/MemberAPI.java index c7e48c99..da733ae1 100644 --- a/infrastructure/src/main/java/com/callv2/drive/infrastructure/api/MemberAPI.java +++ b/infrastructure/src/main/java/com/callv2/drive/infrastructure/api/MemberAPI.java @@ -14,7 +14,6 @@ import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.tags.Tag; @@ -22,22 +21,18 @@ @RequestMapping("members") public interface MemberAPI { - @PostMapping("quotas/requests/{amount}") @Operation(summary = "Request drive quota", description = "This method request a drive ammount quota", security = @SecurityRequirement(name = "bearerAuth")) - @ApiResponses({ - @ApiResponse(responseCode = "204", description = "Requested successfuly"), - @ApiResponse(responseCode = "404", description = "Member not found", content = @Content(schema = @Schema(implementation = Void.class))) - }) + @ApiResponse(responseCode = "204", description = "Requested successfuly") + @ApiResponse(responseCode = "404", description = "Member not found", content = @Content(schema = @Schema(implementation = Void.class))) + @PostMapping("quotas/requests/{amount}") ResponseEntity requestQuota( @PathVariable(value = "amount", required = true) long amount, @RequestParam(value = "unit", defaultValue = "GIGABYTE") QuotaUnit unit); - @GetMapping("quotas") @Operation(summary = "Retrieve actual drive quota", description = "This method retrieve a drive ammount quota", security = @SecurityRequirement(name = "bearerAuth")) - @ApiResponses({ - @ApiResponse(responseCode = "200", description = "Retrieve successfuly"), - @ApiResponse(responseCode = "404", description = "Member not found", content = @Content(schema = @Schema(implementation = Void.class))) - }) + @ApiResponse(responseCode = "200", description = "Retrieve successfuly") + @ApiResponse(responseCode = "404", description = "Member not found", content = @Content(schema = @Schema(implementation = Void.class))) + @GetMapping("quotas") ResponseEntity getQuota(); } \ No newline at end of file diff --git a/infrastructure/src/main/java/com/callv2/drive/infrastructure/api/MemberAdminAPI.java b/infrastructure/src/main/java/com/callv2/drive/infrastructure/api/MemberAdminAPI.java index 544dd3ec..e2f1884e 100644 --- a/infrastructure/src/main/java/com/callv2/drive/infrastructure/api/MemberAdminAPI.java +++ b/infrastructure/src/main/java/com/callv2/drive/infrastructure/api/MemberAdminAPI.java @@ -1,6 +1,5 @@ package com.callv2.drive.infrastructure.api; -import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; @@ -18,7 +17,6 @@ import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.tags.Tag; @@ -26,31 +24,25 @@ @RequestMapping("admin/members") public interface MemberAdminAPI { - @GetMapping("{id}/quotas") @Operation(summary = "Request drive quota", description = "This method request a drive ammount quota", security = @SecurityRequirement(name = "bearerAuth")) - @ApiResponses({ - @ApiResponse(responseCode = "200", description = "Retrieve successfuly"), - @ApiResponse(responseCode = "404", description = "Member not found", content = @Content(schema = @Schema(implementation = Void.class))) - }) + @ApiResponse(responseCode = "200", description = "Retrieve successfuly") + @ApiResponse(responseCode = "404", description = "Member not found", content = @Content(schema = @Schema(implementation = Void.class))) + @GetMapping("{id}/quotas") ResponseEntity getQuota(@PathVariable(value = "id", required = true) String id); - @PostMapping("{id}/quotas/requests/approve") @Operation(summary = "Approve drive quota request", description = "This method approve a drive ammount quota request", security = @SecurityRequirement(name = "bearerAuth")) - @ApiResponses({ - @ApiResponse(responseCode = "204", description = "Approved successfuly"), - @ApiResponse(responseCode = "404", description = "Member not found", content = @Content(schema = @Schema(implementation = Void.class))) - }) + @ApiResponse(responseCode = "204", description = "Approved successfuly") + @ApiResponse(responseCode = "404", description = "Member not found", content = @Content(schema = @Schema(implementation = Void.class))) + @PostMapping("{id}/quotas/requests/approve") ResponseEntity approveQuotaRequest( @PathVariable(value = "id", required = true) String id, @RequestParam(value = "approved", defaultValue = "true") boolean approved); - @GetMapping(value = "quotas/requests", produces = { MediaType.APPLICATION_JSON_VALUE }) @Operation(summary = "List quotas requests", description = "This method list quotas requests", security = @SecurityRequirement(name = "bearerAuth")) - @ApiResponses({ - @ApiResponse(responseCode = "200", description = "Quotas requests listed successfully", content = @Content(schema = @Schema(implementation = Page.class, subTypes = { - QuotaRequestListResponse.class }))), - @ApiResponse(responseCode = "500", description = "Internal Server Error", content = @Content(schema = @Schema(implementation = ApiError.class))) - }) + @ApiResponse(responseCode = "200", description = "Quotas requests listed successfully", content = @Content(schema = @Schema(implementation = Page.class, subTypes = { + QuotaRequestListResponse.class }))) + @ApiResponse(responseCode = "500", description = "Internal Server Error", content = @Content(schema = @Schema(implementation = ApiError.class))) + @GetMapping("quotas/requests") ResponseEntity> listQuotaRequests( @RequestParam(name = "page", required = false, defaultValue = "0") final int page, @RequestParam(name = "perPage", required = false, defaultValue = "10") final int perPage, From dc25f2984f25baa87c0b913ba3038c35265334c2 Mon Sep 17 00:00:00 2001 From: jhonatapers Date: Sun, 24 Aug 2025 18:48:09 -0300 Subject: [PATCH 8/9] refactor: update FileAPI to use @RequestParam for folderId and change MemberAdminAPI to use @PatchMapping for quota approval --- .../callv2/drive/infrastructure/api/FileAPI.java | 16 ++++++++-------- .../drive/infrastructure/api/MemberAdminAPI.java | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/infrastructure/src/main/java/com/callv2/drive/infrastructure/api/FileAPI.java b/infrastructure/src/main/java/com/callv2/drive/infrastructure/api/FileAPI.java index 01ca14b3..9f61d40f 100644 --- a/infrastructure/src/main/java/com/callv2/drive/infrastructure/api/FileAPI.java +++ b/infrastructure/src/main/java/com/callv2/drive/infrastructure/api/FileAPI.java @@ -4,6 +4,7 @@ import java.util.UUID; import org.springframework.core.io.Resource; +import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; @@ -11,7 +12,6 @@ import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; import com.callv2.drive.domain.pagination.Filter; @@ -38,31 +38,31 @@ public interface FileAPI { @ApiResponse(responseCode = "404", description = "Folder not found", content = @Content(schema = @Schema(implementation = Void.class))) @ApiResponse(responseCode = "413", description = "File is too large", content = @Content(schema = @Schema(implementation = ApiError.class))) @ApiResponse(responseCode = "500", description = "Internal Server Error", content = @Content(schema = @Schema(implementation = ApiError.class))) - @PostMapping("/folders/{folderId}/upload") + @PostMapping(consumes = MediaType.MULTIPART_FORM_DATA_VALUE) ResponseEntity create( - @PathVariable(required = true, name = "folderId") UUID folderId, - @RequestPart("file") MultipartFile file); + @RequestParam("folderId") UUID folderId, + @RequestParam("file") MultipartFile file); @Operation(summary = "Delete a file", description = "This method deletes a file", security = @SecurityRequirement(name = "bearerAuth")) @ApiResponse(responseCode = "204", description = "File deleted successfully") @ApiResponse(responseCode = "404", description = "File not found", content = @Content(schema = @Schema(implementation = Void.class))) @ApiResponse(responseCode = "500", description = "Internal Server Error", content = @Content(schema = @Schema(implementation = ApiError.class))) @DeleteMapping("{id}") - ResponseEntity delete(@PathVariable(required = true) UUID id); + ResponseEntity delete(@PathVariable UUID id); @Operation(summary = "Retrive a file", description = "This method retrive a file", security = @SecurityRequirement(name = "bearerAuth")) @ApiResponse(responseCode = "200", description = "File retrieved successfully", content = @Content(schema = @Schema(implementation = GetFileResponse.class))) @ApiResponse(responseCode = "404", description = "File not found", content = @Content(schema = @Schema(implementation = Void.class))) @ApiResponse(responseCode = "500", description = "Internal Server Error", content = @Content(schema = @Schema(implementation = ApiError.class))) @GetMapping("{id}") - ResponseEntity getById(@PathVariable(required = true) UUID id); + ResponseEntity getById(@PathVariable UUID id); @Operation(summary = "Download a file", description = "This method downloads a file", security = @SecurityRequirement(name = "bearerAuth")) @ApiResponse(responseCode = "200", description = "File downloaded successfully", content = @Content(schema = @Schema(implementation = Resource.class))) @ApiResponse(responseCode = "404", description = "File not found", content = @Content(schema = @Schema(implementation = Void.class))) @ApiResponse(responseCode = "500", description = "Internal Server Error", content = @Content(schema = @Schema(implementation = ApiError.class))) - @GetMapping("{id}/download") - ResponseEntity download(@PathVariable(required = true) UUID id); + @GetMapping("{id}/content") + ResponseEntity download(@PathVariable UUID id); @Operation(summary = "List files", description = "This method list files", security = @SecurityRequirement(name = "bearerAuth")) @ApiResponse(responseCode = "200", description = "Files listed successfully", content = @Content(schema = @Schema(implementation = Page.class, subTypes = { diff --git a/infrastructure/src/main/java/com/callv2/drive/infrastructure/api/MemberAdminAPI.java b/infrastructure/src/main/java/com/callv2/drive/infrastructure/api/MemberAdminAPI.java index e2f1884e..f3ea018a 100644 --- a/infrastructure/src/main/java/com/callv2/drive/infrastructure/api/MemberAdminAPI.java +++ b/infrastructure/src/main/java/com/callv2/drive/infrastructure/api/MemberAdminAPI.java @@ -2,8 +2,8 @@ import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PatchMapping; import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; @@ -33,7 +33,7 @@ public interface MemberAdminAPI { @Operation(summary = "Approve drive quota request", description = "This method approve a drive ammount quota request", security = @SecurityRequirement(name = "bearerAuth")) @ApiResponse(responseCode = "204", description = "Approved successfuly") @ApiResponse(responseCode = "404", description = "Member not found", content = @Content(schema = @Schema(implementation = Void.class))) - @PostMapping("{id}/quotas/requests/approve") + @PatchMapping("{id}/quotas/requests") ResponseEntity approveQuotaRequest( @PathVariable(value = "id", required = true) String id, @RequestParam(value = "approved", defaultValue = "true") boolean approved); From 0ec76b21a6f273e340e6055e868923f1a7c52400 Mon Sep 17 00:00:00 2001 From: jhonatapers Date: Sun, 24 Aug 2025 18:48:44 -0300 Subject: [PATCH 9/9] refactor: update Spring Boot version to 3.5.5 and change deprecated specification usage in repositories --- infrastructure/build.gradle | 2 +- .../callv2/drive/infrastructure/file/FileJPAGateway.java | 2 +- .../callv2/drive/infrastructure/filter/FilterService.java | 6 +++--- .../drive/infrastructure/folder/FolderJpaGateway.java | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/infrastructure/build.gradle b/infrastructure/build.gradle index c5ab35fc..ebd9c95d 100644 --- a/infrastructure/build.gradle +++ b/infrastructure/build.gradle @@ -1,7 +1,7 @@ plugins { id 'java' id 'application' - id 'org.springframework.boot' version '3.4.6' + id 'org.springframework.boot' version '3.5.5' id 'io.spring.dependency-management' version '1.1.7' } diff --git a/infrastructure/src/main/java/com/callv2/drive/infrastructure/file/FileJPAGateway.java b/infrastructure/src/main/java/com/callv2/drive/infrastructure/file/FileJPAGateway.java index 59bda478..825302a8 100644 --- a/infrastructure/src/main/java/com/callv2/drive/infrastructure/file/FileJPAGateway.java +++ b/infrastructure/src/main/java/com/callv2/drive/infrastructure/file/FileJPAGateway.java @@ -61,7 +61,7 @@ public Page findAll(final SearchQuery searchQuery) { searchQuery.filters()); final org.springframework.data.domain.Page pageResult = this.fileRepository - .findAll(Specification.where(specification), page); + .findAll(specification, page); return new Page<>( pageResult.getNumber(), diff --git a/infrastructure/src/main/java/com/callv2/drive/infrastructure/filter/FilterService.java b/infrastructure/src/main/java/com/callv2/drive/infrastructure/filter/FilterService.java index c95c8fd7..5e58773f 100644 --- a/infrastructure/src/main/java/com/callv2/drive/infrastructure/filter/FilterService.java +++ b/infrastructure/src/main/java/com/callv2/drive/infrastructure/filter/FilterService.java @@ -23,12 +23,12 @@ public Specification buildSpecification( final List filters) { if (filterMethod.equals(Filter.Operator.AND)) - return Specification.where(andSpecifications(buildSpecifications(entityClass, filters))); + return andSpecifications(buildSpecifications(entityClass, filters)); if (filterMethod.equals(Filter.Operator.OR)) - return Specification.where(orSpecifications(buildSpecifications(entityClass, filters))); + return orSpecifications(buildSpecifications(entityClass, filters)); - return Specification.where(andSpecifications(buildSpecifications(entityClass, filters))); + return andSpecifications(buildSpecifications(entityClass, filters)); } private List> buildSpecifications(Class entityClass, diff --git a/infrastructure/src/main/java/com/callv2/drive/infrastructure/folder/FolderJpaGateway.java b/infrastructure/src/main/java/com/callv2/drive/infrastructure/folder/FolderJpaGateway.java index 59365ad8..bd2f6843 100644 --- a/infrastructure/src/main/java/com/callv2/drive/infrastructure/folder/FolderJpaGateway.java +++ b/infrastructure/src/main/java/com/callv2/drive/infrastructure/folder/FolderJpaGateway.java @@ -81,7 +81,7 @@ public Page findAll(SearchQuery searchQuery) { searchQuery.filters()); final org.springframework.data.domain.Page pageResult = this.folderRepository.findAll( - Specification.where(specification), + specification, page); return new Page<>(