From d83d50b60935ad24730488c23e996b651647c295 Mon Sep 17 00:00:00 2001
From: wayne <wayne8692wayne8692@gmail.com>
Date: 星期一, 24 一月 2022 11:19:28 +0800
Subject: [PATCH] [update] 修正客戶若沒有未處理預約單時,改回null而非404

---
 pamapi/src/main/java/com/pollex/pam/service/mapper/AppointmentCustomerViewMapper.java |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/pamapi/src/main/java/com/pollex/pam/service/mapper/AppointmentCustomerViewMapper.java b/pamapi/src/main/java/com/pollex/pam/service/mapper/AppointmentCustomerViewMapper.java
index 823d73b..4389195 100644
--- a/pamapi/src/main/java/com/pollex/pam/service/mapper/AppointmentCustomerViewMapper.java
+++ b/pamapi/src/main/java/com/pollex/pam/service/mapper/AppointmentCustomerViewMapper.java
@@ -3,13 +3,19 @@
 import static java.util.stream.Collectors.toList;
 
 import java.util.List;
+import java.util.Optional;
 
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import com.pollex.pam.domain.AppointmentClosedInfo;
 import com.pollex.pam.domain.AppointmentCustomerView;
+import com.pollex.pam.domain.AppointmentNoticeLog;
+import com.pollex.pam.repository.AppointmentClosedInfoRepository;
+import com.pollex.pam.service.AppointmentClosedInfoService;
+import com.pollex.pam.service.AppointmentNoticeLogService;
 import com.pollex.pam.service.AppointmentService;
 import com.pollex.pam.service.dto.AppointmentCustomerViewDTO;
 
@@ -19,12 +25,27 @@
 	@Autowired
 	AppointmentService appointmentService;
 	
+	@Autowired
+	AppointmentNoticeLogService appointmentNoticeLogService;
+	
+	@Autowired
+	AppointmentClosedInfoRepository appointmentClosedInfoRepository;
+	
 	@Transactional
 	public AppointmentCustomerViewDTO toAppointmentCustomerViewDTO(AppointmentCustomerView source) {
 		AppointmentCustomerViewDTO target = new AppointmentCustomerViewDTO();
 		BeanUtils.copyProperties(source, target);
 		target.setAppointmentMemoList(source.getAppointmentMemoList());
 		appointmentService.setInterviewRecordDTO(target);
+		List<AppointmentNoticeLog> noticeLogs = appointmentNoticeLogService.findByAppointmentId(source.getId());
+		target.setAppointmentNoticeLogs(noticeLogs);
+		Optional<AppointmentClosedInfo> appointmentClosedInfoOP = appointmentClosedInfoRepository
+				.findByAppointmentId(source.getId());
+		if(appointmentClosedInfoOP.isPresent()) {
+			target.setAppointmentClosedInfo(appointmentClosedInfoOP.get());
+		}
+		appointmentService.setSatisfactionScore(target, source.getId());
+		
 		return target;
 	}
 

--
Gitblit v1.8.0