This commit is contained in:
2025-12-11 21:16:40 +03:00
parent 6e83eb0cbb
commit cd9bde6641

View File

@@ -2,8 +2,10 @@ 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.EmployeeRepository;
import com.example.nto.service.EmployeeService;
import jakarta.transaction.Transactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -29,6 +31,7 @@ public class EmployeeServiceImpl implements EmployeeService {
}
@Override
@Transactional
public Optional<Map<String, Object>> getEmployeeInfo(String code) {
Optional<Employee> employeeOpt = employeeRepository.findByCode(code);
@@ -43,12 +46,17 @@ public class EmployeeServiceImpl implements EmployeeService {
Map<String, Map<String, Object>> bookingsMap = new HashMap<>();
// Используем bookingList вместо bookings
if (employee.getBookingList() != null) {
for (Booking booking : employee.getBookingList()) {
Map<String, Object> bookingInfo = new HashMap<>();
bookingInfo.put("id", booking.getId());
bookingInfo.put("place", booking.getPlace());
Place place = booking.getPlace();
String placeName = "";
if (place != null) {
placeName = place.getPlace();
}
bookingInfo.put("place", placeName);
bookingsMap.put(booking.getDate().toString(), bookingInfo);
}