import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import java.util.*; @RestController public class CheckoutController { @GetMapping("/checkout") public Map checkout( @RequestParam String products, @RequestParam(required = false) String coupon) { // Parse products Map productQuantities = new HashMap<>(); for (String productEntry : products.split(",")) { String[] parts = productEntry.split(":"); productQuantities.put( parts[0], // Product ID Integer.parseInt(parts[1]) // Quantity ); } // Build result Map result = new HashMap<>(); result.put("products", productQuantities); result.put("coupon", coupon != null ? coupon : "No coupon applied"); return result; } }
top of page
Stephen Patrick

Stephen Patrick

Writer

Functional Organization Expert

More actions

Profile

Join date: Feb 2, 2024

Posts (105)

Feb 18, 20266 min
How a Spaced-Out Closet Makes Mornings Faster
We have all been there: it’s 7:15 AM, you’re five minutes behind schedule, and you’re standing in front of a closet packed so tight you need both hands to pry two hangers apart. By the time you find your attire of the day, it’s a messy doppelganger of your favorite shirt having been crushed between a heavy coat and a blazer you haven’t worn for ages. The "closet struggle" is more than a minor annoyance; it’s a form of decision fatigue that drains your mental energy before the day begins. The...

2
0
Jan 31, 20267 min
How to Get Creases Out of Clothes (And Keep Them Out)
Let’s be real: you almost certainly own an iron. It’s likely sitting in a cupboard, wrapped in its cord, waiting for a wedding, a job interview, or a very specific formal event. But for the day-to-day grind? Most of us avoid it at all costs. Dragging out the squeaky ironing board and waiting for the iron to heat up is not how anyone wants to spend their morning. Yet, walking out the door looking crumpled isn't an option either. A sharp outfit commands respect, while a wrinkled one suggests...

11
0
2
Jan 28, 20268 min
Will Perfume Stain Clothes? (Prevention & Removal Tips)
You spend good money on your wardrobe. You spend good money on your perfume. It is ironic, then, that putting these two things together can result in an expensive disaster. There is a common misconception that because perfume is a liquid spray, it will just "dry clear." Unfortunately, that is often not the case. If you have ever ruined a silk scarf or noticed a yellow tint on your favorite tee, you already know the answer to "will perfume stain clothes." But you don't have to choose between...

15
0
2
bottom of page