Legend:
- Unmodified
- Added
- Removed
-
src/main/java/project/fmo/app/projcetfmo/Service/impl/CenaServiceImpl.java
r1dd9226 rd14176d 1 package project.fmo.app.projcetfmo.Service.impl;public class CenaServiceImpl { 1 package project.fmo.app.projcetfmo.Service.impl; 2 3 import javax.transaction.Transactional; 4 import org.springframework.stereotype.Service; 5 import project.fmo.app.projcetfmo.Model.Cena; 6 import project.fmo.app.projcetfmo.Model.CenaPK; 7 import project.fmo.app.projcetfmo.Repository.CenaRepository; 8 import project.fmo.app.projcetfmo.Service.CenaService; 9 10 import java.sql.Date; 11 import java.util.List; 12 13 @Service 14 public class CenaServiceImpl implements CenaService { 15 16 private final CenaRepository cenaRepository; 17 18 public CenaServiceImpl(CenaRepository cenaRepository) { 19 this.cenaRepository = cenaRepository; 20 } 21 22 @Override 23 public Cena save(Integer idProdukt, java.sql.Date cenaOd, java.sql.Date cenaDo, int iznos) { 24 Cena c = new Cena(idProdukt,cenaOd,cenaDo,iznos); 25 cenaRepository.save(c); 26 return c; 27 } 28 29 @Transactional 30 @Override 31 public Cena edit(Integer idProdukt, Date cenaOd, Date cenaDo, int iznos) { 32 Cena c = cenaRepository.findByIdProdukt(idProdukt); 33 cenaRepository.deleteByIdProdukt(c.getIdProdukt()); 34 Cena c1 = new Cena(idProdukt,cenaOd,cenaDo,iznos); 35 cenaRepository.save(c1); 36 return c; 37 } 38 39 @Override 40 public List<Cena> findAll() { 41 return cenaRepository.findAll(); 42 } 43 44 @Override 45 public Cena findByIdProdukt(int idProdukt) { 46 return cenaRepository.findByIdProdukt(idProdukt); 47 } 48 49 @Transactional 50 @Override 51 public void deleteByIdProdukt(int idProdukt) { 52 cenaRepository.deleteByIdProdukt(idProdukt); 53 } 2 54 }
Note:
See TracChangeset
for help on using the changeset viewer.