@Transactional public UserPaymentUI create(UserPaymentUI uiBean) { UserPayment newUserPayment = mapper.toPersistenceBean(uiBean); if (uiBean.getUserName() == null) { return null; } Customer customer = userRepository.findByUsername(uiBean.getUserName()); newUserPayment.setCustomer(customer); UserPayment saved = repository.save(newUserPayment); logger.debug("Added Payment : " + saved); return mapper.toUIBean(saved); }
public UserPaymentUI update(UserPaymentUI uiBean) { UserPayment existing = repository.findById(uiBean.getId()); if (existing == null) { return null; } existing.setAmount(uiBean.getAmount()); existing.setNotes(uiBean.getNotes()); UserPayment saved = null; try { saved = repository.save(existing); } catch (Exception e) { logger.error(e); } return mapper.toUIBean(saved); }
public List<UserPaymentUI> findByUser(String userName) { Customer customer = new Customer(); customer.setUsername(userName); return mapper.toUIBean(repository.findByCustomer(customer)); }
public Page<UserPaymentUI> findAll(Pageable pageable, List<FilterRequest> filters) { Predicate predicate = toPredicate(filters); return mapper.toUIBean(repository.findAll(predicate, pageable), pageable); }
public UserPaymentUI find(long paymentId) { return mapper.toUIBean(repository.findById(paymentId)); }