The goal of this task is to build a simple Student Management System using Spring Boot, where each student has a list of courses. Students will implement APIs to manage students and their courses without using a database, storing data in-memory using ArrayList.
Each student should have the following attributes:
id: A unique identifier for the student (e.g., Long).
name: The student's name (e.g., String).
email: The student's email address (e.g., String).
courses: A list of courses the student is enrolled in (e.g., List<String>).
Course Class
Each class should have the following attributes:
id: A unique identifier for the student (e.g., Long).
name: The student's name (e.g., String).
teacher: the course instructor (e.g., String).
credits: the course credits (e.g., Integer)
Course Management:
Implement functionality to add and remove courses for a student.
Service Class:
Create a StudentService class that contains business logic for managing students and their courses using an ArrayList to store the students.
Controller Class:
Create a StudentController class to handle HTTP requests and interact with the StudentService.
APIs:
Implement the following APIs and test them using Postman:
Create a Student:
Method: POST
Endpoint: /students
Request Body: JSON object with name and email.
Response: Created student with id, name, email, and an empty list of courses.
Get All Students:
Method: GET
Endpoint: /students
Response: A list of all students.
Get a Student by ID:
Method: GET
Endpoint: /students/{id}
Response: The student with the specified id, including their list of courses.
Update a Student's Details:
Method: PUT
Endpoint: /students/{id}
Request Body: JSON object with name and email.
Response: The updated student information.
Delete a Student:
Method: DELETE
Endpoint: /students/{id}
Response: A confirmation that the student was deleted.
Add a Course to a Student: (student can has a maximum of 17 credit)
Method: POST
Endpoint: /students/{id}/courses
Request Body: JSON object with courseName.
Response: The updated list of courses for the student.
Remove a Course from a Student:
Method: DELETE
Endpoint: /students/{id}/courses
Request Body: JSON object with courseName.
Response: The updated list of courses for the student.
Create a Course:
Method: POST
Endpoint: /courses
Get All Courses:
Method: GET
Endpoint: /courses
Response: A list of all courses.
Get a Course by ID:
Method: GET
Endpoint: /courses/{courseId}
Response: The course with the specified courseId.
Update a Course's Details:
Method: PUT
Endpoint: /courses/{courseId}
Delete a Course:
Method: DELETE
Endpoint: /courses/{courseId}
Response: A confirmation that the course was deleted.
In-Memory Storage:
Use an ArrayList in the StudentService class to store the list of students. No database is required for this task.
Instructions
Project Setup:
Use Spring Initializr or your IDE to create a Spring Boot project with the Web dependency.
Implement the Student Class:
Create a Student class with the required attributes and methods (e.g., constructors, getters, and setters).
Implement the StudentService Class:
Create a StudentService class that handles the business logic for managing students and their courses.
Implement the StudentController Class:
Create a StudentController class to map the APIs to their respective service methods.
Test the APIs:
Use Postman to test all the implemented APIs, ensuring they work as expected.
Example Scenario
create a simple scenario to add list of courses, list of students with set of courses, in case the student had more than 17 course let the operation fail,
update courses and remove some courses and list them
Submission
Submit the completed project files along with a Postman screenshots containing the API requests and response . Include screenshots of successful API responses in Postman as evidence of testing.
Objective
The goal of this task is to build a simple Student Management System using Spring Boot, where each student has a list of courses. Students will implement APIs to manage students and their courses without using a database, storing data in-memory using
ArrayList
.You can use the code in this discussion: https://github.com/dgPadBootcamps/Java-Bootcamp-2024/discussions/185
Requirements
id
: A unique identifier for the student (e.g.,Long
).name
: The student's name (e.g.,String
).email
: The student's email address (e.g.,String
).courses
: A list of courses the student is enrolled in (e.g.,List<String>
).id
: A unique identifier for the student (e.g.,Long
).name
: The student's name (e.g.,String
).teacher
: the course instructor (e.g.,String
).credits
: the course credits (e.g.,Integer
)StudentService
class that contains business logic for managing students and their courses using anArrayList
to store the students.StudentController
class to handle HTTP requests and interact with theStudentService
.POST
/students
name
andemail
.id
,name
,email
, and an empty list of courses.GET
/students
GET
/students/{id}
id
, including their list of courses.PUT
/students/{id}
name
andemail
.DELETE
/students/{id}
POST
/students/{id}/courses
courseName
.DELETE
/students/{id}/courses
courseName
.POST
/courses
GET
/courses
GET
/courses/{courseId}
courseId
.PUT
/courses/{courseId}
DELETE
/courses/{courseId}
ArrayList
in theStudentService
class to store the list of students. No database is required for this task.Instructions
Student
class with the required attributes and methods (e.g., constructors, getters, and setters).StudentService
class that handles the business logic for managing students and their courses.StudentController
class to map the APIs to their respective service methods.Example Scenario
create a simple scenario to add list of courses, list of students with set of courses, in case the student had more than 17 course let the operation fail,
update courses and remove some courses and list them
Submission
Submit the completed project files along with a Postman screenshots containing the API requests and response . Include screenshots of successful API responses in Postman as evidence of testing.