Class InstructorController
java.lang.Object
org.codewithmagret.rest.instructor.InstructorController
@RestController
@RequestMapping("/api/v1/instructors")
public class InstructorController
extends Object
REST controller for managing instructors.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.http.ResponseEntity<Instructor> addInstructor(Instructor instructor) Creates a new instructor.org.springframework.http.ResponseEntity<Void> deleteInstructor(Long id) Deletes an instructor by its ID.Retrieves a list of all instructors.org.springframework.http.ResponseEntity<Instructor> Retrieves an instructor by its ID.org.springframework.http.ResponseEntity<Instructor> updateInstructor(Long id, Instructor instructor) Updates an existing instructor.
-
Constructor Details
-
InstructorController
public InstructorController()Default constructor for InstructorController.
-
-
Method Details
-
getAllInstructors
Retrieves a list of all instructors.- Returns:
- A list of Instructor objects.
-
getInstructorById
@GetMapping("/{id}") public org.springframework.http.ResponseEntity<Instructor> getInstructorById(@PathVariable Long id) Retrieves an instructor by its ID.- Parameters:
id- The ID of the instructor to retrieve.- Returns:
- A ResponseEntity containing the Instructor object if found, or a 404 Not Found status if not found.
-
addInstructor
@PostMapping public org.springframework.http.ResponseEntity<Instructor> addInstructor(@RequestBody Instructor instructor) Creates a new instructor.- Parameters:
instructor- The Instructor object to create.- Returns:
- A ResponseEntity containing the created Instructor object, or a 400 Bad Request status if the creation failed.
-
updateInstructor
@PutMapping("/{id}") public org.springframework.http.ResponseEntity<Instructor> updateInstructor(@PathVariable Long id, @RequestBody Instructor instructor) Updates an existing instructor.- Parameters:
id- The ID of the instructor to update.instructor- The Instructor object containing the updated data.- Returns:
- A ResponseEntity containing the updated Instructor object if found, or a 400 Bad Request status if the update failed.
-
deleteInstructor
@DeleteMapping("/{id}") public org.springframework.http.ResponseEntity<Void> deleteInstructor(@PathVariable Long id) Deletes an instructor by its ID.- Parameters:
id- The ID of the instructor to delete.- Returns:
- A ResponseEntity with a 204 No Content status if the deletion was successful, or a 404 Not Found status if the instructor was not found.
-