Guest User

Untitled

a guest
Oct 16th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. @GetMapping
  2. @PreAuthorize("hasRole('CLIENT')")
  3. public List<AccountListResponse> accountList(@CurrentUser UserPrincipal userPrincipal) {
  4. List<AccountListResponse> accountList = new ArrayList<>();
  5. accountRepo.findAllByClient_User_Id(userPrincipal.getId())
  6. .forEach(account ->
  7. accountList.add(new AccountListResponse(
  8. account.getUniqCheckId(),
  9. account.getSum(),
  10. account.getUpdatedAt(),
  11. account.getCurrencyName().getName(),
  12. account.getTypeAccount().getType())
  13. )
  14. );
  15. return accountList;
  16. }
  17.  
  18. @Data
  19. public class AccountListResponse {
  20. private String accountId;
  21. private BigDecimal sum;
  22. private LocalDateTime updatedAt;
  23. private CurrencyName currency;
  24. private TypeAccountName type;
  25.  
  26. public AccountListResponse(String accountId,
  27. BigDecimal sum,
  28. LocalDateTime updatedAt,
  29. CurrencyName currency,
  30. TypeAccountName type) {
  31. this.accountId = accountId;
  32. this.sum = sum;
  33. this.updatedAt = updatedAt;
  34. this.currency = currency;
  35. this.type = type;
  36. }
  37. }
  38.  
  39. {
  40. "accountId": "804cd3da-7865-45b2-bf48-1cb471cb4484",
  41. "sum": 480,
  42. "updatedAt": "2018-10-15T09:40:26.302",
  43. "currency": "RUB",
  44. "type": "DEBIT"
  45. },
  46. {
  47. "accountId": "6e388506-04f6-410a-b63f-e3e7e9d24693",
  48. "sum": 0,
  49. "updatedAt": "2018-10-15T14:12:15.491",
  50. "currency": "EUR",
  51. "type": "DEBIT"
  52. },
  53. {
  54. "accountId": "bec1cb7c-8543-452d-bf3c-329b0e268468",
  55. "sum": 0,
  56. "updatedAt": "2018-10-15T14:12:22.591",
  57. "currency": "USD",
  58. "type": "DEBIT"
  59. }
Add Comment
Please, Sign In to add comment