This commit is contained in:
2025-12-04 17:20:04 +06:00
parent 83b3202ea2
commit 7e286a3a7b
22 changed files with 431 additions and 15 deletions

View File

@@ -0,0 +1,40 @@
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;
}
}