Files
garage_appointment/src/main/java/de/etecture/ga/service/GarageService.java
Matthias Engelien ebc66ff8f6 Documentation
2024-09-16 07:59:27 +02:00

34 lines
769 B
Java

package de.etecture.ga.service;
import java.util.Optional;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import de.etecture.ga.model.Garage;
import de.etecture.ga.repository.GarageRepository;
import lombok.AllArgsConstructor;
/**
* Service to handle all {@link Garage} related tasks
*/
@Service
@AllArgsConstructor
public class GarageService {
private final GarageRepository repository;
/**
* Reads the {@link Garage} object for the given id.
*
* @param garageId id of {@link Garage} to read
*
* @return a {@link Garage} for the given id
*/
public Optional<Garage> getGarage(long garageId) {
Assert.isTrue(garageId > 0, "A valid garageId must be given");
return repository.findById(garageId);
}
}