pamapi/src/doc/預約單/結案API.txt | ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程 | |
pamapi/src/main/java/com/pollex/pam/appointment/process/AppointmentProcess.java | ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程 | |
pamapi/src/main/java/com/pollex/pam/appointment/process/ClosedProcess.java | ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程 | |
pamapi/src/main/java/com/pollex/pam/appointment/process/DoneProcess.java | ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程 | |
pamapi/src/main/java/com/pollex/pam/repository/AppointmentClosedInfoRepository.java | ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程 | |
pamapi/src/main/java/com/pollex/pam/service/AppointmentClosedInfoService.java | ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程 | |
pamapi/src/main/java/com/pollex/pam/web/rest/AppointmentResource.java | ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程 | |
pamapi/src/main/java/com/pollex/pam/web/rest/errors/AppointmentClosedInfoNotFoundException.java | ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程 |
pamapi/src/doc/預約單/結案API.txt
@@ -13,7 +13,8 @@ "planCode":"ATM", "policyEntryDate":"2022-01-12", "contactStatus":"done", "appointmentId": 385 "appointmentId": 385, "remark":"test remark" } pamapi/src/main/java/com/pollex/pam/appointment/process/AppointmentProcess.java
@@ -1,10 +1,17 @@ package com.pollex.pam.appointment.process; import java.util.List; import java.util.Optional; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.pollex.pam.domain.Appointment; import com.pollex.pam.domain.AppointmentClosedInfo; import com.pollex.pam.repository.AppointmentClosedInfoRepository; import com.pollex.pam.repository.AppointmentRepository; import com.pollex.pam.service.AppointmentClosedInfoService; import com.pollex.pam.service.AppointmentService; import com.pollex.pam.service.dto.AbstractAppointmentProcessDTO; @Service @@ -13,13 +20,26 @@ @Autowired List<AppointmentProcessInterface> processList; @Autowired AppointmentService appointmentService; @Autowired AppointmentRepository appointmentRepository; @Autowired AppointmentClosedInfoRepository appointmentClosedInfoRepository; public void process(AbstractAppointmentProcessDTO dto) { AbstractAppointmentProcessDTO appointmentProcessDTO = (AbstractAppointmentProcessDTO)dto; processList.stream().forEach(process ->{ if(process.getProcessType() == appointmentProcessDTO.getContactStatus()) { process.doProcess(appointmentProcessDTO); } }); Appointment appointment = appointmentService.findById(dto.getAppointmentId()); appointment.setCommunicateStatus(dto.getContactStatus()); appointmentRepository.save(appointment); } } pamapi/src/main/java/com/pollex/pam/appointment/process/ClosedProcess.java
@@ -1,12 +1,16 @@ package com.pollex.pam.appointment.process; import java.util.Optional; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.pollex.pam.domain.Appointment; import com.pollex.pam.domain.AppointmentClosedInfo; import com.pollex.pam.enums.ContactStatusEnum; import com.pollex.pam.repository.AppointmentClosedInfoRepository; import com.pollex.pam.service.AppointmentService; import com.pollex.pam.service.dto.AbstractAppointmentProcessDTO; import com.pollex.pam.service.dto.ClosedProcessDTO; import com.pollex.pam.service.dto.DoneProcessDTO; @@ -16,14 +20,29 @@ @Autowired AppointmentClosedInfoRepository appointmentClosedInfoRepository; @Autowired AppointmentService appointmentService; @Override public void doProcess(AbstractAppointmentProcessDTO processDTO) { checkClosedInfo(processDTO.getAppointmentId()); ClosedProcessDTO doneProcess = (ClosedProcessDTO)processDTO; BeanUtils.copyProperties(processDTO, doneProcess); AppointmentClosedInfo closedInfo = new AppointmentClosedInfo(); BeanUtils.copyProperties(doneProcess, closedInfo); appointmentClosedInfoRepository.save(closedInfo); } private void checkClosedInfo(Long appointmentId) { Optional<AppointmentClosedInfo> closedInfo = appointmentClosedInfoRepository.findByAppointmentId(appointmentId); if(closedInfo.isPresent()) { throw new IllegalArgumentException("appointment closed info exist"); } } @Override pamapi/src/main/java/com/pollex/pam/appointment/process/DoneProcess.java
@@ -1,5 +1,7 @@ package com.pollex.pam.appointment.process; import java.util.Optional; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -18,6 +20,7 @@ @Override public void doProcess(AbstractAppointmentProcessDTO processDTO) { checkClosedInfo(processDTO.getAppointmentId()); DoneProcessDTO doneProcess = (DoneProcessDTO)processDTO; BeanUtils.copyProperties(processDTO, doneProcess); AppointmentClosedInfo closedInfo = new AppointmentClosedInfo(); @@ -30,5 +33,11 @@ return ContactStatusEnum.DONE; } private void checkClosedInfo(Long appointmentId) { Optional<AppointmentClosedInfo> closedInfo = appointmentClosedInfoRepository.findByAppointmentId(appointmentId); if(closedInfo.isPresent()) { throw new IllegalArgumentException("appointment closed info exist"); } } } pamapi/src/main/java/com/pollex/pam/repository/AppointmentClosedInfoRepository.java
@@ -1,5 +1,7 @@ package com.pollex.pam.repository; import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; @@ -8,4 +10,6 @@ @Repository public interface AppointmentClosedInfoRepository extends JpaRepository<AppointmentClosedInfo, Long>{ Optional<AppointmentClosedInfo> findByAppointmentId(Long apId); } pamapi/src/main/java/com/pollex/pam/service/AppointmentClosedInfoService.java
@@ -1,10 +1,22 @@ package com.pollex.pam.service; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import com.pollex.pam.domain.AppointmentClosedInfo; import com.pollex.pam.repository.AppointmentClosedInfoRepository; import com.pollex.pam.web.rest.errors.AppointmentClosedInfoNotFoundException; @Service @Transactional public class AppointmentClosedInfoService { @Autowired AppointmentClosedInfoRepository appointmentClosedInfoRepository; public AppointmentClosedInfo findByAppointmentId(Long apId) { return appointmentClosedInfoRepository.findByAppointmentId(apId) .orElseThrow(AppointmentClosedInfoNotFoundException::new); } } pamapi/src/main/java/com/pollex/pam/web/rest/AppointmentResource.java
@@ -82,11 +82,9 @@ ClosedProcessDTO dto = new ClosedProcessDTO(); BeanUtils.copyProperties(closeDTO, dto); abstractAppointmentProcess.process(dto); }else { return ResponseEntity.notFound().build(); } // Appointment ap = appointmentService.findById(closeDTO.getAppointmentId()); // System.out.println("getClosedInfo().getClosedOtherReason()::"+ap.getClosedInfo().getClosedOtherReason()); return ResponseEntity.noContent().build(); } pamapi/src/main/java/com/pollex/pam/web/rest/errors/AppointmentClosedInfoNotFoundException.java
比對新檔案 @@ -0,0 +1,13 @@ 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 close info not found") public class AppointmentClosedInfoNotFoundException extends RuntimeException{ /** * */ private static final long serialVersionUID = 1L; }