Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @GetMapping
- @PreAuthorize("hasRole('CLIENT')")
- public List<AccountListResponse> accountList(@CurrentUser UserPrincipal userPrincipal) {
- List<AccountListResponse> accountList = new ArrayList<>();
- accountRepo.findAllByClient_User_Id(userPrincipal.getId())
- .forEach(account ->
- accountList.add(new AccountListResponse(
- account.getUniqCheckId(),
- account.getSum(),
- account.getUpdatedAt(),
- account.getCurrencyName().getName(),
- account.getTypeAccount().getType())
- )
- );
- return accountList;
- }
- @Data
- public class AccountListResponse {
- private String accountId;
- private BigDecimal sum;
- private LocalDateTime updatedAt;
- private CurrencyName currency;
- private TypeAccountName type;
- public AccountListResponse(String accountId,
- BigDecimal sum,
- LocalDateTime updatedAt,
- CurrencyName currency,
- TypeAccountName type) {
- this.accountId = accountId;
- this.sum = sum;
- this.updatedAt = updatedAt;
- this.currency = currency;
- this.type = type;
- }
- }
- {
- "accountId": "804cd3da-7865-45b2-bf48-1cb471cb4484",
- "sum": 480,
- "updatedAt": "2018-10-15T09:40:26.302",
- "currency": "RUB",
- "type": "DEBIT"
- },
- {
- "accountId": "6e388506-04f6-410a-b63f-e3e7e9d24693",
- "sum": 0,
- "updatedAt": "2018-10-15T14:12:15.491",
- "currency": "EUR",
- "type": "DEBIT"
- },
- {
- "accountId": "bec1cb7c-8543-452d-bf3c-329b0e268468",
- "sum": 0,
- "updatedAt": "2018-10-15T14:12:22.591",
- "currency": "USD",
- "type": "DEBIT"
- }
Add Comment
Please, Sign In to add comment