保誠-保戶業務員媒合平台
wayne
2022-02-17 4394e4248455637ab7836756058ac872fdf4af10
pamapi/src/main/java/com/pollex/pam/service/mapper/SatisfactionMapper.java
@@ -3,6 +3,7 @@
import static java.util.stream.Collectors.toList;
import java.util.List;
import java.util.Objects;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -17,19 +18,19 @@
@Service
public class SatisfactionMapper {
   @Autowired
   ConsultantRepository consultantRepository;
   @Autowired
   CustomerRepository customerRepository;
   public SatisfactionDTO toDTO(Satisfaction source) {
      SatisfactionDTO target = new SatisfactionDTO();
      BeanUtils.copyProperties(source, target);
      target.setScore(source.getScore());
      Consultant consultant= consultantRepository.findOneByAgentNo(source.getAgentNo()).get();
      target.setAgentName(consultant.getName());
      Consultant consultant= consultantRepository.findOneByAgentNo(source.getAgentNo()).orElse(null);
      target.setAgentName(Objects.isNull(consultant) ? null : consultant.getName());
      Customer customer = customerRepository.findById(source.getCustomerId()).get();
      target.setCustomerName(customer.getName());
      return target;