-
Notifications
You must be signed in to change notification settings - Fork 343
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Created simple app for working with products and its categories #319
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job, you can improve it if you want
@RequestParam BigDecimal priceTo) { | ||
return productService.getAllByPriceBetween(priceFrom, priceTo).stream() | ||
.map(dtoMapper::toDto) | ||
.collect(Collectors.toList()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use short option
.collect(Collectors.toList()); | |
.toList(); |
public List<ProductResponseDto> getAllByCategoryIds(@RequestParam Set<Long> categoryIds) { | ||
List<Product> allByCategoryIds = productService.getAllByCategoryIds(categoryIds); | ||
return allByCategoryIds.stream() | ||
.map(dtoMapper::toDto).collect(Collectors.toList()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.map(dtoMapper::toDto).collect(Collectors.toList()); | |
.map(dtoMapper::toDto).toList(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, you are right. But I'm not using toList() in homework cos this method appears in Java 16 but most of our homework uses Java 11. I missed that this task is using Java 17. Also, I had some problems before with List immutability after using the "toList()" method, so...
|
||
@Data | ||
public class CategoryResponseDto { | ||
private Long id; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need send id in response?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, I want to return the ID of the saved element
|
||
@Data | ||
public class ProductResponseDto { | ||
private Long id; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same, do you realy need send id in Response?
@Getter | ||
@Setter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use one annotation Data
@Getter | |
@Setter | |
@Data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's great you're using technologies studied during the group project :)) Good job!
No description provided.