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

Last change on this file was f29cd58, checked in by gjoko kostadinov <gjokokostadinov@…>, 10 months ago

Add services search functionality.

  • Property mode set to 100644
File size: 1.3 KB
Line 
1package edu.gjoko.schedlr.mappers;
2
3import edu.gjoko.schedlr.dto.AppointmentDto;
4import edu.gjoko.schedlr.dto.ServiceDto;
5import edu.gjoko.schedlr.entity.Appointment;
6import org.modelmapper.ModelMapper;
7import org.modelmapper.TypeMap;
8import org.modelmapper.config.Configuration;
9import org.springframework.stereotype.Service;
10
11import java.lang.reflect.Type;
12
13@Service
14public class ServiceDtoMapper extends ModelMapper {
15
16 public ServiceDtoMapper() {
17 this.getConfiguration().setFieldMatchingEnabled(true).setFieldAccessLevel(Configuration.AccessLevel.PRIVATE);
18 TypeMap<edu.gjoko.schedlr.entity.Service, ServiceDto> propertyMapper = this.createTypeMap(edu.gjoko.schedlr.entity.Service.class, ServiceDto.class);
19 propertyMapper.addMappings(
20 mapper -> mapper.map(service -> service.getBusiness().getCompanyName(), ServiceDto::setBusinessName)
21 );
22 propertyMapper.addMappings(
23 mapper -> mapper.map(service -> service.getServiceType().getName(), ServiceDto::setServiceName)
24 );
25 propertyMapper.addMappings(
26 mapper -> mapper.map(service -> service.getBusiness().getId(), ServiceDto::setBusinessId)
27 );
28 }
29
30 public ServiceDto serviceToServiceDto(edu.gjoko.schedlr.entity.Service service) {
31 return this.map(service, ServiceDto.class);
32 }
33}
Note: See TracBrowser for help on using the repository browser.