From 82e2a62e7c90cc191f9e2ebc569fe3a3663b68b0 Mon Sep 17 00:00:00 2001 From: wayne <wayne8692wayne8692@gmail.com> Date: 星期五, 03 十二月 2021 11:19:00 +0800 Subject: [PATCH] Merge branch '預約單更新與刪除' --- pamapi/src/main/java/com/pollex/pam/service/AppointmentService.java | 17 ++++++++++------- 1 files changed, 10 insertions(+), 7 deletions(-) diff --git a/pamapi/src/main/java/com/pollex/pam/service/AppointmentService.java b/pamapi/src/main/java/com/pollex/pam/service/AppointmentService.java index 7e23420..42ef0ae 100644 --- a/pamapi/src/main/java/com/pollex/pam/service/AppointmentService.java +++ b/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()); } } -- Gitblit v1.8.0