This commit is contained in:
jleroy2023
2025-07-16 15:50:03 +02:00
4 changed files with 18 additions and 0 deletions

View File

@@ -10,5 +10,6 @@ public interface StockService {
void add(Stock game);
Optional<Stock> findById(Long gameId);
List<StockCount> findAllByName(String name);
Stock findByRef(String ref);
}

View File

@@ -3,6 +3,7 @@ package fr.eni.demo.bll;
import fr.eni.demo.bo.Stock;
import fr.eni.demo.bo.StockCount;
import fr.eni.demo.dal.StockRepository;
import jakarta.persistence.EntityNotFoundException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -39,4 +40,13 @@ public class StockServiceImpl implements StockService{
.toList();
return result;
}
@Override
public Stock findByRef(String ref) {
Stock stock = stockRepository.findByRefEQ(ref);
if (stock == null) {
throw new EntityNotFoundException("Ref non valide");
}
return stock;
}
}