保誠-保戶業務員媒合平台
jack
2022-09-02 3fbe6659509418c11739dfe4961b7d986d8ba789
pamapi/src/main/java/com/pollex/pam/service/CustomerService.java
@@ -7,6 +7,9 @@
import com.pollex.pam.business.service.UsernameAlreadyUsedException;
import com.pollex.pam.business.service.dto.CustomerDTO;
import com.pollex.pam.business.service.mapper.CustomerMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;
@@ -14,6 +17,7 @@
import com.pollex.pam.business.domain.Customer;
import com.pollex.pam.business.domain.OtpTmp;
import com.pollex.pam.business.enums.DataFromEnum;
import com.pollex.pam.business.enums.OtpLoginTypeEnum;
import com.pollex.pam.business.enums.OtpTmpStatusEnum;
import com.pollex.pam.business.repository.CustomerRepository;
@@ -23,6 +27,9 @@
@Service
@Transactional
public class CustomerService {
   private static final Logger log = LoggerFactory.getLogger(CustomerService.class);
   @Autowired
   CustomerRepository customerRepository;
@@ -44,6 +51,7 @@
   }
   public Customer registerCustomer(CustomerRegisterDTO registDTO) {
      boolean isCustomerExist = checkCustomerExist(registDTO);
      if(isCustomerExist) {
         throw new UsernameAlreadyUsedException();
@@ -54,7 +62,9 @@
         OtpTmp otpTmp = otpTmpService.findByAccountAndIndexKey(account, registDTO.getIndexKey());
          if(otpTmp.getStatus() == OtpTmpStatusEnum.VERRIFIED) {
             Customer customer = customerDTOMapper.toCustomer(registDTO);
             customer.setDataFrom(DataFromEnum.PAM);
              save(customer);
              Customer test = customerRepository.findById(customer.getId()).get();
              return customer;
          }else {
             throw new IllegalArgumentException("Invalid indexKey state error. IndexKey: "