Package one.suhas.rmc.controller
Class ClassController
java.lang.Object
one.suhas.rmc.controller.ClassController
Defines web routes for functions relating to courses.
- 
Constructor Summary
Constructors - 
Method Summary
Modifier and TypeMethodDescriptionAPI route to add a class to the databaseorg.springframework.web.servlet.ModelAndViewaddReview(long id) Renders a webpage where users can add ratings (no text)org.springframework.web.servlet.ModelAndViewaddTextReview(long id) Renders a webpage where users can add reviews (has text)deleteClass(long id) Deletes a class from the database based on the provided ID, and returns itorg.springframework.web.servlet.ModelAndViewHelper route to generate some test classesAn API route to return a JSON object of all classes in the databasegetClassById(long id) An API route to fetch a class given an IDgetClassReviews(long id) Fetches the reviews for a given classgetClassTextReviews(long id) Fetches reviews with text for a given classorg.springframework.web.servlet.ModelAndViewindex()Renders the main webpage with a list of classesorg.springframework.web.servlet.ModelAndViewviewClass(long id) Renders a webpage for a given class, where users can view and add reviews 
- 
Constructor Details
- 
ClassController
 
 - 
 - 
Method Details
- 
generateClasses
@GetMapping("/generateClasses") public org.springframework.web.servlet.ModelAndView generateClasses()Helper route to generate some test classes- Returns:
 - A redirect to the index page
 
 - 
getAllClasses
An API route to return a JSON object of all classes in the database- Returns:
 - A list of all classes in the database
 
 - 
deleteClass
Deletes a class from the database based on the provided ID, and returns it- Parameters:
 id- The ID of the class to delete- Returns:
 - The deleted class
 
 - 
addClass
API route to add a class to the database- Parameters:
 className- The name of the class to add- Returns:
 - The class object
 
 - 
getClassById
An API route to fetch a class given an ID- Parameters:
 id- the ID of the class to fetch- Returns:
 - The fetched class
 
 - 
viewClass
@GetMapping("/view/classes/{class}") public org.springframework.web.servlet.ModelAndView viewClass(@PathVariable("class") long id) Renders a webpage for a given class, where users can view and add reviews- Parameters:
 id- the ID of the class to render- Returns:
 - An object containing a link to the webpage for Spring to render, and the objects it embeds in the page
 
 - 
getClassReviews
@GetMapping("/classes/{class}/reviews") public Set<Review> getClassReviews(@PathVariable("class") long id) Fetches the reviews for a given class- Parameters:
 id- The ID of the class to fetch reviews for- Returns:
 - A list of reviews.
 
 - 
getClassTextReviews
@GetMapping("/classes/{class}/textReviews") public Set<TextReview> getClassTextReviews(@PathVariable("class") long id) Fetches reviews with text for a given class- Parameters:
 id- the ID of the class to fetch reviews for- Returns:
 - A list of reviews.
 
 - 
addReview
@GetMapping("/view/classes/{class}/addReview") public org.springframework.web.servlet.ModelAndView addReview(@PathVariable("class") long id) Renders a webpage where users can add ratings (no text)- Parameters:
 id- the ID of the class that the user will add a rating for- Returns:
 - the webpage with all necessary objects for the webpage
 
 - 
addTextReview
@GetMapping("/view/classes/{class}/addTextReview") public org.springframework.web.servlet.ModelAndView addTextReview(@PathVariable("class") long id) Renders a webpage where users can add reviews (has text)- Parameters:
 id- the ID of the class that the user will add a rating for- Returns:
 - the webpage with all necessary objects for the webpage
 
 - 
index
@GetMapping("/") public org.springframework.web.servlet.ModelAndView index()Renders the main webpage with a list of classes- Returns:
 - The main webpage object
 
 
 -