main
Last change
on this file since deea3c4 was deea3c4, checked in by Aleksandar Panovski <apano77@…>, 3 weeks ago |
Big change done fully handle_reservation_update() trigger works
|
-
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 | // Map Restaurant to RestaurantDTO
|
---|
20 | modelMapper.typeMap(Restaurant.class, RestaurantDTO.class).addMappings(mapper -> {
|
---|
21 | mapper.map(Restaurant::getTablesList, RestaurantDTO::setTablesList);
|
---|
22 | });
|
---|
23 |
|
---|
24 | // Map TableEntity to TableDTO
|
---|
25 | modelMapper.typeMap(TableEntity.class, TableDTO.class).addMappings(mapper -> {
|
---|
26 | mapper.map(TableEntity::getReservations, TableDTO::setReservations);
|
---|
27 | });
|
---|
28 |
|
---|
29 | // Map Reservation to ReservationDTO
|
---|
30 | modelMapper.typeMap(Reservation.class, ReservationDTO.class);
|
---|
31 |
|
---|
32 | return modelMapper;
|
---|
33 | }
|
---|
34 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.