forked from Olympic/NTO-2025-Backend-TeamTask
41 lines
1.2 KiB
Java
41 lines
1.2 KiB
Java
package com.example.nto.utils;
|
|
|
|
import com.example.nto.DTO.BookingDTO;
|
|
import com.example.nto.DTO.EmployeeDTO;
|
|
import com.example.nto.DTO.PlaceDTO;
|
|
import com.example.nto.entity.Booking;
|
|
import com.example.nto.entity.Employee;
|
|
import com.example.nto.entity.Place;
|
|
|
|
public class MapperEnToDTO {
|
|
public static EmployeeDTO toEmployeeInfoDto(Employee employee) {
|
|
EmployeeDTO dto = new EmployeeDTO();
|
|
dto.setName(employee.getName());
|
|
dto.setPhotoUrl(employee.getPhotoUrl());
|
|
|
|
if (employee.getBookingList() != null) {
|
|
for (Booking booking : employee.getBookingList()) {
|
|
BookingDTO bookingDto = toBookingInfoDto(booking);
|
|
dto.getBookings().put(booking.getDate().toString(), bookingDto);
|
|
}
|
|
}
|
|
|
|
return dto;
|
|
}
|
|
public static BookingDTO toBookingInfoDto(Booking booking) {
|
|
BookingDTO dto = new BookingDTO();
|
|
dto.setId(booking.getId());
|
|
dto.setPlace(toPlaceDto(booking.getPlace()));
|
|
return dto;
|
|
}
|
|
|
|
public static PlaceDTO toPlaceDto(Place place) {
|
|
if (place == null) return null;
|
|
|
|
PlaceDTO dto = new PlaceDTO();
|
|
dto.setId(place.getId());
|
|
dto.setName(place.getPlace());
|
|
return dto;
|
|
}
|
|
}
|