починка сеансов
This commit is contained in:
parent
ce15f93adb
commit
a41fcf5618
@ -39,6 +39,12 @@ public class SessionService {
|
||||
.orElseThrow(() -> new SessionNotFoundException(id));
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public Session findBaseSession(Long id) {
|
||||
return sessionRepository.findById(id)
|
||||
.orElseThrow(() -> new SessionNotFoundException(id));
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public List<SessionExtension> findAllSessions() {
|
||||
return sessionRepository.getSessionsWithCapacity();
|
||||
@ -46,7 +52,7 @@ public class SessionService {
|
||||
|
||||
@Transactional
|
||||
public Session updateSession(Long id, Double price) {
|
||||
final Session currentSession = findSession(id);
|
||||
final Session currentSession = findBaseSession(id);
|
||||
currentSession.setPrice(price);
|
||||
validatorUtil.validate(currentSession);
|
||||
return sessionRepository.save(currentSession);
|
||||
@ -54,7 +60,7 @@ public class SessionService {
|
||||
|
||||
@Transactional
|
||||
public Session deleteSession(Long id) {
|
||||
final Session currentSession = findSession(id);
|
||||
final Session currentSession = findBaseSession(id);
|
||||
// все равно сеанс не удалился бы, который участвует в заказах
|
||||
// для отслеживания операции с ошибкой
|
||||
if (currentSession.getOrders().size() > 0)
|
||||
|
Loading…
Reference in New Issue
Block a user