correction multiple

This commit is contained in:
mepiphana2023
2025-07-16 16:45:52 +02:00
parent dff2b033c6
commit d803446144
7 changed files with 10 additions and 16 deletions

View File

@@ -5,7 +5,6 @@ import fr.eni.demo.bo.Location;
public interface LocationService {
Location findById(Long id);
void add(Location location);
void update(Location location);
void updateDateEnd(String id, Location location);
Location findByCodeBarre(String codeBarre);
}

View File

@@ -6,6 +6,7 @@ import jakarta.persistence.EntityNotFoundException;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.NoSuchElementException;
@Service
public class LocationServiceImpl implements LocationService {
@@ -29,12 +30,6 @@ public class LocationServiceImpl implements LocationService {
stockService.isRent(location.getStock(), true);
}
@Override
public void update(Location location) {
locationRepository.save(location);
stockService.isRent(location.getStock(), false);
}
@Override
public void updateDateEnd(String id, Location location) {
Location existing = findById(Long.valueOf(id));
@@ -43,4 +38,10 @@ public class LocationServiceImpl implements LocationService {
locationRepository.save(location);
}
@Override
public Location findByCodeBarre(String codeBarre) {
return locationRepository.findByCodeBarre(codeBarre)
.orElseThrow(() -> new NoSuchElementException("Code-barre inconnu : " + codeBarre));
}
}

View File

@@ -28,15 +28,12 @@ public class Client {
@Field(name = "EMAIL")
private String email;
@DBRef
@Field(name = "ADRESSE")
private Adresse adresse;
@DBRef
@Field(name = "LOCATIONS")
private List<Location> locations;
@DBRef
@Field(name = "FACTURES")
private List<Facture> factures;
}

View File

@@ -27,7 +27,6 @@ public class Facture {
@Field(name = "DATEPAY")
private Date datePay;
@DBRef
@Field(name = "CLIENTS")
private Client client;
}

View File

@@ -28,11 +28,9 @@ public class Location {
@Field(name = "LOCATION_END_DATE")
private Date endDate;
@DBRef
@Field(name = "CLIENT")
private Client client;
@DBRef
@Field(name = "STOCK")
private Stock stock;
}

View File

@@ -34,11 +34,9 @@ public class Stock {
@Field(name = "GAME_IS_RENT")
private Boolean isRent;
@DBRef
@Field(name = "GAME_TYPE")
private List<GameType> gameType;
@DBRef
@Field(name = "LOCATIONS")
private List<Location> locations;
}

View File

@@ -4,8 +4,10 @@ import fr.eni.demo.bo.Location;
import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.stereotype.Repository;
import java.util.Optional;
@Repository
public interface LocationRepository extends MongoRepository<Location, Integer> {
public interface LocationRepository extends MongoRepository<Location, Long> {
Optional<Location> findByCodeBarre(String codeBarre);