libdo

Untitled

Nov 5th, 2017
13,039
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.websystique.springboot.service;
  2.  
  3. import java.util.Collection;
  4.  
  5. import org.springframework.beans.factory.annotation.Autowired;
  6. import org.springframework.stereotype.Service;
  7.  
  8. import com.websystique.springboot.model.AnimalEntity;
  9. import com.websystique.springboot.repository.AnimalEntityRepository;
  10.  
  11.  
  12.  
  13. @Service
  14. public class AnimalEntityServiceImpl implements AnimalEntityService{
  15.  
  16.  
  17. @Autowired
  18. private AnimalEntityRepository animalEntityRepo;
  19.  
  20. public Collection<AnimalEntity> findAllAnimals() {
  21.  
  22. return animalEntityRepo.findAll();
  23. }
  24.  
  25. public AnimalEntity findById(long id) {
  26. return animalEntityRepo.findOne(id);
  27. }
  28.  
  29. public void saveAnimal(AnimalEntity animal) {
  30. animalEntityRepo.save(animal);
  31. }
  32.  
  33. public void updateAnimal(AnimalEntity animal) {
  34. animalEntityRepo.save(animal);
  35. }
  36.  
  37. public void deleteAnimalById(long id) {
  38. animalEntityRepo.delete(id);
  39. }
  40.  
  41. public boolean isAnimalExist(AnimalEntity animal) {
  42. return animalEntityRepo.exists(animal.getId());
  43. }
  44.  
  45. public void deleteAllAnimals(){
  46. animalEntityRepo.deleteAll();
  47. }
  48.  
  49.  
  50. }
Add Comment
Please, Sign In to add comment