Starter Project

The purpose of this document

Now that we have constructed a first draft of the database for the Tasker system it is time to think about building a Spring Boot application that will serve up data from our database. This document will set out the initial specifications for what that Spring Boot application should do.

I will be describing a collection of services the server needs to be able to supply. In each case a service will be described by the combination of HTTP method and URL that clients will use, along with a description of the data that gets sent to and from the server. Your job will be to implement each of these services in the Spring Boot application.

One feature that our Spring Boot server will not need to support is registering workers in the database. I am going to operate under the assumption that there is a desktop application that communicates directly with the database that the office will use in the worker registration process.

Below I have grouped the services into logical groups to make them easier to understand.

Registering and logging in customers and workers

In the Tasker system both workers and customers are considered users.

Workers have already been registered via a separate process, so we will assume that all workers already have an assigned user name and password stored in the database.

The first service our server will have to provide is registering a new customer. To do this, clients will POST an object with all of the properties needed for a user to the URL that ends with /users. In response the server will send back the integer id number for that new user.

To log in an existing user clients will send a GET request with a URL that ends with

/users?name=<name>&password=<password>

where <name> has been replaced by a valid user name and <password> has been replaced with a valid password. The server will respond by sending back the id number of that user if the login is successful or 0 otherwise.

Creating a new job

Once customers have logged in they can create new jobs. To upload a new job description to the server clients will POST an object describing the new job to a URL that ends with /jobs.

To display a list of all of the jobs a user has posted, send a GET request with the URL

/jobs?customer=<id>

with <id> replaced by the customer's user id number.

To display a list of all current jobs posted by all customers, send a GET request to /jobs/all. (Helpful hint: the method to handle that request in the JobsController class would be annotated with @GetMapping("/all").)

Bidding on jobs

Workers can bid for jobs by posting a bid object to the URL /bids.

Workers can fetch a list of all of the jobs they have currently bid on by sending a GET request with the URL

/bids?worker=<id>

A customer can ask to see information on all of the bids that have come in for a job they have posted by sending a GET request with the URL

/bids?job=<id>

where <id> is the id number of the job they want to ask about. (Helpful hint: the data returned from this request should probably be pulled from one of the views that I created, which shows more detailed information about the workers who are bidding on the job.)

Selecting a worker and rating the work

Once a customer has selected a worker for a job, the client will POST an object to the URL /ratings. That object should contain the id number of the job and id number of the selected worker.

When the worker has completed work on a job they will POST an object to the URL /ratings/completed. That object should contain the id number of the job, the time when the work was completed, and how many hours the worker spent on the job. (Helpful hint: the method to handle that request in the RatingsController class would be annotated with @PostRequest("/completed").)

A customer can post feedback on a job by POSTing an object to the URL /ratings/feedback. That object should contain the id number of the job, a numerical rating, and a text comment (which can be empty).

Homework assignment

Construct the Spring Boot server application that meets all of the specifications outlined above.

At the top of these notes you will find a button that you can click to download an empty Spring Boot project. Use this project as the starting point for your work.

You may have to edit the pom.xml file for this project: one of the settings there is for the Java version to use. Right now that is set to version 21. If you are using a different version of Java you will need to change this setting.

At the top of the "Tasker Database" notes you will also find a button that you can click to download the database files for your project. Create a new empty schema named 'tasker' in the MySQL workbench and use the data import feature to import the contents of these database files.

This project is a partner project. You will be working with a partner to complete the server application.