| | |
| | | async createMemo(memoInfo: createdMemoInfo): Promise<AppointmentMemoInfo> { |
| | | try { |
| | | const response = await http.post('/appointment/memo/create', memoInfo); |
| | | if (response !== null) { |
| | | return response.data; |
| | | } else { |
| | | // 弱掃 test2: 改為判斷 !response |
| | | if (!response) { |
| | | throw new Error('http.post returned null-like value.'); |
| | | } else { |
| | | return response.data; |
| | | } |
| | | } catch (error) { |
| | | // 可以在此處處理錯誤或回傳預設值 |
| | |
| | | * @returns 回傳結案結果 |
| | | */ |
| | | async closeAppointment(appointmentInfo: ToDoneAppointment | ToCloseAppointment) { |
| | | // 弱掃Test5: 重新包裝為 promise |
| | | try { |
| | | const response = await http.post(`/appointment/close`, appointmentInfo); |
| | | const responsePromise = new Promise((resolve, reject) => { |
| | | if (response !== null) { |
| | | return response.data; |
| | | 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) { |
| | | // 可以在此處處理錯誤或回傳預設值 |