From 3ecee0fa557b7bb9e83b67e289b316f04efa9ce5 Mon Sep 17 00:00:00 2001 From: jack <jack.su@pollex.com.tw> Date: 星期二, 05 九月 2023 11:59:07 +0800 Subject: [PATCH] Merge branch '滲透' of ssh://dev.pollex.com.tw:29418/pcalife/PAM into 滲透 --- PAMapp/shared/services/appointment.service.ts | 120 +++++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 110 insertions(+), 10 deletions(-) diff --git a/PAMapp/shared/services/appointment.service.ts b/PAMapp/shared/services/appointment.service.ts index 9f07fe9..b36fb3f 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; + } } // 霈�������孛�嚗������������ @@ -40,34 +49,114 @@ return http.put('/appointment', editAppointmentParams); } - // �憓酉閮� + /** + * �憓酉閮� + * @param memoInfo ���憓酉閮�����隞� + * @returns ���憓�酉閮��� + */ async createMemo(memoInfo: createdMemoInfo): Promise<AppointmentMemoInfo> { - return http.post('/appointment/memo/create', memoInfo).then(res => res.data); + try { + const response = await http.post('/appointment/memo/create', memoInfo); + // 撘望�� test2: ���� !response + if (!response) { + throw new Error('http.post returned null-like value.'); + } else { + return response.data; + } + } catch (error) { + // �隞亙甇方���隤斗����身�� + console.error('An error occurred while creating memo:', error); + throw error; + } } - // 蝺刻摩閮餉�� + + /** + * 蝺刻摩閮餉�� + * @param memoInfo ��蝺刻摩閮餉������隞� + * @returns ����敺�酉閮��� + */ async updateMemo(memoInfo: updatedMemoInfo): Promise<AppointmentMemoInfo> { - return http.post('/appointment/memo/update', memoInfo).then(res => res.data); + 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) { - return http.post(`/appointment/close`, appointmentInfo).then((res) => res.data); + // 撘望�est5: ����� promise + try { + const response = await http.post(`/appointment/close`, appointmentInfo); + const responsePromise = new Promise((resolve, reject) => { + if (response !== null) { + resolve(response.data); + } else { + reject('http.post returned null-like value.'); + } + }); + if (!response) { + throw new Error('http.post returned null-like value.'); + } else { + return responsePromise.then(res => res); + } + } 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; + } } // 靽格蝝赤閮�� @@ -79,6 +168,17 @@ 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.8.0