Proof of concept (#6)
* Sample template created * added findByName functionality for item * Solve Cors errors and inhibit DefaultExposure * changed project structure * Added frontend * Creation of base template (#1) * changed base path of REST api and updated frontend api quering
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
package whattocook.implementation;
|
||||
|
||||
import whattocook.models.Item;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import whattocook.repositories.ItemRepository;
|
||||
import whattocook.services.ItemService;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Service
|
||||
public class ItemServiceImpl implements ItemService {
|
||||
|
||||
@Autowired
|
||||
private ItemRepository itemRepository;
|
||||
|
||||
@Override
|
||||
public Item save(Item item) {
|
||||
return itemRepository.save(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteById(Long id) {
|
||||
itemRepository.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Item> findById(long id) {
|
||||
return itemRepository.findById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Item> findByName(String name) {
|
||||
return itemRepository.findByName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Item> findAll() {
|
||||
return itemRepository.findAll();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user