java.lang.Object
com.shr4pnel.web.WebApplication
The entry point for the project. Hosts the web API and clients.
API documentation available here: swagger-ui.shrapnelnet.co.uk
- Since:
- v0.1.0
- Author:
- shrapnelnet
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.http.ResponseEntity<?> Adds the specified specified amount of stock to the databaseorg.springframework.http.ResponseEntity<?> buyStockCustomer(org.springframework.http.HttpEntity<String> httpEntity) Removes stock from the StockTable, and places it into the OrderTable and BasketTable respectivelyorg.springframework.http.ResponseEntity<?> finishPacking(String orderID) Delete orders that are sent to be packed in the packing frontend clientorg.springframework.http.ResponseEntity<?> Fetch all items in OrderTable, then all items in BasketTable with a matching foreign key to aggregate the baskets correctlyorg.springframework.http.ResponseEntity<?> getStock()Get the current amount of stock in the database, and send it to the client.static voidmain.org.springframework.http.ResponseEntity<org.springframework.core.io.Resource> root()Hosts the bundled react.js clients.
-
Constructor Details
-
WebApplication
public WebApplication()
-
-
Method Details
-
main
main.
- Parameters:
args- an array ofStringobjects
-
root
@GetMapping("/") public org.springframework.http.ResponseEntity<org.springframework.core.io.Resource> root()Hosts the bundled react.js clients.- Returns:
- A responseentity containing the HTML of the client.
-
getStock
@GetMapping("/api/stock") public org.springframework.http.ResponseEntity<?> getStock()Get the current amount of stock in the database, and send it to the client. Used to synchronize customer, cashier and backdoor clients- Returns:
- A JSON object in a responseentity containing the current contents of the StockTable
-
buyStock
@PostMapping("/api/staff/buy") public org.springframework.http.ResponseEntity<?> buyStock(org.springframework.http.HttpEntity<String> httpEntity) Adds the specified specified amount of stock to the database- Parameters:
httpEntity- a HTTP entity (JSON request body) containing a product number and the quantity to add to the database- Returns:
- A HTTP status code.
- See Also:
-
buyStockCustomer
@PostMapping("/api/customer/buy") public org.springframework.http.ResponseEntity<?> buyStockCustomer(org.springframework.http.HttpEntity<String> httpEntity) Removes stock from the StockTable, and places it into the OrderTable and BasketTable respectively- Parameters:
httpEntity- JSON Object containing a basket, an array of objects, each of which have a product number and a quantity to purchase- Returns:
- A HTTP status code.
- See Also:
-
getOrdersToPack
@GetMapping("/api/staff/pack") public org.springframework.http.ResponseEntity<?> getOrdersToPack()Fetch all items in OrderTable, then all items in BasketTable with a matching foreign key to aggregate the baskets correctly- Returns:
- A stringified JSON object containing the items which are waiting to be packed.
- See Also:
-
finishPacking
@DeleteMapping("/api/staff/finalizePack") public org.springframework.http.ResponseEntity<?> finishPacking(@RequestParam("orderid") String orderID) Delete orders that are sent to be packed in the packing frontend client- Parameters:
orderID- The UUID of the order to be deleted- Returns:
- a HTTP status code.
-