chore: Refactor CategoryController and CategoryService to return created category

This commit is contained in:
Erik Foris 2024-07-06 21:59:22 +02:00
parent cf1babf069
commit 146eb0e8f5
2 changed files with 4 additions and 4 deletions

View File

@ -37,8 +37,8 @@ public class CategoryController {
}
@ResponseStatus(HttpStatus.CREATED)
@PostMapping
public void createCategory(@RequestBody CategoryDto dto) {
categoryService.addCategory(dto);
public Category createCategory(@RequestBody CategoryDto dto) {
return categoryService.addCategory(dto);
}

View File

@ -12,9 +12,9 @@ public class CategoryService {
this.categoryRepository = categoryRepository;
}
void addCategory(CategoryDto category) {
Category addCategory(CategoryDto category) {
Category cat = new Category(category.getName());
categoryRepository.save(cat);
return categoryRepository.save(cat);
}
List<CategoryDto> getAllCategories() {