Legend:
- Unmodified
- Added
- Removed
-
src/main/java/project/fmo/app/projcetfmo/Service/impl/NarackaServiceImpl.java
r1dd9226 rd14176d 1 package project.fmo.app.projcetfmo.Service.impl;public class NarackaServiceImpl { 1 package project.fmo.app.projcetfmo.Service.impl; 2 3 import org.springframework.stereotype.Service; 4 import project.fmo.app.projcetfmo.Model.Kupuvac; 5 import project.fmo.app.projcetfmo.Model.Naracka; 6 import project.fmo.app.projcetfmo.Model.Produkt; 7 import project.fmo.app.projcetfmo.Repository.KupuvacRepository; 8 import project.fmo.app.projcetfmo.Repository.NarackaRepository; 9 import project.fmo.app.projcetfmo.Service.NarackaService; 10 11 import java.sql.Date; 12 import java.util.List; 13 14 @Service 15 public class NarackaServiceImpl implements NarackaService { 16 17 private final NarackaRepository narackaRepository; 18 private final KupuvacRepository kupuvacRepository; 19 20 public NarackaServiceImpl(NarackaRepository narackaRepository, KupuvacRepository kupuvacRepository) { 21 this.narackaRepository = narackaRepository; 22 this.kupuvacRepository = kupuvacRepository; 23 } 24 25 @Override 26 public List<Produkt> allProductsInOrder(Integer narackaId) { 27 return null; 28 } 29 30 @Override 31 public Naracka getActiveOrder(String username) { 32 return null; 33 } 34 35 @Override 36 public Naracka findByIdKorisniktAndStatus(Integer id, String s) { 37 Kupuvac k = kupuvacRepository.findById(id).orElse(null); 38 return narackaRepository.findByKupuvacAndStatus(k,s); 39 } 40 41 @Override 42 public Naracka save(int vkupnoSuma, Date date, String status, String adresa, Kupuvac k) { 43 return narackaRepository.save(new Naracka(vkupnoSuma,date,status,adresa,k)); 44 } 45 46 @Override 47 public Naracka edit(int vkupnoSuma, String status, String adresa, Integer idK, Integer idN) { 48 Kupuvac k = kupuvacRepository.findById(idK).orElse(null); 49 Naracka n = narackaRepository.findByKupuvacAndIdNaracka(k,idN); 50 n.setVkupnoSuma(n.getVkupnoSuma()+vkupnoSuma); 51 n.setStatus(status); 52 n.setAdresa(adresa); 53 narackaRepository.save(n); 54 return n; 55 } 56 57 @Override 58 public Naracka findByKupuvac(Kupuvac k) { 59 return narackaRepository.findByKupuvac(k); 60 } 61 62 @Override 63 public Naracka findByIdNaracka(Integer id) { 64 return narackaRepository.findById(id).orElse(null); 65 } 66 67 @Override 68 public List<Naracka> findAll() { 69 return narackaRepository.findAll(); 70 } 2 71 }
Note:
See TracChangeset
for help on using the changeset viewer.