From 1adfdb0ffed271b97cf88471c94ab2735dc12b35 Mon Sep 17 00:00:00 2001
From: Tomas <tomasysh@gmail.com>
Date: 星期六, 05 八月 2023 17:43:34 +0800
Subject: [PATCH] Fixed: [弱掃] p13.1 Bad use of null-like value

---
 PAMapp/shared/services/appointment.service.ts |  124 ++++++++++++++++++++++++++++++++++++++---
 1 files changed, 115 insertions(+), 9 deletions(-)

diff --git a/PAMapp/shared/services/appointment.service.ts b/PAMapp/shared/services/appointment.service.ts
index c8c6f9d..8094bf1 100644
--- a/PAMapp/shared/services/appointment.service.ts
+++ b/PAMapp/shared/services/appointment.service.ts
@@ -1,14 +1,13 @@
 import { http } from "./httpClient";
 
-import { ClientInfo } from "~/shared/models/client.model";
-import { AppointmentDetail, EditAppointmentParams } from "~/shared/models/appointment.model";
+import { Appointment, AppointmentMemoInfo, createdMemoInfo, EditAppointmentParams,  InterviewRecordInfo, ToCloseAppointment, ToDoneAppointment, ToInformAppointment, updatedMemoInfo, UpdateInterviewRecordInfo } from "~/shared/models/appointment.model";
 
 class AppointmentService {
 
-  // ���������
-  async getMyAppointmentList(): Promise<ClientInfo[]> {
+  // 憿批������撌梁���API
+  async getMyAppointmentList(): Promise<Appointment[]> {
     return http.get('/consultant/getMyAppointment').then((res) => {
-      const hasNewAppointment = res.data.find((appointment: ClientInfo) => !appointment.consultantViewTime);
+      const hasNewAppointment = res.data.find((appointment: Appointment) => !appointment.consultantViewTime);
       if (hasNewAppointment) {
         this.viewAllAppointment();
       }
@@ -16,9 +15,18 @@
     });
   }
 
-  // 憿批��憿舐內����蝑敺孛�
-  private viewAllAppointment(): void {
-    http.post('/consultant/record/allAppointmentsView').then();
+  // 憿批��汗�撌望������蝝���孛�API
+  private async viewAllAppointment(): Promise<void> {
+    try {
+      const response = await http.post('/consultant/record/allAppointmentsView');
+      if (response !== null) {
+      } else {
+        throw new Error('http.post returned null-like value.');
+      }
+    } catch (error) {
+      console.error('An error occurred while viewing all appointments:', error);
+      throw error;
+    }
   }
 
   // 霈�������孛�嚗������������
@@ -27,7 +35,7 @@
   }
 
   // �����蝝啁�
-  async getAppointmentDetail(appointmentId: number):Promise<AppointmentDetail> {
+  async getAppointmentDetail(appointmentId: number):Promise<Appointment> {
     return http.get(`/appointment/getDetail/${appointmentId}`).then((res) => res.data);
   }
 
@@ -41,6 +49,104 @@
     return http.put('/appointment', editAppointmentParams);
   }
 
+  /**
+   * �憓酉閮�
+   * @param memoInfo ���憓酉閮�����隞�
+   * @returns ���憓�酉閮���
+   */
+  async createMemo(memoInfo: createdMemoInfo): Promise<AppointmentMemoInfo> {
+    try {
+      const response = await http.post('/appointment/memo/create', memoInfo);
+      if (response !== null) {
+        return response.data;
+      } else {
+        throw new Error('http.post returned null-like value.');
+      }
+    } catch (error) {
+      // �隞亙甇方���隤斗����身��
+      console.error('An error occurred while creating memo:', error);
+      throw error;
+    }
+  }
+
+
+  /**
+   * 蝺刻摩閮餉��
+   * @param memoInfo ��蝺刻摩閮餉������隞�
+   * @returns ����敺�酉閮���
+   */
+  async updateMemo(memoInfo: updatedMemoInfo): Promise<AppointmentMemoInfo> {
+    try {
+      const response = await http.post('/appointment/memo/update', memoInfo);
+      if (response !== null) {
+        return response.data;
+      } else {
+        throw new Error('http.post returned null-like value.');
+      }
+    } catch (error) {
+      // �隞亙甇方���隤斗����身��
+      console.error('An error occurred while updating memo:', error);
+      throw error;
+    }
+  }
+
+
+  // ��閮餉��
+  deleteMemo(appointmentMemoId: number) {
+    return http.delete(`/appointment/memo/${appointmentMemoId}`)
+  }
+
+  /**
+   * ���蝯��, ��蝯��敦
+   * @param appointmentInfo ��蝯������隞�
+   * @returns ��蝯����
+   */
+  async closeAppointment(appointmentInfo: ToDoneAppointment | ToCloseAppointment) {
+    try {
+      const response = await http.post(`/appointment/close`, appointmentInfo);
+      if (response !== null) {
+        return response.data;
+      } else {
+        throw new Error('http.post returned null-like value.');
+      }
+    } catch (error) {
+      // �隞亙甇方���隤斗����身��
+      console.error('An error occurred while closing appointment:', error);
+      throw error;
+    }
+  }
+
+
+  // 蝝赤� API
+  async informAppointment(appointmentInformation: ToInformAppointment) {
+    return http.post(`/notice/send`, appointmentInformation).then((res) => res.data);
+  }
+
+  // �憓�赤閮��
+  async createInterviewRecord(interviewRecordInfo: InterviewRecordInfo) {
+    return http.post('/interview_record/create', interviewRecordInfo).then(res => res.data);
+  }
+
+  // 靽格蝝赤閮��
+  async updateInterviewRecord(updateInterviewRecordInfo: UpdateInterviewRecordInfo) {
+    return http.post('/interview_record/update', updateInterviewRecordInfo)
+  }
+
+  // ��蝝赤閮��
+  async deleteInterviewRecord(interviewRecordId) {
+    return http.delete(`/interview_record/${interviewRecordId}`);
+  }
+
+  // 摰X��������������
+  async getNotContactAppointment(): Promise<Appointment> {
+    return http.get(`/appointment/customer/expiring/newest`).then((res) => res.data);
+  }
+
+  // 憿批������������
+  async getPendingAppointmentSum(): Promise<number> {
+    return http.get(`/appointment/consultant/pending/sum`).then((res) => res.data)
+  }
+
 }
 
 export default new AppointmentService();

--
Gitblit v1.9.3