define api controller
This commit is contained in:
@@ -59,9 +59,43 @@ public class ApiController { // SINGLETON
|
||||
|
||||
/* Update Customer List */
|
||||
CustomerManager.getInstance().save();
|
||||
|
||||
InventoryList customerCart = new InventoryList();
|
||||
customerCart.add(InventoryManager.getInstance().INVENTORY.getFirst());
|
||||
customerCart.add(InventoryManager.getInstance().INVENTORY.getLast());
|
||||
|
||||
enterTransaction(CustomerManager.getInstance().findByEmail("kate@museum.com"), customerCart);
|
||||
}
|
||||
|
||||
return new ResponseEntity<>("Resource loaded!", HttpStatus.OK);
|
||||
InventoryManager imgr = InventoryManager.getInstance();
|
||||
|
||||
return new ResponseEntity<>("Resource loaded! \n" + String.format("Art Pieces in INVENTORY: count %d", imgr.INVENTORY.size())
|
||||
, HttpStatus.OK);
|
||||
}
|
||||
|
||||
static void enterTransaction(Customer customer, InventoryList customerCart){
|
||||
|
||||
TransactionManager tmgr = TransactionManager.getInstance();
|
||||
tmgr.load();
|
||||
/*
|
||||
* 3. Add a new transaction object to the list manager is handling
|
||||
*/
|
||||
Transaction tran = tmgr.TransactRequest(customer, customerCart);
|
||||
/*
|
||||
* 4. Calculate and return transaction price
|
||||
* 5. Complete transaction
|
||||
|
||||
*/
|
||||
tmgr.compute(tran);
|
||||
tmgr.complete(tran);
|
||||
/*
|
||||
* 9. Update inventory file(s) on local system
|
||||
*/
|
||||
InventoryManager.getInstance().save();
|
||||
/*
|
||||
* 10. Update transaction file(s) on local system
|
||||
*/
|
||||
TransactionManager.getInstance().save();
|
||||
}
|
||||
|
||||
static void callerInterface() {
|
||||
@@ -93,25 +127,10 @@ public class ApiController { // SINGLETON
|
||||
return;
|
||||
}
|
||||
|
||||
CustomerManager cmgr = CustomerManager.getInstance();
|
||||
Customer customer = cmgr.findByEmail("kate@museum.com");
|
||||
InventoryList customerCart = new InventoryList();
|
||||
customerCart.add(imgr.INVENTORY.getFirst());
|
||||
customerCart.add(imgr.INVENTORY.getLast());
|
||||
Transaction tran = null;
|
||||
TransactionManager tmgr = null;
|
||||
|
||||
TransactionManager tmgr = TransactionManager.getInstance();
|
||||
tmgr.load();
|
||||
/*
|
||||
* 3. Add a new transaction object to the list manager is handling
|
||||
*/
|
||||
Transaction tran = tmgr.TransactRequest(customer, customerCart);
|
||||
/*
|
||||
* 4. Calculate and return transaction price
|
||||
* 5. Complete transaction
|
||||
* 6. Remove transaction object
|
||||
*/
|
||||
tmgr.compute(tran);
|
||||
tmgr.complete(tran);
|
||||
//* 6. Remove transaction object
|
||||
// tmgr.remove(tran);
|
||||
/*
|
||||
* 7. Format and return transaction data in print format
|
||||
@@ -121,6 +140,7 @@ public class ApiController { // SINGLETON
|
||||
* 8. Retrieve and return transactions based on:
|
||||
* customer email
|
||||
*/
|
||||
Customer customer = CustomerManager.getInstance().findByEmail("kate@museum.com");
|
||||
TransactionList foundTrans = tmgr.findByCustomerEmail(customer.getEmail());
|
||||
/*
|
||||
* transaction date
|
||||
@@ -134,15 +154,6 @@ public class ApiController { // SINGLETON
|
||||
* art id
|
||||
*/
|
||||
foundTrans = tmgr.findByTransactionId(tran.getId());
|
||||
|
||||
/*
|
||||
* 9. Update inventory file(s) on local system
|
||||
*/
|
||||
InventoryManager.getInstance().save();
|
||||
/*
|
||||
* 10. Update transaction file(s) on local system
|
||||
*/
|
||||
TransactionManager.getInstance().save();
|
||||
}
|
||||
|
||||
static Drawing make(Drawing o) {
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
[
|
||||
{
|
||||
"email": "kate@museum.com",
|
||||
"id": "2020281777",
|
||||
"id": "3138660874",
|
||||
"nameFirst": "Kate",
|
||||
"nameLast": "Demsey",
|
||||
"phone": "310-676-4844"
|
||||
},
|
||||
{
|
||||
"email": "jim@homedeco.com",
|
||||
"id": "5261329301",
|
||||
"id": "2183321125",
|
||||
"nameFirst": "Jim",
|
||||
"nameLast": "Gumbly",
|
||||
"phone": "203-676-4844"
|
||||
},
|
||||
{
|
||||
"email": "evan@homedeco.com",
|
||||
"id": "4961460829",
|
||||
"id": "5208154740",
|
||||
"nameFirst": "Evan",
|
||||
"nameLast": "Hao",
|
||||
"phone": "203-676-8943"
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
{
|
||||
"Author": "Dave Janson",
|
||||
"author": "Dave Janson",
|
||||
"created": "2026-01-28T18:21:41.628880822-05:00[America/New_York]",
|
||||
"created": "2026-01-29T20:03:27.5385961-05:00[America/New_York]",
|
||||
"description": "East Market Square find. Local Author.",
|
||||
"id": "3215738680",
|
||||
"id": "2679997537",
|
||||
"price": 92.0,
|
||||
"title": "Windy Rowing",
|
||||
"type": "DRAWING"
|
||||
@@ -12,9 +12,9 @@
|
||||
{
|
||||
"Author": "Dave Janson",
|
||||
"author": "Dave Janson",
|
||||
"created": "2026-01-28T18:21:41.628927081-05:00[America/New_York]",
|
||||
"created": "2026-01-29T20:03:27.5385961-05:00[America/New_York]",
|
||||
"description": "East Market Square find. Local Author.",
|
||||
"id": "5150484617",
|
||||
"id": "3264962183",
|
||||
"price": 102.0,
|
||||
"title": "Different day same thing",
|
||||
"type": "PRINT"
|
||||
@@ -22,9 +22,9 @@
|
||||
{
|
||||
"Author": "Dave Janson",
|
||||
"author": "Dave Janson",
|
||||
"created": "2026-01-28T18:21:41.628966511-05:00[America/New_York]",
|
||||
"created": "2026-01-29T20:03:27.5385961-05:00[America/New_York]",
|
||||
"description": "East Market Square find. Local Author.",
|
||||
"id": "4279724246",
|
||||
"id": "4028811925",
|
||||
"price": 51.0,
|
||||
"title": "Walking by the beach.",
|
||||
"type": "PAINTING",
|
||||
@@ -34,9 +34,9 @@
|
||||
{
|
||||
"Author": "Dave Janson",
|
||||
"author": "Dave Janson",
|
||||
"created": "2026-01-28T18:21:41.628997921-05:00[America/New_York]",
|
||||
"created": "2026-01-29T20:03:27.5385961-05:00[America/New_York]",
|
||||
"description": "East Market Square find. Local Author.",
|
||||
"id": "2561610938",
|
||||
"id": "4044784693",
|
||||
"price": 32.0,
|
||||
"title": "Jolly Romp",
|
||||
"type": "SCULPTURE",
|
||||
@@ -45,9 +45,9 @@
|
||||
{
|
||||
"Author": "Dave Janson",
|
||||
"author": "Dave Janson",
|
||||
"created": "2026-01-28T18:21:41.629066491-05:00[America/New_York]",
|
||||
"created": "2026-01-29T20:03:27.5385961-05:00[America/New_York]",
|
||||
"description": "East Market Square find. Local Author.",
|
||||
"id": "3819887576",
|
||||
"id": "1288927655",
|
||||
"price": 32.0,
|
||||
"title": "Jolly Romp",
|
||||
"type": "SCULPTURE",
|
||||
@@ -56,9 +56,9 @@
|
||||
{
|
||||
"Author": "Dave Janson",
|
||||
"author": "Dave Janson",
|
||||
"created": "2026-01-28T18:21:41.62908951-05:00[America/New_York]",
|
||||
"created": "2026-01-29T20:03:27.5385961-05:00[America/New_York]",
|
||||
"description": "East Market Square find. Local Author.",
|
||||
"id": "4329655027",
|
||||
"id": "3852318757",
|
||||
"price": 32.0,
|
||||
"title": "Jolly Romp",
|
||||
"type": "SCULPTURE",
|
||||
|
||||
32
Ui/src/resources/db/transactions.json
Normal file
32
Ui/src/resources/db/transactions.json
Normal file
@@ -0,0 +1,32 @@
|
||||
[
|
||||
{
|
||||
"completed": "2026-01-29T20:03:27.6062321-05:00[America/New_York]",
|
||||
"created": "2026-01-29T20:03:27.6062321-05:00[America/New_York]",
|
||||
"customerId": "3138660874",
|
||||
"customerInventoryList": [
|
||||
{
|
||||
"Author": "Dave Janson",
|
||||
"author": "Dave Janson",
|
||||
"created": "2026-01-29T20:03:27.5385961-05:00[America/New_York]",
|
||||
"description": "East Market Square find. Local Author.",
|
||||
"id": "2679997537",
|
||||
"price": 92.0,
|
||||
"title": "Windy Rowing",
|
||||
"type": "DRAWING"
|
||||
},
|
||||
{
|
||||
"Author": "Dave Janson",
|
||||
"author": "Dave Janson",
|
||||
"created": "2026-01-29T20:03:27.5385961-05:00[America/New_York]",
|
||||
"description": "East Market Square find. Local Author.",
|
||||
"id": "3852318757",
|
||||
"price": 32.0,
|
||||
"title": "Jolly Romp",
|
||||
"type": "SCULPTURE",
|
||||
"weight": 4.0
|
||||
}
|
||||
],
|
||||
"id": "ZcXUQAck4PPQiN-Qmeowsw",
|
||||
"totalPrice": 124.8
|
||||
}
|
||||
]
|
||||
Reference in New Issue
Block a user