Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
vokarl committed Aug 16, 2024
1 parent 9a069a1 commit f2ed69f
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 23 deletions.
1 change: 1 addition & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion backend/src/main/java/org/example/backend/Product.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
public record Product(
String id,
String name,
int ammount
int amount
) {
}
Original file line number Diff line number Diff line change
@@ -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<Product> getAllGroceries() {
return productService.findAllGroceries();
Expand Down
Original file line number Diff line number Diff line change
@@ -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<Product, String> {

}
7 changes: 3 additions & 4 deletions backend/src/main/java/org/example/backend/ProductService.java
Original file line number Diff line number Diff line change
@@ -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<Product> findAllGroceries(){
return productRepository.findAll();
}
Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion frontend/src/componets/ProductList.tsx
Original file line number Diff line number Diff line change
@@ -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';

Expand Down

0 comments on commit f2ed69f

Please sign in to comment.