Advertisement
andersonalmada

Untitled

Jul 29th, 2022
832
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.94 KB | None | 0 0
  1. package br.ufc.mandacaru5.service;
  2.  
  3. import java.util.List;
  4.  
  5. import org.springframework.beans.factory.annotation.Autowired;
  6. import org.springframework.stereotype.Service;
  7.  
  8. import br.ufc.mandacaru5.dao.ProductJDBCDAO;
  9. import br.ufc.mandacaru5.model.Product;
  10.  
  11. @Service
  12. public class ProductService {
  13.  
  14.     @Autowired
  15.     ProductJDBCDAO productDAO;
  16.  
  17.     public void save(int id, Product entity) {
  18.         if(id != 0) {
  19.             entity.setId(id);
  20.         }
  21.         productDAO.save(entity);
  22.     }
  23.  
  24.     public void delete(int id) {
  25.         productDAO.delete(id);
  26.     }
  27.  
  28.     public Product find(int id) {
  29.         if(id < 1) {
  30.             return null;
  31.         }
  32.        
  33.         return productDAO.find(id);
  34.     }
  35.  
  36.     public List<Product> findAll() {
  37.         return productDAO.findAll();
  38.     }
  39.  
  40.     public Product findByName(String str) {
  41.         if(str.length() < 3) {
  42.             return null;
  43.         }
  44.        
  45.         return productDAO.findByName(str);
  46.     }
  47.  
  48.     public List<Product> findAllByName(String str) {
  49.         return productDAO.findAllByName(str);
  50.     }
  51.  
  52. }
  53.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement