保誠-保戶業務員媒合平台
wayne
2022-02-17 4394e4248455637ab7836756058ac872fdf4af10
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package com.pollex.pam.service.mapper;
 
import static java.util.stream.Collectors.toList;
 
import java.util.List;
 
import com.pollex.pam.enums.SatisfactionTypeEnum;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import com.pollex.pam.domain.Appointment;
import com.pollex.pam.domain.Satisfaction;
import com.pollex.pam.enums.SatisfactionStatusEnum;
import com.pollex.pam.repository.AppointmentRepository;
import com.pollex.pam.service.dto.AppointmentDTO;
 
@Service
public class AppointmentMapper {
 
    @Autowired
    AppointmentRepository appointmentRepository;
 
    public AppointmentDTO toAppointmentDTO(Appointment source) {
        AppointmentDTO target = new AppointmentDTO();
        BeanUtils.copyProperties(source, target);
        return target;
    }
 
    public List<AppointmentDTO> toAppointmentDTO(List<Appointment> source) {
        return source.stream()
                .map(s -> toAppointmentDTO(s)).collect(toList());
    }
 
    public Satisfaction toAppointmentSatisfaction(Appointment appointment) {
        Satisfaction target = new Satisfaction();
        target.setAppointmentId(appointment.getId());
        target.setAgentNo(appointment.getAgentNo());
        target.setCustomerId(appointment.getCustomerId());
        target.setType(SatisfactionTypeEnum.APPOINTMENT);
        target.setStatus(SatisfactionStatusEnum.UNFILLED);
        return target;
    }
 
    public Satisfaction toAppointmentSatisfaction(Long appointmentId) {
        Appointment appointment = appointmentRepository.findById(appointmentId).get();
        return toAppointmentSatisfaction(appointment);
    }
 
 
 
}