Class CafeService

java.lang.Object
balu.pizza.webapp.services.CafeService

@Service @Transactional(readOnly=true) public class CafeService extends Object
Cafe Service
  • Constructor Details

    • CafeService

      @Autowired public CafeService(CafeRepository cafeRepository, PizzaRepository pizzaRepository)
      Parameters:
      cafeRepository - Cafe Repository
      pizzaRepository - Pizza Repository
  • Method Details

    • findById

      public Cafe findById(int id)
      Find Cafe by ID
      Parameters:
      id -
      Returns:
      Cafe or throw NotFoundException
    • findAll

      public List<Cafe> findAll()
      Returns:
      List of all cafes from DB
    • create

      @Transactional public Cafe create(Cafe cafe)
      Save new Cafe to DB
      Parameters:
      cafe -
      Returns:
      saved cafe
    • findAllSorted

      public List<Cafe> findAllSorted()
      Returns:
      Sorted by title list of all cafes from DB
    • update

      @Transactional public Cafe update(Cafe cafe)
      Update cafe ib DB
      Parameters:
      cafe -
      Returns:
      updated cafe
    • addPizzaToCafe

      @Transactional public void addPizzaToCafe(int cafeId, int pizzaId)
      Adds pizza to the cafe menu
      Parameters:
      cafeId - Cafe id
      pizzaId - Pizza id
    • delPizzaFromCafe

      @Transactional public void delPizzaFromCafe(int cafeId, int pizzaId)
      Remove pizza from cafe manu
      Parameters:
      cafeId - cafe ID
      pizzaId - pizza ID