Untitled

mail@pastecode.io avatar
unknown
java
12 days ago
1.0 kB
7
Indexable
Never
public void validateRequest(String userId, String transactionId ) {
        log.info("PerlasService.validateRequest");

        Optional<Customer> customer = customerRepository.findById(Long.valueOf(userId));
        if (customer.isEmpty()) {
            log.info("PerlasService.validateRequest.NoCustomerException.CustomerId:{}.TransactionId:{}", userId, transactionId);
            throw new NoCustomerException("No customer with customerId:" + userId);
        }

        //if its checkId request, then do this check
        boolean earlierCheckIdRequestExists = salesOrdersRepository.existsByTransactionIdAndStatus(transactionId,"CHECK ID");
        if (earlierCheckIdRequestExists) {
            System.out.println("DUPLICATE");
            log.info("PerlasService.validateRequest.DuplicateRequestException.CustomerId:{}.TransactionId:{}", userId,transactionId);
            throw new DuplicateRequestException("Duplicate checkId request.UserId:" + userId + ".TransactionId:" + transactionId);
        }
    }
Leave a Comment