Complete backend functionality
Some checks failed
Android Test / validate-and-test (pull_request) Has been cancelled

This commit is contained in:
2025-12-11 20:15:53 +07:00
parent 83b3202ea2
commit cebc033f0f
17 changed files with 327 additions and 14 deletions

View File

@@ -1,6 +1,18 @@
package com.example.nto.service.impl;
import com.example.nto.entity.Booking;
import com.example.nto.entity.Employee;
import com.example.nto.entity.Place;
import com.example.nto.repository.BookingRepository;
import com.example.nto.service.BookingService;
import io.micrometer.common.lang.Nullable;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.time.LocalDate;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
/**
* TODO: ДОРАБОТАТЬ в рамках задания
@@ -8,5 +20,29 @@ import com.example.nto.service.BookingService;
* МОЖНО: Добавлять методы, аннотации, зависимости
* НЕЛЬЗЯ: Изменять название класса и пакета
*/
@Service
public class BookingServiceImpl implements BookingService {
@Autowired
private BookingRepository bookingRepository;
@Override
@Nullable
public Booking getById(Long id) {
return bookingRepository.findById(id).orElseGet(() -> null);
}
@Override
public List<Booking> getAll() {
return StreamSupport.stream(bookingRepository.findAll().spliterator(), false).collect(Collectors.toList());
}
@Override
public void save(LocalDate date, Place place, Employee employee) {
var booking = Booking.builder()
.date(date)
.place(place)
.employee(employee)
.build();
bookingRepository.save(booking);
}
}