Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public Category(final AddCategoryRequest categoryRequest) {
this.name = categoryRequest.name();
this.description = categoryRequest.description();
}

public void addItem(final Item item) {
items.add(item);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.Set;

Expand Down Expand Up @@ -61,6 +63,7 @@ public Category updateCategory(final UpdateCategoryRequest updateCategoryRequest
return categoryRepository.save(updatedCategory);
}

@Transactional(propagation = Propagation.REQUIRED)
public Category addItemToCategory(final Long categoryId, final Long itemId) {
final Category category = findById(categoryId);
final Item item = itemService.findById(itemId);
Expand Down