Привет, братья и сестры, могу ли я решить этот метод с помощью потокового API? Я пытаюсь, но не могу
public Response addDetail(DetailDto detailDto) {
Optional ordersOptional = orderRepo.findById(detailDto.getOrderId());
if (ordersOptional.isEmpty()) return new Response("it is order not found", false);
Optional productOptional = productRepo.findById(detailDto.getProductId());
if (productOptional.isEmpty()) return new Response("it is product not found", false);
Detail detail = new Detail();
detail.setOrders(ordersOptional.get());
detail.setProduct(productOptional.get());
detail.setQuantity(detailDto.getQuantity());
detailRepo.save(detail);
return new Response("order saved successfully", true);
}
Подробнее здесь: https://stackoverflow.com/questions/699 ... stream-api