Skip to content
Porogaramu edited this page Apr 8, 2024 · 21 revisions

Initial Dependencies

Setup

Install Java 21 from Oracle based on your OS.

Install the Database you want to use MySQL and the connector MySQL Connector.

Set up the database configuration from here

Setup the configuration file as outlined in configuration

To run the application, execute the command ./gradlew bootRun

Configuration

Create a file src/main/resources/application.properties This has configuration based off of Spring. An example configuration exists in src/main/resources/application.example.properties.

  • server.port the port to host on (default 8080).
  • spring.jpa.hibernate.ddl-auto is how the program will manage the database during setup and shutdown. Docs
  • spring.datasource.url is where the database is stored via HTTP. Docs
  • spring.datasource.driver-class-name is the driver for the database. Docs

For unit and integration tests, create a file src/test/resources/application.properties. This has similar configuration, but with a different database that is in memory.

APIs

All APIs are in JSON format and can be accessed by managers. All, except for login, require a query with a token t.

General

GET login: logs into the server.

  • Takes query uname for the username
  • Takes query passwd for the password
  • Returns a String for the token.

GET logout: logs out of the server.

GET getDetails: gets the worker's details.

GET items: Gets the items on the menu.

  • Returns { items: [Item] } Item

Waiter

GET waiter/order: gets all the orders for the waiter.

GET waiter/tables: gets all the tables in the restaurant.

  • Returns { tables: [ Table ]}. Table

POST waiter/addOrder: adds an order to be cooked.

  • Takes a body of { items: [ int ], tableId: int }, where each int is the id of the item on the menu.
  • Returns int orderId.

POST waiter/completeOrder: marks an order as delivered.

  • Takes a body of int, which is the orderId to complete.
  • Returns Boolean.

POST waiter/orderDone: marks an order as completed.

  • Takes a body of int, which is the orderId to complete.
  • Returns Boolean.

POST waiter/cancelOrder: marks an order as canceled.

  • Takes a body of int, which is the orderId to cancel.
  • Returns Boolean.

Cook

GET cook/getOrders: gets all the orders to cook.

  • Returns { orders: [ Order ] }. Order

POST cook/setStatus: sets the status of the order (Only Cooked, InProgress, and Ordered).

  • Takes a body of Status
  • Returns Boolean

POST cook/itemDepleted marks an item as not in stock.

POST cook/itemRestocked marks an item as in stock.

Manager

POST manager/createWorker creates a new worker.

POST manager/deleteWorker deletes a worker.

  • Body: Integer for worker's id.

POST manager/addItem creates a new item.

POST manager/deleteItem deletes an item.

  • Body: Integer for item's id.
  • Returns boolean

POST manager/changeItem changes an item's values.

  • Body: { id: int, details: item}. Item

POST manager/setTable sets a table's information.

GET manager/workers gets all the workers.

  • Returns `{ workers: [Worker] }. Worker

Websockets

Websocket Endpoint: /websocket

To subscribe to a websocket, connect to /websocket and subscribe to /{broker}/{path}.

Broker: Topic

/message/{worker_id}: Fires whenever a manager sends a message to a worker with id worker_id.

  • Returns a String in the form of {manager} said: {message}.

/order/{waiter_id}: For waiters. Fires whenever an order that the waiter has placed is done.

  • Returns a String in the form of {order_id} {table_number}.

Data

WorkerOrders

Items, Status

{
  "id": "int",
  "items": ["Items"],
  "timeOrdered": "Date (or long)",
  "status": "Status",
  "totalPrice": "int"
}

CookOrders

Items, Status

{
  "items": ["Items"],
  "timeOrdered": ["long"],
  "status": "Status",
  "id": "int"
}

PostCreateWorker

{
	"firstName": "String",
	"lastName": "String",
    "age": "int",
    "job": "Job",
    "username": "String",
    "password": "String",
    "tableIds": { ["int"] }
}

PostAddItem

ItemType

{
    "name": "String",
    "description": "String",
    "price": "int (in cents)",
    "inStock": "boolean",
    "type:" "ItemType"
}

Items

ItemType

{
  "id": "int",
  "name": "String",
  "description": "String",
  "type": "ItemType",
  "price": "int (in cents)",
  "inStock": "boolean"
}

Tables

{
  "id": "int",
  "number": "number",
  "waiter": {
    "firstName": "String",
    "lastName": "String",
    "id": "int"
  },
  "isOccupied": "boolean",
  "numSeats": "int",
  "x": "int",
  "y": "int"
}

PostTable

{
  "x": "int",
  "y": "int",
  "waiter": "int",
  "number": "int",
  "numSeats": "int",
  "isOccupied": "boolean",
  "isActive": "boolean"
}

WorkerDetails

Job

{
  "id": "int",
  "firstName": "String",
  "lastName": "String",
  "age": "int",
  "job": "Job"
}

Status

Cooked, Ordered, InProgress, Delivered, Completed, Canceled

ItemType

Food, Beverage

Job

Waiter, Host, Cook, Manager

Clone this wiki locally