Ignore:
Timestamp:
07/07/23 12:14:58 (16 months ago)
Author:
HristijanMitic00 <hristijan.mitic.01@…>
Branches:
main
Parents:
1dd9226
Message:

First commit

File:
1 edited

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 {
     1package project.fmo.app.projcetfmo.Service.impl;
     2
     3import org.springframework.stereotype.Service;
     4import project.fmo.app.projcetfmo.Model.Kupuvac;
     5import project.fmo.app.projcetfmo.Model.Naracka;
     6import project.fmo.app.projcetfmo.Model.Produkt;
     7import project.fmo.app.projcetfmo.Repository.KupuvacRepository;
     8import project.fmo.app.projcetfmo.Repository.NarackaRepository;
     9import project.fmo.app.projcetfmo.Service.NarackaService;
     10
     11import java.sql.Date;
     12import java.util.List;
     13
     14@Service
     15public 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    }
    271}
Note: See TracChangeset for help on using the changeset viewer.