AccountInfo 的构建使用 Builder 模式。

This commit is contained in:
2023-03-12 13:29:07 +08:00
parent b4bccfe663
commit 5f1cb36235
6 changed files with 86 additions and 27 deletions

View File

@@ -176,10 +176,6 @@ public class AccountRepositoryImpl extends JdbcRepositorySupport<Account, Long>
@Override
protected final Account mapRow(ResultSet rs) throws SQLException {
long accountId = rs.getLong("id");
AccountInfo accountInfo = AccountInfo.of(
rs.getString("nickname"),
rs.getString("avatar"),
Sex.of(rs.getInt("sex")));
return new Account(
accountId,
rs.getString("username"),
@@ -187,7 +183,11 @@ public class AccountRepositoryImpl extends JdbcRepositorySupport<Account, Long>
rs.getString("mobile_phone"),
Password.of(rs.getString("password"), rs.getString("salt")),
AccountStatus.of(rs.getInt("status")),
accountInfo,
AccountInfo.builder()
.nickname(rs.getString("nickname"))
.avatar(rs.getString("avatar"))
.sex(Sex.of(rs.getInt("sex")))
.build(),
this.accountRoleDAO.selectRoleIdsByAccountId(accountId),
rs.getLong("created_by"),
rs.getLong("updated_by"),