保誠-保戶業務員媒合平台
pamapi/src/main/java/com/pollex/pam/service/AppointmentService.java
@@ -25,6 +25,7 @@
import com.pollex.pam.service.mapper.AppointmentDTOMapper;
import com.pollex.pam.web.rest.errors.AppointmentNotFoundException;
import static com.pollex.pam.enums.AppointmentStatusEnum.AVAILABLE;
import static com.pollex.pam.enums.AppointmentStatusEnum.DELETED;
@Service
@@ -70,16 +71,17 @@
      return appointmentRepository.save(appointment);
   }
   public AppointmentCustomerViewDTO getAppointmentDetail(Long appointmentId) {
      AppointmentCustomerView appointment = appointmentCustomerViewRepository.findById(appointmentId)
            .orElseThrow(AppointmentNotFoundException::new);
      return appointmentCustomerViewMapper.toAppointmentCustomerViewDTO(appointment);
   }
    public List<Appointment> findByAgentNoAndCustomerId(String agentNo, Long customerId) {
        return appointmentRepository.findByAgentNoAndCustomerId(agentNo, customerId);
    public List<AppointmentCustomerView> findAvailableByAgentNoAndCustomerId(String agentNo, Long customerId) {
        return appointmentCustomerViewRepository.findByAgentNoAndCustomerId(agentNo, customerId)
            .stream()
            .filter(appointmentCustomerView -> appointmentCustomerView.getStatus() == AVAILABLE)
            .collect(Collectors.toList());
    }
    public void recordConsultantReadTime(Long appointmentId) {
@@ -102,7 +104,6 @@
    public void markAppointmentDeleted(Long appointmentId) {
        Appointment appointment = appointmentRepository.findById(appointmentId).get();
        appointment.setStatus(DELETED);
        appointmentRepository.save(appointment);
    }
@@ -117,7 +118,9 @@
    }
    public List<AppointmentCustomerViewDTO> getConsultantAppointments(String agentNo) {
        List<AppointmentCustomerView> appointmentList = appointmentCustomerViewRepository.findByAgentNo(agentNo);
        return appointmentCustomerViewMapper.toAppointmentCustomerViewDTO(appointmentList);
        return appointmentCustomerViewRepository.findByAgentNo(agentNo).stream()
            .filter(appointment -> appointment.getStatus() != DELETED)
            .map(appointmentCustomerViewMapper::toAppointmentCustomerViewDTO)
            .collect(Collectors.toList());
    }
}