Skip to content

Order controler service jpa#12

Open
den021987 wants to merge 8 commits intomasterfrom
orderControlerServiceJpa
Open

Order controler service jpa#12
den021987 wants to merge 8 commits intomasterfrom
orderControlerServiceJpa

Conversation

@den021987
Copy link
Copy Markdown
Collaborator

Order controler service jpa

Copy link
Copy Markdown
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.

see comments

private Long totalAmount;
private LocalDateTime dateTime;
private String address;
private boolean orderStatus;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

isActive? isValid?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

fixed

private Long orderId;
private String customerName;
private Long totalAmount;
private LocalDateTime dateTime;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

createDate

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

fixed

private String address;
private boolean orderStatus;
private String notes;
private Long userId;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

private User user

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

fixed

return "orders/order";
}

@GetMapping("/statustrue")
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

/status/{status} <--- pathvariable

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

fixed

public interface OrderRepository extends JpaRepository<Order, Long> {

List<Order> findAllByOrderStatusTrue();

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

findAllByStatus(String status) (would work if you have a field called status)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

fixed

}

@GetMapping("/new")
public String createOrder(Model model){
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

createOrderForm/Input

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

fixed

}

@PostMapping
public String showOrders(@ModelAttribute("order") OrderDto orderDto){
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

the true createOrder

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

fixed

public String editOrder(@PathVariable("orderId") Long orderId , Model model) {

Order order = orderService.getOrderById(orderId);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

all good here

@NoArgsConstructor
public class OrderDto {

private Long orderId;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Should have separate DTOs for different actions. C R U D <--

order.setDateTime(orderDto.getDateTime());
order.setOrderStatus(orderDto.isOrderStatus());
order.setAddress(orderDto.getAddress());
order.setNotes(orderDto.getNotes());
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Good stuff!

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