Implementation of category updating.

This commit is contained in:
Florian THIERRY
2024-03-12 14:42:57 +01:00
parent b0e682e82e
commit 94180e8efc
4 changed files with 44 additions and 1 deletions

View File

@@ -1,12 +1,15 @@
package org.codiki.exposition.category;
import java.util.UUID;
import static org.springframework.http.HttpStatus.CREATED;
import org.codiki.application.category.CategoryUseCases;
import org.codiki.domain.category.model.Category;
import org.codiki.exposition.category.model.CategoryDto;
import org.codiki.exposition.category.model.CategoryEditionRequest;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseStatus;
@@ -27,4 +30,17 @@ public class CategoryController {
Category createdCategory = categoryUseCases.createCategory(request.name(), request.subCategoryIds());
return new CategoryDto(createdCategory);
}
@PutMapping("/{categoryId}")
public CategoryDto updateCategory(
@PathVariable("categoryId") UUID categoryId,
@RequestBody CategoryEditionRequest request
) {
Category createdCategory = categoryUseCases.updateCategory(
categoryId,
request.name(),
request.subCategoryIds()
);
return new CategoryDto(createdCategory);
}
}