source: src/main/java/edu/gjoko/schedlr/mappers/AppointmentInfoDtoCustomerMapper.java

Last change on this file was 77205be, checked in by gjoko kostadinov <gjokokostadinov@…>, 11 months ago

Add entire code

  • Property mode set to 100644
File size: 1.7 KB
Line 
1package edu.gjoko.schedlr.mappers;
2
3import edu.gjoko.schedlr.dto.AppointmentInfoDto;
4import edu.gjoko.schedlr.entity.Appointment;
5import org.modelmapper.ModelMapper;
6import org.modelmapper.TypeMap;
7import org.modelmapper.config.Configuration;
8import org.springframework.stereotype.Service;
9
10@Service
11public class AppointmentInfoDtoCustomerMapper extends ModelMapper {
12
13 public AppointmentInfoDtoCustomerMapper() {
14 this.getConfiguration().setFieldMatchingEnabled(true).setFieldAccessLevel(Configuration.AccessLevel.PRIVATE);
15 TypeMap<Appointment, AppointmentInfoDto> propertyMapper = this.createTypeMap(Appointment.class, AppointmentInfoDto.class);
16 propertyMapper.addMappings(
17 mapper -> {
18 mapper.map(Appointment::getId, AppointmentInfoDto::setAppointmentId);
19 mapper.map(appointment -> appointment.getService().getBusiness().getOwner().getFullName(), AppointmentInfoDto::setFullName);
20 mapper.map(appointment -> appointment.getCustomer().getEmail(), AppointmentInfoDto::setEmail);
21 mapper.map(appointment -> appointment.getCustomer().getPhoneNumber(),AppointmentInfoDto::setPhoneNumber);
22 mapper.map(Appointment::getTimePeriod, AppointmentInfoDto::setTimePeriod);
23 mapper.map(appointment -> appointment.getService().getServiceType().getName(), AppointmentInfoDto::setServiceName);
24 mapper.map(Appointment::getAppointmentStatus, AppointmentInfoDto::setStatus);
25 }
26 );
27 }
28
29 public AppointmentInfoDto appointmentToAppointmentInfoDto(Appointment appointment) {
30 return this.map(appointment, AppointmentInfoDto.class);
31 }
32}
Note: See TracBrowser for help on using the repository browser.