Skip to content
Extraits de code Groupes Projets
Valider 6becb0a9 rédigé par safae.rabbouzi's avatar safae.rabbouzi
Parcourir les fichiers

remove comments

parent 9dcdfd71
Branches
1 requête de fusion!6MLC-331/implement the full crud operations for reservation
Pipeline #21419 réussi avec les étapes
in 2 minutes et 3 secondes
......@@ -10,21 +10,7 @@ import java.time.LocalDate;
public interface ContractService {
ContractDTO getContractById(Long id) throws FunctionalException;
public Page<ContractDTO> getAllContracts(
int page,
int size,
String sortBy,
String sortDirection,
String search,
String statusSearch,
String reservationSearch,
String registrationSearch,
LocalDate startDate,
LocalDate endDate,
String contractNumber,
String client,
String vehicule
) throws FunctionalException;
public Page<ContractDTO> getAllContracts(int page, int size, String sortBy, String sortDirection, String search, String statusSearch, String reservationSearch, String registrationSearch, LocalDate startDate, LocalDate endDate, String contractNumber, String client, String vehicule) throws FunctionalException;
public ContractDTO changeContractStatus(Long id, ContractStatus newStatus, String cancellationReason) throws FunctionalException;
......
......@@ -34,10 +34,16 @@ public interface GlobalReservationService {
List<GlobalReservation> getAllGlobalReservations();
GlobalReservation changeReservationType(Long id, ReservationType type) throws FunctionalException;
List<GlobalReservation> getReservationsByClientId(Long clientId);
List<GlobalReservation> getReservationsByType(ReservationType type);
List<GlobalReservation> getReservationsByDateRange(LocalDate startDate, LocalDate endDate);
Optional<GlobalReservation> getReservationByNumber(String reservationNumber) throws FunctionalException;
GlobalReservation addSingleReservation(Long globalReservationId, SingleReservation singleReservation) throws FunctionalException;
Double calculateTotalPaid(Long globalReservationId) throws FunctionalException;
}
\ No newline at end of file
......@@ -12,19 +12,33 @@ import java.util.Optional;
public interface SingleReservationService {
SingleReservation createSingleReservation(SingleReservationDTO singleReservationDTO) throws FunctionalException;
SingleReservation updateSingleReservation(Long id, SingleReservationDTO singleReservationDTO) throws FunctionalException;
void deleteSingleReservation(Long id) throws FunctionalException;
List<SingleReservation> getAllSingleReservations();
Optional<SingleReservation> getSingleReservationById(Long id) throws FunctionalException;
SingleReservation changeReservationStatus(Long id, SingleReservationStatus status) throws FunctionalException;
List<SingleReservation> getReservationsByVehicleId(Long vehicleId);
List<SingleReservation> getReservationsByPickupDateRange(LocalDate startDate, LocalDate endDate);
List<SingleReservation> getReservationsByStatus(SingleReservationStatus status);
List<SingleReservation> getReservationsByAgencies(Long departureAgency, Long returnAgency);
boolean checkVehicleAvailability(Long vehicleId, LocalDate startDate, LocalDate endDate) throws FunctionalException;
int calculateRentalDuration(Long singleReservationId) throws FunctionalException;
SingleReservation updateInsuranceOption(Long id, Boolean insurance) throws FunctionalException;
SingleReservation associateContract(Long singleReservationId, Long contractId) throws FunctionalException;
Double calculateTotalCost(Long singleReservationId) throws FunctionalException;
ReservationDetailsDTO getReservationVehicleAndContractDetails(Long reservationId) throws FunctionalException;
......
package com.marketingconfort.mobiloca.service.impl;
import com.marketingconfort.mobiloca.common.Reservation.enums.ContractStatus;
import com.marketingconfort.mobiloca.common.Vehicle.models.Vehicle;
import com.marketingconfort.mobiloca.constants.Message;
import com.marketingconfort.mobiloca.dto.ClientDTO;
import com.marketingconfort.mobiloca.dto.ContractDTO;
......@@ -34,8 +33,7 @@ public class ContractServiceImpl implements ContractService {
@Override
public ContractDTO getContractById(Long id) throws FunctionalException {
Contract contract = contractRepository.findById(id)
.orElseThrow(() -> new FunctionalException(Message.CONTRACT_NOT_FOUND + id));
Contract contract = contractRepository.findById(id).orElseThrow(() -> new FunctionalException(Message.CONTRACT_NOT_FOUND + id));
Long clientId = contract.getSingleReservation().getGlobalReservation().getClientId();
Long vehicleId = contract.getSingleReservation().getVehicleId();
......@@ -52,84 +50,46 @@ public class ContractServiceImpl implements ContractService {
}
@Override
public Page<ContractDTO> getAllContracts(
int page,
int size,
String sortBy,
String sortDirection,
String search,
String statusSearch,
String reservationSearch,
String registrationSearch,
LocalDate startDate,
LocalDate endDate,
String contractNumber,
String client,
String vehicule
) {
Pageable pageable = PageRequest.of(
page,
size,
Sort.by(Sort.Direction.fromString(sortDirection), sortBy)
);
public Page<ContractDTO> getAllContracts(int page, int size, String sortBy, String sortDirection, String search, String statusSearch, String reservationSearch, String registrationSearch, LocalDate startDate, LocalDate endDate, String contractNumber, String client, String vehicule) {
Pageable pageable = PageRequest.of(page, size, Sort.by(Sort.Direction.fromString(sortDirection), sortBy));
Specification<Contract> spec = Specification.where(null);
if (search != null && !search.isBlank()) {
String pattern = "%" + search.toLowerCase() + "%";
spec = spec.and((root, query, cb) -> cb.or(
cb.like(cb.lower(root.get("singleReservation").get("globalReservation").get("firstName")), pattern),
cb.like(cb.lower(root.get("singleReservation").get("globalReservation").get("lastName")), pattern)
));
spec = spec.and((root, query, cb) -> cb.or(cb.like(cb.lower(root.get("singleReservation").get("globalReservation").get("firstName")), pattern), cb.like(cb.lower(root.get("singleReservation").get("globalReservation").get("lastName")), pattern)));
}
if (statusSearch != null && !statusSearch.isBlank()) {
spec = spec.and((root, query, cb) ->
cb.equal(root.get("status"), ContractStatus.valueOf(statusSearch))
);
spec = spec.and((root, query, cb) -> cb.equal(root.get("status"), ContractStatus.valueOf(statusSearch)));
}
if (reservationSearch != null && !reservationSearch.isBlank()) {
spec = spec.and((root, query, cb) ->
cb.like(cb.lower(root.get("singleReservation").get("reservationNumber")), "%" + reservationSearch.toLowerCase() + "%")
);
spec = spec.and((root, query, cb) -> cb.like(cb.lower(root.get("singleReservation").get("reservationNumber")), "%" + reservationSearch.toLowerCase() + "%"));
}
if (registrationSearch != null && !registrationSearch.isBlank()) {
spec = spec.and((root, query, cb) ->
cb.like(cb.lower(root.get("singleReservation").get("vehicle").get("registration")), "%" + registrationSearch.toLowerCase() + "%")
);
spec = spec.and((root, query, cb) -> cb.like(cb.lower(root.get("singleReservation").get("vehicle").get("registration")), "%" + registrationSearch.toLowerCase() + "%"));
}
if (startDate != null) {
spec = spec.and((root, query, cb) ->
cb.greaterThanOrEqualTo(root.get("singleReservation").get("pickupDate"), startDate)
);
spec = spec.and((root, query, cb) -> cb.greaterThanOrEqualTo(root.get("singleReservation").get("pickupDate"), startDate));
}
if (endDate != null) {
spec = spec.and((root, query, cb) ->
cb.lessThanOrEqualTo(root.get("singleReservation").get("returnDate"), endDate)
);
spec = spec.and((root, query, cb) -> cb.lessThanOrEqualTo(root.get("singleReservation").get("returnDate"), endDate));
}
if (contractNumber != null && !contractNumber.isBlank()) {
spec = spec.and((root, query, cb) ->
cb.like(cb.lower(root.get("contractNumber")), "%" + contractNumber.toLowerCase() + "%")
);
spec = spec.and((root, query, cb) -> cb.like(cb.lower(root.get("contractNumber")), "%" + contractNumber.toLowerCase() + "%"));
}
if (vehicule != null && !vehicule.isBlank()) {
spec = spec.and((root, query, cb) ->
cb.like(cb.lower(root.get("singleReservation").get("vehicle").get("model")), "%" + vehicule.toLowerCase() + "%")
);
spec = spec.and((root, query, cb) -> cb.like(cb.lower(root.get("singleReservation").get("vehicle").get("model")), "%" + vehicule.toLowerCase() + "%"));
}
if (client != null && !client.isBlank()) {
spec = spec.and((root, query, cb) -> cb.or(
cb.like(cb.lower(root.get("singleReservation").get("globalReservation").get("firstName")), "%" + client.toLowerCase() + "%"),
cb.like(cb.lower(root.get("singleReservation").get("globalReservation").get("lastName")), "%" + client.toLowerCase() + "%")
));
spec = spec.and((root, query, cb) -> cb.or(cb.like(cb.lower(root.get("singleReservation").get("globalReservation").get("firstName")), "%" + client.toLowerCase() + "%"), cb.like(cb.lower(root.get("singleReservation").get("globalReservation").get("lastName")), "%" + client.toLowerCase() + "%")));
}
Page<Contract> contractPage = contractRepository.findAll(spec, pageable);
......@@ -160,8 +120,7 @@ public class ContractServiceImpl implements ContractService {
@Override
@Transactional
public ContractDTO changeContractStatus(Long id, ContractStatus status, String cancellationReason) throws FunctionalException {
Contract contract = contractRepository.findById(id)
.orElseThrow(() -> new FunctionalException(Message.CONTRACT_NOT_FOUND + id));
Contract contract = contractRepository.findById(id).orElseThrow(() -> new FunctionalException(Message.CONTRACT_NOT_FOUND + id));
contract.setStatus(status);
contract.setCancellationReason(status.equals(ContractStatus.CANCELED) ? cancellationReason : null);
......@@ -192,8 +151,7 @@ public class ContractServiceImpl implements ContractService {
@Override
@Transactional
public void deleteContract(Long id) throws FunctionalException {
contractRepository.findById(id)
.orElseThrow(() -> new FunctionalException(Message.CONTRACT_NOT_FOUND + id));
contractRepository.findById(id).orElseThrow(() -> new FunctionalException(Message.CONTRACT_NOT_FOUND + id));
contractRepository.deleteById(id);
}
......@@ -211,8 +169,7 @@ public class ContractServiceImpl implements ContractService {
@Override
@Transactional
public ContractDTO updateDepositAndActivate(Long id, double depositAmount) throws FunctionalException {
Contract contract = contractRepository.findById(id)
.orElseThrow(() -> new FunctionalException("CONTRACT_NOT_FOUND"));
Contract contract = contractRepository.findById(id).orElseThrow(() -> new FunctionalException("CONTRACT_NOT_FOUND"));
contract.setDepositAmount(depositAmount);
contract.setStatus(ContractStatus.ACTIVE);
......
......@@ -173,8 +173,7 @@ public class GlobalReservationServiceImpl implements GlobalReservationService {
@Transactional
public GlobalReservationDTO updateReservation(Long id, GlobalReservationDTO request) throws FunctionalException {
GlobalReservation reservationEntity = globalReservationRepository.findById(id)
.orElseThrow(() -> new FunctionalException(Message.RESERVATION_NOT_FOUND));
GlobalReservation reservationEntity = globalReservationRepository.findById(id).orElseThrow(() -> new FunctionalException(Message.RESERVATION_NOT_FOUND));
if (request.getClient() == null || request.getClient().id() == null) {
throw new FunctionalException(Message.CLIENT_FAILED_TO_GET);
......@@ -277,8 +276,7 @@ public class GlobalReservationServiceImpl implements GlobalReservationService {
@Override
public GlobalReservationDTO getReservationById(Long id) throws FunctionalException {
GlobalReservation reservation = globalReservationRepository.findById(id)
.orElseThrow(() -> new FunctionalException(Message.RESERVATION_NOT_FOUND));
GlobalReservation reservation = globalReservationRepository.findById(id).orElseThrow(() -> new FunctionalException(Message.RESERVATION_NOT_FOUND));
ClientDTO client = clientService.getClient(reservation.getClientId());
......@@ -343,30 +341,17 @@ public class GlobalReservationServiceImpl implements GlobalReservationService {
@Override
@Transactional(readOnly = true)
public Page<GlobalReservationDTO> getAllReservations(
int page,
int size,
String sortBy,
String sortDirection,
String reservationNumberSearch,
String clientSearch,
String typeSearch,
String vehicleSearch
) throws FunctionalException {
public Page<GlobalReservationDTO> getAllReservations(int page, int size, String sortBy, String sortDirection, String reservationNumberSearch, String clientSearch, String typeSearch, String vehicleSearch) throws FunctionalException {
Pageable pageable = PageRequest.of(page, size);
Specification<GlobalReservation> spec = Specification.where(null);
if (reservationNumberSearch != null && !reservationNumberSearch.isBlank()) {
spec = spec.and((root, query, cb) ->
cb.like(cb.lower(root.get("reservationNumber")), "%" + reservationNumberSearch.toLowerCase() + "%")
);
spec = spec.and((root, query, cb) -> cb.like(cb.lower(root.get("reservationNumber")), "%" + reservationNumberSearch.toLowerCase() + "%"));
}
if (typeSearch != null && !typeSearch.isBlank()) {
spec = spec.and((root, query, cb) ->
cb.equal(root.get("type"), ReservationType.valueOf(typeSearch.toUpperCase()))
);
spec = spec.and((root, query, cb) -> cb.equal(root.get("type"), ReservationType.valueOf(typeSearch.toUpperCase())));
}
Page<GlobalReservation> reservationPage = globalReservationRepository.findAll(spec, Pageable.unpaged());
......@@ -454,8 +439,7 @@ public class GlobalReservationServiceImpl implements GlobalReservationService {
@Override
@Transactional
public void deleteReservation(Long id) throws FunctionalException {
GlobalReservation reservation = globalReservationRepository.findById(id)
.orElseThrow(() -> new FunctionalException(Message.RESERVATION_NOT_FOUND));
GlobalReservation reservation = globalReservationRepository.findById(id).orElseThrow(() -> new FunctionalException(Message.RESERVATION_NOT_FOUND));
globalReservationRepository.delete(reservation);
}
......@@ -469,8 +453,7 @@ public class GlobalReservationServiceImpl implements GlobalReservationService {
@Override
@Transactional
public GlobalReservation changeReservationType(Long id, ReservationType type) throws FunctionalException {
GlobalReservation globalReservation = globalReservationRepository.findById(id)
.orElseThrow(() -> new FunctionalException(Message.RESERVATION_NOT_FOUND + id));
GlobalReservation globalReservation = globalReservationRepository.findById(id).orElseThrow(() -> new FunctionalException(Message.RESERVATION_NOT_FOUND + id));
globalReservation.setType(type);
return globalReservationRepository.save(globalReservation);
}
......@@ -502,8 +485,7 @@ public class GlobalReservationServiceImpl implements GlobalReservationService {
@Override
@Transactional
public GlobalReservation addSingleReservation(Long globalReservationId, SingleReservation singleReservation) throws FunctionalException {
GlobalReservation globalReservation = globalReservationRepository.findById(globalReservationId)
.orElseThrow(() -> new FunctionalException(Message.RESERVATION_NOT_FOUND + globalReservationId));
GlobalReservation globalReservation = globalReservationRepository.findById(globalReservationId).orElseThrow(() -> new FunctionalException(Message.RESERVATION_NOT_FOUND + globalReservationId));
singleReservation.setGlobalReservation(globalReservation);
singleReservationRepository.save(singleReservation);
globalReservation.getSingleReservations().add(singleReservation);
......@@ -512,8 +494,7 @@ public class GlobalReservationServiceImpl implements GlobalReservationService {
@Override
public Double calculateTotalPaid(Long globalReservationId) throws FunctionalException {
GlobalReservation globalReservation = globalReservationRepository.findById(globalReservationId)
.orElseThrow(() -> new FunctionalException(Message.RESERVATION_NOT_FOUND + globalReservationId));
GlobalReservation globalReservation = globalReservationRepository.findById(globalReservationId).orElseThrow(() -> new FunctionalException(Message.RESERVATION_NOT_FOUND + globalReservationId));
return globalReservation.getTotalAmount();
}
}
......
......@@ -38,42 +38,39 @@ public class SingleReservationServiceImpl implements SingleReservationService {
@Override
@Transactional
public SingleReservation createSingleReservation(SingleReservationDTO singleReservationDTO) throws FunctionalException {
// vehicleService.getVehicleById(singleReservationDTO.getVehicleId());
// GlobalReservation globalReservation = globalReservationRepository.findById(singleReservationDTO.getGlobalReservationId())
// .orElseThrow(() -> new FunctionalException(Message.RESERVATION_NOT_FOUND + singleReservationDTO.getGlobalReservationId()));
// SingleReservation singleReservation = singleReservationMapper.toEntity(singleReservationDTO);
// singleReservation.setGlobalReservation(globalReservation);
// return singleReservationRepository.save(singleReservation);
return null;
vehicleService.getVehicleById(singleReservationDTO.getVehicle().getId());
GlobalReservation globalReservation = globalReservationRepository.findById(singleReservationDTO.getGlobalReservationId())
.orElseThrow(() -> new FunctionalException(Message.RESERVATION_NOT_FOUND + singleReservationDTO.getGlobalReservationId()));
SingleReservation singleReservation = singleReservationMapper.toEntity(singleReservationDTO);
singleReservation.setGlobalReservation(globalReservation);
return singleReservationRepository.save(singleReservation);
}
@Override
@Transactional
public SingleReservation updateSingleReservation(Long id, SingleReservationDTO singleReservationDTO) throws FunctionalException {
// SingleReservation singleReservation = singleReservationRepository.findById(id)
// .orElseThrow(() -> new FunctionalException(Message.RESERVATION_NOT_FOUND + id));
// vehicleService.getVehicleById(singleReservationDTO.getVehicleId());
// GlobalReservation globalReservation = globalReservationRepository.findById(singleReservationDTO.getGlobalReservationId())
// .orElseThrow(() -> new FunctionalException(Message.RESERVATION_NOT_FOUND + singleReservationDTO.getGlobalReservationId()));
//
// SingleReservation updatedReservation = singleReservationMapper.toEntity(singleReservationDTO);
//
// updatedReservation.setUnitReservationId(singleReservation.getUnitReservationId());
// updatedReservation.setGlobalReservation(globalReservation);
// updatedReservation.setCancellationRequests(singleReservation.getCancellationRequests());
// updatedReservation.setReview(singleReservation.getReview());
// updatedReservation.setContract(singleReservation.getContract());
// updatedReservation.setDeposits(singleReservation.getDeposits());
//
// return singleReservationRepository.save(updatedReservation);
return null;
SingleReservation singleReservation = singleReservationRepository.findById(id)
.orElseThrow(() -> new FunctionalException(Message.RESERVATION_NOT_FOUND + id));
vehicleService.getVehicleById(singleReservationDTO.getVehicle().getId());
GlobalReservation globalReservation = globalReservationRepository.findById(singleReservationDTO.getGlobalReservationId())
.orElseThrow(() -> new FunctionalException(Message.RESERVATION_NOT_FOUND + singleReservationDTO.getGlobalReservationId()));
SingleReservation updatedReservation = singleReservationMapper.toEntity(singleReservationDTO);
updatedReservation.setUnitReservationId(singleReservation.getUnitReservationId());
updatedReservation.setGlobalReservation(globalReservation);
updatedReservation.setCancellationRequests(singleReservation.getCancellationRequests());
updatedReservation.setReview(singleReservation.getReview());
updatedReservation.setContract(singleReservation.getContract());
updatedReservation.setDeposits(singleReservation.getDeposits());
return singleReservationRepository.save(updatedReservation);
}
@Override
@Transactional
public void deleteSingleReservation(Long id) throws FunctionalException {
singleReservationRepository.findById(id)
.orElseThrow(() -> new FunctionalException(Message.RESERVATION_NOT_FOUND + id));
singleReservationRepository.findById(id).orElseThrow(() -> new FunctionalException(Message.RESERVATION_NOT_FOUND + id));
singleReservationRepository.deleteById(id);
}
......@@ -84,15 +81,13 @@ public class SingleReservationServiceImpl implements SingleReservationService {
@Override
public Optional<SingleReservation> getSingleReservationById(Long id) throws FunctionalException {
return Optional.of(singleReservationRepository.findById(id)
.orElseThrow(() -> new FunctionalException(Message.RESERVATION_NOT_FOUND + id)));
return Optional.of(singleReservationRepository.findById(id).orElseThrow(() -> new FunctionalException(Message.RESERVATION_NOT_FOUND + id)));
}
@Override
@Transactional
public SingleReservation changeReservationStatus(Long id, SingleReservationStatus status) throws FunctionalException {
SingleReservation singleReservation = singleReservationRepository.findById(id)
.orElseThrow(() -> new FunctionalException(Message.RESERVATION_NOT_FOUND + id));
SingleReservation singleReservation = singleReservationRepository.findById(id).orElseThrow(() -> new FunctionalException(Message.RESERVATION_NOT_FOUND + id));
singleReservation.setStatus(status);
return singleReservationRepository.save(singleReservation);
}
......@@ -121,22 +116,19 @@ public class SingleReservationServiceImpl implements SingleReservationService {
public boolean checkVehicleAvailability(Long vehicleId, LocalDate startDate, LocalDate endDate) throws FunctionalException {
vehicleService.getVehicleById(vehicleId);
List<SingleReservation> reservations = singleReservationRepository.findByVehicleId(vehicleId);
return reservations.stream().noneMatch(reservation ->
!(reservation.getReturnDate().isBefore(startDate) || reservation.getPickupDate().isAfter(endDate)));
return reservations.stream().noneMatch(reservation -> !(reservation.getReturnDate().isBefore(startDate) || reservation.getPickupDate().isAfter(endDate)));
}
@Override
public int calculateRentalDuration(Long singleReservationId) throws FunctionalException {
SingleReservation singleReservation = singleReservationRepository.findById(singleReservationId)
.orElseThrow(() -> new FunctionalException(Message.RESERVATION_NOT_FOUND + singleReservationId));
SingleReservation singleReservation = singleReservationRepository.findById(singleReservationId).orElseThrow(() -> new FunctionalException(Message.RESERVATION_NOT_FOUND + singleReservationId));
return (int) ChronoUnit.DAYS.between(singleReservation.getPickupDate(), singleReservation.getReturnDate());
}
@Override
@Transactional
public SingleReservation updateInsuranceOption(Long id, Boolean insurance) throws FunctionalException {
SingleReservation singleReservation = singleReservationRepository.findById(id)
.orElseThrow(() -> new FunctionalException(Message.RESERVATION_NOT_FOUND + id));
SingleReservation singleReservation = singleReservationRepository.findById(id).orElseThrow(() -> new FunctionalException(Message.RESERVATION_NOT_FOUND + id));
singleReservation.setInsurance(insurance);
return singleReservationRepository.save(singleReservation);
}
......@@ -144,26 +136,22 @@ public class SingleReservationServiceImpl implements SingleReservationService {
@Override
@Transactional
public SingleReservation associateContract(Long singleReservationId, Long contractId) throws FunctionalException {
SingleReservation singleReservation = singleReservationRepository.findById(singleReservationId)
.orElseThrow(() -> new FunctionalException(Message.RESERVATION_NOT_FOUND + singleReservationId));
Contract contract = contractRepository.findById(contractId)
.orElseThrow(() -> new FunctionalException(Message.CONTRACT_NOT_FOUND + contractId));
SingleReservation singleReservation = singleReservationRepository.findById(singleReservationId).orElseThrow(() -> new FunctionalException(Message.RESERVATION_NOT_FOUND + singleReservationId));
Contract contract = contractRepository.findById(contractId).orElseThrow(() -> new FunctionalException(Message.CONTRACT_NOT_FOUND + contractId));
singleReservation.setContract(contract);
return singleReservationRepository.save(singleReservation);
}
@Override
public Double calculateTotalCost(Long singleReservationId) throws FunctionalException {
SingleReservation singleReservation = singleReservationRepository.findById(singleReservationId)
.orElseThrow(() -> new FunctionalException(Message.RESERVATION_NOT_FOUND + singleReservationId));
SingleReservation singleReservation = singleReservationRepository.findById(singleReservationId).orElseThrow(() -> new FunctionalException(Message.RESERVATION_NOT_FOUND + singleReservationId));
return 100.0 * calculateRentalDuration(singleReservationId);
}
@Override
public ReservationDetailsDTO getReservationVehicleAndContractDetails(Long reservationId) throws FunctionalException {
SingleReservation reservation = singleReservationRepository.findById(reservationId)
.orElseThrow(() -> new FunctionalException(Message.RESERVATION_NOT_FOUND + reservationId));
SingleReservation reservation = singleReservationRepository.findById(reservationId).orElseThrow(() -> new FunctionalException(Message.RESERVATION_NOT_FOUND + reservationId));
Contract contract = reservation.getContract();
if (contract == null) {
......@@ -180,14 +168,7 @@ public class SingleReservationServiceImpl implements SingleReservationService {
throw new FunctionalException("Vehicle not found for ID: " + vehicleId);
}
return new ReservationDetailsDTO(
reservation.getUnitReservationId(),
vehicle.getId(),
vehicle.getRegistration(),
vehicle.getBrand(),
vehicle.getModel(),
contract.getId()
);
return new ReservationDetailsDTO(reservation.getUnitReservationId(), vehicle.getId(), vehicle.getRegistration(), vehicle.getBrand(), vehicle.getModel(), contract.getId());
}
}
0% ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter