Commit bd7cdd45 authored by Eduard Štefan Mlynárik's avatar Eduard Štefan Mlynárik
Browse files

Merge branch 'PA-165-pagination_and_other_minor_changes' into 'master'

[MZ] - Pagination for getList methods, JPA version updated in pom.xml...

See merge request !26
parents 3058dc43 42615730
Loading
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -54,7 +54,6 @@
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
            <version>3.2.2</version>
        </dependency>
        <dependency>
            <groupId>com.mysql</groupId>
+20 −25
Original line number Diff line number Diff line
package cz.muni.fi.pa165.controller;

import cz.muni.fi.pa165.Exceptions.GrapeAlreadyExistsException;
import cz.muni.fi.pa165.Exceptions.GrapeDoesNotExistException;
import cz.muni.fi.pa165.Exceptions.ProductAlreadyExistsException;
import cz.muni.fi.pa165.Exceptions.ProductNotFoundException;
import cz.muni.fi.pa165.exceptions.GrapeAlreadyExistsException;
import cz.muni.fi.pa165.exceptions.GrapeDoesNotExistException;
import cz.muni.fi.pa165.exceptions.ProductAlreadyExistsException;
import cz.muni.fi.pa165.exceptions.ProductNotFoundException;
import cz.muni.fi.pa165.facade.InventoryFacade;
import cz.muni.fi.pa165.model.DTO.GrapeDTO;
import cz.muni.fi.pa165.model.DTO.IngredientDTO;
import cz.muni.fi.pa165.model.DTO.ProductDTO;
import cz.muni.fi.pa165.model.DTO.TransactionDTO;
import cz.muni.fi.pa165.model.validatorInterfaces.AddGrapeValidationGroup;
import cz.muni.fi.pa165.model.validatorInterfaces.AddWineValidationGroup;
import cz.muni.fi.pa165.model.validatorInterfaces.RestockGrapeValidationGroup;
import cz.muni.fi.pa165.model.validatorInterfaces.RestockWineValidationGroup;
import cz.muni.fi.pa165.model.dto.GrapeDTO;
import cz.muni.fi.pa165.model.dto.IngredientDTO;
import cz.muni.fi.pa165.model.dto.ProductDTO;
import cz.muni.fi.pa165.model.dto.TransactionDTO;
import cz.muni.fi.pa165.model.validator.interfaces.AddGrapeValidationGroup;
import cz.muni.fi.pa165.model.validator.interfaces.AddWineValidationGroup;
import cz.muni.fi.pa165.model.validator.interfaces.RestockWineValidationGroup;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
@@ -20,21 +19,17 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class InventoryManagementAPI {
public class InventoryManagement {

    private final InventoryFacade inventoryFacade;

    @Autowired
    public InventoryManagementAPI(InventoryFacade inventoryFacade) {
    public InventoryManagement(InventoryFacade inventoryFacade) {
        this.inventoryFacade = inventoryFacade;
    }

@@ -43,8 +38,8 @@ public class InventoryManagementAPI {
            @ApiResponse(responseCode = "200", description = "List of wines"),
    })
    @GetMapping("/wine/list")
    public ResponseEntity<List<ProductDTO>> getWineList() {
        return new ResponseEntity<>(inventoryFacade.getWineList(), HttpStatus.OK);
    public ResponseEntity<List<ProductDTO>> getWineList(@RequestParam(name = "page",defaultValue = "0")int page, @RequestParam(name = "pageSize",defaultValue = "10")int pageSize){
        return new ResponseEntity<>(inventoryFacade.getWineList(page, pageSize), HttpStatus.OK);
    }

    @Operation(summary = "Get wine by id")
@@ -118,8 +113,8 @@ public class InventoryManagementAPI {
    })
    @GetMapping("/grape/list")

    public ResponseEntity<List<GrapeDTO>> getGrapeList() {
        return new ResponseEntity<>(inventoryFacade.getGrapeList(), HttpStatus.OK);
    public ResponseEntity<List<GrapeDTO>> getGrapeList(@RequestParam(name = "page",defaultValue = "0")int page, @RequestParam(name = "pageSize",defaultValue = "10")int pageSize) {
        return new ResponseEntity<>(inventoryFacade.getGrapeList(page, pageSize), HttpStatus.OK);
    }

    @Operation(summary = "Get grape by code")
@@ -170,8 +165,8 @@ public class InventoryManagementAPI {
            @ApiResponse(responseCode = "200", description = "List of ingredients")
    })
    @GetMapping("/ingredient/list")
    public ResponseEntity<List<IngredientDTO>> getIngredientList() {
        return new ResponseEntity<>(inventoryFacade.getIngredientList(), HttpStatus.OK);
    public ResponseEntity<List<IngredientDTO>> getIngredientList(@RequestParam(name = "page",defaultValue = "0")int page, @RequestParam(name = "pageSize",defaultValue = "10")int pageSize) {
        return new ResponseEntity<>(inventoryFacade.getIngredientList(page, pageSize), HttpStatus.OK);
    }

    @Operation(summary = "Get ingredient by name")
+1 −1
Original line number Diff line number Diff line
package cz.muni.fi.pa165.exceptionHandler;
package cz.muni.fi.pa165.exception.handler;

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
+1 −1
Original line number Diff line number Diff line
package cz.muni.fi.pa165.Exceptions;
package cz.muni.fi.pa165.exceptions;

public class GrapeAlreadyExistsException extends Exception{
    public GrapeAlreadyExistsException(String message) {
+1 −1
Original line number Diff line number Diff line
package cz.muni.fi.pa165.Exceptions;
package cz.muni.fi.pa165.exceptions;

public class GrapeDoesNotExistException extends Exception{
    public GrapeDoesNotExistException(String message) {
Loading