| | |
| | | import java.util.List; |
| | | import java.util.Optional; |
| | | |
| | | import com.pollex.pam.enums.SatisfactionTypeEnum; |
| | | import com.pollex.pam.security.SecurityUtils; |
| | | import com.pollex.pam.service.dto.SatisfactionSystemScoreDTO; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | Satisfaction satisfaction = satisfactionOP.orElseThrow(SatisfactionNotFoundException::new); |
| | | satisfaction.setScore(scoreDTO.getScore()); |
| | | satisfaction.setStatus(SatisfactionStatusEnum.FILLED); |
| | | satisfaction.setType(SatisfactionTypeEnum.APPOINTMENT); |
| | | save(satisfaction); |
| | | personalNotificationService.createScorefactionToConsultant(satisfaction); |
| | | return satisfaction; |
| | | } |
| | | |
| | | public Satisfaction createSatisfaction(Appointment appointment) { |
| | | public Satisfaction createAppointmentSatisfaction(Appointment appointment) { |
| | | boolean isexist = getByAppointmentId(appointment.getId()).isPresent(); |
| | | if(isexist) { |
| | | throw new SatisfactionAlreadyExistException(); |
| | | } |
| | | Satisfaction satisfaction = appointmentMapper.toSatisfaction(appointment); |
| | | Satisfaction satisfaction = appointmentMapper.toAppointmentSatisfaction(appointment); |
| | | return save(satisfaction); |
| | | } |
| | | // |
| | |
| | | // return save(satisfaction); |
| | | // } |
| | | |
| | | public List<SatisfactionDTO> getByAgentNo(String agentNo) { |
| | | List<Satisfaction> satisfactionList = satisfactionRepository.findByAgentNo(agentNo); |
| | | public List<SatisfactionDTO> getByAgentNoAndType(String agentNo, SatisfactionTypeEnum type) { |
| | | List<Satisfaction> satisfactionList = satisfactionRepository.findByAgentNoAndType(agentNo, type); |
| | | return satisfactionMapper.toDTO(satisfactionList); |
| | | } |
| | | |
| | | public List<SatisfactionDTO> getByCustomerId(Long customerDBId) { |
| | | List<Satisfaction> satisfactionList = satisfactionRepository.findByCustomerId(customerDBId); |
| | | public List<SatisfactionDTO> getByCustomerIdAndType(Long customerDBId, SatisfactionTypeEnum type) { |
| | | List<Satisfaction> satisfactionList = satisfactionRepository.findByCustomerIdAndType(customerDBId, type); |
| | | return satisfactionMapper.toDTO(satisfactionList); |
| | | } |
| | | |
| | |
| | | return satisfactionRepository.findOneByAppointmentId(appointmentId); |
| | | } |
| | | |
| | | public List<Satisfaction> getByStatus(SatisfactionStatusEnum status) { |
| | | return satisfactionRepository.findAllByStatus(status); |
| | | public List<Satisfaction> getByStatusAndType(SatisfactionStatusEnum status, SatisfactionTypeEnum type) { |
| | | return satisfactionRepository.findAllByStatusAndType(status, type); |
| | | } |
| | | |
| | | public List<Satisfaction> scoreAllfaction(List<SatisfactionCustomerScoreDTO> scoreDTO) { |
| | |
| | | }); |
| | | return satisfactionList; |
| | | } |
| | | |
| | | public Satisfaction createSystemSatisfaction(SatisfactionSystemScoreDTO scoreDTO) { |
| | | Satisfaction satisfaction = new Satisfaction(); |
| | | satisfaction.setCustomerId(SecurityUtils.getCustomerDBId()); |
| | | satisfaction.setAppointmentId(scoreDTO.getAppointmentId()); |
| | | satisfaction.setStatus(SatisfactionStatusEnum.FILLED); |
| | | satisfaction.setScore(scoreDTO.getScore()); |
| | | satisfaction.setType(SatisfactionTypeEnum.SYSTEM); |
| | | return satisfactionRepository.save(satisfaction); |
| | | } |
| | | } |