| | |
| | | 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 org.springframework.transaction.annotation.Transactional; |
| | | |
| | | 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.AppointmentClosedInfoService; |
| | | import com.pollex.pam.service.AppointmentService; |
| | | import com.pollex.pam.service.SatisfactionService; |
| | | import com.pollex.pam.service.dto.AbstractAppointmentProcessDTO; |
| | | import com.pollex.pam.service.dto.ClosedProcessDTO; |
| | | import com.pollex.pam.service.dto.DoneProcessDTO; |
| | | import com.pollex.pam.web.rest.errors.AppointmentClosedInfoNotFoundException; |
| | | |
| | | @Service |
| | | @Transactional |
| | | public class DoneProcess implements AppointmentProcessInterface{ |
| | | |
| | | |
| | | @Autowired |
| | | AppointmentClosedInfoRepository appointmentClosedInfoRepository; |
| | | |
| | | |
| | | @Autowired |
| | | AppointmentClosedInfoService appointmentClosedInfoService; |
| | | |
| | | |
| | | @Autowired |
| | | SatisfactionService satisfactionService; |
| | | |
| | | @Autowired |
| | | AppointmentService appointmentService; |
| | | |
| | | @Override |
| | | public void createProcess(AbstractAppointmentProcessDTO processDTO) { |
| | | checkClosedInfo(processDTO.getAppointmentId()); |
| | | public AppointmentClosedInfo create(AbstractAppointmentProcessDTO processDTO) { |
| | | DoneProcessDTO doneProcess = toDoneProcessDTO(processDTO); |
| | | AppointmentClosedInfo closedInfo = new AppointmentClosedInfo(); |
| | | BeanUtils.copyProperties(doneProcess, closedInfo); |
| | | appointmentClosedInfoRepository.save(closedInfo); |
| | | Appointment appointment = appointmentService.findById(processDTO.getAppointmentId()); |
| | | satisfactionService.createAppointmentSatisfaction(appointment); |
| | | return appointmentClosedInfoRepository.save(closedInfo); |
| | | } |
| | | |
| | | @Override |
| | | public ContactStatusEnum getProcessType() { |
| | | return ContactStatusEnum.DONE; |
| | | } |
| | | |
| | | private void checkClosedInfo(Long appointmentId) { |
| | | Optional<AppointmentClosedInfo> closedInfo = appointmentClosedInfoRepository.findByAppointmentId(appointmentId); |
| | | if(closedInfo.isPresent()) { |
| | | throw new IllegalArgumentException("appointment closed info exist"); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public AppointmentClosedInfo editClosedInfo(AbstractAppointmentProcessDTO abstractDTO) { |
| | | public AppointmentClosedInfo editClosedInfo( |
| | | AbstractAppointmentProcessDTO abstractDTO |
| | | , AppointmentClosedInfo closedInfo) { |
| | | DoneProcessDTO doneProcess = toDoneProcessDTO(abstractDTO); |
| | | AppointmentClosedInfo closedInfo = appointmentClosedInfoService.findByAppointmentId(abstractDTO.getAppointmentId()); |
| | | BeanUtils.copyProperties(doneProcess, closedInfo); |
| | | return appointmentClosedInfoRepository.save(closedInfo); |
| | | } |
| | | |
| | | private DoneProcessDTO toDoneProcessDTO(AbstractAppointmentProcessDTO abstractDTO) { |
| | | |
| | | DoneProcessDTO doneProcess = (DoneProcessDTO)abstractDTO; |
| | | BeanUtils.copyProperties(abstractDTO, doneProcess); |
| | | return doneProcess; |
| | | } |
| | | |
| | | |
| | | } |