Class ClassController

java.lang.Object
one.suhas.rmc.controller.ClassController

@RestController public class ClassController extends Object
Defines web routes for functions relating to courses.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    addClass(String className)
    API route to add a class to the database
    org.springframework.web.servlet.ModelAndView
    addReview(long id)
    Renders a webpage where users can add ratings (no text)
    org.springframework.web.servlet.ModelAndView
    addTextReview(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 it
    org.springframework.web.servlet.ModelAndView
    Helper route to generate some test classes
    An API route to return a JSON object of all classes in the database
    getClassById(long id)
    An API route to fetch a class given an ID
    getClassReviews(long id)
    Fetches the reviews for a given class
    Fetches reviews with text for a given class
    org.springframework.web.servlet.ModelAndView
    Renders the main webpage with a list of classes
    org.springframework.web.servlet.ModelAndView
    viewClass(long id)
    Renders a webpage for a given class, where users can view and add reviews

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ClassController

      @Autowired public ClassController(ClassService classService)
  • 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

      @GetMapping("/classes") public List<RMCClass> 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

      @DeleteMapping("/classes/{id}") public String deleteClass(@PathVariable("id") long id)
      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

      @PostMapping("/classes") public RMCClass addClass(@RequestParam(name="className") String className)
      API route to add a class to the database
      Parameters:
      className - The name of the class to add
      Returns:
      The class object
    • getClassById

      @GetMapping("/classes/{class}") public RMCClass getClassById(@PathVariable("class") long id)
      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