forked from Olympic/NTO-2025-Backend-TeamTask
Задания Backend нто
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
package com.example.nto.service.impl;
|
||||
|
||||
import com.example.nto.entity.Place;
|
||||
import com.example.nto.repository.PlaceRepository;
|
||||
import com.example.nto.service.PlaceService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class PlaceServiceImpl implements PlaceService {
|
||||
|
||||
private final PlaceRepository placeRepository;
|
||||
|
||||
public PlaceServiceImpl(PlaceRepository placeRepository) {
|
||||
this.placeRepository = placeRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Place> getAllPlaces() {
|
||||
return placeRepository.findAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Place getPlaceById(Long id) {
|
||||
return placeRepository.findById(id)
|
||||
.orElseThrow(() -> new RuntimeException("Place not found"));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user