Implementation of category updating.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user