Class QuestionController


  • @RestController
    @RequestMapping("/questions")
    public class QuestionController
    extends Object
    This class creates REST endpoints that has access to the Question entity in the database through the Question and User services. Identified by the URL /interviewprep/questions.
    • Constructor Detail

      • QuestionController

        @Autowired
        public QuestionController​(UserService userService,
                                  QuestionService questionService)
        Constructor that instantiates a new User service object.
        Parameters:
        userService - User service object.
        questionService - Question service object.
    • Method Detail

      • get

        @GetMapping(value="/{externalKey}",
                    produces="application/json")
        public Question get​(@PathVariable
                            UUID externalKey)
        This method defines the behavior of a GET request to the URL /interviewprep/questions/externalKey. It grabs the current question from the Question service.
        Parameters:
        externalKey - External key in the form of a universally unique identifier as identified by the path variable external key.
        Returns:
        A Question object in the form of JSON.
      • post

        @PostMapping(consumes="application/json",
                     produces="application/json")
        public Question post​(@RequestBody
                             Question question)
        This method defines the behavior of a POST request to the URL /interviewprep/questions. It creates a new question through the Question service for the current user.
        Parameters:
        question - A Question Object in the form of request body.
        Returns:
        A Question object in the form of JSON.
      • put

        @PutMapping(value="/{questionId}",
                    consumes="application/json",
                    produces="application/json")
        public Question put​(@PathVariable
                            UUID questionId,
                            @RequestBody
                            Question question)
        This method defines the behavior of a PUT request to the URL /interviewprep/questions/questionid. It updates a question through the Question service for the current user.
        Parameters:
        questionId - An id in the form of a universally unique identifier as identified by * the path variable questionId.
        question - A Question Object in the form of request body.
        Returns:
        A Question object in the form of JSON.
      • delete

        @DeleteMapping("/{externalKey}")
        @ResponseStatus(NO_CONTENT)
        public void delete​(@PathVariable
                           UUID externalKey)
        This method defines the behavior of a DELETE request to the URL /interviewprep/questions/externalkey. Returns a HTTP no content status via header.
        Parameters:
        externalKey - External key in the form of a universally unique identifier as identified by the path variable external key.
      • getRandom

        @GetMapping(value="/random",
                    produces="application/json")
        public Question getRandom()
        This method defines the behavior of a GET request to the URL /interviewprep/questions/random.
        Returns:
        Question object in the form of JSON.
      • get

        @GetMapping(produces="application/json")
        public Iterable<Question> get()
        This method defines the behavior of a GET request to the URL /interviewprep/questions.
        Returns:
        a list of all questions from database via the question service.