| | |
| | | import java.util.List; |
| | | |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import com.pollex.pam.domain.Consultant; |
| | | import com.pollex.pam.domain.Customer; |
| | | import com.pollex.pam.domain.Satisfaction; |
| | | import com.pollex.pam.repository.ConsultantRepository; |
| | | import com.pollex.pam.repository.CustomerRepository; |
| | | import com.pollex.pam.service.dto.SatisfactionDTO; |
| | | |
| | | @Service |
| | | public class SatisfactionMapper { |
| | | |
| | | @Autowired |
| | | ConsultantRepository consultantRepository; |
| | | |
| | | @Autowired |
| | | CustomerRepository customerRepository; |
| | | |
| | | public SatisfactionDTO toDTO(Satisfaction source) { |
| | | SatisfactionDTO target = new SatisfactionDTO(); |
| | | target.setScore(source.getScore()); |
| | | BeanUtils.copyProperties(source, target); |
| | | target.setScore(source.getScore()); |
| | | Consultant consultant= consultantRepository.findOneByAgentNo(source.getAgentNo()).get(); |
| | | target.setAgentName(consultant.getName()); |
| | | Customer customer = customerRepository.findById(source.getCustomerId()).get(); |
| | | target.setCustomerName(customer.getName()); |
| | | return target; |
| | | } |
| | | |