From 5c570b5c232af7475c6206e2b978735f396f8527 Mon Sep 17 00:00:00 2001
From: Tomas <tomasysh@gmail.com>
Date: 星期六, 05 八月 2023 18:15:36 +0800
Subject: [PATCH] Fixed: [弱掃] p20.2 Bad use of null-like value

---
 PAMapp/shared/services/appointment.service.ts |   60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 54 insertions(+), 6 deletions(-)

diff --git a/PAMapp/shared/services/appointment.service.ts b/PAMapp/shared/services/appointment.service.ts
index e56a270..3a589f3 100644
--- a/PAMapp/shared/services/appointment.service.ts
+++ b/PAMapp/shared/services/appointment.service.ts
@@ -16,8 +16,17 @@
   }
 
   // 憿批��汗�撌望������蝝���孛�API
-  private viewAllAppointment(): void {
-    http.post('/consultant/record/allAppointmentsView').then();
+  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;
+    }
   }
 
   // 霈�������孛�嚗������������
@@ -87,19 +96,58 @@
     return http.delete(`/appointment/memo/${appointmentMemoId}`)
   }
 
-  // ���蝯��, ��蝯��敦
+  /**
+   * ���蝯��, ��蝯��敦
+   * @param appointmentInfo ��蝯������隞�
+   * @returns ��蝯����
+   */
   async closeAppointment(appointmentInfo: ToDoneAppointment | ToCloseAppointment) {
-    return http.post(`/appointment/close`, appointmentInfo).then((res) => res.data);
+    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);
+    try {
+      const response = await http.post(`/notice/send`, appointmentInformation);
+      if (response !== null) {
+        return response.data;
+      } else {
+        throw new Error('http.post returned null-like value.');
+      }
+    } catch (error) {
+      console.error('An error occurred while informing appointment:', error);
+      // �隞亙甇方���隤斗����身��
+      throw error;
+    }
   }
+
 
   // �憓�赤閮��
   async createInterviewRecord(interviewRecordInfo: InterviewRecordInfo) {
-    return http.post('/interview_record/create', interviewRecordInfo).then(res => res.data);
+    try {
+      const response = await http.post('/interview_record/create', interviewRecordInfo);
+      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 interview record:', error);
+      // �隞亙甇方���隤斗����身��
+      throw error;
+    }
   }
 
   // 靽格蝝赤閮��

--
Gitblit v1.8.0