Class CategoryController
- java.lang.Object
-
- edu.cnm.deepdive.interviewprep.controller.CategoryController
-
@RestController @RequestMapping("/categories") public class CategoryController extends Object
This class creates REST endpoints that has access to the Question entity in the database through the Category services. Identified by the URL /interviewprep/categories.
-
-
Constructor Summary
Constructors Constructor Description CategoryController(CategoryService categoryService)
Constructor that instantiates a new User service object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
delete(UUID externalKey)
This method defines the behavior of a DELETE request to the URL /interviewprep/categories/externalkey.Iterable<Category>
get()
This method defines the behavior of a GET request to the URL /interviewprep/categories.Category
get(UUID externalKey)
This method defines the behavior of a GET request to the URL /interviewprep/categories/externalKey.Category
post(Category category)
This method defines the behavior of a POST request to the URL /interviewprep/categories.Category
put(UUID categoryId, Category category)
This method defines the behavior of a PUT request to the URL /interviewprep/categorie/categoryId.
-
-
-
Constructor Detail
-
CategoryController
@Autowired public CategoryController(CategoryService categoryService)
Constructor that instantiates a new User service object.- Parameters:
categoryService
- Category service object.
-
-
Method Detail
-
get
@GetMapping(value="/{externalKey}", produces="application/json") public Category get(@PathVariable UUID externalKey)
This method defines the behavior of a GET request to the URL /interviewprep/categories/externalKey. It grabs the current category from the Category service.- Parameters:
externalKey
- External key in the form of a universally unique identifier as identified by the path variable external key.- Returns:
- A Category object in the form of JSON.
-
post
@PostMapping(consumes="application/json", produces="application/json") public Category post(@RequestBody Category category)
This method defines the behavior of a POST request to the URL /interviewprep/categories. It creates a new category through the Category service.- Parameters:
category
- A Category Object in the form of request body.- Returns:
- A Category object in the form of JSON.
-
put
@PutMapping(value="/{categoryId}", consumes="application/json", produces="application/json") public Category put(@PathVariable UUID categoryId, @RequestBody Category category)
This method defines the behavior of a PUT request to the URL /interviewprep/categorie/categoryId. It updates a category through the Category service.- Parameters:
categoryId
- An id in the form of a universally unique identifier as identified by * * the path variable categoryId.category
- A Category Object in the form of request body.- Returns:
- A Category 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/categories/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.
-
get
@GetMapping(produces="application/json") public Iterable<Category> get()
This method defines the behavior of a GET request to the URL /interviewprep/categories.- Returns:
- a list of all categories from database via the category service.
-
-