source: src/main/java/com/example/rezevirajmasa/demo/config/ModelMapperConfig.java

main
Last change on this file was b67dfd3, checked in by Aleksandar Panovski <apano77@…>, 12 days ago

Normalization needed to continue, till here done

  • Property mode set to 100644
File size: 1.3 KB
Line 
1package com.example.rezevirajmasa.demo.config;
2
3import com.example.rezevirajmasa.demo.dto.ReservationDTO;
4import com.example.rezevirajmasa.demo.dto.RestaurantDTO;
5import com.example.rezevirajmasa.demo.dto.TableDTO;
6import com.example.rezevirajmasa.demo.model.Reservation;
7import com.example.rezevirajmasa.demo.model.Restaurant;
8import com.example.rezevirajmasa.demo.model.TableEntity;
9import org.modelmapper.ModelMapper;
10import org.springframework.context.annotation.Bean;
11import org.springframework.context.annotation.Configuration;
12
13@Configuration
14public class ModelMapperConfig {
15 @Bean
16 public ModelMapper modelMapper() {
17 ModelMapper modelMapper = new ModelMapper();
18
19 modelMapper.typeMap(Restaurant.class, RestaurantDTO.class).addMappings(mapper -> {
20 mapper.map(Restaurant::getTablesList, RestaurantDTO::setTablesList);
21 });
22
23 modelMapper.typeMap(TableEntity.class, TableDTO.class).addMappings(mapper -> {
24 mapper.map(TableEntity::getReservations, TableDTO::setReservations);
25 });
26
27 modelMapper.typeMap(Reservation.class, ReservationDTO.class).addMappings(mapper -> {
28 mapper.map(Reservation::getReservationStatus, ReservationDTO::setReservationStatus);
29 mapper.map(Reservation::getPaymentStatus, ReservationDTO::setPaymentStatus);
30 });
31
32 return modelMapper;
33 }
34}
Note: See TracBrowser for help on using the repository browser.