| | |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import com.pollex.pam.domain.Satisfaction; |
| | | import com.pollex.pam.service.dto.AppointmentUpdateDTO; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | |
| | | public AppointmentCustomerViewDTO getAppointmentDetail(Long appointmentId) { |
| | | AppointmentCustomerView appointment = appointmentCustomerViewRepository.findById(appointmentId) |
| | | .orElseThrow(AppointmentNotFoundException::new); |
| | | return appointmentCustomerViewMapper.toAppointmentCustomerViewDTO(appointment); |
| | | |
| | | AppointmentCustomerViewDTO dto = appointmentCustomerViewMapper.toAppointmentCustomerViewDTO(appointment); |
| | | setSatisfactionScore(dto, appointmentId); |
| | | return dto; |
| | | } |
| | | |
| | | public List<AppointmentCustomerViewDTO> getConsultantAvailableAppointments(String agentNo) { |
| | | return appointmentCustomerViewRepository.findByAgentNo(agentNo).stream() |
| | | .filter(appointment -> appointment.getStatus() == AVAILABLE) |
| | | .map(appointmentCustomerView -> { |
| | | AppointmentCustomerViewDTO dto = appointmentCustomerViewMapper.toAppointmentCustomerViewDTO(appointmentCustomerView); |
| | | setSatisfactionScore(dto, appointmentCustomerView.getId()); |
| | | return dto; |
| | | }) |
| | | .collect(Collectors.toList()); |
| | | } |
| | | |
| | | public void setSatisfactionScore(AppointmentCustomerViewDTO dto, Long appointmentId) { |
| | | satisfactionService.getByAppointmentId(appointmentId).ifPresent(satisfaction -> { |
| | | dto.setSatisfactionScore(satisfaction.getScore()); |
| | | }); |
| | | } |
| | | |
| | | public List<AppointmentCustomerView> findAvailableByAgentNoAndCustomerId(String agentNo, Long customerId) { |
| | |
| | | |
| | | consultantNotViewAppointments.forEach(appointment -> appointment.setConsultantViewTime(Instant.now())); |
| | | appointmentRepository.saveAll(consultantNotViewAppointments); |
| | | } |
| | | |
| | | public List<AppointmentCustomerViewDTO> getConsultantAppointments(String agentNo) { |
| | | return appointmentCustomerViewRepository.findByAgentNo(agentNo).stream() |
| | | .filter(appointment -> appointment.getStatus() != DELETED) |
| | | .map(appointmentCustomerViewMapper::toAppointmentCustomerViewDTO) |
| | | .collect(Collectors.toList()); |
| | | } |
| | | } |