Untitled

mail@pastecode.io avatar
unknown
java
13 days ago
1.2 kB
14
Indexable
Never
    public void validateRequest(PerlasIdCheckRequestDTO perlasIdCheckRequestDTO) {
        log.info("PerlasService.validateRequest");

        Optional<Customer> customer = customerRepository.findById(Long.valueOf(perlasIdCheckRequestDTO.getUserId()));
        if (customer.isEmpty()) {
            System.out.println("customer is empty aaa");
            log.info("PerlasService.validateRequest.NoCustomerException.CustomerId:{}.TransactionId:{}", perlasIdCheckRequestDTO.getUserId(), perlasIdCheckRequestDTO.getTransactionId());
            throw new NoCustomerException("No customer with customerId:" + perlasIdCheckRequestDTO.getUserId());
        }

        Optional<SalesOrder> earlierSalesOrder = salesOrdersRepository.findByTransactionId(perlasIdCheckRequestDTO.getTransactionId());
        if (earlierSalesOrder.isPresent()) {
            log.info("PerlasService.validateRequest.DuplicateRequestException.CustomerId:{}.TransactionId:{}", perlasIdCheckRequestDTO.getUserId(), perlasIdCheckRequestDTO.getTransactionId());
            throw new DuplicateRequestException("Duplicate checkId request.UserId:" + perlasIdCheckRequestDTO.getUserId() + ".TransactionId:" + perlasIdCheckRequestDTO.getTransactionId());
        }
    }
Leave a Comment