From bb9e8aad46c1667625b451b8df458a441bfc792f Mon Sep 17 00:00:00 2001 From: wayne <wayne8692wayne8692@gmail.com> Date: 星期四, 02 十二月 2021 16:02:12 +0800 Subject: [PATCH] [update]【todo 131433, 131432】預約單更新與刪除API --- pamapi/src/main/java/com/pollex/pam/service/AppointmentService.java | 37 +++++++++++++++++++++++++++++++++++-- 1 files changed, 35 insertions(+), 2 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 5b67184..0d4c458 100644 --- a/pamapi/src/main/java/com/pollex/pam/service/AppointmentService.java +++ b/pamapi/src/main/java/com/pollex/pam/service/AppointmentService.java @@ -1,7 +1,12 @@ package com.pollex.pam.service; +import java.time.Instant; import java.util.List; +import com.pollex.pam.enums.AppointmentStatusEnum; +import com.pollex.pam.service.dto.AppointmentDTO; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -18,9 +23,13 @@ import com.pollex.pam.service.mapper.AppointmentDTOMapper; import com.pollex.pam.web.rest.errors.AppointmentNotFoundException; +import static com.pollex.pam.enums.AppointmentStatusEnum.DELETED; + @Service @Transactional public class AppointmentService { + + private static final Logger log = LoggerFactory.getLogger(AppointmentService.class); @Autowired AppointmentRepository appointmentRepository; @@ -36,7 +45,7 @@ @Autowired AppointmentCustomerViewRepository appointmentCustomerViewRepository; - + @Autowired SatisfactionService satisfactionService; @@ -45,7 +54,7 @@ appointment.setCustomerId(SecurityUtils.getCustomerDBId()); appointment.setCommunicateStatus(ContactStatusEnum.RESERVED); appointmentRepository.save(appointment); - + } public List<Appointment> findByAgentNo(String agentNo) { @@ -70,4 +79,28 @@ public List<Appointment> findByAgentNoAndCustomerId(String agentNo, Long customerId) { return appointmentRepository.findByAgentNoAndCustomerId(agentNo, customerId); } + + public void recordConsultantReadTime(Long appointmentId) { + Appointment appointment = appointmentRepository.findById(appointmentId).get(); + + if(appointment.getConsultantReadTime() == null) { + appointment.setConsultantReadTime(Instant.now()); + appointmentRepository.save(appointment); + } + else { + log.debug("this appointment was read, read time = {}", appointment.getConsultantReadTime()); + } + } + + public void updateAppointment(AppointmentDTO appointmentDTO) { + Appointment appointment = appointmentDTOMapper.toAppointment(appointmentDTO); + appointmentRepository.save(appointment); + } + + public void markAppointmentDeleted(Long appointmentId) { + Appointment appointment = appointmentRepository.findById(appointmentId).get(); + appointment.setStatus(DELETED); + + appointmentRepository.save(appointment); + } } -- Gitblit v1.8.0