diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/model/product/Product.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/model/product/Product.java new file mode 100644 index 0000000000000000000000000000000000000000..7de88e53c85e081887b09549000ec9407680d6c1 --- /dev/null +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/model/product/Product.java @@ -0,0 +1,12 @@ +package ntnu.idatt2016.v233.SmartMat.model.product; + +/** + * Product is a record class representing a product in the system. + * All other info about the product is fetched from api call on fronted. + * this ensures that the product is always up to date. + * @author Birk + * @version 1.0 + * @since 04.04.2023 + */ +public record Product (int ean, String name, String description){ +} diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/repository/ProductRepository.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/repository/ProductRepository.java new file mode 100644 index 0000000000000000000000000000000000000000..0682ee55f3ffd9c5a5f35d72dac089d302f59543 --- /dev/null +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/repository/ProductRepository.java @@ -0,0 +1,54 @@ +package ntnu.idatt2016.v233.SmartMat.repository; + +import ntnu.idatt2016.v233.SmartMat.model.ShoppingList; +import ntnu.idatt2016.v233.SmartMat.model.product.Product; + +import java.util.List; +import java.util.Optional; + +/** + * Repository for Products + * @author Birk + * @version 1.0 + * @since 04.04.2023 + */ +public interface ProductRepository { + /** + * Saves a Product to the database + * + * @param product Product to save + */ + Product save (Product product); + + /** + * Gets a Product by its ID + * + * @param id the ID of the product + * @return an optional containing the product if it exists + */ + Optional<Product> getById(int id); + + /** + * Gets a Product by name + * + * @param id the ID of the group + * @return an optional containing the product if it exists + */ + Optional<Product> getByProductName(int id); + + /** + * Gets all Products + * + * @return an optional containing a list of all products + */ + Optional<List<Product>> getAll(); + + + /** + * Deletes a product by its ID + * + * @param id the ID of the Product + */ + void deleteById(int id); + +}