【List转Map】
public Map<Long, String> getIdNameMap(List accounts) {
return accounts.stream().collect(Collectors.toMap(Account::getId, Account::getUsername));
}
public Map<Long, Account> getIdAccountMap(List accounts) {
return accounts.stream().collect(Collectors.toMap(Account::getId, account -> account));
}