Class AtributDishController

java.lang.Object
com.myfood.controllers.AtributDishController

@RestController @RequestMapping("api/v1") public class AtributDishController extends Object
Controller class for handling attribute-dish-related operations. This controller provides endpoints for basic CRUD operations on attribute-dish relationships.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    org.springframework.http.ResponseEntity<?>
    addAtributDishToDish(Long dishId, Long atributDishId)
    Add an existing attribute-dish relationship to a dish.
    org.springframework.http.ResponseEntity<?>
    deleteAtributDishRelation(Long atributId, Long dishId)
    Delete the relationship between an attribute and a dish.
    org.springframework.http.ResponseEntity<org.springframework.data.domain.Page<com.myfood.dto.Atribut_Dish>>
    getAllAtribut_Dishes(int page, int size)
    Retrieve a paginated list of all attribute-dish relationships.
    org.springframework.http.ResponseEntity<?>
    getAllAttributes(String attributes, int page, int size)
    Retrieve attribute-dish relationships by the specified attributes.
    org.springframework.http.ResponseEntity<?>
    getDishesByAtributVisible(String atribut, int page, int size)
    Retrieve dishes filtered by the specified attribute, considering only visible dishes.
    org.springframework.http.ResponseEntity<org.springframework.data.domain.Page<com.myfood.dto.Atribut_Dish>>
    getOneAtribut_Dish(Long id, int page, int size)
    Retrieve a single attribute-dish relationship by ID.
    org.springframework.http.ResponseEntity<?>
    updateAtribut_Dish(Long id, com.myfood.dto.Atribut_Dish entity)
    Update an existing attribute-dish relationship associated with a dish.

    Methods inherited from class java.lang.Object

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

    • AtributDishController

      public AtributDishController()
  • Method Details

    • getAllAtribut_Dishes

      @PreAuthorize("hasRole(\'ADMIN\')") @GetMapping("/atributs") public org.springframework.http.ResponseEntity<org.springframework.data.domain.Page<com.myfood.dto.Atribut_Dish>> getAllAtribut_Dishes(@RequestParam(defaultValue="0") int page, @RequestParam(defaultValue="10") int size)
      Retrieve a paginated list of all attribute-dish relationships. This endpoint requires ADMIN role for access.
      Parameters:
      page - The page number for pagination (default is 0).
      size - The size of each page for pagination (default is 10).
      Returns:
      ResponseEntity containing a paginated list of attribute-dish relationships or a not found response if no relationships are found.
    • getOneAtribut_Dish

      @PreAuthorize("hasRole(\'ADMIN\')") @GetMapping("/atribut/{id}") public org.springframework.http.ResponseEntity<org.springframework.data.domain.Page<com.myfood.dto.Atribut_Dish>> getOneAtribut_Dish(@PathVariable(name="id") Long id, @RequestParam(defaultValue="0") int page, @RequestParam(defaultValue="1") int size)
      Retrieve a single attribute-dish relationship by ID. This endpoint requires ADMIN role for access.
      Parameters:
      id - The ID of the attribute-dish relationship to retrieve.
      page - The page number for pagination (default is 0).
      size - The size of each page for pagination (default is 1).
      Returns:
      ResponseEntity containing the requested attribute-dish relationship or a not found response if the relationship is not found.
    • getAllAttributes

      @PreAuthorize("hasRole(\'ADMIN\')") @GetMapping("/atribut/ByName/{attributes}") public org.springframework.http.ResponseEntity<?> getAllAttributes(@PathVariable(name="attributes") String attributes, @RequestParam(defaultValue="0") int page, @RequestParam(defaultValue="10") int size)
      Retrieve attribute-dish relationships by the specified attributes. This endpoint requires ADMIN role for access.
      Parameters:
      attributes - The attributes to filter by. Accepted values are: CELIAC, LACTOSE, VEGAN, VEGETARIAN, NUTS.
      page - The page number for pagination (default is 0).
      size - The size of each page for pagination (default is 10).
      Returns:
      ResponseEntity containing a paginated list of attribute-dish relationships filtered by the specified attributes, or an error response if the attributes are invalid.
    • getDishesByAtributVisible

      @GetMapping("/atribut/visible/{atribut}/dishes") public org.springframework.http.ResponseEntity<?> getDishesByAtributVisible(@PathVariable(name="atribut") String atribut, @RequestParam(defaultValue="0") int page, @RequestParam(defaultValue="10") int size)
      Retrieve dishes filtered by the specified attribute, considering only visible dishes. This endpoint requires ADMIN role for access.
      Parameters:
      atribut - The attribute to filter dishes by. Accepted values are: CELIAC, LACTOSE, VEGAN, VEGETARIAN, NUTS.
      page - The page number for pagination (default is 0).
      size - The size of each page for pagination (default is 10).
      Returns:
      ResponseEntity containing a paginated list of visible dishes filtered by the specified attribute, or an error response if the attribute is invalid.
    • addAtributDishToDish

      @PreAuthorize("hasRole(\'ADMIN\')") @PostMapping("/atribut/{atributDishId}/dish/{dishId}") public org.springframework.http.ResponseEntity<?> addAtributDishToDish(@PathVariable(name="dishId") Long dishId, @PathVariable(name="atributDishId") Long atributDishId)
      Add an existing attribute-dish relationship to a dish. This endpoint requires ADMIN role for access.
      Parameters:
      dishId - The ID of the dish to associate with the attribute-dish relationship.
      atributDishId - The ID of the attribute-dish relationship to associate with the dish.
      Returns:
      ResponseEntity indicating success or a not found response if either the dish or attribute-dish relationship is not found.
    • updateAtribut_Dish

      @PreAuthorize("hasRole(\'ADMIN\')") @PutMapping("/atribut/{dish_id}") public org.springframework.http.ResponseEntity<?> updateAtribut_Dish(@PathVariable(name="dish_id") Long id, @RequestBody com.myfood.dto.Atribut_Dish entity)
      Update an existing attribute-dish relationship associated with a dish. This endpoint requires ADMIN role for access.
      Parameters:
      id - The ID of the dish associated with the attribute.
      entity - The updated attribute-dish relationship.
      Returns:
      ResponseEntity containing the updated attribute-dish relationship or an error response if the attribute is invalid.
    • deleteAtributDishRelation

      @PreAuthorize("hasRole(\'ADMIN\')") @DeleteMapping("/atribut/{atributId}/dish/{dishId}") public org.springframework.http.ResponseEntity<?> deleteAtributDishRelation(@PathVariable(name="atributId") Long atributId, @PathVariable(name="dishId") Long dishId)
      Delete the relationship between an attribute and a dish. This endpoint requires ADMIN role for access.
      Parameters:
      atributId - The ID of the attribute-dish relationship to delete.
      dishId - The ID of the dish associated with the attribute-dish relationship.
      Returns:
      ResponseEntity indicating success or a not found response if either the attribute-dish relationship or the dish is not found.