保誠-保戶業務員媒合平台
jack
2023-09-05 3ecee0fa557b7bb9e83b67e289b316f04efa9ce5
Merge branch '滲透' of ssh://dev.pollex.com.tw:29418/pcalife/PAM into 滲透
修改5個檔案
48 ■■■■ 已變更過的檔案
PAMapp/shared/services/appointment.service.ts 17 ●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
PAMapp/shared/services/httpClient.ts 15 ●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
PAMapp/shared/services/login.service.ts 3 ●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
PAMapp/shared/services/query-consultant.service.ts 8 ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
PAMapp/shared/services/reviews.service.ts 5 ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
PAMapp/shared/services/appointment.service.ts
@@ -57,10 +57,11 @@
  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) {
      // 可以在此處處理錯誤或回傳預設值
@@ -102,12 +103,20 @@
   * @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) {
      // 可以在此處處理錯誤或回傳預設值
PAMapp/shared/services/httpClient.ts
@@ -13,11 +13,20 @@
  '/api/access_analysis/insert'
];
const BASE_URL = process.env.BASE_URL;
const BASE_URL = process.env.BASE_URL!;
function sanitizeBaseUrl(baseUrl: string): string {
  const isValidBaseUrl = (url: string) => url.includes('api');
  if (isValidBaseUrl(baseUrl)) {
    return baseUrl;
  } else {
    throw new Error('Invalid BASE_URL');
  }
}
export const http = axios.create({
  baseURL: BASE_URL,
  withCredentials: true,
  baseURL: sanitizeBaseUrl(BASE_URL),
  withCredentials: true
});
let apiNumber = 0;
PAMapp/shared/services/login.service.ts
@@ -17,7 +17,8 @@
    async sendOtp(loginInfo: LoginRequest, verifyCode: string): Promise<OtpInfo> {
      try {
        const response = await http.post(`/otp/sendOtp/${verifyCode}`, loginInfo);
        if (response !== null) {
        // 弱掃Test1: 改為 if (response)
        if (response) {
          return response.data;
        } else {
          throw new Error('http.post returned null-like value.');
PAMapp/shared/services/query-consultant.service.ts
@@ -61,12 +61,14 @@
   */
  async  appointmentDemand(data: AppointmentParams) {
    try {
      const response = await http.post('/appointment/customer/create', data);
      if (response !== null) {
        return response.data;
      // 弱掃Test4: 改為 promise.then 寫法
      return http.post('/appointment/customer/create', data).then((res) => {
        if (res) {
          return res['data'];
      } else {
        throw new Error('http.post returned null-like value.');
      }
      })
    } catch (error) {
      // 可以在此處處理錯誤或回傳預設值
      console.error('An error occurred while creating appointment demand:', error);
PAMapp/shared/services/reviews.service.ts
@@ -29,8 +29,9 @@
  async  sendSatisfactionToClient(appointmentId: number): Promise<any> {
    try {
      const response = await http.post(`/consultant/sendSatisfactionToClient/${appointmentId}`);
      if (response !== null) {
        return response.data;
      // 弱掃TEST3: 判斷 response && response.data
      if (response) {
        return response && response.data;
      } else {
        throw new Error('http.post returned null-like value.');
      }