system-sekkei/isolating-the-domain

時給の履歴の並び順に関する質問

Closed this issue · 2 comments

/webapp/src/main/resources/templates/wage/list.htmlで表示している時給の履歴について、example.infrastructure.datasource.contract.ContractMapper.selectContractsではORDER句が指定されておらず、example.infrastructure.datasource.contract.ContractDataSource.getContractWages(EmployeeNumber)では、sortedによる並べ替えもされていないようですが、画面上は開始日付の降順で表示されているかと思います。並べ替えをどこでどのように行われているのか、ご教示いただいてもよろしいでしょうか。

irof commented

日付の降順は契約時給を一覧する際の関心として ContractWages#list() でやっています。

public List<ContractWage> list() {
return list.stream()
.sorted((c1, c2) -> c2.effectiveDate().value().compareTo(c1.effectiveDate().value()))
.collect(Collectors.toList());
}

ご回答ありがとうございます。理解できました。