correction multiple
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ public class Facture {
|
||||
@Field(name = "DATEPAY")
|
||||
private Date datePay;
|
||||
|
||||
@DBRef
|
||||
@Field(name = "CLIENTS")
|
||||
private Client client;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user