34 lines
769 B
Java
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);
|
|
}
|
|
}
|