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 |   20 ++++++++++++++++++--
 1 files changed, 18 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 fec6545..0d4c458 100644
--- a/pamapi/src/main/java/com/pollex/pam/service/AppointmentService.java
+++ b/pamapi/src/main/java/com/pollex/pam/service/AppointmentService.java
@@ -3,6 +3,8 @@
 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;
@@ -20,6 +22,8 @@
 import com.pollex.pam.service.mapper.AppointmentCustomerViewMapper;
 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
@@ -41,7 +45,7 @@
 
 	@Autowired
 	AppointmentCustomerViewRepository appointmentCustomerViewRepository;
-	
+
 	@Autowired
 	SatisfactionService satisfactionService;
 
@@ -50,7 +54,7 @@
 		appointment.setCustomerId(SecurityUtils.getCustomerDBId());
 		appointment.setCommunicateStatus(ContactStatusEnum.RESERVED);
 		appointmentRepository.save(appointment);
-		
+
 	}
 
 	public List<Appointment> findByAgentNo(String agentNo) {
@@ -87,4 +91,16 @@
             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