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 | |
---|
1 | package com.example.rezevirajmasa.demo.config;
|
---|
2 |
|
---|
3 | import com.example.rezevirajmasa.demo.dto.ReservationDTO;
|
---|
4 | import com.example.rezevirajmasa.demo.dto.RestaurantDTO;
|
---|
5 | import com.example.rezevirajmasa.demo.dto.TableDTO;
|
---|
6 | import com.example.rezevirajmasa.demo.model.Reservation;
|
---|
7 | import com.example.rezevirajmasa.demo.model.Restaurant;
|
---|
8 | import com.example.rezevirajmasa.demo.model.TableEntity;
|
---|
9 | import org.modelmapper.ModelMapper;
|
---|
10 | import org.springframework.context.annotation.Bean;
|
---|
11 | import org.springframework.context.annotation.Configuration;
|
---|
12 |
|
---|
13 | @Configuration
|
---|
14 | public 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.