Skip to content

Conversation

@stefadan
Copy link
Collaborator

No description provided.

Copy link
Owner

@adrianbucur83 adrianbucur83 left a comment

Choose a reason for hiding this comment

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

Nice job overall, see comments

//create ShoppingCart
@PostMapping
@ResponseStatus(HttpStatus.CREATED)
public void createShoppingCart(@RequestBody ShoppingCartDto shoppingCartDto){
Copy link
Owner

Choose a reason for hiding this comment

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

}

@GetMapping("/description/{description}")
public List<ShoppingCartReturnDto> getShoppingCartByDescription
Copy link
Owner

Choose a reason for hiding this comment

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

shopping carts are a bit special, you kinda want to set a cookie on the users' browser to identify his shopping cart id so that every time he comes to your website he has the products already in the cart. Maybe you want to implement something like this

Copy link
Owner

Choose a reason for hiding this comment

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

also don't take long strings as path variables it use request param better or request body. it will make your urls like this:

http://mysite.com/also%20don't%20take%20long%20strings%20as

//update ShoppingCart
@PutMapping
@ResponseStatus(HttpStatus.NO_CONTENT)
public void updateShoppingCart(@RequestBody ShoppingCartUpdateDto shoppingCartUpdateDto){
Copy link
Owner

Choose a reason for hiding this comment

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

add validation

//@Data
//@Builder
@Entity
@Table(name="shopping_cart")
Copy link
Owner

Choose a reason for hiding this comment

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

use plural


List<ShoppingCart> findByDescriptionProduct(String description);

@Query(value="SELECT * FROM public.shopping_cart s WHERE s.description_product = :description",
Copy link
Owner

Choose a reason for hiding this comment

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

nice mix of native and jpa queries, good job

{
throw new RuntimeException("Delivery cannot be made on date specified");
}
if (shoppingCartDto.getDescriptionProduct().length()<1)
Copy link
Owner

Choose a reason for hiding this comment

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

you can use the the @Valid on the dto to check for min length and such

public void create(ShoppingCartDto shoppingCartDto){
if (!shoppingCartDto.isAvailability())
{
throw new RuntimeException("Delivery is not available");
Copy link
Owner

Choose a reason for hiding this comment

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

define your own exception eg BusinessException and maybe an @ExceptionHandler too

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.

3 participants