From 0f1695c2df8145fd355243f2972ae457e9d6ba0b Mon Sep 17 00:00:00 2001
From: wayne <wayne8692wayne8692@gmail.com>
Date: 星期一, 29 十一月 2021 19:57:41 +0800
Subject: [PATCH] [update] 調整EService的錯誤回覆代碼與訊息規格

---
 pamapi/src/main/java/com/pollex/pam/service/AppointmentService.java |   27 ++++++++++++++-------------
 1 files changed, 14 insertions(+), 13 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 5932aca..b23f88e 100644
--- a/pamapi/src/main/java/com/pollex/pam/service/AppointmentService.java
+++ b/pamapi/src/main/java/com/pollex/pam/service/AppointmentService.java
@@ -16,44 +16,41 @@
 import com.pollex.pam.service.dto.AppointmentCustomerViewDTO;
 import com.pollex.pam.service.mapper.AppointmentCustomerViewMapper;
 import com.pollex.pam.service.mapper.AppointmentDTOMapper;
-import com.pollex.pam.service.mapper.AppointmentMapper;
 import com.pollex.pam.web.rest.errors.AppointmentNotFoundException;
 
 @Service
 @Transactional
 public class AppointmentService {
-	
+
 	@Autowired
 	AppointmentRepository appointmentRepository;
-	
+
 	@Autowired
 	AppointmentDTOMapper appointmentDTOMapper;
-	
+
 	@Autowired
 	ConsultantService consultantService;
-	
+
 	@Autowired
 	AppointmentCustomerViewMapper appointmentCustomerViewMapper;
-	
+
 	@Autowired
 	AppointmentCustomerViewRepository appointmentCustomerViewRepository;
-	
-	
+
 	public void customerCreateAppointment(AppointmentCreateDTO appointmentCreateDTO) {
 		Appointment appointment = appointmentDTOMapper.toAppointment(appointmentCreateDTO);
-		appointment.setCustomerId(SecurityUtils.getCustomerId());
+		appointment.setCustomerId(SecurityUtils.getCustomerDBId());
 		appointment.setCommunicateStatus(ContactStatusEnum.RESERVED);
 		appointmentRepository.save(appointment);
 	}
-
 
 	public List<Appointment> findByAgentNo(String agentNo) {
 		return appointmentRepository.findByAgentNo(agentNo);
 	}
 
 	public void markAsContacted(Long appointmentId) {
-		
-		Appointment appointment = appointmentRepository.getById(appointmentId);
+
+		Appointment appointment = appointmentRepository.findById(appointmentId).get();
 		appointment.setCommunicateStatus(ContactStatusEnum.CONTACTED);
 		appointmentRepository.save(appointment);
 	}
@@ -64,5 +61,9 @@
 				.orElseThrow(AppointmentNotFoundException::new);
 		return appointmentCustomerViewMapper.toAppointmentCustomerViewDTO(appointment);
 	}
-	
+
+
+    public List<Appointment> findByAgentNoAndCustomerId(String agentNo, Long customerId) {
+        return appointmentRepository.findByAgentNoAndCustomerId(agentNo, customerId);
+    }
 }

--
Gitblit v1.8.0