Class CategoryController
java.lang.Object
it.unimib.unimibmodules.controller.DTOMapping<M,T>
it.unimib.unimibmodules.controller.DTOListMapping<Category,CategoryDTO>
it.unimib.unimibmodules.controller.CategoryController
@RestController
@RequestMapping("/api")
public class CategoryController
extends DTOListMapping<Category,CategoryDTO>
Controller handling HTTP requests related to Category.
- Version:
- 0.4.1
- Author:
- Lorenzo Occhipinti, Khalil Mohamed Khalil
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final CategoryRepositoryInstance of AnswerRepository that will be used to access the db.Fields inherited from class it.unimib.unimibmodules.controller.DTOMapping
modelMapper -
Constructor Summary
ConstructorsConstructorDescriptionCategoryController(CategoryRepository categoryRepository, org.modelmapper.ModelMapper modelMapper) -
Method Summary
Modifier and TypeMethodDescriptionconvertListToDTO(Iterable<Category> categories) convertToDTO(Category value) Converts an instance of M to an instance of TConverts an instance of T to an instance of Morg.springframework.http.ResponseEntity<List<CategoryDTO>>Gets all the categoriesorg.springframework.http.ResponseEntity<CategoryDTO>findCategory(int id) Gets the Category associated with the given id.
-
Field Details
-
categoryRepository
Instance of AnswerRepository that will be used to access the db.
-
-
Constructor Details
-
CategoryController
@Autowired public CategoryController(CategoryRepository categoryRepository, org.modelmapper.ModelMapper modelMapper)
-
-
Method Details
-
findCategory
@GetMapping(path="/findCategory/{id}") public org.springframework.http.ResponseEntity<CategoryDTO> findCategory(@PathVariable int id) throws NotFoundException Gets the Category associated with the given id.- Parameters:
id- the id of the category- Returns:
- an HTTP response with status 200, 500 otherwise
- Throws:
NotFoundException
-
findCategories
@GetMapping(path="/findCategories") public org.springframework.http.ResponseEntity<List<CategoryDTO>> findCategories() throws NotFoundExceptionGets all the categories- Returns:
- an HTTP response with status 200, 500 otherwise
- Throws:
NotFoundException
-
convertToDTO
Description copied from class:DTOMappingConverts an instance of M to an instance of T- Specified by:
convertToDTOin classDTOMapping<Category,CategoryDTO> - Parameters:
value- an instance of M- Returns:
- an instance of T, containing the serialized data of value
-
convertToEntity
Description copied from class:DTOMappingConverts an instance of T to an instance of M- Specified by:
convertToEntityin classDTOMapping<Category,CategoryDTO> - Parameters:
dto- an instance of T- Returns:
- an instance of M, containing the deserialized data of T
-
convertListToDTO
- Specified by:
convertListToDTOin classDTOListMapping<Category,CategoryDTO>
-