Merge branch '53-respond-with-the-new-category-json-when-creating-a-new-category' into '22-integrate-api-and-frontend'

Resolve "Respond with the new category JSON when creating a new category"

See merge request padas/24ss-5430-web-and-data-eng/gruppe-3/datadash!53
This commit is contained in:
Erik Foris 2024-07-06 21:59:48 +02:00
commit 69b6697f62
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() {