Skip to content

Order Model || HW#12

Merged
Jelors merged 10 commits into
mainfrom
om-hw
Dec 26, 2025
Merged

Order Model || HW#12
Jelors merged 10 commits into
mainfrom
om-hw

Conversation

@Jelors

@Jelors Jelors commented Dec 22, 2025

Copy link
Copy Markdown
Owner

No description provided.

@Elena-Bruyako Elena-Bruyako left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

see comments

@PreAuthorize("hasAnyRole('USER', 'ADMIN')")
@Operation(summary = "Place an order", description = "Place an order")
public ResponseEntity<OrderResponseDto> placeOrder(
@RequestBody String shippingAddress

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

create dto

@RestController
@RequestMapping("/orders/{orderId}/items")
@RequiredArgsConstructor
public class OrderItemController {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

all logic should be in OrderController

@Getter
@Setter
public class UpdateOrderStatusDto {
private Order.Status status;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

add validation

@@ -0,0 +1,7 @@
package com.springm.store.exception;

public class UserNotFoundException extends RuntimeException {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

remove

Comment on lines +14 to +17
@Mapping(source = "bookId", target = "bookId")
@Mapping(source = "bookTitle", target = "bookTitle")
@Mapping(source = "quantity", target = "quantity")
@Mapping(source = "price", target = "price")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
@Mapping(source = "bookId", target = "bookId")
@Mapping(source = "bookTitle", target = "bookTitle")
@Mapping(source = "quantity", target = "quantity")
@Mapping(source = "price", target = "price")

@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@ManyToOne

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

add LAZY

Comment on lines +59 to +64
@JsonManagedReference
@JoinTable(
name = "orders_parts",
joinColumns = @JoinColumn(name = "order_id"),
inverseJoinColumns = @JoinColumn(name = "order_item_id")
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
@JsonManagedReference
@JoinTable(
name = "orders_parts",
joinColumns = @JoinColumn(name = "order_id"),
inverseJoinColumns = @JoinColumn(name = "order_item_id")
)

@Service
@Transactional
@RequiredArgsConstructor
public class OrderItemServiceImpl implements OrderItemService {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

all logic should be in OrderService

public User getCurrentUser() {
Long userId = getCurrentUserId();
return userRepository.findById(userId)
.orElseThrow(() -> new UserNotFoundException(

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
.orElseThrow(() -> new UserNotFoundException(
.orElseThrow(() -> new EntityNotFoundException(

@@ -0,0 +1,40 @@
databaseChangeLog:
- changeSet:
id: create-books-categories-table

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

remove

@Jelors Jelors requested a review from Elena-Bruyako December 24, 2025 10:47
@Jelors Jelors merged commit 0f39915 into main Dec 26, 2025
2 checks passed
@Jelors Jelors deleted the om-hw branch December 26, 2025 08:19
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