docs: data transfer object + refactor

This commit is contained in:
Ilkka Seppälä
2024-04-07 18:44:04 +03:00
parent b8f5d46ba7
commit 99f77f8119
6 changed files with 112 additions and 128 deletions
@@ -67,15 +67,15 @@ public class App {
var customerResource = new CustomerResource(customers);
LOGGER.info("All customers:-");
var allCustomers = customerResource.getAllCustomers();
LOGGER.info("All customers:");
var allCustomers = customerResource.customers();
printCustomerDetails(allCustomers);
LOGGER.info("----------------------------------------------------------");
LOGGER.info("Deleting customer with id {1}");
customerResource.delete(customerOne.getId());
allCustomers = customerResource.getAllCustomers();
customerResource.delete(customerOne.id());
allCustomers = customerResource.customers();
printCustomerDetails(allCustomers);
LOGGER.info("----------------------------------------------------------");
@@ -83,7 +83,7 @@ public class App {
LOGGER.info("Adding customer three}");
var customerThree = new CustomerDto("3", "Lynda", "Blair");
customerResource.save(customerThree);
allCustomers = customerResource.getAllCustomers();
allCustomers = customerResource.customers();
printCustomerDetails(allCustomers);
// Example 2: Product DTO
@@ -131,10 +131,10 @@ public class App {
productResource.save(createProductRequestDto);
LOGGER.info(
"####### List of products after adding PS5: {}",
Arrays.toString(productResource.getProducts().toArray()));
Arrays.toString(productResource.products().toArray()));
}
private static void printCustomerDetails(List<CustomerDto> allCustomers) {
allCustomers.forEach(customer -> LOGGER.info(customer.getFirstName()));
allCustomers.forEach(customer -> LOGGER.info(customer.firstName()));
}
}