From 0d3fcf60fec51cb3c2a8b06e41d61291d79c3470 Mon Sep 17 00:00:00 2001 From: Jack <jack.su@pollex.com.tw> Date: 星期日, 14 十一月 2021 23:01:40 +0800 Subject: [PATCH] [ADD] 取得預約單BY預約單ID的API --- pamapi/src/main/java/com/pollex/pam/service/LoginService.java | 34 ++++++++++------- pamapi/src/main/java/com/pollex/pam/service/AppointmentService.java | 18 +++++++++ pamapi/src/main/java/com/pollex/pam/web/rest/AppointmentResource.java | 7 +++ pamapi/src/doc/預約單/取得預約單細節API.txt | 24 ++++++++++++ pamapi/src/main/java/com/pollex/pam/web/rest/errors/AppointmentNotFoundException.java | 9 ++++ 5 files changed, 78 insertions(+), 14 deletions(-) diff --git "a/pamapi/src/doc/\351\240\220\347\264\204\345\226\256/\345\217\226\345\276\227\351\240\220\347\264\204\345\226\256\347\264\260\347\257\200API.txt" "b/pamapi/src/doc/\351\240\220\347\264\204\345\226\256/\345\217\226\345\276\227\351\240\220\347\264\204\345\226\256\347\264\260\347\257\200API.txt" new file mode 100644 index 0000000..58e8a30 --- /dev/null +++ "b/pamapi/src/doc/\351\240\220\347\264\204\345\226\256/\345\217\226\345\276\227\351\240\220\347\264\204\345\226\256\347\264\260\347\257\200API.txt" @@ -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" +} \ No newline at end of file diff --git a/pamapi/src/main/java/com/pollex/pam/service/AppointmentService.java b/pamapi/src/main/java/com/pollex/pam/service/AppointmentService.java index a0aee52..5932aca 100644 --- a/pamapi/src/main/java/com/pollex/pam/service/AppointmentService.java +++ b/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); + } } diff --git a/pamapi/src/main/java/com/pollex/pam/service/LoginService.java b/pamapi/src/main/java/com/pollex/pam/service/LoginService.java index c8ca009..8c08089 100644 --- a/pamapi/src/main/java/com/pollex/pam/service/LoginService.java +++ b/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 diff --git a/pamapi/src/main/java/com/pollex/pam/web/rest/AppointmentResource.java b/pamapi/src/main/java/com/pollex/pam/web/rest/AppointmentResource.java index 77f770e..0acd996 100644 --- a/pamapi/src/main/java/com/pollex/pam/web/rest/AppointmentResource.java +++ b/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); + } + } diff --git a/pamapi/src/main/java/com/pollex/pam/web/rest/errors/AppointmentNotFoundException.java b/pamapi/src/main/java/com/pollex/pam/web/rest/errors/AppointmentNotFoundException.java new file mode 100644 index 0000000..be2eb8b --- /dev/null +++ b/pamapi/src/main/java/com/pollex/pam/web/rest/errors/AppointmentNotFoundException.java @@ -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{ + +} -- Gitblit v1.8.0