content: package com.webapp.bankingportal.service;
  
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.stereotype.Service;
  
  import com.webapp.bankingportal.dto.AccountResponse;
  import com.webapp.bankingportal.dto.UserResponse;
  import com.webapp.bankingportal.exception.NotFoundException;
  import com.webapp.bankingportal.repository.AccountRepository;
  import com.webapp.bankingportal.repository.UserRepository;
  import com.webapp.bankingportal.util.ApiMessages;
  
  import lombok.RequiredArgsConstructor;
  import lombok.val;
  
  @Service
  @RequiredArgsConstructor
  public class DashboardServiceImpl implements DashboardService {
  @Autowired
      private final UserRepository userRepository;
  @Autowired
      private final AccountRepository accountRepository;
  
      @Override
      public UserResponse getUserDetails(String accountNumber) {
          val user = userRepository.findByAccountAccountNumber(accountNumber)
                  .orElseThrow(() -> new NotFoundException(
                          String.format(ApiMessages.USER_NOT_FOUND_BY_ACCOUNT.getMessage(), accountNumber)));
  
          return new UserResponse(user);
      }
  
      @Override
      public AccountResponse getAccountDetails(String accountNumber) {
          val account = accountRepository.findByAccountNumber(accountNumber);
          if (account == null) {
              throw new NotFoundException(String.format(ApiMessages.USER_NOT_FOUND_BY_ACCOUNT.getMessage(), accountNumber));
          }
  
          return new AccountResponse(account);
      }
  
  }
  