| | |
| | | package com.pollex.pam.service; |
| | | |
| | | import com.pollex.pam.config.ApplicationProperties; |
| | | import com.pollex.pam.domain.AppointmentCustomerView; |
| | | import com.pollex.pam.domain.Consultant; |
| | | import com.pollex.pam.domain.CustomerFavoriteConsultant; |
| | |
| | | import com.pollex.pam.security.SecurityUtils; |
| | | import com.pollex.pam.service.dto.*; |
| | | import com.pollex.pam.service.mapper.AppointmentCustomerViewMapper; |
| | | import com.pollex.pam.service.mapper.ConsultantDTOMapper; |
| | | import com.pollex.pam.service.mapper.ConsultantMapper; |
| | | import com.pollex.pam.service.util.FileUtil; |
| | | import com.pollex.pam.web.rest.errors.ConsultantNotFoundException; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.io.File; |
| | | import java.io.FileInputStream; |
| | | import java.io.FileNotFoundException; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.time.Instant; |
| | | import java.util.Comparator; |
| | | import java.util.List; |
| | |
| | | |
| | | @Autowired |
| | | SatisfactionService satisfactionService; |
| | | |
| | | @Autowired |
| | | ConsultantDTOMapper consultantDTOMapper; |
| | | |
| | | @Autowired |
| | | ApplicationProperties applicationProperty; |
| | | |
| | | public List<CustomerFavoriteConsultantDTO> getMyConsultantList() { |
| | | Long customerId = SecurityUtils.getCustomerDBId(); |
| | |
| | | customerFavoriteConsultantRepository.saveAll(notViewRelation); |
| | | } |
| | | |
| | | public Consultant findByAgentNo(String agentNo) { |
| | | return consultantRepository.findOneByAgentNo(agentNo).get(); |
| | | } |
| | | public Consultant editConsultant(ConsultantEditDTO editDTO) { |
| | | Consultant consultant = consultantRepository.findOneByAgentNo(editDTO.getAgentNo()) |
| | | .orElseThrow(ConsultantNotFoundException::new); |
| | | consultantDTOMapper.copyToConsultant(editDTO, consultant); |
| | | FileUtil.base64ToFile(editDTO.getPhotoBase64(), editDTO.getPhotoFileName(), applicationProperty.getFileFolderPath()); |
| | | return consultantRepository.save(consultant); |
| | | } |
| | | |
| | | public InputStream getAvatarImage(String agentNo) { |
| | | Consultant consultant = consultantRepository.findOneByAgentNo(agentNo) |
| | | .orElseThrow(ConsultantNotFoundException::new); |
| | | File file = new File(consultant.getPhotoPath()); |
| | | try { |
| | | InputStream in = new FileInputStream(file); |
| | | return in; |
| | | } catch (FileNotFoundException e) { |
| | | log.error("agent photo not found , agentNo:"+agentNo,e); |
| | | return null; |
| | | } |
| | | } |
| | | } |