source: backend/src/main/java/com/finki/icare/mapper/TherapistMapper.java

main
Last change on this file was 700e2f9, checked in by 186079 <matej.milevski@…>, 5 days ago

Init

  • Property mode set to 100644
File size: 1.2 KB
RevLine 
[700e2f9]1package com.finki.icare.mapper;
2
3import com.finki.icare.dto.TherapistDTO;
4import com.finki.icare.model.Therapist;
5import org.mapstruct.*;
6
7import java.time.LocalDate;
8import java.util.ArrayList;
9import java.util.Arrays;
10import java.util.List;
11
12@Mapper(componentModel = MappingConstants.ComponentModel.SPRING)
13public interface TherapistMapper {
14
15 @Mapping(target = "idUser", source = "idUser")
16 @Mapping(target = "name", source = "name")
17 @Mapping(target = "surname", source = "surname")
18 @Mapping(target = "email", source = "email")
19 @Mapping(target = "officeLocation", source = "officeLocation")
20 @Mapping(target = "degree", source = "degree")
21 @Mapping(target = "yearsExp", source = "yearsExp")
22 @Mapping(target = "phoneNumber", source = "phoneNumber")
23 @Mapping(target = "freeConsultationSlots", source = "consultationSlots", qualifiedByName = "filterFutureSlots")
24 TherapistDTO toDTO(Therapist therapist);
25
26 @Named("filterFutureSlots")
27 default List<LocalDate> filterFutureSlots(LocalDate[] slots) {
28 if (slots == null) {
29 return new ArrayList<>();
30 }
31 return Arrays.stream(slots)
32 .filter(slot -> !slot.isBefore(LocalDate.now()))
33 .sorted()
34 .toList();
35 }
36}
37
Note: See TracBrowser for help on using the repository browser.