Skip to content

Added Spring JPA data layer#29

Open
mynameiszp wants to merge 8 commits intomasterfrom
rapira
Open

Added Spring JPA data layer#29
mynameiszp wants to merge 8 commits intomasterfrom
rapira

Conversation

@mynameiszp
Copy link
Copy Markdown
Collaborator

No description provided.

…apira

# Conflicts:
#	src/main/java/com/example/springlabs/configuration/StoreConfiguration.java
#	src/main/java/com/example/springlabs/repositories/CategoryRepository.java
#	src/main/java/com/example/springlabs/repositories/CategoryRepositoryImpl.java
#	src/main/java/com/example/springlabs/repositories/ProductRepository.java
#	src/main/java/com/example/springlabs/repositories/ProductRepositoryImpl.java
#	src/main/java/com/example/springlabs/repositories/UserRepository.java
#	src/main/java/com/example/springlabs/repositories/UserRepositoryImpl.java
#	src/main/java/com/example/springlabs/services/CategoryService.java
#	src/main/java/com/example/springlabs/services/ProductService.java
#	src/main/java/com/example/springlabs/services/UserService.java
Copy link
Copy Markdown
Collaborator

@xd6d xd6d left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And we have no implementation for creating sub-category

Comment thread src/main/java/com/example/springlabs/repositories/CategoryRepository.java Outdated
@Transactional
public Category addCategory(Category category) {
categoryRepository.save(category);
return category;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can simplify it just to return categoryRepository.save(category);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and for some reason there is no line formatting

long id = saveParseId(stringId);
return categoryRepository.updateCategory(id, categoryFromDto, getSubcategories(categoriesNames))
.orElseThrow(() -> new CategoryNotFoundException(CATEGORY_ID_NOT_FOUND.formatted(stringId)));
getCategoryByName(categoriesNames);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is useless

@mynameiszp mynameiszp requested a review from xd6d December 7, 2023 09:30
Comment on lines +93 to +97
Optional<Category> category = categoryService.addCategory(categoryDtoMapper.createCategoryFromDto(categoryDto), urlComponents);
if (category.isEmpty()) {
throw new CategoryNotFoundException(
CATEGORY_NAME_NOT_FOUND.formatted("Category is empty"));
} else return categoryDtoMapper.createDto(category.get());
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO, this logic is better to move to the CategoryService and leave here only return categoryDtoMapper.createDto(categoryService.addCategory(categoryDtoMapper.createCategoryFromDto(categoryDto), urlComponents));

@mynameiszp mynameiszp requested a review from xd6d December 7, 2023 10:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants