Class EquipmentAdminRestController
java.lang.Object
de.gustavblass.fsu.fmi.roombooking.controller.admin.EquipmentAdminRestController
Defines the behaviour of the API server for the path
/api/v1/admin/equipment.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final EquipmentServiceUsed to retrieve and save EquipmentTypes from the database.private final @NonNull EquipmentTypeMapperConverts data-transfer objects to EquipmentTypes. -
Constructor Summary
ConstructorsConstructorDescriptionEquipmentAdminRestController(@NonNull EquipmentService equipmentService, @NonNull EquipmentTypeMapper equipmentTypeMapper) Constructs a newEquipmentAdminRestControllerwith the givenequipmentService. -
Method Summary
Modifier and TypeMethodDescription@NonNull org.springframework.http.ResponseEntity<Void> createEquipment(@Valid @NonNull EquipmentTypeDTO dto) HandlesPOSTrequests to/api/v1/admin/equipmentand adds the givenEquipmentTypeDTOas a newEquipmentTypeto the database.org.springframework.http.ResponseEntity<Void> deleteEquipment(@NonNull String name) Removes theEquipmentTypewith the givenEquipmentType.namefrom the database.
-
Field Details
-
equipmentService
Used to retrieve and save EquipmentTypes from the database. -
equipmentTypeMapper
Converts data-transfer objects to EquipmentTypes.
-
-
Constructor Details
-
EquipmentAdminRestController
public EquipmentAdminRestController(@NonNull @NonNull EquipmentService equipmentService, @NonNull @NonNull EquipmentTypeMapper equipmentTypeMapper) Constructs a newEquipmentAdminRestControllerwith the givenequipmentService.- Parameters:
equipmentService- TheequipmentServiceto use for database access.equipmentTypeMapper- TheequipmentTypeMapperto use for database access.
-
-
Method Details
-
createEquipment
@PostMapping("/api/v1/admin/equipment") @NonNull public @NonNull org.springframework.http.ResponseEntity<Void> createEquipment(@RequestBody @Valid @NonNull @Valid @NonNull EquipmentTypeDTO dto) throws AlreadyExistsException, InvalidEquipmentException HandlesPOSTrequests to/api/v1/admin/equipmentand adds the givenEquipmentTypeDTOas a newEquipmentTypeto the database.- Parameters:
dto-The data-transfer object that represents the new EquipmentType. Must be valid according to the annotations on the class fields. Allowed values for the
EquipmentTypeDTO.type:- Returns:
- Empty response. Only the status code indicates success. The response's
locationheader will point to the URI of all equipment. - Throws:
AlreadyExistsException- If the new EquipmentType is not unique.InvalidEquipmentException- If theEquipmentTypeDTO.typedoes not exist.
-
deleteEquipment
@DeleteMapping("/api/v1/admin/equipment/{name}") public org.springframework.http.ResponseEntity<Void> deleteEquipment(@NonNull @PathVariable @NonNull String name) throws NotFoundException Removes theEquipmentTypewith the givenEquipmentType.namefrom the database.- Parameters:
name- The title of the EquipmentType that shall no longer be part of the system.- Returns:
- Empty response. Only the status code indicates success.
- Throws:
NotFoundException- If no EquipmentType with the given number exists.
-