source: bus-n-go-do-5ta-faza/src/main/java/mk/ukim/finki/busngo/service/impl/PatnikServiceImpl.java

Last change on this file was baf4cc4, checked in by ppaunovski <paunovskipavel@…>, 3 months ago

split group project and individual project into two separate folders

  • Property mode set to 100644
File size: 1.9 KB
Line 
1package mk.ukim.finki.busngo.service.impl;
2
3import mk.ukim.finki.busngo.model.entities.Instancanalinija;
4import mk.ukim.finki.busngo.model.entities.Korisnik;
5import mk.ukim.finki.busngo.model.entities.Patnik;
6import mk.ukim.finki.busngo.model.exceptions.InvalidPatnikIdException;
7import mk.ukim.finki.busngo.repository.PatnikRepository;
8import mk.ukim.finki.busngo.service.InstancaNaLinijaService;
9import mk.ukim.finki.busngo.service.PatnikService;
10import org.springframework.stereotype.Service;
11
12import java.util.Collections;
13import java.util.List;
14
15@Service
16public class PatnikServiceImpl implements PatnikService {
17 private final PatnikRepository patnikRepository;
18 private final InstancaNaLinijaService instancaNaLinijaService;
19
20 public PatnikServiceImpl(PatnikRepository patnikRepository, InstancaNaLinijaService instancaNaLinijaService) {
21 this.patnikRepository = patnikRepository;
22 this.instancaNaLinijaService = instancaNaLinijaService;
23 }
24
25 @Override
26 public List<Patnik> listAll() {
27 return patnikRepository.findAll();
28 }
29
30 @Override
31 public Patnik findById(Long id) {
32 return patnikRepository.findById(id).orElseThrow(InvalidPatnikIdException::new);
33 }
34
35 @Override
36 public Patnik loadUserByEmail(String email) {
37 return patnikRepository.findByKEmail(email).orElseThrow(InvalidPatnikIdException::new);
38 }
39
40 @Override
41 public Patnik save(Korisnik korisnik) {
42 Patnik patnik = new Patnik();
43 patnik.setKId(korisnik.getKId());
44 patnik.setKEmail(korisnik.getKEmail());
45 patnik.setKAdresa(korisnik.getKAdresa());
46 patnik.setKIme(korisnik.getKIme());
47 patnik.setKTelefon(korisnik.getKTelefon());
48 patnik.setKIsAdmin(korisnik.getKIsAdmin());
49 patnik.setKLozinka(korisnik.getKLozinka());
50
51 return patnikRepository.save((Patnik) korisnik);
52 }
53
54
55}
Note: See TracBrowser for help on using the repository browser.