From 0e73f60f5e9acede5438b0c38332183916f9d552 Mon Sep 17 00:00:00 2001
From: Jack <jack.su@pollex.com.tw>
Date: 星期五, 03 十二月 2021 16:54:57 +0800
Subject: [PATCH] Merge branch 'master' of ssh://192.168.0.10:29418/pcalife/PAM

---
 pamapi/src/main/resources/config/application-dev.yml                               |    1 
 pamapi/src/doc/顧問API/客戶的顧問清單.txt                                                   |   19 -
 pamapi/src/main/java/com/pollex/pam/service/dto/AppointmentUpdateDTO.java          |   94 ++++++++++
 pamapi/src/main/java/com/pollex/pam/web/rest/ConsultantResource.java               |    1 
 pamapi/src/main/java/com/pollex/pam/web/rest/AppointmentResource.java              |    4 
 pamapi/src/main/java/com/pollex/pam/service/mapper/ConsultantMapper.java           |    7 
 /dev/null                                                                          |   85 ---------
 pamapi/src/doc/預約單/顧問取得所有自己的預約單API.txt                                             |  140 +++++++++++++++
 pamapi/src/doc/sql/20211203_w.sql                                                  |    1 
 pamapi/src/main/java/com/pollex/pam/service/dto/AppointmentCustomerViewDTO.java    |    8 
 pamapi/src/main/java/com/pollex/pam/service/AppointmentService.java                |   49 ++++-
 pamapi/src/main/java/com/pollex/pam/service/dto/CustomerFavoriteConsultantDTO.java |   27 ---
 pamapi/src/main/java/com/pollex/pam/service/ConsultantService.java                 |   36 +--
 pamapi/src/doc/預約單/更新預約單明細API.txt                                                  |    9 
 14 files changed, 297 insertions(+), 184 deletions(-)

diff --git a/pamapi/src/doc/sql/20211203_w.sql b/pamapi/src/doc/sql/20211203_w.sql
new file mode 100644
index 0000000..b6adcdc
--- /dev/null
+++ b/pamapi/src/doc/sql/20211203_w.sql
@@ -0,0 +1 @@
+UPDATE omo.appointment SET contact_time = appointment_date where communicate_status = 'CONTACTED';
diff --git "a/pamapi/src/doc/\351\240\220\347\264\204\345\226\256/\346\233\264\346\226\260\351\240\220\347\264\204\345\226\256\346\230\216\347\264\260API.txt" "b/pamapi/src/doc/\351\240\220\347\264\204\345\226\256/\346\233\264\346\226\260\351\240\220\347\264\204\345\226\256\346\230\216\347\264\260API.txt"
index 366e360..b9031dc 100644
--- "a/pamapi/src/doc/\351\240\220\347\264\204\345\226\256/\346\233\264\346\226\260\351\240\220\347\264\204\345\226\256\346\230\216\347\264\260API.txt"
+++ "b/pamapi/src/doc/\351\240\220\347\264\204\345\226\256/\346\233\264\346\226\260\351\240\220\347\264\204\345\226\256\346\230\216\347\264\260API.txt"
@@ -11,15 +11,8 @@
     "age": "under_20",
     "job": "��",
     "requirement": "�摨瑁����,摮戊��,鞈閬��",
-    "communicateStatus": "reserved",
     "hopeContactTime": "'蝳格��,蝳格���,蝳格���,蝳格���,蝳格���,蝳格�,蝳格���9:00~12:00,12:00~14:00,14:00~18:00,18:00~21:00'",
-    "otherRequirement": null,
-    "appointmentDate": "2021-12-01T04:27:20.154Z",
-    "lastModifiedDate": "2021-12-01T04:27:20.154Z",
-    "agentNo": "J149388015",
-    "customerId": 76,
-    "consultantViewTime": null,
-    "consultantReadTime": null
+    "otherRequirement": null
 }
 
 http response status: 204
diff --git "a/pamapi/src/doc/\351\240\220\347\264\204\345\226\256/\351\241\247\345\225\217\345\217\226\345\276\227\346\211\200\346\234\211\350\207\252\345\267\261\347\232\204\351\240\220\347\264\204\345\226\256API" "b/pamapi/src/doc/\351\240\220\347\264\204\345\226\256/\351\241\247\345\225\217\345\217\226\345\276\227\346\211\200\346\234\211\350\207\252\345\267\261\347\232\204\351\240\220\347\264\204\345\226\256API"
deleted file mode 100644
index 2d3cb76..0000000
--- "a/pamapi/src/doc/\351\240\220\347\264\204\345\226\256/\351\241\247\345\225\217\345\217\226\345\276\227\346\211\200\346\234\211\350\207\252\345\267\261\347\232\204\351\240\220\347\264\204\345\226\256API"
+++ /dev/null
@@ -1,85 +0,0 @@
-http get :
-
-http://localhost:8080/api/consultant/getMyAppointment
-
-
-
-response body :
-[
-    {
-        "id": 13,
-        "phone": "09123456789",
-        "email": "pollex@pollex.comm.tw",
-        "contactType": "phone",
-        "gender": "male",
-        "age": null,
-        "job": "撠����",
-        "requirement": "鞎∪����,鞈蝘餉��",
-        "communicateStatus": "reserved",
-        "hopeContactTime": "'����~�����, 12:00~14:00, 18:00~21:00'",
-        "otherRequirement": "憭馳����",
-        "appointmentDate": "2021-11-10T04:15:11.292Z",
-        "agentNo": "admin",
-        "customerId": 2,
-        "name": "Jack",
-        "consultantViewTime": "2021-12-01T08:04:59.369Z",
-        "consultantReadTime": "2021-12-01T08:05:59.857Z"
-    },
-    {
-        "id": 14,
-        "phone": "09123456789",
-        "email": "pollex@pollex.comm.tw",
-        "contactType": "phone",
-        "gender": "male",
-        "age": null,
-        "job": "撠����",
-        "requirement": "鞎∪����,鞈蝘餉��",
-        "communicateStatus": "reserved",
-        "hopeContactTime": "'����~�����, 12:00~14:00, 18:00~21:00'",
-        "otherRequirement": "憭馳����",
-        "appointmentDate": "2021-11-10T04:16:22.526Z",
-        "agentNo": "admin",
-        "customerId": 2,
-        "name": "Jack",
-        "consultantViewTime": "2021-12-01T08:04:59.369Z",
-        "consultantReadTime": "2021-12-01T08:05:59.857Z"
-    },
-    {
-        "id": 15,
-        "phone": "09123456789",
-        "email": "pollex@pollex.comm.tw",
-        "contactType": "phone",
-        "gender": "male",
-        "age": null,
-        "job": "撠����",
-        "requirement": "鞎∪����,鞈蝘餉��",
-        "communicateStatus": "reserved",
-        "hopeContactTime": "'����~�����, 12:00~14:00, 18:00~21:00'",
-        "otherRequirement": "憭馳����",
-        "appointmentDate": "2021-11-10T09:42:28.134Z",
-        "agentNo": "admin",
-        "customerId": 2,
-        "name": "Jack",
-        "consultantViewTime": "2021-12-01T08:04:59.369Z",
-        "consultantReadTime": "2021-12-01T08:05:59.857Z"
-    },
-    {
-        "id": 16,
-        "phone": "09123456789",
-        "email": "pollex@pollex.comm.tw",
-        "contactType": "phone",
-        "gender": "male",
-        "age": "20-25",
-        "job": "撠����",
-        "requirement": "鞎∪����,鞈蝘餉��",
-        "communicateStatus": "reserved",
-        "hopeContactTime": "'����~�����, 12:00~14:00, 18:00~21:00'",
-        "otherRequirement": "憭馳����",
-        "appointmentDate": "2021-11-10T09:44:43.445Z",
-        "agentNo": "admin",
-        "customerId": 2,
-        "name": "Jack",
-        "consultantViewTime": "2021-12-01T08:04:59.369Z",
-        "consultantReadTime": "2021-12-01T08:05:59.857Z"
-    }
-]
diff --git "a/pamapi/src/doc/\351\240\220\347\264\204\345\226\256/\351\241\247\345\225\217\345\217\226\345\276\227\346\211\200\346\234\211\350\207\252\345\267\261\347\232\204\351\240\220\347\264\204\345\226\256API.txt" "b/pamapi/src/doc/\351\240\220\347\264\204\345\226\256/\351\241\247\345\225\217\345\217\226\345\276\227\346\211\200\346\234\211\350\207\252\345\267\261\347\232\204\351\240\220\347\264\204\345\226\256API.txt"
new file mode 100644
index 0000000..24949fd
--- /dev/null
+++ "b/pamapi/src/doc/\351\240\220\347\264\204\345\226\256/\351\241\247\345\225\217\345\217\226\345\276\227\346\211\200\346\234\211\350\207\252\345\267\261\347\232\204\351\240\220\347\264\204\345\226\256API.txt"
@@ -0,0 +1,140 @@
+http get :
+
+http://localhost:8080/api/consultant/getMyAppointment
+
+
+
+[
+    {
+        "id": 110,
+        "phone": "09123456789",
+        "email": "",
+        "contactType": "mobile",
+        "gender": "male",
+        "age": "30",
+        "job": "��",
+        "requirement": "摮戊��,鞈閬��,��靽����",
+        "communicateStatus": "contacted",
+        "hopeContactTime": "'蝳格���,蝳格����12:00~14:00,14:00~18:00'",
+        "otherRequirement": null,
+        "appointmentDate": "2021-12-02T09:58:58.932Z",
+        "lastModifiedDate": "2021-12-02T09:58:58.932Z",
+        "agentNo": "AG0109051204",
+        "customerId": 70,
+        "name": null,
+        "consultantViewTime": "2021-12-02T09:58:12.066Z",
+        "consultantReadTime": "2021-12-02T09:58:58.930Z",
+        "contactTime": "2021-12-02T09:58:58.930Z",
+        "satisfactionScore":3 // null 隞�銵刻府蝑��撠憛怠神皛踵�漲
+    },
+    {
+        "id": 109,
+        "phone": "09123456789",
+        "email": "",
+        "contactType": "mobile",
+        "gender": "male",
+        "age": "20",
+        "job": "��",
+        "requirement": "�摨瑁����,摮戊��,靽�瑼�/閬��,��靽����",
+        "communicateStatus": "contacted",
+        "hopeContactTime": "'蝳格��,蝳格���,蝳格���,蝳格���,蝳格���,蝳格�,蝳格���12:00~14:00,14:00~18:00'",
+        "otherRequirement": null,
+        "appointmentDate": "2021-12-02T10:12:24.613Z",
+        "lastModifiedDate": "2021-12-02T10:12:24.613Z",
+        "agentNo": "AG0109051204",
+        "customerId": 67,
+        "name": null,
+        "consultantViewTime": "2021-12-02T09:58:12.066Z",
+        "consultantReadTime": "2021-12-02T10:12:24.612Z",
+        "contactTime": null,
+        "satisfactionScore":3 // null 隞�銵刻府蝑��撠憛怠神皛踵�漲
+    },
+    {
+        "id": 114,
+        "phone": "09123456789",
+        "email": "",
+        "contactType": "mobile",
+        "gender": "male",
+        "age": "70",
+        "job": "��",
+        "requirement": "�摨瑁����,摮戊��,鞈閬��,璅暑��隡�,��靽����",
+        "communicateStatus": "contacted",
+        "hopeContactTime": "'蝳格��,蝳格���,蝳格���,蝳格���,蝳格���,蝳格�,蝳格���12:00~14:00,14:00~18:00'",
+        "otherRequirement": null,
+        "appointmentDate": "2021-12-02T09:58:12.248Z",
+        "lastModifiedDate": "2021-12-02T09:58:12.248Z",
+        "agentNo": "AG0109051204",
+        "customerId": 71,
+        "name": null,
+        "consultantViewTime": "2021-12-02T09:58:12.066Z",
+        "consultantReadTime": null,
+        "contactTime": null,
+        "satisfactionScore":3 // null 隞�銵刻府蝑��撠憛怠神皛踵�漲
+    },
+    {
+        "id": 121,
+        "phone": "09123456789",
+        "email": "",
+        "contactType": "mobile",
+        "gender": "male",
+        "age": "20",
+        "job": "��",
+        "requirement": "摮戊��",
+        "communicateStatus": "contacted",
+        "hopeContactTime": "'蝳格��,蝳格���,蝳格���,蝳格���,蝳格���,蝳格�,蝳格���9:00~12:00,12:00~14:00,14:00~18:00,18:00~21:00'",
+        "otherRequirement": null,
+        "appointmentDate": "2021-12-02T09:58:12.248Z",
+        "lastModifiedDate": "2021-12-02T09:58:12.248Z",
+        "agentNo": "AG0109051204",
+        "customerId": 76,
+        "name": "��蝬�",
+        "consultantViewTime": "2021-12-02T09:58:12.066Z",
+        "consultantReadTime": "2021-12-02T09:54:20.872Z",
+        "contactTime": null,
+        "satisfactionScore":3 // null 隞�銵刻府蝑��撠憛怠神皛踵�漲
+    },
+    {
+        "id": 118,
+        "phone": "09123456789",
+        "email": "",
+        "contactType": "mobile",
+        "gender": "male",
+        "age": "20",
+        "job": "��",
+        "requirement": "�摨瑁����",
+        "communicateStatus": "contacted",
+        "hopeContactTime": "'蝳格��,蝳格���,蝳格���,蝳格���,蝳格���,蝳格�,蝳格���12:00~14:00,14:00~18:00'",
+        "otherRequirement": null,
+        "appointmentDate": "2021-12-02T10:02:52.797Z",
+        "lastModifiedDate": "2021-12-02T10:02:52.797Z",
+        "agentNo": "AG0109051204",
+        "customerId": 72,
+        "name": null,
+        "consultantViewTime": "2021-12-02T09:58:12.066Z",
+        "consultantReadTime": "2021-12-02T10:02:52.796Z",
+        "contactTime": null,
+        "satisfactionScore":3 // null 隞�銵刻府蝑��撠憛怠神皛踵�漲
+    },
+    {
+        "id": 180,
+        "phone": "0911111111",
+        "email": "",
+        "contactType": "phone",
+        "gender": "female",
+        "age": "31-40",
+        "job": "��",
+        "requirement": "摮戊��,�摨瑁����",
+        "communicateStatus": "contacted",
+        "hopeContactTime": "'蝳格���,蝳格���,蝳格���,蝳格���,蝳格���9:00~12:00,12:00~14:00,14:00~18:00,18:00~21:00','蝳格��,蝳格���,蝳格���,蝳格���,蝳格���,蝳格���12:00~14:00,14:00~18:00,18:00~21:00','蝳格��,蝳格���,蝳格�,蝳格���14:00~18:00,18:00~21:00'",
+        "otherRequirement": null,
+        "appointmentDate": "2021-12-02T10:10:53.341Z",
+        "lastModifiedDate": "2021-12-03T03:40:16.344Z",
+        "agentNo": "AG0109051204",
+        "customerId": 77,
+        "name": "111",
+        "consultantViewTime": "2021-12-02T10:10:46.358Z",
+        "consultantReadTime": "2021-12-02T10:10:53.340Z",
+        "contactTime": "2021-12-03T03:40:16.215Z",
+        "satisfactionScore":3 // null 隞�銵刻府蝑��撠憛怠神皛踵�漲
+    }
+]
diff --git "a/pamapi/src/doc/\351\241\247\345\225\217API/\345\256\242\346\210\266\347\232\204\351\241\247\345\225\217\346\270\205\345\226\256.txt" "b/pamapi/src/doc/\351\241\247\345\225\217API/\345\256\242\346\210\266\347\232\204\351\241\247\345\225\217\346\270\205\345\226\256.txt"
index fbe3e9d..eb81537 100644
--- "a/pamapi/src/doc/\351\241\247\345\225\217API/\345\256\242\346\210\266\347\232\204\351\241\247\345\225\217\346\270\205\345\226\256.txt"
+++ "b/pamapi/src/doc/\351\241\247\345\225\217API/\345\256\242\346\210\266\347\232\204\351\241\247\345\225\217\346\270\205\345\226\256.txt"
@@ -20,9 +20,6 @@
         "updateTime": "2021-12-02T10:56:32.741Z",   // ��餈�����
         "role": "憡��蝬�鈭�",
         "seniority": "22 撟� 8 ���",
-        "latestAppointmentId": 130,                 // ��敺�蝑��ID
-        "latestAppointmentDate": "2021-12-02T10:56:32.741Z",    // ��敺�蝑��������
-        "latestAppointmentScore": null,                 // ��敺�蝑����� (null�撠閰��)
         "appointments": [       // 摰X撌脤���“���
             {
                 "id": 130,
@@ -42,7 +39,8 @@
                 "customerId": 76,
                 "name": "��蝬�",
                 "consultantViewTime": null,
-                "consultantReadTime": null
+                "consultantReadTime": null,
+                "satisfactionScore":3 // null 隞�銵刻府蝑��撠憛怠神皛踵�漲
             }
         ],
         "new": true
@@ -65,9 +63,6 @@
         "updateTime": "2021-12-02T10:56:56.946Z",
         "role": "����蝬�鈭�",
         "seniority": "30 撟� 8 ���",
-        "latestAppointmentId": 131,
-        "latestAppointmentDate": "2021-12-02T10:56:56.946Z",
-        "latestAppointmentScore": null,
         "appointments": [
             {
                 "id": 131,
@@ -87,7 +82,8 @@
                 "customerId": 76,
                 "name": "��蝬�",
                 "consultantViewTime": null,
-                "consultantReadTime": null
+                "consultantReadTime": null,
+                "satisfactionScore":3 // null 隞�銵刻府蝑��撠憛怠神皛踵�漲
             }
         ],
         "new": true
@@ -110,9 +106,6 @@
         "updateTime": null,
         "role": "����蝬�鈭�",
         "seniority": "38 撟� ",
-        "latestAppointmentId": null,
-        "latestAppointmentDate": null,
-        "latestAppointmentScore": null,
         "appointments": [],
         "new": true
     },
@@ -133,10 +126,6 @@
         "createTime": "2021-12-02T10:56:04.620Z",
         "updateTime": null,
         "role": "��陸靽蝬�鈭�",
-        "seniority": "17 撟� 1 ���",
-        "latestAppointmentId": null,
-        "latestAppointmentDate": null,
-        "latestAppointmentScore": null,                 // ��敺�蝑����� (null�撠閰��)
         "appointments": [],
         "new": true
     }
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 f1785b9..0730d6d 100644
--- a/pamapi/src/main/java/com/pollex/pam/service/AppointmentService.java
+++ b/pamapi/src/main/java/com/pollex/pam/service/AppointmentService.java
@@ -5,8 +5,8 @@
 import java.util.Objects;
 import java.util.stream.Collectors;
 
-import com.pollex.pam.enums.AppointmentStatusEnum;
-import com.pollex.pam.service.dto.AppointmentDTO;
+import com.pollex.pam.domain.Satisfaction;
+import com.pollex.pam.service.dto.AppointmentUpdateDTO;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -60,9 +60,19 @@
 		appointmentRepository.save(appointment);
 	}
 
-    public void updateAppointment(AppointmentDTO appointmentDTO) {
-        Appointment appointment = appointmentDTOMapper.toAppointment(appointmentDTO);
-        appointment.setStatus(AVAILABLE);
+    public void updateAppointment(AppointmentUpdateDTO updateAppointmentDTO) {
+        Appointment appointment = appointmentRepository.findById(updateAppointmentDTO.getId()).get();
+
+        appointment.setPhone(updateAppointmentDTO.getPhone());
+        appointment.setEmail(updateAppointmentDTO.getEmail());
+        appointment.setContactType(updateAppointmentDTO.getContactType());
+        appointment.setGender(updateAppointmentDTO.getGender());
+        appointment.setAge(updateAppointmentDTO.getAge());
+        appointment.setJob(updateAppointmentDTO.getJob());
+        appointment.setRequirement(updateAppointmentDTO.getRequirement());
+        appointment.setHopeContactTime(updateAppointmentDTO.getHopeContactTime());
+        appointment.setOtherRequirement(updateAppointmentDTO.getOtherRequirement());
+
         appointmentRepository.save(appointment);
     }
 
@@ -87,8 +97,28 @@
 	public AppointmentCustomerViewDTO getAppointmentDetail(Long appointmentId) {
 		AppointmentCustomerView appointment = appointmentCustomerViewRepository.findById(appointmentId)
 				.orElseThrow(AppointmentNotFoundException::new);
-		return appointmentCustomerViewMapper.toAppointmentCustomerViewDTO(appointment);
+
+        AppointmentCustomerViewDTO dto = appointmentCustomerViewMapper.toAppointmentCustomerViewDTO(appointment);
+        setSatisfactionScore(dto, appointmentId);
+		return dto;
 	}
+
+    public List<AppointmentCustomerViewDTO> getConsultantAvailableAppointments(String agentNo) {
+        return appointmentCustomerViewRepository.findByAgentNo(agentNo).stream()
+            .filter(appointment -> appointment.getStatus() == AVAILABLE)
+            .map(appointmentCustomerView -> {
+                AppointmentCustomerViewDTO dto = appointmentCustomerViewMapper.toAppointmentCustomerViewDTO(appointmentCustomerView);
+                setSatisfactionScore(dto, appointmentCustomerView.getId());
+                return dto;
+            })
+            .collect(Collectors.toList());
+    }
+
+    public void setSatisfactionScore(AppointmentCustomerViewDTO dto, Long appointmentId) {
+        satisfactionService.getByAppointmentId(appointmentId).ifPresent(satisfaction -> {
+            dto.setSatisfactionScore(satisfaction.getScore());
+        });
+    }
 
     public List<AppointmentCustomerView> findAvailableByAgentNoAndCustomerId(String agentNo, Long customerId) {
         return appointmentCustomerViewRepository.findByAgentNoAndCustomerId(agentNo, customerId)
@@ -117,12 +147,5 @@
 
         consultantNotViewAppointments.forEach(appointment -> appointment.setConsultantViewTime(Instant.now()));
         appointmentRepository.saveAll(consultantNotViewAppointments);
-    }
-
-    public List<AppointmentCustomerViewDTO> getConsultantAppointments(String agentNo) {
-        return appointmentCustomerViewRepository.findByAgentNo(agentNo).stream()
-            .filter(appointment -> appointment.getStatus() != DELETED)
-            .map(appointmentCustomerViewMapper::toAppointmentCustomerViewDTO)
-            .collect(Collectors.toList());
     }
 }
diff --git a/pamapi/src/main/java/com/pollex/pam/service/ConsultantService.java b/pamapi/src/main/java/com/pollex/pam/service/ConsultantService.java
index 7a9c552..adbb6ab 100644
--- a/pamapi/src/main/java/com/pollex/pam/service/ConsultantService.java
+++ b/pamapi/src/main/java/com/pollex/pam/service/ConsultantService.java
@@ -3,7 +3,6 @@
 import com.pollex.pam.domain.AppointmentCustomerView;
 import com.pollex.pam.domain.Consultant;
 import com.pollex.pam.domain.CustomerFavoriteConsultant;
-import com.pollex.pam.domain.Satisfaction;
 import com.pollex.pam.enums.ContactStatusEnum;
 import com.pollex.pam.enums.LoginResult;
 import com.pollex.pam.repository.ConsultantRepository;
@@ -21,7 +20,6 @@
 
 import java.util.Comparator;
 import java.util.List;
-import java.util.Optional;
 import java.util.stream.Collectors;
 
 @Service
@@ -60,10 +58,7 @@
                 CustomerFavoriteConsultantDTO dto = consultantMapper.toCustomerFavoriteConsultantDto(consultant);
 
                 dto.setContactStatus(ContactStatusEnum.PICKED);
-                dto.setLatestAppointmentId(null);
-                dto.setLatestAppointmentDate(null);
-                dto.setLatestAppointmentScore(null);
-                dto.setCreateTime(customerFavoriteConsultantRelation.getLastModifiedDate());
+                dto.setCreateTime(customerFavoriteConsultantRelation.getCreatedDate());
 
                 setAppointmentInfo(
                     dto,
@@ -75,32 +70,21 @@
             }).collect(Collectors.toList());
     }
 
-    private void setAppointmentInfo(CustomerFavoriteConsultantDTO dto, List<AppointmentCustomerView> appointmentList) {
+    private void setAppointmentInfo(CustomerFavoriteConsultantDTO customerFavoriteConsultantDTO, List<AppointmentCustomerView> appointmentList) {
         List<AppointmentCustomerView> appointments = appointmentList.stream()
             .sorted(Comparator.comparing(AppointmentCustomerView::getAppointmentDate).reversed())
             .collect(Collectors.toList());
 
-        dto.setAppointments(appointmentCustomerViewMapper.toAppointmentCustomerViewDTO(appointments));
+        List<AppointmentCustomerViewDTO> appointmentCustomerViewDTOS = appointmentCustomerViewMapper.toAppointmentCustomerViewDTO(appointments);
+        appointmentCustomerViewDTOS.forEach(appointmentCustomerViewDTO -> {
+            appointmentService.setSatisfactionScore(appointmentCustomerViewDTO, appointmentCustomerViewDTO.getId());
+        });
+        customerFavoriteConsultantDTO.setAppointments(appointmentCustomerViewDTOS);
 
         if (!appointments.isEmpty()) {
             AppointmentCustomerView latestAppointment = appointments.get(0);
-            dto.setContactStatus(latestAppointment.getCommunicateStatus());
-            dto.setLatestAppointmentId(latestAppointment.getId());
-            dto.setLatestAppointmentDate(latestAppointment.getAppointmentDate());
-            dto.setUpdateTime(latestAppointment.getLastModifiedDate());
-
-            setLatestAppointmentScore(dto, latestAppointment);
-        }
-    }
-
-    private void setLatestAppointmentScore(CustomerFavoriteConsultantDTO dto, AppointmentCustomerView latestAppointment) {
-        Optional<Satisfaction> satisfactionOptional = satisfactionService.getByAppointmentId(latestAppointment.getId());
-        if(satisfactionOptional.isPresent()) {
-            Satisfaction satisfaction = satisfactionOptional.get();
-            dto.setLatestAppointmentScore(satisfaction.getScore());
-        }
-        else {
-            dto.setLatestAppointmentScore(null);
+            customerFavoriteConsultantDTO.setContactStatus(latestAppointment.getCommunicateStatus());
+            customerFavoriteConsultantDTO.setUpdateTime(latestAppointment.getLastModifiedDate());
         }
     }
 
@@ -160,7 +144,7 @@
 
 	public List<AppointmentCustomerViewDTO> getMyAppointment() {
 		String agentNo = SecurityUtils.getAgentNo();
-		return appointmentService.getConsultantAppointments(agentNo);
+		return appointmentService.getConsultantAvailableAppointments(agentNo);
 	}
 
     public void removeConsultantFromCustomList(String agentNo) {
diff --git a/pamapi/src/main/java/com/pollex/pam/service/dto/AppointmentCustomerViewDTO.java b/pamapi/src/main/java/com/pollex/pam/service/dto/AppointmentCustomerViewDTO.java
index 7aae35a..5605843 100644
--- a/pamapi/src/main/java/com/pollex/pam/service/dto/AppointmentCustomerViewDTO.java
+++ b/pamapi/src/main/java/com/pollex/pam/service/dto/AppointmentCustomerViewDTO.java
@@ -25,6 +25,8 @@
     private Instant consultantViewTime;
     private Instant consultantReadTime;
     private Instant contactTime;
+    private Float satisfactionScore;
+
 	public Long getId() {
 		return id;
 	}
@@ -139,4 +141,10 @@
     public void setContactTime(Instant contactTime) {
         this.contactTime = contactTime;
     }
+    public Float getSatisfactionScore() {
+        return satisfactionScore;
+    }
+    public void setSatisfactionScore(Float satisfactionScore) {
+        this.satisfactionScore = satisfactionScore;
+    }
 }
diff --git a/pamapi/src/main/java/com/pollex/pam/service/dto/AppointmentUpdateDTO.java b/pamapi/src/main/java/com/pollex/pam/service/dto/AppointmentUpdateDTO.java
new file mode 100644
index 0000000..0be3753
--- /dev/null
+++ b/pamapi/src/main/java/com/pollex/pam/service/dto/AppointmentUpdateDTO.java
@@ -0,0 +1,94 @@
+package com.pollex.pam.service.dto;
+
+public class AppointmentUpdateDTO {
+    private Long id;
+    private String phone;
+    private String email;
+    private String contactType;
+    private String gender;
+    private String age;
+    private String job;
+    private String requirement;
+    private String hopeContactTime;
+    private String otherRequirement;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public String getPhone() {
+        return phone;
+    }
+
+    public void setPhone(String phone) {
+        this.phone = phone;
+    }
+
+    public String getEmail() {
+        return email;
+    }
+
+    public void setEmail(String email) {
+        this.email = email;
+    }
+
+    public String getContactType() {
+        return contactType;
+    }
+
+    public void setContactType(String contactType) {
+        this.contactType = contactType;
+    }
+
+    public String getGender() {
+        return gender;
+    }
+
+    public void setGender(String gender) {
+        this.gender = gender;
+    }
+
+    public String getAge() {
+        return age;
+    }
+
+    public void setAge(String age) {
+        this.age = age;
+    }
+
+    public String getJob() {
+        return job;
+    }
+
+    public void setJob(String job) {
+        this.job = job;
+    }
+
+    public String getRequirement() {
+        return requirement;
+    }
+
+    public void setRequirement(String requirement) {
+        this.requirement = requirement;
+    }
+
+    public String getHopeContactTime() {
+        return hopeContactTime;
+    }
+
+    public void setHopeContactTime(String hopeContactTime) {
+        this.hopeContactTime = hopeContactTime;
+    }
+
+    public String getOtherRequirement() {
+        return otherRequirement;
+    }
+
+    public void setOtherRequirement(String otherRequirement) {
+        this.otherRequirement = otherRequirement;
+    }
+}
diff --git a/pamapi/src/main/java/com/pollex/pam/service/dto/CustomerFavoriteConsultantDTO.java b/pamapi/src/main/java/com/pollex/pam/service/dto/CustomerFavoriteConsultantDTO.java
index 78bc277..3142151 100644
--- a/pamapi/src/main/java/com/pollex/pam/service/dto/CustomerFavoriteConsultantDTO.java
+++ b/pamapi/src/main/java/com/pollex/pam/service/dto/CustomerFavoriteConsultantDTO.java
@@ -21,9 +21,6 @@
     private Instant updateTime;
     private String role;
     private String seniority;
-    private Long latestAppointmentId;
-    private Instant latestAppointmentDate;
-    private Float latestAppointmentScore;
     private List<AppointmentCustomerViewDTO> appointments;
 
     public boolean isNewConsultant() {
@@ -66,14 +63,6 @@
         this.expertise = expertise;
     }
 
-    public Float getLatestAppointmentScore() {
-        return latestAppointmentScore;
-    }
-
-    public void setLatestAppointmentScore(Float latestAppointmentScore) {
-        this.latestAppointmentScore = latestAppointmentScore;
-    }
-
     public Float getAvgScore() {
         return avgScore;
     }
@@ -88,14 +77,6 @@
 
     public void setContactStatus(ContactStatusEnum contactStatus) {
         this.contactStatus = contactStatus;
-    }
-
-    public Instant getLatestAppointmentDate() {
-        return latestAppointmentDate;
-    }
-
-    public void setLatestAppointmentDate(Instant latestAppointmentDate) {
-        this.latestAppointmentDate = latestAppointmentDate;
     }
 
     public Instant getCreateTime() {
@@ -132,14 +113,6 @@
 
     public void setNewConsultant(boolean newConsultant) {
         this.newConsultant = newConsultant;
-    }
-
-    public Long getLatestAppointmentId() {
-        return latestAppointmentId;
-    }
-
-    public void setLatestAppointmentId(Long latestAppointmentId) {
-        this.latestAppointmentId = latestAppointmentId;
     }
 
     public List<AppointmentCustomerViewDTO> getAppointments() {
diff --git a/pamapi/src/main/java/com/pollex/pam/service/mapper/ConsultantMapper.java b/pamapi/src/main/java/com/pollex/pam/service/mapper/ConsultantMapper.java
index 30e0e47..46c4f45 100644
--- a/pamapi/src/main/java/com/pollex/pam/service/mapper/ConsultantMapper.java
+++ b/pamapi/src/main/java/com/pollex/pam/service/mapper/ConsultantMapper.java
@@ -1,16 +1,10 @@
 package com.pollex.pam.service.mapper;
 
-import com.pollex.pam.domain.Appointment;
 import com.pollex.pam.domain.Consultant;
-import com.pollex.pam.domain.CustomerFavoriteConsultant;
-import com.pollex.pam.enums.ContactStatusEnum;
-import com.pollex.pam.service.AppointmentService;
 import com.pollex.pam.service.dto.ConsultantDTO;
 import com.pollex.pam.service.dto.ConsultantDetailDTO;
 import com.pollex.pam.service.dto.CustomerFavoriteConsultantDTO;
 import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.BeanUtils;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.util.*;
@@ -33,7 +27,6 @@
 
         consultantDTO.setContactStatus(null);
         consultantDTO.setUpdateTime(null);
-        consultantDTO.setLatestAppointmentId(null);
 
         return consultantDTO;
     }
diff --git a/pamapi/src/main/java/com/pollex/pam/web/rest/AppointmentResource.java b/pamapi/src/main/java/com/pollex/pam/web/rest/AppointmentResource.java
index 27957f3..1704d11 100644
--- a/pamapi/src/main/java/com/pollex/pam/web/rest/AppointmentResource.java
+++ b/pamapi/src/main/java/com/pollex/pam/web/rest/AppointmentResource.java
@@ -1,6 +1,6 @@
 package com.pollex.pam.web.rest;
 
-import com.pollex.pam.service.dto.AppointmentDTO;
+import com.pollex.pam.service.dto.AppointmentUpdateDTO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.ResponseEntity;
 import org.springframework.web.bind.annotation.*;
@@ -21,7 +21,7 @@
 	SatisfactionService satisfactionService;
 
     @PutMapping("")
-    public ResponseEntity<Void> updateAppointment(@RequestBody AppointmentDTO appointment) {
+    public ResponseEntity<Void> updateAppointment(@RequestBody AppointmentUpdateDTO appointment) {
         appointmentService.updateAppointment(appointment);
         return ResponseEntity.noContent().build();
     }
diff --git a/pamapi/src/main/java/com/pollex/pam/web/rest/ConsultantResource.java b/pamapi/src/main/java/com/pollex/pam/web/rest/ConsultantResource.java
index d672590..19f5000 100644
--- a/pamapi/src/main/java/com/pollex/pam/web/rest/ConsultantResource.java
+++ b/pamapi/src/main/java/com/pollex/pam/web/rest/ConsultantResource.java
@@ -1,6 +1,5 @@
 package com.pollex.pam.web.rest;
 
-import com.pollex.pam.service.AppointmentService;
 import com.pollex.pam.service.ConsultantService;
 import com.pollex.pam.service.dto.*;
 import org.apache.commons.compress.utils.IOUtils;
diff --git a/pamapi/src/main/resources/config/application-dev.yml b/pamapi/src/main/resources/config/application-dev.yml
index cba1e82..f81590c 100644
--- a/pamapi/src/main/resources/config/application-dev.yml
+++ b/pamapi/src/main/resources/config/application-dev.yml
@@ -33,6 +33,7 @@
   datasource:
     type: com.zaxxer.hikari.HikariDataSource
     url: jdbc:postgresql://dev.pollex.com.tw:5433/pam
+    #url: jdbc:postgresql://localhost:5432/omo?currentSchema=omo
     username: pamadmin
     password: pamadmin
     hikari:

--
Gitblit v1.8.0