Ignore:
Timestamp:
01/09/24 01:26:08 (10 months ago)
Author:
ppaunovski <paunovskipavel@…>
Branches:
master
Children:
e272096
Parents:
b101b69
Message:

All 3 main use cases implemented.

  1. Starting a commute
  2. Writing a ticket
  3. Starting an instance of a Bus Line
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/main/java/mk/ukim/finki/busngo/service/impl/PatnikServiceImpl.java

    rb101b69 rbde8b13  
    11package mk.ukim.finki.busngo.service.impl;
    22
     3import mk.ukim.finki.busngo.model.entities.Instancanalinija;
     4import mk.ukim.finki.busngo.model.entities.Korisnik;
    35import mk.ukim.finki.busngo.model.entities.Patnik;
    46import mk.ukim.finki.busngo.model.exceptions.InvalidPatnikIdException;
    57import mk.ukim.finki.busngo.repository.PatnikRepository;
     8import mk.ukim.finki.busngo.service.InstancaNaLinijaService;
    69import mk.ukim.finki.busngo.service.PatnikService;
    710import org.springframework.stereotype.Service;
    811
     12import java.util.Collections;
    913import java.util.List;
    1014
     
    1216public class PatnikServiceImpl implements PatnikService {
    1317    private final PatnikRepository patnikRepository;
     18    private final InstancaNaLinijaService instancaNaLinijaService;
    1419
    15     public PatnikServiceImpl(PatnikRepository patnikRepository) {
     20    public PatnikServiceImpl(PatnikRepository patnikRepository, InstancaNaLinijaService instancaNaLinijaService) {
    1621        this.patnikRepository = patnikRepository;
     22        this.instancaNaLinijaService = instancaNaLinijaService;
    1723    }
    1824
    1925    @Override
    2026    public List<Patnik> listAll() {
    21         return patnikRepository.findAll();
     27        return  patnikRepository.findAll();
    2228    }
    2329
     
    2632        return patnikRepository.findById(id).orElseThrow(InvalidPatnikIdException::new);
    2733    }
     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
    2855}
Note: See TracChangeset for help on using the changeset viewer.