diff --git a/.idea/compiler.xml b/.idea/compiler.xml index c86ed3f..66bc19f 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -2,6 +2,7 @@ + diff --git a/backend/src/main/java/org/example/backend/Product.java b/backend/src/main/java/org/example/backend/Product.java index b290558..bab9ee3 100644 --- a/backend/src/main/java/org/example/backend/Product.java +++ b/backend/src/main/java/org/example/backend/Product.java @@ -3,6 +3,6 @@ public record Product( String id, String name, - int ammount + int amount ) { } diff --git a/backend/src/main/java/org/example/backend/ProductController.java b/backend/src/main/java/org/example/backend/ProductController.java index 7cc978b..880073e 100644 --- a/backend/src/main/java/org/example/backend/ProductController.java +++ b/backend/src/main/java/org/example/backend/ProductController.java @@ -1,19 +1,17 @@ package org.example.backend; +import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import java.util.List; - +@RequiredArgsConstructor @RestController @RequestMapping("/api/products") public class ProductController { private final ProductService productService; - public ProductController(ProductService productService) { - this.productService = productService; - } @GetMapping public List getAllGroceries() { return productService.findAllGroceries(); diff --git a/backend/src/main/java/org/example/backend/ProductRepository.java b/backend/src/main/java/org/example/backend/ProductRepository.java index 15aa29b..6c1b23c 100644 --- a/backend/src/main/java/org/example/backend/ProductRepository.java +++ b/backend/src/main/java/org/example/backend/ProductRepository.java @@ -1,7 +1,9 @@ package org.example.backend; import org.springframework.data.mongodb.repository.MongoRepository; +import org.springframework.stereotype.Repository; +@Repository public interface ProductRepository extends MongoRepository { } diff --git a/backend/src/main/java/org/example/backend/ProductService.java b/backend/src/main/java/org/example/backend/ProductService.java index 83de4f2..7434024 100644 --- a/backend/src/main/java/org/example/backend/ProductService.java +++ b/backend/src/main/java/org/example/backend/ProductService.java @@ -1,18 +1,17 @@ package org.example.backend; +import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import java.util.List; - +@RequiredArgsConstructor @Service public class ProductService { private final ProductRepository productRepository; - public ProductService(ProductRepository productRepository) { - this.productRepository = productRepository; - } + public List findAllGroceries(){ return productRepository.findAll(); } diff --git a/backend/src/test/java/org/example/backend/BackendApplicationTest.java b/backend/src/test/java/org/example/backend/BackendApplicationTest.java deleted file mode 100644 index 8c1aac8..0000000 --- a/backend/src/test/java/org/example/backend/BackendApplicationTest.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.example.backend; - -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.context.SpringBootTest; - -@SpringBootTest -class TodoBackendApplicationTests { - - @Test - void contextLoads() { - } - -} diff --git a/frontend/src/componets/ProductList.tsx b/frontend/src/componets/ProductList.tsx index 5ae6063..a4d6a01 100644 --- a/frontend/src/componets/ProductList.tsx +++ b/frontend/src/componets/ProductList.tsx @@ -1,4 +1,4 @@ -import React, { useEffect, useState } from 'react'; +import { useEffect, useState } from 'react'; import axios from 'axios'; import { Product } from '../models/product.tsx';