request.getParameter() → queryString과 x-www-form 파싱

HistoryRepository
public List<AccountResponse.HistoryDTO> findByNumber(int number) {
List<AccountResponse.HistoryDTO> historyDTOList = new ArrayList<>();
String q = "select substr(created_at,1,16) created_at, withdraw_number, deposit_number, amount," +
"case when withdraw_number = ? then withdraw_balance " +
"else deposit_balance " +
"end as \"balance\"," +
"case when withdraw_number = ? then '출금' " +
"else '입금' " +
"end as \"type\" " +
"from history_tb where withdraw_number = ? or deposit_number = ?";
Query query = em.createNativeQuery(q);
query.setParameter(1, number);
query.setParameter(2, number);
query.setParameter(3, number);
query.setParameter(4, number);
List<Object[]> obsList = (List<Object[]>) query.getResultList();
for (Object[] obs : obsList) {
AccountResponse.HistoryDTO history = new AccountResponse.HistoryDTO(
(String) obs[0], (int) obs[1], (int) obs[2], (int) obs[3], (int) obs[4], (String) obs[5]);
historyDTOList.add(history);
}
return historyDTOList;
}account/detail.mustache
{{>layout/header}}
<!--마진 : mt, mr, ml, mb (1~5) ex) mt-5-->
<div class="container mt-2">
<div class="mt-4 p-5 bg-light text-dark rounded-4">
<p>{{model.fullname}}님 계좌</p>
<p>계좌번호 : {{model.number}}</p>
<p>계좌잔액 : {{model.balance}}원</p>
</div>
<div class="mt-3 mb-3">
<button type="button" class="btn btn-outline-primary">전체</button>
<button type="button" class="btn btn-outline-primary">입금</button>
<button type="button" class="btn btn-outline-primary">출금</button>
</div>
<table class="table table-hover">
<thead>
<tr>
<th>날짜</th>
<th>출금계좌</th>
<th>입금계좌</th>
<th>금액</th>
<th>계좌잔액</th>
<th>입금/출금</th>
</tr>
</thead>
<tbody>
{{#model.histories}}
<tr>
<td>{{createdAt}}</td>
<td>{{withdrawNumber}}</td>
<td>{{depositNumber}}</td>
<td>{{amount}}원</td>
<td>{{balance}}원</td>
<td>{{type}}</td>
</tr>
{{/model.histories}}
</tbody>
</table>
</div>
{{>layout/footer}}
Share article