chore: Refactor CategoryController and CategoryService to return created category
This commit is contained in:
parent
cf1babf069
commit
146eb0e8f5
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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() {
|
||||
|
Loading…
Reference in New Issue
Block a user