保誠-保戶業務員媒合平台
wayne
2021-12-02 00ac6f95a8cc129ec262f27ce6a162d0713bf002
pamapi/src/main/java/com/pollex/pam/service/AppointmentService.java
@@ -2,6 +2,8 @@
import java.time.Instant;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import com.pollex.pam.enums.AppointmentStatusEnum;
import com.pollex.pam.service.dto.AppointmentDTO;
@@ -103,4 +105,19 @@
        appointmentRepository.save(appointment);
    }
    public void recordAllAppointmentsView(String agentNo) {
        List<Appointment> consultantNotViewAppointments = findByAgentNo(agentNo)
            .stream()
            .filter(appointment -> Objects.isNull(appointment.getConsultantViewTime()))
            .collect(Collectors.toList());
        consultantNotViewAppointments.forEach(appointment -> appointment.setConsultantViewTime(Instant.now()));
        appointmentRepository.saveAll(consultantNotViewAppointments);
    }
    public List<AppointmentCustomerViewDTO> getConsultantAppointments(String agentNo) {
        List<AppointmentCustomerView> appointmentList = appointmentCustomerViewRepository.findByAgentNo(agentNo);
        return appointmentCustomerViewMapper.toAppointmentCustomerViewDTO(appointmentList);
    }
}