Module CI

Class WebApplication

java.lang.Object
com.shr4pnel.web.WebApplication

@SpringBootApplication @RestController public class WebApplication extends Object
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
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    org.springframework.http.ResponseEntity<?>
    buyStock(org.springframework.http.HttpEntity<String> httpEntity)
    Adds the specified specified amount of stock to the database
    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
    org.springframework.http.ResponseEntity<?>
    Delete orders that are sent to be packed in the packing frontend client
    org.springframework.http.ResponseEntity<?>
    Fetch all items in OrderTable, then all items in BasketTable with a matching foreign key to aggregate the baskets correctly
    org.springframework.http.ResponseEntity<?>
    Get the current amount of stock in the database, and send it to the client.
    static void
    main(String[] args)
    main.
    org.springframework.http.ResponseEntity<org.springframework.core.io.Resource>
    Hosts the bundled react.js clients.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • WebApplication

      public WebApplication()
  • Method Details

    • main

      public static void main(String[] args)

      main.

      Parameters:
      args - an array of String objects
    • 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:
      • BuyStockHelper
    • 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:
      • BuyStockHelper
    • 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.