Génération facture et location end date set
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package fr.eni.demo.bll;
|
||||
|
||||
import fr.eni.demo.bo.Facture;
|
||||
import fr.eni.demo.bo.Location;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -8,4 +9,5 @@ public interface FactureService {
|
||||
List<Facture> getByClient(Long clientId);
|
||||
List<Facture> getAll();
|
||||
List<Facture> getUnpayed();
|
||||
void add(Facture facture);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package fr.eni.demo.bll;
|
||||
|
||||
import fr.eni.demo.bo.Facture;
|
||||
import fr.eni.demo.bo.Location;
|
||||
import fr.eni.demo.dal.FactureRepository;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -35,4 +36,10 @@ public class FactureServiceImpl implements FactureService {
|
||||
public List<Facture> getUnpayed() {
|
||||
return factureRepo.findByDatePayEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(Facture facture) {
|
||||
factureRepo.save(facture);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,5 +3,7 @@ package fr.eni.demo.bll;
|
||||
import fr.eni.demo.bo.Location;
|
||||
|
||||
public interface LocationService {
|
||||
Location findById(int id);
|
||||
void add(Location location);
|
||||
void updateDateEnd(int id, Location location);
|
||||
}
|
||||
|
||||
@@ -1,20 +1,39 @@
|
||||
package fr.eni.demo.bll;
|
||||
|
||||
import fr.eni.demo.bo.Adresse;
|
||||
import fr.eni.demo.bo.Location;
|
||||
import fr.eni.demo.dal.LocationRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import jakarta.persistence.EntityNotFoundException;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Service
|
||||
public class LocationServiceImpl implements LocationService {
|
||||
|
||||
private LocationRepository locationRepository;
|
||||
|
||||
public LocationServiceImpl(LocationRepository locationRepository) {
|
||||
this.locationRepository = locationRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location findById(int id) {
|
||||
return locationRepository.findById(id)
|
||||
.orElseThrow(() -> new EntityNotFoundException("Location non trouvée"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(Location location) {
|
||||
locationRepository.save(location);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDateEnd(int id, Location location) {
|
||||
Location existing = findById(id);
|
||||
location.setId(existing.getId());
|
||||
location.setEndDate(new Date());
|
||||
locationRepository.save(location);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user