use account object instead of map
This commit is contained in:
@ -12,9 +12,9 @@ import java.util.HashMap;
|
|||||||
public class MoneyTransferController {
|
public class MoneyTransferController {
|
||||||
|
|
||||||
// Global accounts variable
|
// Global accounts variable
|
||||||
private static final Map<String, Map<String, Double>> accounts = new HashMap<String, Map<String, Double>>() {{
|
private static final Map<String, Account> accounts = new HashMap<String, Account>() {{
|
||||||
put("1", new HashMap<String, Double>() {{ put("amount", 1000.0); }});
|
put("1", new Account("1", 1000.0));
|
||||||
put("2", new HashMap<String, Double>() {{ put("amount", 1000.0); }});
|
put("2", new Account("2", 1000.0));
|
||||||
}};
|
}};
|
||||||
|
|
||||||
@PostMapping("/transfer")
|
@PostMapping("/transfer")
|
||||||
@ -33,6 +33,17 @@ public class MoneyTransferController {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class Account {
|
||||||
|
private String id;
|
||||||
|
private Double amount;
|
||||||
|
|
||||||
|
public Account(String id, Double amount) {
|
||||||
|
this.id = id;
|
||||||
|
this.amount = amount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public static class TransferRequest {
|
public static class TransferRequest {
|
||||||
private Double amount;
|
private Double amount;
|
||||||
|
|||||||
Reference in New Issue
Block a user