Created
September 25, 2022 11:04
-
-
Save GayanM/8125b64837c220742d9f0264ab61722b to your computer and use it in GitHub Desktop.
Produce a data map with order record and product total sum
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RequestMapping("/product-total-sum") | |
public Map<Order, Double> getProductTotalSumByOrder() { | |
return orderRepo.findAll().stream().collect(Collectors.toMap(o -> new Order(o.getId(), o.getOrderDate(), | |
o.getDeliveryDate(), o.getStatus()), o -> o.getProducts().stream().mapToDouble(p -> | |
p.getPrice()).sum())); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment