保誠-保戶業務員媒合平台
Jack
2021-11-14 0d3fcf60fec51cb3c2a8b06e41d61291d79c3470
[ADD] 取得預約單BY預約單ID的API
修改3個檔案
新增2個檔案
92 ■■■■ 已變更過的檔案
pamapi/src/doc/預約單/取得預約單細節API.txt 24 ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
pamapi/src/main/java/com/pollex/pam/service/AppointmentService.java 18 ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
pamapi/src/main/java/com/pollex/pam/service/LoginService.java 34 ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
pamapi/src/main/java/com/pollex/pam/web/rest/AppointmentResource.java 7 ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
pamapi/src/main/java/com/pollex/pam/web/rest/errors/AppointmentNotFoundException.java 9 ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
pamapi/src/doc/¹w¬ù³æ/¨ú±o¹w¬ù³æ²Ó¸`API.txt
¤ñ¹ï·sÀÉ®×
@@ -0,0 +1,24 @@
http get :
http://localhost:8080/api/appointment/getDetail/{appointmentId}
response body:
{
    "id": 26,
    "phone": "09123456789",
    "email": "123",
    "contactType": "email",
    "gender": "male",
    "age": "20",
    "job": "外勤",
    "requirement": "防疫保單相關",
    "communicateStatus": "contacted",
    "hopeContactTime": "','",
    "otherRequirement": "",
    "appointmentDate": "2021-11-12T10:17:14.107Z",
    "agentNo": "6",
    "customerId": 2,
    "name": "Jack"
}
pamapi/src/main/java/com/pollex/pam/service/AppointmentService.java
@@ -7,12 +7,17 @@
import org.springframework.transaction.annotation.Transactional;
import com.pollex.pam.domain.Appointment;
import com.pollex.pam.domain.AppointmentCustomerView;
import com.pollex.pam.enums.ContactStatusEnum;
import com.pollex.pam.repository.AppointmentCustomerViewRepository;
import com.pollex.pam.repository.AppointmentRepository;
import com.pollex.pam.security.SecurityUtils;
import com.pollex.pam.service.dto.AppointmentCreateDTO;
import com.pollex.pam.service.dto.AppointmentCustomerViewDTO;
import com.pollex.pam.service.mapper.AppointmentCustomerViewMapper;
import com.pollex.pam.service.mapper.AppointmentDTOMapper;
import com.pollex.pam.service.mapper.AppointmentMapper;
import com.pollex.pam.web.rest.errors.AppointmentNotFoundException;
@Service
@Transactional
@@ -26,6 +31,12 @@
    
    @Autowired
    ConsultantService consultantService;
    @Autowired
    AppointmentCustomerViewMapper appointmentCustomerViewMapper;
    @Autowired
    AppointmentCustomerViewRepository appointmentCustomerViewRepository;
    
    
    public void customerCreateAppointment(AppointmentCreateDTO appointmentCreateDTO) {
@@ -46,5 +57,12 @@
        appointment.setCommunicateStatus(ContactStatusEnum.CONTACTED);
        appointmentRepository.save(appointment);
    }
    public AppointmentCustomerViewDTO getAppointmentDetail(Long appointmentId) {
        AppointmentCustomerView appointment = appointmentCustomerViewRepository.findById(appointmentId)
                .orElseThrow(AppointmentNotFoundException::new);
        return appointmentCustomerViewMapper.toAppointmentCustomerViewDTO(appointment);
    }
    
}
pamapi/src/main/java/com/pollex/pam/service/LoginService.java
@@ -1,28 +1,34 @@
package com.pollex.pam.service;
import com.fasterxml.jackson.databind.ObjectMapper;;
import com.pollex.pam.config.ApplicationProperties;
import com.pollex.pam.service.dto.EServiceRequest;
import com.pollex.pam.web.rest.vm.EServiceRequestVM;
import com.pollex.pam.service.dto.EServiceResponse;
import com.pollex.pam.web.rest.vm.OtpEmailLoginVM;
import com.pollex.pam.web.rest.vm.OtpSMSLoginVM;
import com.pollex.pam.web.rest.vm.VerifyOtpVM;
import java.security.KeyManagementException;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.X509Certificate;
import javax.net.ssl.SSLContext;
import org.apache.http.conn.ssl.NoopHostnameVerifier;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.ssl.SSLContexts;
import org.springframework.http.*;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import javax.net.ssl.SSLContext;
import java.security.KeyManagementException;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.X509Certificate;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.pollex.pam.config.ApplicationProperties;
import com.pollex.pam.service.dto.EServiceRequest;
import com.pollex.pam.service.dto.EServiceResponse;
import com.pollex.pam.web.rest.vm.EServiceRequestVM;
import com.pollex.pam.web.rest.vm.OtpEmailLoginVM;
import com.pollex.pam.web.rest.vm.OtpSMSLoginVM;
import com.pollex.pam.web.rest.vm.VerifyOtpVM;
@Service
pamapi/src/main/java/com/pollex/pam/web/rest/AppointmentResource.java
@@ -8,8 +8,10 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.pollex.pam.domain.AppointmentCustomerView;
import com.pollex.pam.service.AppointmentService;
import com.pollex.pam.service.dto.AppointmentCreateDTO;
import com.pollex.pam.service.dto.AppointmentCustomerViewDTO;
@RestController
@RequestMapping("/api/appointment")
@@ -28,5 +30,10 @@
        appointmentService.markAsContacted(appointmentId);
    }
    
    @GetMapping("/getDetail/{appointmentId}")
    public AppointmentCustomerViewDTO getAppointmentDetail(@PathVariable Long appointmentId) {
        return appointmentService.getAppointmentDetail(appointmentId);
    }
    
}
pamapi/src/main/java/com/pollex/pam/web/rest/errors/AppointmentNotFoundException.java
¤ñ¹ï·sÀÉ®×
@@ -0,0 +1,9 @@
package com.pollex.pam.web.rest.errors;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ResponseStatus;
@ResponseStatus(code = HttpStatus.NOT_FOUND, reason = "Appointment not found")
public class AppointmentNotFoundException extends RuntimeException{
}